diff mbox series

[2/3] mmc: sdhci-esdhc-imx: add SD clock limitation for imx6ull

Message ID 1545292612-14471-2-git-send-email-haibo.chen@nxp.com (mailing list archive)
State New, archived
Headers show
Series [1/3] dt-bindings: mmc: fsl-imx-esdhc: add imx6ull compatible string | expand

Commit Message

Bough Chen Dec. 20, 2018, 7:49 a.m. UTC
i.MX6ULL has errata ERR010450, point out that due to SOC I/O
timing limitation, for eMMC HS200 and SD/SDIO 3.0 SDR104, the
clock rate can't exceed 150MHz. And for eMMC DDR52 and SD/SDIO
DDR50 mode, the clock rate can't exceed 45MHz.

This patch add this limit for imx6ull.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

kernel test robot Dec. 22, 2018, 9:33 p.m. UTC | #1
Hi BOUGH,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ulf.hansson-mmc/next]
[also build test WARNING on v4.20-rc7 next-20181221]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/BOUGH-CHEN/dt-bindings-mmc-fsl-imx-esdhc-add-imx6ull-compatible-string/20181223-011123
base:   git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
config: arm-imx_v6_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm 

All warnings (new ones prefixed by >>):

   drivers/mmc/host/sdhci-esdhc-imx.c:1511:24: error: initializer element is not constant
    module_platform_driver(sdhci_esdhc_imx_driver);
                           ^
   include/linux/init.h:195:50: note: in definition of macro '___define_initcall'
      __attribute__((__section__(#__sec ".init"))) = fn;
                                                     ^~
   include/linux/init.h:227:30: note: in expansion of macro '__define_initcall'
    #define device_initcall(fn)  __define_initcall(fn, 6)
                                 ^~~~~~~~~~~~~~~~~
   include/linux/init.h:232:24: note: in expansion of macro 'device_initcall'
    #define __initcall(fn) device_initcall(fn)
                           ^~~~~~~~~~~~~~~
   include/linux/module.h:87:24: note: in expansion of macro '__initcall'
    #define module_init(x) __initcall(x);
                           ^~~~~~~~~~
   include/linux/device.h:1615:1: note: in expansion of macro 'module_init'
    module_init(__driver##_init); \
    ^~~~~~~~~~~
   include/linux/platform_device.h:229:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^~~~~~~~~~~~~
   drivers/mmc/host/sdhci-esdhc-imx.c:1511:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(sdhci_esdhc_imx_driver);
    ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/mmc/host.h:14:0,
                    from drivers/mmc/host/sdhci-esdhc-imx.c:17:
   drivers/mmc/host/sdhci-esdhc-imx.c:1511:24: error: invalid storage class for function 'sdhci_esdhc_imx_driver_exit'
    module_platform_driver(sdhci_esdhc_imx_driver);
                           ^
   include/linux/device.h:1616:20: note: in definition of macro 'module_driver'
    static void __exit __driver##_exit(void) \
                       ^~~~~~~~
   drivers/mmc/host/sdhci-esdhc-imx.c:1511:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(sdhci_esdhc_imx_driver);
    ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/device.h:1616:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
    static void __exit __driver##_exit(void) \
    ^
   include/linux/platform_device.h:229:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^~~~~~~~~~~~~
   drivers/mmc/host/sdhci-esdhc-imx.c:1511:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(sdhci_esdhc_imx_driver);
    ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/io.h:22:0,
                    from drivers/mmc/host/sdhci-esdhc-imx.c:11:
   drivers/mmc/host/sdhci-esdhc-imx.c:1511:24: error: initializer element is not constant
    module_platform_driver(sdhci_esdhc_imx_driver);
                           ^
   include/linux/init.h:235:50: note: in definition of macro '__exitcall'
     static exitcall_t __exitcall_##fn __exit_call = fn
                                                     ^~
   include/linux/device.h:1620:1: note: in expansion of macro 'module_exit'
    module_exit(__driver##_exit);
    ^~~~~~~~~~~
   include/linux/platform_device.h:229:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^~~~~~~~~~~~~
   drivers/mmc/host/sdhci-esdhc-imx.c:1511:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(sdhci_esdhc_imx_driver);
    ^~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/module.h:18:0,
                    from drivers/mmc/host/sdhci-esdhc-imx.c:15:
   include/linux/moduleparam.h:28:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
      struct __UNIQUE_ID(name) {}
      ^
   include/linux/module.h:161:32: note: in expansion of macro '__MODULE_INFO'
    #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
                                   ^~~~~~~~~~~~~
   include/linux/module.h:208:42: note: in expansion of macro 'MODULE_INFO'
    #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
                                             ^~~~~~~~~~~
   drivers/mmc/host/sdhci-esdhc-imx.c:1513:1: note: in expansion of macro 'MODULE_DESCRIPTION'
    MODULE_DESCRIPTION("SDHCI driver for Freescale i.MX eSDHC");
    ^~~~~~~~~~~~~~~~~~
   In file included from <command-line>:0:0:
   include/linux/compiler-gcc.h:75:45: error: expected declaration or statement at end of input
    #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
                                                ^
   include/linux/compiler_types.h:53:23: note: in definition of macro '___PASTE'
    #define ___PASTE(a,b) a##b
                          ^
   include/linux/compiler-gcc.h:75:29: note: in expansion of macro '__PASTE'
    #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
                                ^~~~~~~
   include/linux/compiler_types.h:54:22: note: in expansion of macro '___PASTE'
    #define __PASTE(a,b) ___PASTE(a,b)
                         ^~~~~~~~
   include/linux/compiler-gcc.h:75:37: note: in expansion of macro '__PASTE'
    #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
                                        ^~~~~~~
   include/linux/moduleparam.h:28:10: note: in expansion of macro '__UNIQUE_ID'
      struct __UNIQUE_ID(name) {}
             ^~~~~~~~~~~
   include/linux/module.h:161:32: note: in expansion of macro '__MODULE_INFO'
    #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
                                   ^~~~~~~~~~~~~
   include/linux/module.h:199:34: note: in expansion of macro 'MODULE_INFO'
    #define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
                                     ^~~~~~~~~~~
>> drivers/mmc/host/sdhci-esdhc-imx.c:1515:1: note: in expansion of macro 'MODULE_LICENSE'
    MODULE_LICENSE("GPL v2");
    ^~~~~~~~~~~~~~

vim +/MODULE_LICENSE +1515 drivers/mmc/host/sdhci-esdhc-imx.c

85d6509dc8 Shawn Guo    2011-05-27  1512  
85d6509dc8 Shawn Guo    2011-05-27  1513  MODULE_DESCRIPTION("SDHCI driver for Freescale i.MX eSDHC");
035ff831cd Wolfram Sang 2015-04-20  1514  MODULE_AUTHOR("Wolfram Sang <kernel@pengutronix.de>");
85d6509dc8 Shawn Guo    2011-05-27 @1515  MODULE_LICENSE("GPL v2");

:::::: The code at line 1515 was first introduced by commit
:::::: 85d6509dc8ca24b2b652863ef7a75622ddca17d6 mmc: sdhci: make sdhci-pltfm device drivers self registered

:::::: TO: Shawn Guo <shawn.guo@linaro.org>
:::::: CC: Chris Ball <cjb@laptop.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Adrian Hunter Dec. 27, 2018, 8:01 a.m. UTC | #2
On 20/12/18 9:49 AM, BOUGH CHEN wrote:
> i.MX6ULL has errata ERR010450, point out that due to SOC I/O
> timing limitation, for eMMC HS200 and SD/SDIO 3.0 SDR104, the
> clock rate can't exceed 150MHz. And for eMMC DDR52 and SD/SDIO
> DDR50 mode, the clock rate can't exceed 45MHz.
> 
> This patch add this limit for imx6ull.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>

Apart from the kbuild test robot complaints (do they need to be fixed?):

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index d0d3193..75a2484 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -138,7 +138,11 @@
>  #define ESDHC_FLAG_HS200		BIT(8)
>  /* The IP supports HS400 mode */
>  #define ESDHC_FLAG_HS400		BIT(9)
> -
> +/* The IP has errata ERR010450
> + * uSDHC: Due to the I/O timing limit, for SDR mode, SD card clock can't
> + * exceed 150MHz, for DDR mode, SD card clock can't exceed 45MHz.
> + */
> +#define ESDHC_FLAG_ERR010450           BIT(10)
>  /* A clock frequency higher than this rate requires strobe dll control */
>  #define ESDHC_STROBE_DLL_CLK_FREQ	100000000
>  
> @@ -177,6 +181,12 @@ struct esdhc_soc_data {
>  			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200,
>  };
>  
> +static struct esdhc_soc_data usdhc_imx6ull_data = {
> +	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
> +			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
> +			| ESDHC_FLAG_ERR010450,
> +};
> +
>  static struct esdhc_soc_data usdhc_imx7d_data = {
>  	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
>  			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
> @@ -227,6 +237,7 @@ struct pltfm_imx_data {
>  	{ .compatible = "fsl,imx6sx-usdhc", .data = &usdhc_imx6sx_data, },
>  	{ .compatible = "fsl,imx6sl-usdhc", .data = &usdhc_imx6sl_data, },
>  	{ .compatible = "fsl,imx6q-usdhc", .data = &usdhc_imx6q_data, },
> +	{ .compatible = "fsl,imx6ull-usdhc", .data = &usdhc_imx6ull_data, },
>  	{ .compatible = "fsl,imx7d-usdhc", .data = &usdhc_imx7d_data, },
>  	{ /* sentinel */ }
>  };
> @@ -733,6 +744,12 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
>  		| ESDHC_CLOCK_MASK);
>  	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
>  
> +	if (imx_data->socdata->flags & ESDHC_FLAG_ERR010450) {
> +		if (imx_data->is_ddr)
> +			clock = clock > 45000000 ? 45000000 : clock;
> +		else
> +			clock = clock > 150000000 ? 150000000 : clock;
> +
>  	while (host_clock / (16 * pre_div * ddr_pre_div) > clock &&
>  			pre_div < 256)
>  		pre_div *= 2;
>
Russell King (Oracle) Dec. 27, 2018, 12:22 p.m. UTC | #3
On Thu, Dec 27, 2018 at 10:01:24AM +0200, Adrian Hunter wrote:
> On 20/12/18 9:49 AM, BOUGH CHEN wrote:
> > i.MX6ULL has errata ERR010450, point out that due to SOC I/O
> > timing limitation, for eMMC HS200 and SD/SDIO 3.0 SDR104, the
> > clock rate can't exceed 150MHz. And for eMMC DDR52 and SD/SDIO
> > DDR50 mode, the clock rate can't exceed 45MHz.
> > 
> > This patch add this limit for imx6ull.
> > 
> > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> 
> Apart from the kbuild test robot complaints (do they need to be fixed?):
> 
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>

Nacked-by: Russell King <rmk+kernel@armlinux.org.uk>

The kbuild test robot complaints do need to be fixed first.  They're
confusing because GCC produces quite a lot of garbage in its error
messages now.  If you look at the patch, there's a hunk that has:

+       if (imx_data->socdata->flags & ESDHC_FLAG_ERR010450) {
+               if (imx_data->is_ddr)
+                       clock = clock > 45000000 ? 45000000 : clock;
+               else
+                       clock = clock > 150000000 ? 150000000 : clock;
+

which is missing a closing brace.  This patch could not have been
build tested before it was mailed to the list, and the test robot
is highlighting that fact.

It may also be a good idea to encourage a different approach to the
above anyway:

	if (imx_data->socdata->flags & ESDHC_FLAG_ERR010450) {
		unsigned long max_clock;

		max_clock = imx_data->is_ddr ? 45000000 : 150000000;

		clock = max(clock, max_clock);
	}

rather than open-coding the max() stuff in the driver.

Thanks.
Bough Chen Dec. 28, 2018, 2:40 a.m. UTC | #4
> -----Original Message-----
> From: Russell King - ARM Linux [mailto:linux@armlinux.org.uk]
> Sent: 2018年12月27日 20:23
> To: Adrian Hunter <adrian.hunter@intel.com>
> Cc: BOUGH CHEN <haibo.chen@nxp.com>; ulf.hansson@linaro.org;
> robh+dt@kernel.org; mark.rutland@arm.com; shawnguo@kernel.org;
> s.hauer@pengutronix.de; kernel@pengutronix.de; Fabio Estevam
> <fabio.estevam@nxp.com>; devicetree@vger.kernel.org;
> linux-mmc@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> linux-arm-kernel@lists.infradead.org
> Subject: Re: [PATCH 2/3] mmc: sdhci-esdhc-imx: add SD clock limitation for
> imx6ull
> 
> On Thu, Dec 27, 2018 at 10:01:24AM +0200, Adrian Hunter wrote:
> > On 20/12/18 9:49 AM, BOUGH CHEN wrote:
> > > i.MX6ULL has errata ERR010450, point out that due to SOC I/O timing
> > > limitation, for eMMC HS200 and SD/SDIO 3.0 SDR104, the clock rate
> > > can't exceed 150MHz. And for eMMC DDR52 and SD/SDIO
> > > DDR50 mode, the clock rate can't exceed 45MHz.
> > >
> > > This patch add this limit for imx6ull.
> > >
> > > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> >
> > Apart from the kbuild test robot complaints (do they need to be fixed?):
> >
> > Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> 
> Nacked-by: Russell King <rmk+kernel@armlinux.org.uk>
> 
> The kbuild test robot complaints do need to be fixed first.  They're confusing
> because GCC produces quite a lot of garbage in its error messages now.  If
> you look at the patch, there's a hunk that has:
> 
> +       if (imx_data->socdata->flags & ESDHC_FLAG_ERR010450) {
> +               if (imx_data->is_ddr)
> +                       clock = clock > 45000000 ? 45000000 : clock;
> +               else
> +                       clock = clock > 150000000 ? 150000000 : clock;
> +
> 
> which is missing a closing brace.  This patch could not have been build tested
> before it was mailed to the list, and the test robot is highlighting that fact.
> 

I'm really sorry about that.  Thanks for point out that, I will double check my patch when I mail to the list next time.

> It may also be a good idea to encourage a different approach to the above
> anyway:
> 
> 	if (imx_data->socdata->flags & ESDHC_FLAG_ERR010450) {
> 		unsigned long max_clock;
> 
> 		max_clock = imx_data->is_ddr ? 45000000 : 150000000;
> 
> 		clock = max(clock, max_clock);
> 	}
> 
> rather than open-coding the max() stuff in the driver.

Thanks for giving such a good suggestion, I will take care of it, with a little change:
		clock = min(clock, max_clock);

Best Regard
Bough Chen
> 
> Thanks.
> 
> --
> RMK's Patch system:
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
> armlinux.org.uk%2Fdeveloper%2Fpatches%2F&amp;data=02%7C01%7Chaibo.
> chen%40nxp.com%7C13ae59760de24de29a7c08d66bf61174%7C686ea1d3bc2
> b4c6fa92cd99c5c301635%7C0%7C0%7C636815101937146642&amp;sdata=UP
> S7z2UTLpfgqgyWFPM%2FyXP%2BQu1qULoavFOBLFWkQjw%3D&amp;reserved
> =0
> FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps
> up According to speedtest.net: 11.9Mbps down 500kbps up
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index d0d3193..75a2484 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -138,7 +138,11 @@ 
 #define ESDHC_FLAG_HS200		BIT(8)
 /* The IP supports HS400 mode */
 #define ESDHC_FLAG_HS400		BIT(9)
-
+/* The IP has errata ERR010450
+ * uSDHC: Due to the I/O timing limit, for SDR mode, SD card clock can't
+ * exceed 150MHz, for DDR mode, SD card clock can't exceed 45MHz.
+ */
+#define ESDHC_FLAG_ERR010450           BIT(10)
 /* A clock frequency higher than this rate requires strobe dll control */
 #define ESDHC_STROBE_DLL_CLK_FREQ	100000000
 
@@ -177,6 +181,12 @@  struct esdhc_soc_data {
 			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200,
 };
 
+static struct esdhc_soc_data usdhc_imx6ull_data = {
+	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
+			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
+			| ESDHC_FLAG_ERR010450,
+};
+
 static struct esdhc_soc_data usdhc_imx7d_data = {
 	.flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
 			| ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
@@ -227,6 +237,7 @@  struct pltfm_imx_data {
 	{ .compatible = "fsl,imx6sx-usdhc", .data = &usdhc_imx6sx_data, },
 	{ .compatible = "fsl,imx6sl-usdhc", .data = &usdhc_imx6sl_data, },
 	{ .compatible = "fsl,imx6q-usdhc", .data = &usdhc_imx6q_data, },
+	{ .compatible = "fsl,imx6ull-usdhc", .data = &usdhc_imx6ull_data, },
 	{ .compatible = "fsl,imx7d-usdhc", .data = &usdhc_imx7d_data, },
 	{ /* sentinel */ }
 };
@@ -733,6 +744,12 @@  static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
 		| ESDHC_CLOCK_MASK);
 	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
 
+	if (imx_data->socdata->flags & ESDHC_FLAG_ERR010450) {
+		if (imx_data->is_ddr)
+			clock = clock > 45000000 ? 45000000 : clock;
+		else
+			clock = clock > 150000000 ? 150000000 : clock;
+
 	while (host_clock / (16 * pre_div * ddr_pre_div) > clock &&
 			pre_div < 256)
 		pre_div *= 2;