diff mbox series

mmc: Parse new binding for eMMC fixed driver type

Message ID 20200626020624.31588-1-s-tokumoto@fujitsu.com
State Deferred
Delegated to: Tom Rini
Headers show
Series mmc: Parse new binding for eMMC fixed driver type | expand

Commit Message

s-tokumoto@fujitsu.com June 26, 2020, 2:06 a.m. UTC
Parse the new binding and store it in the mmc config struct after doing
some sanity checks. The code is designed to support fixed mmc driver type
if we ever need that.

Signed-off-by: Shunsuke Tokumoto <s-tokumoto@fujitsu.com>
Signed-off-by: Yasushi Iida <yasushi.iida@fujitsu.com>
---
 drivers/mmc/mmc-uclass.c | 30 ++++++++++++++++++++++++++++++
 drivers/mmc/mmc.c        |  8 ++++++++
 include/mmc.h            |  3 +++
 3 files changed, 41 insertions(+)

Comments

Peng Fan July 14, 2020, 7:51 a.m. UTC | #1
> Subject: [PATCH] mmc: Parse new binding for eMMC fixed driver type
> 
> Parse the new binding and store it in the mmc config struct after doing some
> sanity checks. The code is designed to support fixed mmc driver type if we
> ever need that.
> 
> Signed-off-by: Shunsuke Tokumoto <s-tokumoto@fujitsu.com>
> Signed-off-by: Yasushi Iida <yasushi.iida@fujitsu.com>
> ---
>  drivers/mmc/mmc-uclass.c | 30 ++++++++++++++++++++++++++++++
>  drivers/mmc/mmc.c        |  8 ++++++++
>  include/mmc.h            |  3 +++
>  3 files changed, 41 insertions(+)
> 
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index
> c5b7872900..e67aae451f 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -162,6 +162,36 @@ int dm_mmc_deferred_probe(struct udevice *dev)
>  	if (ops->deferred_probe)
>  		return ops->deferred_probe(dev);
> 
> +	/* Check eMMC driver type selection */
> +	val = dev_read_u32_default(dev, "fixed-emmc-driver-type", 0);

Has the bindings been accepted by Linux Kernel?

Regards,
Peng.
s-tokumoto@fujitsu.com Oct. 30, 2020, 2:49 a.m. UTC | #2
> From: Peng Fan <peng.fan@nxp.com>
> Sent: Tuesday, July 14, 2020 4:52 PM
> To: Tokumoto, Shunsuke/徳本 俊介 <s-tokumoto@fujitsu.com>
> Cc: u-boot@lists.denx.de; Iida, Yasushi/飯田 康志
> <yasushi.iida@fujitsu.com>
> Subject: RE: [PATCH] mmc: Parse new binding for eMMC fixed driver type
> 
> > Subject: [PATCH] mmc: Parse new binding for eMMC fixed driver type
> >
> > Parse the new binding and store it in the mmc config struct after
> > doing some sanity checks. The code is designed to support fixed mmc
> > driver type if we ever need that.
> >
> > Signed-off-by: Shunsuke Tokumoto <s-tokumoto@fujitsu.com>
> > Signed-off-by: Yasushi Iida <yasushi.iida@fujitsu.com>
> > ---
> >  drivers/mmc/mmc-uclass.c | 30
> ++++++++++++++++++++++++++++++
> >  drivers/mmc/mmc.c        |  8 ++++++++
> >  include/mmc.h            |  3 +++
> >  3 files changed, 41 insertions(+)
> >
> > diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index
> > c5b7872900..e67aae451f 100644
> > --- a/drivers/mmc/mmc-uclass.c
> > +++ b/drivers/mmc/mmc-uclass.c
> > @@ -162,6 +162,36 @@ int dm_mmc_deferred_probe(struct udevice *dev)
> >  	if (ops->deferred_probe)
> >  		return ops->deferred_probe(dev);
> >
> > +	/* Check eMMC driver type selection */
> > +	val = dev_read_u32_default(dev, "fixed-emmc-driver-type", 0);
> 
> Has the bindings been accepted by Linux Kernel?
> 

The bindings "fixed-emmc-driver-type" has already included in the Linux Kernel.
The others, "fixed-emmc-driver-type-hs200" and "fixed-emmc-driver-type-hs400" are 
not included in the Linux Kernel.

> Regards,
> Peng.

Best regards
Shunsuke
diff mbox series

Patch

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index c5b7872900..e67aae451f 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -162,6 +162,36 @@  int dm_mmc_deferred_probe(struct udevice *dev)
 	if (ops->deferred_probe)
 		return ops->deferred_probe(dev);
 
+	/* Check eMMC driver type selection */
+	val = dev_read_u32_default(dev, "fixed-emmc-driver-type", 0);
+	if (val > 4) {
+		puts("\"fixed-emmc-driver-type\" is illegal. force to 0.\n");
+		val = 0;
+	}
+	cfg->driver_type = val;
+
+	val = dev_read_u32_default(dev,
+				   "fixed-emmc-driver-type-hs200",
+				   -ENOENT);
+	if (val != -ENOENT) {
+		if (val > 4) {
+			puts("\"fixed-emmc-driver-type-hs200\" is illegal.\n");
+			val = 0;
+		}
+	}
+	cfg->driver_type_hs200 = val;
+
+	val = dev_read_u32_default(dev,
+				   "fixed-emmc-driver-type-hs400",
+				   -ENOENT);
+	if (val != -ENOENT) {
+		if (val > 4) {
+			puts("\"fixed-emmc-driver-type-hs400\" is illegal.\n");
+			val = 0;
+		}
+	}
+	cfg->driver_type_hs400 = val;
+
 	return 0;
 }
 
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 620bb93064..8241be9996 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -849,11 +849,19 @@  static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,
 #if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
 	case MMC_HS_200:
 		speed_bits = EXT_CSD_TIMING_HS200;
+		if (mmc->cfg->driver_type_hs200 != -ENOENT)
+			speed_bits |= (mmc->cfg->driver_type_hs200 << 4);
+		else
+			speed_bits |= (mmc->cfg->driver_type << 4);
 		break;
 #endif
 #if CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
 	case MMC_HS_400:
 		speed_bits = EXT_CSD_TIMING_HS400;
+		if (mmc->cfg->driver_type_hs400 != -ENOENT)
+			speed_bits |= (mmc->cfg->driver_type_hs400 << 4);
+		else
+			speed_bits |= (mmc->cfg->driver_type << 4);
 		break;
 #endif
 #if CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT)
diff --git a/include/mmc.h b/include/mmc.h
index 82562193cc..8d79ff5cbe 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -555,6 +555,9 @@  struct mmc_config {
 	uint f_max;
 	uint b_max;
 	unsigned char part_type;
+	uint driver_type;
+	uint driver_type_hs200;
+	uint driver_type_hs400;
 };
 
 struct sd_ssr {