From 02ad33aa3a84821c8d9a6c4f167f143f6248b084 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Thu, 2 Feb 2017 13:41:14 +0900 Subject: mmc: mmc-uclass: use the fixed devnum with alias node If there are alias nodes as "mmc", use the devnum as alias index number. This patch is for fixing a problem of Exynos4 series. Problem is the below thing. Current legacy mode: EXYNOS DWMMC: 0, SAMSUNG SDHCI: 1 After using DM: SAMSUNG SDHCI: 0, EXYNOS DWMMC: 1 Dev index is swapped. Then u-boot can't find the kernel image..because it is already set to 0 as mmcdev. If change from legacy to DM, also needs to touch all exynos4 config file. For using simply, just supporting the fixed devnum with alias node is better than it. Usage: alaise { .... mmc0 = &sdhci2; /* eMMC */ mmc1 = &sdhci1; /* SD */ ... } Signed-off-by: Jaehoon Chung Reviewed-by: Simon Glass --- drivers/mmc/mmc-uclass.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'drivers/mmc/mmc-uclass.c') diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 2fe5d61e263..de7acb68262 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -13,6 +13,8 @@ #include #include "mmc_private.h" +DECLARE_GLOBAL_DATA_PTR; + #ifdef CONFIG_DM_MMC_OPS int dm_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data) @@ -192,10 +194,15 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) { struct blk_desc *bdesc; struct udevice *bdev; - int ret; + int ret, devnum = -1; + +#ifndef CONFIG_SPL_BUILD + /* Use the fixed index with aliase node's index */ + fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev->of_offset, &devnum); +#endif - ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC, -1, 512, - 0, &bdev); + ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC, + devnum, 512, 0, &bdev); if (ret) { debug("Cannot create block device\n"); return ret; -- cgit v1.2.3 From a0269bb6e891c6c3b984a2f3d6a12c07e244484a Mon Sep 17 00:00:00 2001 From: Fiach Antaw Date: Wed, 25 Jan 2017 19:00:24 +1000 Subject: mmc: init mmc block devices on probe MMC devices accessed exclusively via the driver model were not being initialized before being exposed as block devices, causing issues in scenarios where the MMC device is first accessed via the uclass block interface. Signed-off-by: Fiach Antaw --- drivers/mmc/mmc-uclass.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/mmc/mmc-uclass.c') diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index de7acb68262..5bb446bcc2a 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -254,6 +254,17 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart) return mmc_switch_part(mmc, hwpart); } +static int mmc_blk_probe(struct udevice *dev) +{ + struct blk_desc *block_dev = dev_get_uclass_platdata(dev); + int dev_num = block_dev->devnum; + struct mmc *mmc = find_mmc_device(dev_num); + + if (!mmc) + return -ENODEV; + return mmc_init(mmc); +} + static const struct blk_ops mmc_blk_ops = { .read = mmc_bread, #ifndef CONFIG_SPL_BUILD @@ -267,6 +278,7 @@ U_BOOT_DRIVER(mmc_blk) = { .name = "mmc_blk", .id = UCLASS_BLK, .ops = &mmc_blk_ops, + .probe = mmc_blk_probe, }; #endif /* CONFIG_BLK */ -- cgit v1.2.3