Jelajahi Sumber

[Components] sdio: try bus width depends on host's capability

It makes no sense to try bus width if not supported by drivers or BSP,
since we know it must be failed. It saves a lot for booting in time
critical environment.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Shawn Lin 5 tahun lalu
induk
melakukan
11277014a3
1 mengubah file dengan 10 tambahan dan 1 penghapusan
  1. 10 1
      components/drivers/sdio/mmc.c

+ 10 - 1
components/drivers/sdio/mmc.c

@@ -318,8 +318,17 @@ static int mmc_select_bus_width(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd)
     * the device to work in 8bit transfer mode. If the
     * the device to work in 8bit transfer mode. If the
     * mmc switch command returns error then switch to
     * mmc switch command returns error then switch to
     * 4bit transfer mode. On success set the corresponding
     * 4bit transfer mode. On success set the corresponding
-    * bus width on the host.
+    * bus width on the host. Meanwhile, mmc core would
+    * bail out early if corresponding bus capable wasn't
+    * set by drivers.
     */
     */
+     if ((!(host->flags & MMCSD_BUSWIDTH_8) &&
+	  ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_8) ||
+         (!(host->flags & MMCSD_BUSWIDTH_4) &&
+	  (ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_4 ||
+	  ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_8)))
+	     continue;
+
     err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
     err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                      EXT_CSD_BUS_WIDTH,
                      EXT_CSD_BUS_WIDTH,
                      ext_csd_bits[idx]);
                      ext_csd_bits[idx]);