diff mbox

[U-Boot,RFC] mmc: mmc-uclass: use the fixed devnum with aliase node

Message ID 20161213083141.27237-1-jh80.chung@samsung.com
State Superseded
Delegated to: Jaehoon Chung
Headers show

Commit Message

Jaehoon Chung Dec. 13, 2016, 8:31 a.m. UTC
If there are aliase nodes as "mmc", use the devnum as aliase 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 aliase node is better than it.

Usage:
alaise {
	....
	mmc0 = &sdhci2; /* eMMC */
	mmc1 = &sdhci1; /* SD */
	...
}

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
 drivers/mmc/mmc-uclass.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Simon Glass Dec. 17, 2016, 10:47 p.m. UTC | #1
Hi Jaehoon,

On 13 December 2016 at 01:31, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> If there are aliase nodes as "mmc", use the devnum as aliase index

s/aliase/alias/g

> 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 aliase node is better than it.
>
> Usage:
> alaise {
>         ....
>         mmc0 = &sdhci2; /* eMMC */
>         mmc1 = &sdhci1; /* SD */
>         ...
> }
>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> ---
>  drivers/mmc/mmc-uclass.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)

Apart from that:

Reviewed-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 2fe5d61..a6c8458 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -13,6 +13,8 @@
>  #include <dm/root.h>
>  #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,13 @@ 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;
> +
> +       /* Use the fixed index with aliase node's index */
> +       fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev->of_offset, &devnum);
>
> -       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;
> --
> 2.10.2
>
diff mbox

Patch

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 2fe5d61..a6c8458 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -13,6 +13,8 @@ 
 #include <dm/root.h>
 #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,13 @@  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;
+
+	/* Use the fixed index with aliase node's index */
+	fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev->of_offset, &devnum);
 
-	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;