浏览代码

Merge pull request #3441 from shawn1221/mmc-upstream-20200312

component sdio fix
Bernard Xiong 5 年之前
父节点
当前提交
23d02c68c0
共有 2 个文件被更改,包括 10 次插入3 次删除
  1. 0 2
      components/drivers/sdio/block_dev.c
  2. 10 1
      components/drivers/sdio/mmc.c

+ 0 - 2
components/drivers/sdio/block_dev.c

@@ -460,8 +460,6 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card)
                     rt_device_register(&blk_dev->dev, "sd0",
                     rt_device_register(&blk_dev->dev, "sd0",
                         RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE);
                         RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE);
                     rt_list_insert_after(&blk_devices, &blk_dev->list);
                     rt_list_insert_after(&blk_devices, &blk_dev->list);
-    
-                    break;
                 }
                 }
                 else
                 else
                 {
                 {

+ 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]);