Add device tree probe for sdhci-esdhc-imx
Subsystems (7)
v2 cover Add device tree probe for sdhci-esdhc-imx
The first patch removes the uses of cpu_is_mx(), the second one makes a dt related fix on sdhci-pltfm.c, and the third one adds device tree probe for sdhci-esdhc-imx driver.
Changes since v1:
* Address review comments given by Grant
Shawn Guo (3):
mmc: sdhci-esdhc-imx: get rid of the uses of cpu_is_mx()
mmc: sdhci-pltfm: dt device does not pass parent to sdhci_alloc_host
mmc: sdhci-esdhc-imx: add device tree probe support
.../devicetree/bindings/mmc/fsl-imx-esdhc.txt | 40 ++++++ arch/arm/mach-imx/clock-imx25.c | 4 +- arch/arm/mach-imx/clock-imx35.c | 6 +- arch/arm/mach-mx5/clock-mx51-mx53.c | 16 +- arch/arm/mach-mx5/mx51_efika.c | 4 +- .../plat-mxc/devices/platform-sdhci-esdhc-imx.c | 17 ++- arch/arm/plat-mxc/include/mach/devices-common.h | 1 + drivers/mmc/host/sdhci-esdhc-imx.c | 144 ++++++++++++++++++-- drivers/mmc/host/sdhci-pltfm.c | 3 +- 9 files changed, 202 insertions(+), 33 deletions(-)
PATCH v2 1/3 mmc: sdhci-esdhc-imx: get rid of the uses of cpu_is_mx()
The patch removes all the uses of cpu_is_mx(). Instead, it utilizes platform_device_id to distinguish the esdhc differences among SoCs.
--- arch/arm/mach-imx/clock-imx25.c | 4 +- arch/arm/mach-imx/clock-imx35.c | 6 +- arch/arm/mach-mx5/clock-mx51-mx53.c | 16 +++--- arch/arm/mach-mx5/mx51_efika.c | 4 +- .../plat-mxc/devices/platform-sdhci-esdhc-imx.c | 17 +++--- arch/arm/plat-mxc/include/mach/devices-common.h | 1 + drivers/mmc/host/sdhci-esdhc-imx.c | 60 ++++++++++++++++++- 7 files changed, 81 insertions(+), 27 deletions(-)
arch/arm/mach-imx/clock-imx25.c +2 -2
@@ -300,8 +300,8 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("imx2-wdt.0", NULL, wdt_clk) _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx25.0", NULL, esdhc1_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx25.1", NULL, esdhc2_clk) _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk) _REGISTER_CLOCK(NULL, "audmux", audmux_clk)_REGISTER_CLOCK ("flexcan.0" ,NULL , can1_clk)
arch/arm/mach-imx/clock-imx35.c +3 -3
@@ -458,9 +458,9 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("imx-epit.0", NULL, epit1_clk) _REGISTER_CLOCK("imx-epit.1", NULL, epit2_clk) _REGISTER_CLOCK(NULL, "esai", esai_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx35.0", NULL, esdhc1_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx35.1", NULL, esdhc2_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx35.2", NULL, esdhc3_clk) _REGISTER_CLOCK("fec.0", NULL, fec_clk) _REGISTER_CLOCK(NULL, "gpio", gpio1_clk)_REGISTER_CLOCK (NULL ,"gpio" , gpio2_clk)
arch/arm/mach-mx5/clock-mx51-mx53.c +8 -8
@@ -1453,10 +1453,10 @@ static struct clk_lookup mx51_lookups[] = { _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk) _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk) _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.3", NULL, esdhc4_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx51.0", NULL, esdhc1_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx51.1", NULL, esdhc2_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx51.2", NULL, esdhc3_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx51.3", NULL, esdhc4_clk) _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk) _REGISTER_CLOCK(NULL, "iim_clk", iim_clk)_REGISTER_CLOCK ("imx2-wdt.0" ,NULL , dummy_clk)
@@ -1480,10 +1480,10 @@ static struct clk_lookup mx53_lookups[] = { _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) _REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_mx53_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_mx53_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_mx53_clk) - _REGISTER_CLOCK("sdhci-esdhc-imx.3", NULL, esdhc4_mx53_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx53.0", NULL, esdhc1_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx53.1", NULL, esdhc2_mx53_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx53.2", NULL, esdhc3_mx53_clk) + _REGISTER_CLOCK("sdhci-esdhc-imx53.3", NULL, esdhc4_mx53_clk) _REGISTER_CLOCK("imx53-ecspi.0", NULL, ecspi1_clk) _REGISTER_CLOCK("imx53-ecspi.1", NULL, ecspi2_clk)_REGISTER_CLOCK ("imx53-cspi.0" ,NULL , cspi_clk)
arch/arm/mach-mx5/mx51_efika.c +2 -2
@@ -260,8 +260,8 @@ static struct regulator_consumer_supply vvideo_consumers[] = { };static struct regulator_consumer_supply vsd_consumers[] = { -REGULATOR_SUPPLY ("vmmc" ,"sdhci-esdhc-imx.0" ), -REGULATOR_SUPPLY ("vmmc" ,"sdhci-esdhc-imx.1" ), +REGULATOR_SUPPLY ("vmmc" ,"sdhci-esdhc-imx51.0" ), +REGULATOR_SUPPLY ("vmmc" ,"sdhci-esdhc-imx51.1" ), };static struct regulator_consumer_supply pwgt1_consumer[] = {
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +9 -8
@@ -10,21 +10,22 @@#include <mach/devices-common.h> #include <mach/esdhc.h> -#define imx_sdhci_esdhc_imx_data_entry_single (soc, _id, hwid) \ +#define imx_sdhci_esdhc_imx_data_entry_single (soc, _devid, _id, hwid) \ { \ + .devid = _devid, \ .id = _id, \ .iobase = soc ## _ESDHC ## hwid ## _BASE_ADDR, \ .irq = soc ## _INT_ESDHC ## hwid, \ } -#define imx_sdhci_esdhc_imx_data_entry (soc, id, hwid) \ - [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, id, hwid) +#define imx_sdhci_esdhc_imx_data_entry (soc, devid, id, hwid) \ + [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, devid, id, hwid)#ifdef CONFIG_SOC_IMX25 const struct imx_sdhci_esdhc_imx_data imx25_sdhci_esdhc_imx_data[]__initconst = { #define imx25_sdhci_esdhc_imx_data_entry(_id, _hwid) \ - imx_sdhci_esdhc_imx_data_entry(MX25, _id, _hwid) + imx_sdhci_esdhc_imx_data_entry(MX25, "sdhci-esdhc-imx25", _id, _hwid)imx25_sdhci_esdhc_imx_data_entry (0 ,1 ),imx25_sdhci_esdhc_imx_data_entry (1 ,2 ), };
@@ -34,7 +35,7 @@ imx25_sdhci_esdhc_imx_data[] __initconst = {const struct imx_sdhci_esdhc_imx_data imx35_sdhci_esdhc_imx_data[]__initconst = { #define imx35_sdhci_esdhc_imx_data_entry(_id, _hwid) \ - imx_sdhci_esdhc_imx_data_entry(MX35, _id, _hwid) + imx_sdhci_esdhc_imx_data_entry(MX35, "sdhci-esdhc-imx35", _id, _hwid)imx35_sdhci_esdhc_imx_data_entry (0 ,1 ),imx35_sdhci_esdhc_imx_data_entry (1 ,2 ),imx35_sdhci_esdhc_imx_data_entry (2 ,3 ),
@@ -45,7 +46,7 @@ imx35_sdhci_esdhc_imx_data[] __initconst = {const struct imx_sdhci_esdhc_imx_data imx51_sdhci_esdhc_imx_data[]__initconst = { #define imx51_sdhci_esdhc_imx_data_entry(_id, _hwid) \ - imx_sdhci_esdhc_imx_data_entry(MX51, _id, _hwid) + imx_sdhci_esdhc_imx_data_entry(MX51, "sdhci-esdhc-imx51", _id, _hwid)imx51_sdhci_esdhc_imx_data_entry (0 ,1 ),imx51_sdhci_esdhc_imx_data_entry (1 ,2 ),imx51_sdhci_esdhc_imx_data_entry (2 ,3 ),
@@ -57,7 +58,7 @@ imx51_sdhci_esdhc_imx_data[] __initconst = {const struct imx_sdhci_esdhc_imx_data imx53_sdhci_esdhc_imx_data[]__initconst = { #define imx53_sdhci_esdhc_imx_data_entry(_id, _hwid) \ - imx_sdhci_esdhc_imx_data_entry(MX53, _id, _hwid) + imx_sdhci_esdhc_imx_data_entry(MX53, "sdhci-esdhc-imx53", _id, _hwid)imx53_sdhci_esdhc_imx_data_entry (0 ,1 ),imx53_sdhci_esdhc_imx_data_entry (1 ,2 ),imx53_sdhci_esdhc_imx_data_entry (2 ,3 ),
@@ -93,6 +94,6 @@ struct platform_device *__init imx_add_sdhci_esdhc_imx(if (!pdata) pdata = &default_esdhc_pdata; -return imx_add_platform_device ("sdhci-esdhc-imx" , data->id, res, +return imx_add_platform_device (data->devid, data->id, res,ARRAY_SIZE (res), pdata,sizeof (*pdata)); }
arch/arm/plat-mxc/include/mach/devices-common.h +1 -0
@@ -276,6 +276,7 @@ struct platform_device *__init imx_add_mxc_w1(#include <mach/esdhc.h> struct imx_sdhci_esdhc_imx_data { +const char *devid;int id;resource_size_t iobase;resource_size_t irq;
drivers/mmc/host/sdhci-esdhc-imx.c +56 -4
104 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v2 1/3 mmc: sdhci-esdhc-imx: get rid of the uses of cpu_is_mx()
Quoted 6 lines · Shawn Guo
The patch removes all the uses of
cpu_is_mx(). ?Instead, it utilizesplatform_device_idto distinguish the esdhc differences among SoCs.Signed-off-by Shawn Guo <[email protected]>Cc Wolfram Sang <[email protected]>Cc Chris Ball <[email protected]>
Quoted 292 lines
---
?arch/arm/mach-imx/clock-imx25.c ? ? ? ? ? ? ? ? ? ?| ? ?4 +- ?arch/arm/mach-imx/clock-imx35.c ? ? ? ? ? ? ? ? ? ?| ? ?6 +- ?arch/arm/mach-mx5/clock-mx51-mx53.c ? ? ? ? ? ? ? ?| ? 16 +++--- ?arch/arm/mach-mx5/mx51_efika.c ? ? ? ? ? ? ? ? ? ? | ? ?4 +- ?.../plat-mxc/devices/platform-sdhci-esdhc-imx.c ? ?| ? 17 +++--- ?arch/arm/plat-mxc/include/mach/devices-common.h ? ?| ? ?1 + ?drivers/mmc/host/sdhci-esdhc-imx.c ? ? ? ? ? ? ? ? | ? 60 ++++++++++++++++++-?7 files changed, 81 insertions(+), 27 deletions(-)
arch/arm/mach-imx/clock-imx25.c +2
-2@@ -300,8 +300,8 @@ static struct clk_lookup lookups[] = { ? ? ? ?_REGISTER_CLOCK("imx2-wdt.0", NULL, wdt_clk) ? ? ? ?_REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) ? ? ? ?_REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx25.0", NULL, esdhc1_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx25.1", NULL, esdhc2_clk) ? ? ? ?_REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk) ? ? ? ?_REGISTER_CLOCK(NULL, "audmux", audmux_clk) ? ? ? ?_REGISTER_CLOCK("flexcan.0", NULL, can1_clk)arch/arm/mach-imx/clock-imx35.c +3
-3@@ -458,9 +458,9 @@ static struct clk_lookup lookups[] = { ? ? ? ?_REGISTER_CLOCK("imx-epit.0", NULL, epit1_clk) ? ? ? ?_REGISTER_CLOCK("imx-epit.1", NULL, epit2_clk) ? ? ? ?_REGISTER_CLOCK(NULL, "esai", esai_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx35.0", NULL, esdhc1_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx35.1", NULL, esdhc2_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx35.2", NULL, esdhc3_clk) ? ? ? ?_REGISTER_CLOCK("fec.0", NULL, fec_clk) ? ? ? ?_REGISTER_CLOCK(NULL, "gpio", gpio1_clk) ? ? ? ?_REGISTER_CLOCK(NULL, "gpio", gpio2_clk)arch/arm/mach-mx5/clock-mx51-mx53.c +8
-8@@ -1453,10 +1453,10 @@ static struct clk_lookup mx51_lookups[] = { ? ? ? ?_REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk) ? ? ? ?_REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk) ? ? ? ?_REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.3", NULL, esdhc4_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx51.0", NULL, esdhc1_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx51.1", NULL, esdhc2_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx51.2", NULL, esdhc3_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx51.3", NULL, esdhc4_clk) ? ? ? ?_REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk) ? ? ? ?_REGISTER_CLOCK(NULL, "iim_clk", iim_clk) ? ? ? ?_REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)@@ -1480,10 +1480,10 @@ static struct clk_lookup mx53_lookups[] = { ? ? ? ?_REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) ? ? ? ?_REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) ? ? ? ?_REGISTER_CLOCK("imx-i2c.2", NULL, i2c3_mx53_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_mx53_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_mx53_clk) - ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx.3", NULL, esdhc4_mx53_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx53.0", NULL, esdhc1_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx53.1", NULL, esdhc2_mx53_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx53.2", NULL, esdhc3_mx53_clk) + ? ? ? _REGISTER_CLOCK("sdhci-esdhc-imx53.3", NULL, esdhc4_mx53_clk) ? ? ? ?_REGISTER_CLOCK("imx53-ecspi.0", NULL, ecspi1_clk) ? ? ? ?_REGISTER_CLOCK("imx53-ecspi.1", NULL, ecspi2_clk) ? ? ? ?_REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk)arch/arm/mach-mx5/mx51_efika.c +2
-2@@ -260,8 +260,8 @@ static struct regulator_consumer_supply vvideo_consumers[] = { ?}; ?static struct regulator_consumer_supply vsd_consumers[] = { - ? ? ? REGULATOR_SUPPLY("vmmc", "sdhci-esdhc-imx.0"), - ? ? ? REGULATOR_SUPPLY("vmmc", "sdhci-esdhc-imx.1"), + ? ? ? REGULATOR_SUPPLY("vmmc", "sdhci-esdhc-imx51.0"), + ? ? ? REGULATOR_SUPPLY("vmmc", "sdhci-esdhc-imx51.1"), ?}; ?static struct regulator_consumer_supply pwgt1_consumer[] = {arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +0
-0@@ -10,21 +10,22 @@?#include <
mach/devices-common.h>
?#include <mach/esdhc.h>arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +1
-1-#define imx_sdhci_esdhc_imx_data_entry_single (soc, _id, hwid) \ +#define imx_sdhci_esdhc_imx_data_entry_single (soc, _devid, _id, hwid) \? ? ? ?{ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
+ ? ? ? ? ? ? ? .devid =_devid, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
? ? ? ? ? ? ? ?.id =_id, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
? ? ? ? ? ? ? ?.iobase = soc ##_ESDHC## hwid ##_BASE_ADDR, ?\
? ? ? ? ? ? ? ?.irq = soc ##_INT_ESDHC## hwid, ? ? ? ? ? ? ? ? ? ? ? \
? ? ? ?}arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +2
-2-#define imx_sdhci_esdhc_imx_data_entry (soc, id, hwid) ?\ - ? ? ? [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, id, hwid) +#define imx_sdhci_esdhc_imx_data_entry (soc, devid, id, hwid) ? \ + ? ? ? [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, devid, id, hwid)?#ifdef
CONFIG_SOC_IMX25
?const structimx_sdhci_esdhc_imx_data?imx25_sdhci_esdhc_imx_data[]__initconst= {
?#defineimx25_sdhci_esdhc_imx_data_entry(_id, _hwid)? ? ? ? ? ? ? ? ? \
- ? ? ?imx_sdhci_esdhc_imx_data_entry(MX25, _id, _hwid)
+ ? ? ?imx_sdhci_esdhc_imx_data_entry(MX25, "sdhci-esdhc-imx25", _id, _hwid)? ? ? ?imx25_sdhci_esdhc_imx_data_entry(0, 1),
? ? ? ?imx25_sdhci_esdhc_imx_data_entry(1, 2),
?};arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +0
-0@@ -34,7 +35,7 @@ imx25_sdhci_esdhc_imx_data[] __initconst = {?const struct
imx_sdhci_esdhc_imx_data?imx35_sdhci_esdhc_imx_data[]__initconst= {
?#defineimx35_sdhci_esdhc_imx_data_entry(_id, _hwid)? ? ? ? ? ? ? ? ? \
- ? ? ?imx_sdhci_esdhc_imx_data_entry(MX35, _id, _hwid)
+ ? ? ?imx_sdhci_esdhc_imx_data_entry(MX35, "sdhci-esdhc-imx35", _id, _hwid)? ? ? ?imx35_sdhci_esdhc_imx_data_entry(0, 1),
? ? ? ?imx35_sdhci_esdhc_imx_data_entry(1, 2),
? ? ? ?imx35_sdhci_esdhc_imx_data_entry(2, 3),arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +0
-0@@ -45,7 +46,7 @@ imx35_sdhci_esdhc_imx_data[] __initconst = {?const struct
imx_sdhci_esdhc_imx_data?imx51_sdhci_esdhc_imx_data[]__initconst= {
?#defineimx51_sdhci_esdhc_imx_data_entry(_id, _hwid)? ? ? ? ? ? ? ? ? \
- ? ? ?imx_sdhci_esdhc_imx_data_entry(MX51, _id, _hwid)
+ ? ? ?imx_sdhci_esdhc_imx_data_entry(MX51, "sdhci-esdhc-imx51", _id, _hwid)? ? ? ?imx51_sdhci_esdhc_imx_data_entry(0, 1),
? ? ? ?imx51_sdhci_esdhc_imx_data_entry(1, 2),
? ? ? ?imx51_sdhci_esdhc_imx_data_entry(2, 3),arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +0
-0@@ -57,7 +58,7 @@ imx51_sdhci_esdhc_imx_data[] __initconst = {?const struct
imx_sdhci_esdhc_imx_data?imx53_sdhci_esdhc_imx_data[]__initconst= {
?#defineimx53_sdhci_esdhc_imx_data_entry(_id, _hwid)? ? ? ? ? ? ? ? ? \
- ? ? ?imx_sdhci_esdhc_imx_data_entry(MX53, _id, _hwid)
+ ? ? ?imx_sdhci_esdhc_imx_data_entry(MX53, "sdhci-esdhc-imx53", _id, _hwid)? ? ? ?imx53_sdhci_esdhc_imx_data_entry(0, 1),
? ? ? ?imx53_sdhci_esdhc_imx_data_entry(1, 2),
? ? ? ?imx53_sdhci_esdhc_imx_data_entry(2, 3),arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +1
-1@@ -93,6 +94,6 @@ struct platform_device *__init imx_add_sdhci_esdhc_imx( ? ? ? ?if (!pdata) ? ? ? ? ? ? ? ?pdata = &default_esdhc_pdata; - ? ? ? return imx_add_platform_device("sdhci-esdhc-imx", data->id, res, + ? ? ? return imx_add_platform_device(data->devid, data->id, res, ? ? ? ? ? ? ? ? ? ? ? ?ARRAY_SIZE(res), pdata, sizeof(*pdata)); ?}arch/arm/plat-mxc/include/mach/devices-common.h +0
-0@@ -276,6 +276,7 @@ struct platform_device *__init imx_add_mxc_w1(?#include <
mach/esdhc.h>
?structimx_sdhci_esdhc_imx_data{
+ ? ? ? const char *devid;
? ? ? ?int id;
? ? ? ?resource_size_t iobase;
? ? ? ?resource_size_t irq;drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -20,7 +20,6 @@?#include <
linux/mmc/host.h>
?#include <linux/mmc/mmc.h>
?#include <linux/mmc/sdio.h>
-#include <mach/hardware.h>
?#include <mach/esdhc.h>
?#include "sdhci-pltfm.h"
?#include "sdhci-esdhc.h"drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -42,11 +41,57 @@?*/
?#defineESDHC_FLAG_MULTIBLK_NO_INT? ? (1 << 1)drivers/mmc/host/sdhci-esdhc-imx.c +7
-0+enum imx_esdhc_type { + ? ? ? IMX25_ESDHC, + ? ? ? IMX35_ESDHC, + ? ? ? IMX51_ESDHC, + ? ? ? IMX53_ESDHC, +}; +?struct
pltfm_imx_data{
? ? ? ?int flags;
? ? ? ?u32 scratchpad;
+ ? ? ? enumimx_esdhc_typedevtype;drivers/mmc/host/sdhci-esdhc-imx.c +18
-0+}; + +static struct platform_device_id imx_esdhc_devtype[] = { + ? ? ? { + ? ? ? ? ? ? ? .name = "sdhci-esdhc-imx25", + ? ? ? ? ? ? ? .driver_data = IMX25_ESDHC, + ? ? ? }, { + ? ? ? ? ? ? ? .name = "sdhci-esdhc-imx35", + ? ? ? ? ? ? ? .driver_data = IMX35_ESDHC, + ? ? ? }, { + ? ? ? ? ? ? ? .name = "sdhci-esdhc-imx51", + ? ? ? ? ? ? ? .driver_data = IMX51_ESDHC, + ? ? ? }, { + ? ? ? ? ? ? ? .name = "sdhci-esdhc-imx53", + ? ? ? ? ? ? ? .driver_data = IMX53_ESDHC, + ? ? ? }, { + ? ? ? ? ? ? ? /* sentinel */ + ? ? ? }?};
drivers/mmc/host/sdhci-esdhc-imx.c +20
-0+static inline int is_imx25_esdhc (struct pltfm_imx_data *data) +{ + ? ? ? return data->devtype == IMX25_ESDHC; +} + +static inline int is_imx35_esdhc (struct pltfm_imx_data *data) +{ + ? ? ? return data->devtype == IMX35_ESDHC; +} + +static inline int is_imx51_esdhc (struct pltfm_imx_data *data) +{ + ? ? ? return data->devtype == IMX51_ESDHC; +} + +static inline int is_imx53_esdhc (struct pltfm_imx_data *data) +{ + ? ? ? return data->devtype == IMX53_ESDHC; +} +?static unsigned int
esdhc_pltfm_get_max_blk_size(struct sdhci_host *host)?{
? ? ? ?/* Force 2048 bytes, which is the maximum supported size in SDHCI. */drivers/mmc/host/sdhci-esdhc-imx.c +3
-0@@ -55,8 +100,12 @@ static unsigned int esdhc_pltfm_get_max_blk_size(struct sdhci_host *host) ?static unsigned int esdhc_pltfm_get_max_blk_count(struct sdhci_host *host) ?{ + ? ? ? struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + ? ? ? struct pltfm_imx_data *imx_data = pltfm_host->priv; +? ? ? ?/* Fix errata ENGcm07207 which is present on i.MX25 and i.MX35 */
- ? ? ? return (cpu_is_mx25()||cpu_is_mx35()) ? 1 : 65535;
+ ? ? ? return (is_imx25_esdhc(imx_data)||is_imx35_esdhc(imx_data)) ?
+ ? ? ? ? ? ? ? 1 : 65535;
?}?static inline void
esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)drivers/mmc/host/sdhci-esdhc-imx.c +5
-2@@ -274,6 +323,8 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) ? ? ? ?imx_data = kzalloc(sizeof(struct pltfm_imx_data), GFP_KERNEL); ? ? ? ?if (!imx_data) ? ? ? ? ? ? ? ?return -ENOMEM; + + ? ? ? imx_data->devtype = pdev->id_entry->driver_data; ? ? ? ?pltfm_host->priv = imx_data; ? ? ? ?clk = clk_get(mmc_dev(host->mmc), NULL);@@ -285,10 +336,10 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) ? ? ? ?clk_enable(clk); ? ? ? ?pltfm_host->clk = clk; - ? ? ? if (!cpu_is_mx25()) + ? ? ? if (!is_imx25_esdhc(imx_data)) ? ? ? ? ? ? ? ?host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; - ? ? ? if (!(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx51())) + ? ? ? if (is_imx53_esdhc(imx_data)) ? ? ? ? ? ? ? ?imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT; ? ? ? ?boarddata = host->mmc->parent->platform_data;@@ -401,6 +452,7 @@ static struct platform_driver sdhci_esdhc_imx_driver = { ? ? ? ? ? ? ? ?.name ? = "sdhci-esdhc-imx", ? ? ? ? ? ? ? ?.owner ?= THIS_MODULE, ? ? ? ?}, + ? ? ? .id_table ? ? ? = imx_esdhc_devtype, ? ? ? ?.probe ? ? ? ? ?= sdhci_esdhc_imx_probe, ? ? ? ?.remove ? ? ? ? = __devexit_p(sdhci_esdhc_imx_remove),?#ifdef
CONFIG_PM
--
1.7.4.1_______________________________________________
devicetree-discuss mailing list
devicetree-discuss at lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
PATCH v2 2/3 mmc: sdhci-pltfm: dt device does not pass parent to sdhci_alloc_host
In reply to Shawn GuoNeither platform based nor dt based device needs to pass the parent to sdhci_alloc_host. There is no difference between platform and dt on this point.
The patch makes the change to pass device itself than its parent to sdhci_alloc_host for dt case too. Otherwise the probe function of sdhci based drivers which is shared between platform and dt will fail on dt case.
--- drivers/mmc/host/sdhci-pltfm.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +2 -1
@@ -85,6 +85,7 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, {struct sdhci_host *host;struct sdhci_pltfm_host *pltfm_host; +struct device_node *np = pdev->dev.of_node;struct resource *iomem;int ret;
@@ -98,7 +99,7 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,dev_err (&pdev->dev,"Invalid iomem size!\n" );/* Some PCI-based MFD need the parent here */ -if (pdev->dev.parent != &platform_bus) +if (pdev->dev.parent != &platform_bus && !np) host =sdhci_alloc_host (pdev->dev.parent,sizeof (*pltfm_host));else host =sdhci_alloc_host (&pdev->dev,sizeof (*pltfm_host));
Signature · 1 line
1.7.4.1
PATCH v2 2/3 mmc: sdhci-pltfm: dt device does not pass parent to sdhci_alloc_host
Hello.
Quoted 5 lines · Shawn Guo
Neither platform based nor dt based device needs to pass the parent to
sdhci_alloc_host. There is no difference between platform and dt on this point.The patch makes the change to pass device itself than its parent to
Maybe "rather than"?
Quoted 7 lines
sdhci_alloc_hostfor dt case too. Otherwise the probe function of sdhci based drivers which is shared between platform and dt will fail on dt case.Signed-off-by Shawn Guo<[email protected]>Acked-by Grant Likely<[email protected]>Cc Chris Ball<[email protected]>
WBR, Sergei
PATCH v2 3/3 mmc: sdhci-esdhc-imx: add device tree probe support
In reply to Shawn GuoThe patch adds device tree probe support for sdhci-esdhc-imx driver.
--- .../devicetree/bindings/mmc/fsl-imx-esdhc.txt | 40 ++++++++ drivers/mmc/host/sdhci-esdhc-imx.c | 102 +++++++++++++++++++- 2 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +40 -0
@@ -0,0 +1,40 @@ +* Freescale Enhanced Secure Digital Host Controller (eSDHC) for i.MX + +The Enhanced Secure Digital Host Controller on Freescale i.MX family +provides an interface for MMC, SD, and SDIO types of memory cards. + +Required properties: +- compatible : Should be "fsl,<chip>-esdhc" +- reg : Should contain eSDHC registers location and length +- interrupts : Should contain eSDHC interrupt +- cd-type : String, card detection (CD) method. Supported values are: + "none" : No CD + "controller" : Uses eSDHC controller internal CD signal + "gpio" : Uses GPIO pin for CD + "permanent" : No CD because card is permanently wired to host +- wp-type : String, write protection (WP) method. Supported values are: + "none" : No WP + "controller" : Uses eSDHC controller internal WP signal + "gpio" : Uses GPIO pin for WP +- gpios : Should specify GPIOs in this order: CD GPIO, WP GPIO, if + properties cd-type and wp-type are "gpio". + +Examples: + +esdhc@70004000 { + compatible = "fsl,imx51-esdhc"; + reg = <0x70004000 0x4000>; + interrupts = <1>; + fsl,cd-type = "controller"; + fsl,wp-type = "controller"; +}; + +esdhc@70008000 { + compatible = "fsl,imx51-esdhc"; + reg = <0x70008000 0x4000>; + interrupts = <2>; + fsl,cd-type = "gpio"; + fsl,wp-type = "gpio"; + cd-gpios = <&gpio0 6 0>; /* GPIO1_6 */ + wp-gpios = <&gpio0 5 0>; /* GPIO1_5 */ +};
drivers/mmc/host/sdhci-esdhc-imx.c +97 -5
157 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v2 3/3 mmc: sdhci-esdhc-imx: add device tree probe support
Quoted 28 lines · Shawn Guo
The patch adds device tree probe support for sdhci-esdhc-imx driver.
Signed-off-by Shawn Guo <[email protected]>Cc Wolfram Sang <[email protected]>Cc Chris Ball <[email protected]>Cc Grant Likely <[email protected]>---
?.../devicetree/bindings/mmc/fsl-imx-esdhc.txt ? ? ?| ? 40 ++++++++ ?drivers/mmc/host/sdhci-esdhc-imx.c ? ? ? ? ? ? ? ? | ?102 +++++++++++++++++++- ?2 files changed, 137 insertions(+), 5 deletions(-)
?create mode 100644Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txtDocumentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +10
-0@@ -0,0 +1,40 @@ +* Freescale Enhanced Secure Digital Host Controller (eSDHC) for i.MX + +The Enhanced Secure Digital Host Controller on Freescale i.MX family +provides an interface for MMC, SD, and SDIO types of memory cards. + +Required properties: +- compatible : Should be "fsl,<chip>-esdhc" +- reg : Should contain eSDHC registers location and length +- interrupts : Should contain eSDHC interrupt +- cd-type : String, card detection (CD) method. ?Supported values are:
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +10
-0+ ? ?"none" : No CD + ? ?"controller" : Uses eSDHC controller internal CD signal + ? ?"gpio" : Uses GPIO pin for CD + ? ?"permanent" : No CD because card is permanently wired to host +- wp-type : String, write protection (WP) method. ?Supported values are: + ? ?"none" : No WP + ? ?"controller" : Uses eSDHC controller internal WP signal + ? ?"gpio" : Uses GPIO pin for WP +- gpios : Should specify GPIOs in this order: CD GPIO, WP GPIO, if + ?properties cd-type and wp-type are "gpio".
Again, be explicit in your gpios property names. Create a different property for each gpio: cd-gpios and wp-gpios.
As for wp-type and cd-type, I think you can drop them. Default to internal controller CD and WP pins. Use gpio if cd-gpios or wp-gpios is present, and define specific properties for the no-wp, no-cd and fixed-card cases. (can you tell that I'm not a fan of the "*-type" binding for this driver?) :-)
Quoted 73 lines
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +20
-0+ +Examples: + +esdhc at 70004000 { + ? ? ? compatible = "fsl,imx51-esdhc"; + ? ? ? reg = <0x70004000 0x4000>; + ? ? ? interrupts = <1>; + ? ? ? fsl,cd-type = "controller"; + ? ? ? fsl,wp-type = "controller"; +}; + +esdhc at 70008000 { + ? ? ? compatible = "fsl,imx51-esdhc"; + ? ? ? reg = <0x70008000 0x4000>; + ? ? ? interrupts = <2>; + ? ? ? fsl,cd-type = "gpio"; + ? ? ? fsl,wp-type = "gpio"; + ? ? ? cd-gpios = <&gpio0 6 0>; /* GPIO1_6 */ + ? ? ? wp-gpios = <&gpio0 5 0>; /* GPIO1_5 */ +};drivers/mmc/host/sdhci-esdhc-imx.c +0
-0@@ -20,6 +20,9 @@?#include <
linux/mmc/host.h>
?#include <linux/mmc/mmc.h>
?#include <linux/mmc/sdio.h>drivers/mmc/host/sdhci-esdhc-imx.c +3
-0+#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_gpio.h> ?#include <
mach/esdhc.h>
?#include "sdhci-pltfm.h"
?#include "sdhci-esdhc.h"drivers/mmc/host/sdhci-esdhc-imx.c +28
-0@@ -72,6 +75,14 @@ static struct platform_device_id imx_esdhc_devtype[] = { ? ? ? ?} ?}; +static const struct of_device_id imx_esdhc_dt_ids[] = { + ? ? ? { .compatible = "fsl,imx25-esdhc", .data = &imx_esdhc_devtype[IMX25_ESDHC], }, + ? ? ? { .compatible = "fsl,imx35-esdhc", .data = &imx_esdhc_devtype[IMX35_ESDHC], }, + ? ? ? { .compatible = "fsl,imx51-esdhc", .data = &imx_esdhc_devtype[IMX51_ESDHC], }, + ? ? ? { .compatible = "fsl,imx53-esdhc", .data = &imx_esdhc_devtype[IMX53_ESDHC], }, + ? ? ? { /* sentinel */ } +}; + ?static inline int is_imx25_esdhc(struct pltfm_imx_data *data) ?{ ? ? ? ?return data->devtype == IMX25_ESDHC;@@ -305,24 +316,96 @@ static irqreturn_t cd_irq(int irq, void *data) ? ? ? ?return IRQ_HANDLED; ?}; +#ifdef CONFIG_OF +static const char *cd_types[] = { + ? ? ? [ESDHC_CD_NONE] ? ? ? ? = "none", + ? ? ? [ESDHC_CD_CONTROLLER] ? = "controller", + ? ? ? [ESDHC_CD_GPIO] ? ? ? ? = "gpio", + ? ? ? [ESDHC_CD_PERMANENT] ? ?= "permanent", +}; + +static const char *wp_types[] = { + ? ? ? [ESDHC_WP_NONE] ? ? ? ? = "none", + ? ? ? [ESDHC_WP_CONTROLLER] ? = "controller", + ? ? ? [ESDHC_WP_GPIO] ? ? ? ? = "gpio", +}; + +static int __devinit sdhci_esdhc_imx_probe_dt (struct platform_device *pdev) +{ + ? ? ? const struct of_device_id *of_id = + ? ? ? ? ? ? ? ? ? ? ? of_match_device(imx_esdhc_dt_ids, &pdev->dev); + ? ? ? struct device_node *np = pdev->dev.of_node; + ? ? ? struct esdhc_platform_data *boarddata;
drivers/mmc/host/sdhci-esdhc-imx.c static irqreturn_t cd_irq(int irq, void *data) · line 348
Quoted 10 lines
drivers/mmc/host/sdhci-esdhc-imx.c +10
-0+ ? ? ? int err, i; + ? ? ? const char *cd, *wp; + + ? ? ? if (!np) + ? ? ? ? ? ? ? return -ENODEV; + + ? ? ? boarddata = kzalloc(sizeof(*boarddata), GFP_KERNEL); + ? ? ? if (!boarddata) + ? ? ? ? ? ? ? return -ENOMEM; + ? ? ? pdev->dev.platform_data = boarddata;
This is illegal. As far as device drivers are concerned, pdev->dev.platform_data is immutable and must not be changed. Otherwise they break the driver model. If you need to keep around a platform_data structure, then it needs to be stored in the driver private data. Your best option is to refactor the driver to not reference pdev->dev.platform_data after probe() exits.
Quoted 109 lines
drivers/mmc/host/sdhci-esdhc-imx.c +47
-5+ + ? ? ? err = of_property_read_string(np, "fsl,cd-type", &cd); + ? ? ? if (err) + ? ? ? ? ? ? ? return err; + ? ? ? for (i = 0; i < ARRAY_SIZE(cd_types); i++) + ? ? ? ? ? ? ? if (!strcasecmp(cd, cd_types[i])) { + ? ? ? ? ? ? ? ? ? ? ? boarddata->cd_type = i; + ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? } + + ? ? ? err = of_property_read_string(np, "fsl,wp-type", &wp); + ? ? ? if (err) + ? ? ? ? ? ? ? return err; + ? ? ? for (i = 0; i < ARRAY_SIZE(wp_types); i++) + ? ? ? ? ? ? ? if (!strcasecmp(wp, wp_types[i])) { + ? ? ? ? ? ? ? ? ? ? ? boarddata->wp_type = i; + ? ? ? ? ? ? ? ? ? ? ? break; + ? ? ? ? ? ? ? } + + ? ? ? boarddata->cd_gpio = of_get_gpio(np, 0); + ? ? ? boarddata->wp_gpio = of_get_gpio(np, 1); + + ? ? ? pdev->id_entry = of_id->data; + + ? ? ? return 0; +} +#else +static inline int sdhci_esdhc_imx_probe_dt (struct platform_device *pdev) +{ + ? ? ? return 0; +} +#endif + ?static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) ?{ + ? ? ? struct device_node *np = pdev->dev.of_node; ? ? ? ?struct sdhci_pltfm_host *pltfm_host; ? ? ? ?struct sdhci_host *host; - ? ? ? struct esdhc_platform_data *boarddata; + ? ? ? struct esdhc_platform_data *boarddata = NULL; ? ? ? ?struct clk *clk; ? ? ? ?int err; ? ? ? ?struct pltfm_imx_data *imx_data; + ? ? ? err = sdhci_esdhc_imx_probe_dt(pdev); + ? ? ? if (err) + ? ? ? ? ? ? ? return err; + ? ? ? ?host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata); - ? ? ? if (IS_ERR(host)) - ? ? ? ? ? ? ? return PTR_ERR(host); + ? ? ? if (IS_ERR(host)) { + ? ? ? ? ? ? ? err = PTR_ERR(host); + ? ? ? ? ? ? ? goto err_sdhci_pltfm; + ? ? ? } ? ? ? ?pltfm_host = sdhci_priv(host); ? ? ? ?imx_data = kzalloc(sizeof(struct pltfm_imx_data), GFP_KERNEL); - ? ? ? if (!imx_data) - ? ? ? ? ? ? ? return -ENOMEM; + ? ? ? if (!imx_data) { + ? ? ? ? ? ? ? err = -ENOMEM; + ? ? ? ? ? ? ? goto err_imx_data; + ? ? ? } ? ? ? ?imx_data->devtype = pdev->id_entry->driver_data; ? ? ? ?pltfm_host->priv = imx_data;@@ -416,12 +499,17 @@ no_board_data: ? ? ? ?clk_put(pltfm_host->clk);?err_clk_get:
? ? ? ?kfree(imx_data);
+err_imx_data:
? ? ? ?sdhci_pltfm_free(pdev);
+err_sdhci_pltfm:
+ ? ? ? if (np)
+ ? ? ? ? ? ? ? kfree(boarddata);
? ? ? ?return err;
?}?static int
__devexitsdhci_esdhc_imx_remove(struct platform_device *pdev)?{
+ ? ? ? structdevice_node*np =pdev->dev.of_node;
? ? ? ?structsdhci_host*host =platform_get_drvdata(pdev);
? ? ? ?structsdhci_pltfm_host*pltfm_host=sdhci_priv(host);
? ? ? ?structesdhc_platform_data*boarddata =host->mmc->parent->platform_data;drivers/mmc/host/sdhci-esdhc-imx.c +4
-1@@ -444,6 +532,9 @@ static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev) ? ? ? ?sdhci_pltfm_free(pdev); + ? ? ? if (np) + ? ? ? ? ? ? ? kfree(boarddata); + ? ? ? ?return 0; ?}@@ -451,6 +542,7 @@ static struct platform_driver sdhci_esdhc_imx_driver = { ? ? ? ?.driver ? ? ? ? = { ? ? ? ? ? ? ? ?.name ? = "sdhci-esdhc-imx", ? ? ? ? ? ? ? ?.owner ?= THIS_MODULE, + ? ? ? ? ? ? ? .of_match_table = imx_esdhc_dt_ids, ? ? ? ?}, ? ? ? ?.id_table ? ? ? = imx_esdhc_devtype, ? ? ? ?.probe ? ? ? ? ?= sdhci_esdhc_imx_probe, --1.7.4.1
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
PATCH v2 3/3 mmc: sdhci-esdhc-imx: add device tree probe support
Quoted 34 lines · Grant Likely
Quoted 33 lines · Shawn Guo
The patch adds device tree probe support for sdhci-esdhc-imx driver.
Signed-off-by Shawn Guo <[email protected]>Cc Wolfram Sang <[email protected]>Cc Chris Ball <[email protected]>Cc Grant Likely <[email protected]>---
.../devicetree/bindings/mmc/fsl-imx-esdhc.txt | 40 ++++++++drivers/mmc/host/sdhci-esdhc-imx.c| 102 +++++++++++++++++++-2 files changed, 137 insertions(+), 5 deletions(-)create mode 100644
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txtDocumentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +15
-0@@ -0,0 +1,40 @@ +* Freescale Enhanced Secure Digital Host Controller (eSDHC) for i.MX + +The Enhanced Secure Digital Host Controller on Freescale i.MX family +provides an interface for MMC, SD, and SDIO types of memory cards. + +Required properties: +- compatible : Should be "fsl,<chip>-esdhc" +- reg : Should contain eSDHC registers location and length +- interrupts : Should contain eSDHC interrupt +- cd-type : String, card detection (CD) method. Supported values are: + "none" : No CD + "controller" : Uses eSDHC controller internal CD signal + "gpio" : Uses GPIO pin for CD + "permanent" : No CD because card is permanently wired to host +- wp-type : String, write protection (WP) method. Supported values are:
Quoted 9 lines
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt line 20
Quoted 5 lines
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +5
-0+ "none" : No WP + "controller" : Uses eSDHC controller internal WP signal + "gpio" : Uses GPIO pin for WP +- gpios : Should specify GPIOs in this order: CD GPIO, WP GPIO, if + properties cd-type and wp-type are "gpio".Again, be explicit in your gpios property names. Create a different property for each gpio: cd-gpios and wp-gpios.
Sorry. I fixed the example below. But this one got missed.
Quoted 6 lines
As for wp-type and cd-type, I think you can drop them. Default to internal controller CD and WP pins. Use gpio if cd-gpios or wp-gpios is present, and define specific properties for the no-wp, no-cd and fixed-card cases. (can you tell that I'm not a fan of the "*-type" binding for this driver?) :-)
Ok, I'm getting to know you.
Quoted 82 lines
Quoted 82 lines
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +20
-0+ +Examples: + +esdhc@70004000 { + compatible = "fsl,imx51-esdhc"; + reg = <0x70004000 0x4000>; + interrupts = <1>; + fsl,cd-type = "controller"; + fsl,wp-type = "controller"; +}; + +esdhc@70008000 { + compatible = "fsl,imx51-esdhc"; + reg = <0x70008000 0x4000>; + interrupts = <2>; + fsl,cd-type = "gpio"; + fsl,wp-type = "gpio"; + cd-gpios = <&gpio0 6 0>; /* GPIO1_6 */ + wp-gpios = <&gpio0 5 0>; /* GPIO1_5 */ +};drivers/mmc/host/sdhci-esdhc-imx.c +40
-0@@ -20,6 +20,9 @@ #include <linux/mmc/host.h> #include <linux/mmc/mmc.h> #include <linux/mmc/sdio.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_gpio.h> #include <mach/esdhc.h> #include "sdhci-pltfm.h" #include "sdhci-esdhc.h"@@ -72,6 +75,14 @@ static struct platform_device_id imx_esdhc_devtype[] = { } }; +static const struct of_device_id imx_esdhc_dt_ids[] = { + { .compatible = "fsl,imx25-esdhc", .data = &imx_esdhc_devtype[IMX25_ESDHC], }, + { .compatible = "fsl,imx35-esdhc", .data = &imx_esdhc_devtype[IMX35_ESDHC], }, + { .compatible = "fsl,imx51-esdhc", .data = &imx_esdhc_devtype[IMX51_ESDHC], }, + { .compatible = "fsl,imx53-esdhc", .data = &imx_esdhc_devtype[IMX53_ESDHC], }, + { /* sentinel */ } +}; + static inline int is_imx25_esdhc(struct pltfm_imx_data *data) { return data->devtype == IMX25_ESDHC;@@ -305,24 +316,96 @@ static irqreturn_t cd_irq(int irq, void *data) return IRQ_HANDLED; }; +#ifdef CONFIG_OF +static const char *cd_types[] = { + [ESDHC_CD_NONE] = "none", + [ESDHC_CD_CONTROLLER] = "controller", + [ESDHC_CD_GPIO] = "gpio", + [ESDHC_CD_PERMANENT] = "permanent", +}; + +static const char *wp_types[] = { + [ESDHC_WP_NONE] = "none", + [ESDHC_WP_CONTROLLER] = "controller", + [ESDHC_WP_GPIO] = "gpio", +}; + +static int __devinit sdhci_esdhc_imx_probe_dt (struct platform_device *pdev) +{ + const struct of_device_id *of_id = + of_match_device(imx_esdhc_dt_ids, &pdev->dev); + struct device_node *np = pdev->dev.of_node; + struct esdhc_platform_data *boarddata; + int err, i; + const char *cd, *wp; + + if (!np) + return -ENODEV; + + boarddata = kzalloc(sizeof(*boarddata), GFP_KERNEL); + if (!boarddata) + return -ENOMEM;
Quoted 9 lines
drivers/mmc/host/sdhci-esdhc-imx.c static irqreturn_t cd_irq(int irq, void *data) · line 348
Quoted 1 line
drivers/mmc/host/sdhci-esdhc-imx.c +1
-0+ pdev->dev.platform_data = boarddata;This is illegal. As far as device drivers are concerned,
pdev->dev.platform_datais immutable and must not be changed. Otherwise they break the driver model. If you need to keep around aplatform_datastructure, then it needs to be stored in the driver private data. Your best option is to refactor the driver to not referencepdev->dev.platform_dataafterprobe()exits.
Ok. I saw a patch from Troy doing this. Will incorporate it into the series.
Regards,
Shawn
Quoted 106 lines
Quoted 106 lines
drivers/mmc/host/sdhci-esdhc-imx.c +47
-5+ + err = of_property_read_string(np, "fsl,cd-type", &cd); + if (err) + return err; + for (i = 0; i < ARRAY_SIZE(cd_types); i++) + if (!strcasecmp(cd, cd_types[i])) { + boarddata->cd_type = i; + break; + } + + err = of_property_read_string(np, "fsl,wp-type", &wp); + if (err) + return err; + for (i = 0; i < ARRAY_SIZE(wp_types); i++) + if (!strcasecmp(wp, wp_types[i])) { + boarddata->wp_type = i; + break; + } + + boarddata->cd_gpio = of_get_gpio(np, 0); + boarddata->wp_gpio = of_get_gpio(np, 1); + + pdev->id_entry = of_id->data; + + return 0; +} +#else +static inline int sdhci_esdhc_imx_probe_dt (struct platform_device *pdev) +{ + return 0; +} +#endif + static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct sdhci_pltfm_host *pltfm_host; struct sdhci_host *host; - struct esdhc_platform_data *boarddata; + struct esdhc_platform_data *boarddata = NULL; struct clk *clk; int err; struct pltfm_imx_data *imx_data; + err = sdhci_esdhc_imx_probe_dt(pdev); + if (err) + return err; + host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata); - if (IS_ERR(host)) - return PTR_ERR(host); + if (IS_ERR(host)) { + err = PTR_ERR(host); + goto err_sdhci_pltfm; + } pltfm_host = sdhci_priv(host); imx_data = kzalloc(sizeof(struct pltfm_imx_data), GFP_KERNEL); - if (!imx_data) - return -ENOMEM; + if (!imx_data) { + err = -ENOMEM; + goto err_imx_data; + } imx_data->devtype = pdev->id_entry->driver_data; pltfm_host->priv = imx_data;@@ -416,12 +499,17 @@ no_board_data: clk_put(pltfm_host->clk);err_clk_get:
kfree(imx_data);
+err_imx_data:
sdhci_pltfm_free(pdev);
+err_sdhci_pltfm:
+ if (np)
+ kfree(boarddata);
return err;
}static int
__devexitsdhci_esdhc_imx_remove(struct platform_device *pdev){
+ structdevice_node*np =pdev->dev.of_node;
structsdhci_host*host =platform_get_drvdata(pdev);
structsdhci_pltfm_host*pltfm_host=sdhci_priv(host); structesdhc_platform_data*boarddata =host->mmc->parent->platform_data;drivers/mmc/host/sdhci-esdhc-imx.c +4
-1@@ -444,6 +532,9 @@ static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev) sdhci_pltfm_free(pdev); + if (np) + kfree(boarddata); + return 0; }@@ -451,6 +542,7 @@ static struct platform_driver sdhci_esdhc_imx_driver = { .driver = { .name = "sdhci-esdhc-imx", .owner = THIS_MODULE, + .of_match_table = imx_esdhc_dt_ids, }, .id_table = imx_esdhc_devtype, .probe = sdhci_esdhc_imx_probe, --1.7.4.1
PATCH v2 3/3 mmc: sdhci-esdhc-imx: add device tree probe support
In reply to Grant LikelyQuoted 43 lines · Grant Likely
Quoted 28 lines · Shawn Guo
The patch adds device tree probe support for sdhci-esdhc-imx driver.
Signed-off-by Shawn Guo <[email protected]>Cc Wolfram Sang <[email protected]>Cc Chris Ball <[email protected]>Cc Grant Likely <[email protected]>---
.../devicetree/bindings/mmc/fsl-imx-esdhc.txt | 40 ++++++++drivers/mmc/host/sdhci-esdhc-imx.c| 102 +++++++++++++++++++-2 files changed, 137 insertions(+), 5 deletions(-)create mode 100644
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txtDocumentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +10
-0@@ -0,0 +1,40 @@ +* Freescale Enhanced Secure Digital Host Controller (eSDHC) for i.MX + +The Enhanced Secure Digital Host Controller on Freescale i.MX family +provides an interface for MMC, SD, and SDIO types of memory cards. + +Required properties: +- compatible : Should be "fsl,<chip>-esdhc" +- reg : Should contain eSDHC registers location and length +- interrupts : Should contain eSDHC interrupt +- cd-type : String, card detection (CD) method. Supported values are:Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +10
-0+ "none" : No CD + "controller" : Uses eSDHC controller internal CD signal + "gpio" : Uses GPIO pin for CD + "permanent" : No CD because card is permanently wired to host +- wp-type : String, write protection (WP) method. Supported values are: + "none" : No WP + "controller" : Uses eSDHC controller internal WP signal + "gpio" : Uses GPIO pin for WP +- gpios : Should specify GPIOs in this order: CD GPIO, WP GPIO, if + properties cd-type and wp-type are "gpio".Again, be explicit in your gpios property names. Create a different property for each gpio: cd-gpios and wp-gpios.
Quoted 6 lines
As for wp-type and cd-type, I think you can drop them. Default to internal controller CD and WP pins. Use gpio if cd-gpios or wp-gpios is present, and define specific properties for the no-wp, no-cd and fixed-card cases. (can you tell that I'm not a fan of the "*-type" binding for this driver?) :-)
I would let default be no CD/WP, and define properties for controller internal CD/WP and wired case, if you do not see a problem with it.
Signature · 2 lines
Regards, Shawn
PATCH v2 3/3 mmc: sdhci-esdhc-imx: add device tree probe support
Quoted 50 lines · Shawn Guo
Quoted 43 lines · Grant Likely
Quoted 28 lines · Shawn Guo
The patch adds device tree probe support for sdhci-esdhc-imx driver.
Signed-off-by Shawn Guo <[email protected]>Cc Wolfram Sang <[email protected]>Cc Chris Ball <[email protected]>Cc Grant Likely <[email protected]>---
?.../devicetree/bindings/mmc/fsl-imx-esdhc.txt ? ? ?| ? 40 ++++++++ ?drivers/mmc/host/sdhci-esdhc-imx.c ? ? ? ? ? ? ? ? | ?102 +++++++++++++++++++- ?2 files changed, 137 insertions(+), 5 deletions(-)
?create mode 100644Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txtDocumentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +10
-0@@ -0,0 +1,40 @@ +* Freescale Enhanced Secure Digital Host Controller (eSDHC) for i.MX + +The Enhanced Secure Digital Host Controller on Freescale i.MX family +provides an interface for MMC, SD, and SDIO types of memory cards. + +Required properties: +- compatible : Should be "fsl,<chip>-esdhc" +- reg : Should contain eSDHC registers location and length +- interrupts : Should contain eSDHC interrupt +- cd-type : String, card detection (CD) method. ?Supported values are:Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt new file +10
-0+ ? ?"none" : No CD + ? ?"controller" : Uses eSDHC controller internal CD signal + ? ?"gpio" : Uses GPIO pin for CD + ? ?"permanent" : No CD because card is permanently wired to host +- wp-type : String, write protection (WP) method. ?Supported values are: + ? ?"none" : No WP + ? ?"controller" : Uses eSDHC controller internal WP signal + ? ?"gpio" : Uses GPIO pin for WP +- gpios : Should specify GPIOs in this order: CD GPIO, WP GPIO, if + ?properties cd-type and wp-type are "gpio".Again, be explicit in your gpios property names. Create a different property for each gpio: cd-gpios and wp-gpios.
Quoted 6 lines
As for wp-type and cd-type, I think you can drop them. Default to internal controller CD and WP pins. Use gpio if cd-gpios or wp-gpios is present, and define specific properties for the no-wp, no-cd and fixed-card cases. (can you tell that I'm not a fan of the "*-type" binding for this driver?) :-)
Quoted 3 lines
I would let default be no CD/WP, and define properties for controller internal CD/WP and wired case, if you do not see a problem with it.
Okay.
g.