diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2011-06-21 10:41:51 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2011-07-26 21:31:14 -0400 |
commit | 913413c307c919f8b21edccea23a9fd9d9d49a64 (patch) | |
tree | f36a4cf7e1f2111d4bdf14253476d115b5110f1f /arch/arm | |
parent | ca2cc333920690db87a03c2ee3bd6f43adb3e7fb (diff) |
mmc: sdhci-esdhc-imx: extend card_detect and write_protect support for mx5
The patch extends card_detect and write_protect support to get mx5
family and more scenarios supported. The changes include:
* Turn platform_data from optional to mandatory
* Add cd_types and wp_types into platform_data to cover more use
cases
* Remove the use of flag ESDHC_FLAG_GPIO_FOR_CD
* Adjust some machine codes to adopt the platform_data changes
* Work around the issue that software reset will get card detection
circuit stop working
With this patch, card_detect and write_protect gets supported on
mx5 based platforms.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Chris Ball <cjb@laptop.org>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Acked-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-imx/mach-mx25_3ds.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-imx/mach-pcm043.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx51_babbage.c | 14 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx53_loco.c | 4 | ||||
-rw-r--r-- | arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c | 12 | ||||
-rw-r--r-- | arch/arm/plat-mxc/include/mach/esdhc.h | 25 |
8 files changed, 53 insertions, 12 deletions
diff --git a/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c b/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c index 01ebcb31e482..66e8726253fa 100644 --- a/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c +++ b/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | |||
@@ -225,7 +225,8 @@ struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = { | |||
225 | 225 | ||
226 | static struct esdhc_platform_data sd1_pdata = { | 226 | static struct esdhc_platform_data sd1_pdata = { |
227 | .cd_gpio = GPIO_SD1CD, | 227 | .cd_gpio = GPIO_SD1CD, |
228 | .wp_gpio = -EINVAL, | 228 | .cd_type = ESDHC_CD_GPIO, |
229 | .wp_type = ESDHC_WP_NONE, | ||
229 | }; | 230 | }; |
230 | 231 | ||
231 | /* | 232 | /* |
diff --git a/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c b/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c index 558eb526ba56..0f0af02b3182 100644 --- a/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c +++ b/arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | |||
@@ -236,7 +236,8 @@ struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = { | |||
236 | 236 | ||
237 | static struct esdhc_platform_data sd1_pdata = { | 237 | static struct esdhc_platform_data sd1_pdata = { |
238 | .cd_gpio = GPIO_SD1CD, | 238 | .cd_gpio = GPIO_SD1CD, |
239 | .wp_gpio = -EINVAL, | 239 | .cd_type = ESDHC_CD_GPIO, |
240 | .wp_type = ESDHC_WP_NONE, | ||
240 | }; | 241 | }; |
241 | 242 | ||
242 | /* | 243 | /* |
diff --git a/arch/arm/mach-imx/mach-mx25_3ds.c b/arch/arm/mach-imx/mach-mx25_3ds.c index 01534bb61305..7f66a91df361 100644 --- a/arch/arm/mach-imx/mach-mx25_3ds.c +++ b/arch/arm/mach-imx/mach-mx25_3ds.c | |||
@@ -215,6 +215,8 @@ static const struct imxi2c_platform_data mx25_3ds_i2c0_data __initconst = { | |||
215 | static const struct esdhc_platform_data mx25pdk_esdhc_pdata __initconst = { | 215 | static const struct esdhc_platform_data mx25pdk_esdhc_pdata __initconst = { |
216 | .wp_gpio = SD1_GPIO_WP, | 216 | .wp_gpio = SD1_GPIO_WP, |
217 | .cd_gpio = SD1_GPIO_CD, | 217 | .cd_gpio = SD1_GPIO_CD, |
218 | .wp_type = ESDHC_WP_GPIO, | ||
219 | .cd_type = ESDHC_CD_GPIO, | ||
218 | }; | 220 | }; |
219 | 221 | ||
220 | static void __init mx25pdk_init(void) | 222 | static void __init mx25pdk_init(void) |
diff --git a/arch/arm/mach-imx/mach-pcm043.c b/arch/arm/mach-imx/mach-pcm043.c index 163cc318cafb..660ec3e80cf8 100644 --- a/arch/arm/mach-imx/mach-pcm043.c +++ b/arch/arm/mach-imx/mach-pcm043.c | |||
@@ -349,6 +349,8 @@ __setup("otg_mode=", pcm043_otg_mode); | |||
349 | static struct esdhc_platform_data sd1_pdata = { | 349 | static struct esdhc_platform_data sd1_pdata = { |
350 | .wp_gpio = SD1_GPIO_WP, | 350 | .wp_gpio = SD1_GPIO_WP, |
351 | .cd_gpio = SD1_GPIO_CD, | 351 | .cd_gpio = SD1_GPIO_CD, |
352 | .wp_type = ESDHC_WP_GPIO, | ||
353 | .cd_type = ESDHC_CD_GPIO, | ||
352 | }; | 354 | }; |
353 | 355 | ||
354 | /* | 356 | /* |
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c index 15c600026aee..e400b09109ce 100644 --- a/arch/arm/mach-mx5/board-mx51_babbage.c +++ b/arch/arm/mach-mx5/board-mx51_babbage.c | |||
@@ -41,8 +41,6 @@ | |||
41 | #define BABBAGE_POWER_KEY IMX_GPIO_NR(2, 21) | 41 | #define BABBAGE_POWER_KEY IMX_GPIO_NR(2, 21) |
42 | #define BABBAGE_ECSPI1_CS0 IMX_GPIO_NR(4, 24) | 42 | #define BABBAGE_ECSPI1_CS0 IMX_GPIO_NR(4, 24) |
43 | #define BABBAGE_ECSPI1_CS1 IMX_GPIO_NR(4, 25) | 43 | #define BABBAGE_ECSPI1_CS1 IMX_GPIO_NR(4, 25) |
44 | #define BABBAGE_SD1_CD IMX_GPIO_NR(1, 0) | ||
45 | #define BABBAGE_SD1_WP IMX_GPIO_NR(1, 1) | ||
46 | #define BABBAGE_SD2_CD IMX_GPIO_NR(1, 6) | 44 | #define BABBAGE_SD2_CD IMX_GPIO_NR(1, 6) |
47 | #define BABBAGE_SD2_WP IMX_GPIO_NR(1, 5) | 45 | #define BABBAGE_SD2_WP IMX_GPIO_NR(1, 5) |
48 | 46 | ||
@@ -146,8 +144,9 @@ static iomux_v3_cfg_t mx51babbage_pads[] = { | |||
146 | MX51_PAD_SD1_DATA1__SD1_DATA1, | 144 | MX51_PAD_SD1_DATA1__SD1_DATA1, |
147 | MX51_PAD_SD1_DATA2__SD1_DATA2, | 145 | MX51_PAD_SD1_DATA2__SD1_DATA2, |
148 | MX51_PAD_SD1_DATA3__SD1_DATA3, | 146 | MX51_PAD_SD1_DATA3__SD1_DATA3, |
149 | MX51_PAD_GPIO1_0__GPIO1_0, | 147 | /* CD/WP from controller */ |
150 | MX51_PAD_GPIO1_1__GPIO1_1, | 148 | MX51_PAD_GPIO1_0__SD1_CD, |
149 | MX51_PAD_GPIO1_1__SD1_WP, | ||
151 | 150 | ||
152 | /* SD 2 */ | 151 | /* SD 2 */ |
153 | MX51_PAD_SD2_CMD__SD2_CMD, | 152 | MX51_PAD_SD2_CMD__SD2_CMD, |
@@ -156,6 +155,7 @@ static iomux_v3_cfg_t mx51babbage_pads[] = { | |||
156 | MX51_PAD_SD2_DATA1__SD2_DATA1, | 155 | MX51_PAD_SD2_DATA1__SD2_DATA1, |
157 | MX51_PAD_SD2_DATA2__SD2_DATA2, | 156 | MX51_PAD_SD2_DATA2__SD2_DATA2, |
158 | MX51_PAD_SD2_DATA3__SD2_DATA3, | 157 | MX51_PAD_SD2_DATA3__SD2_DATA3, |
158 | /* CD/WP gpio */ | ||
159 | MX51_PAD_GPIO1_6__GPIO1_6, | 159 | MX51_PAD_GPIO1_6__GPIO1_6, |
160 | MX51_PAD_GPIO1_5__GPIO1_5, | 160 | MX51_PAD_GPIO1_5__GPIO1_5, |
161 | 161 | ||
@@ -340,13 +340,15 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = { | |||
340 | }; | 340 | }; |
341 | 341 | ||
342 | static const struct esdhc_platform_data mx51_babbage_sd1_data __initconst = { | 342 | static const struct esdhc_platform_data mx51_babbage_sd1_data __initconst = { |
343 | .cd_gpio = BABBAGE_SD1_CD, | 343 | .cd_type = ESDHC_CD_CONTROLLER, |
344 | .wp_gpio = BABBAGE_SD1_WP, | 344 | .wp_type = ESDHC_WP_CONTROLLER, |
345 | }; | 345 | }; |
346 | 346 | ||
347 | static const struct esdhc_platform_data mx51_babbage_sd2_data __initconst = { | 347 | static const struct esdhc_platform_data mx51_babbage_sd2_data __initconst = { |
348 | .cd_gpio = BABBAGE_SD2_CD, | 348 | .cd_gpio = BABBAGE_SD2_CD, |
349 | .wp_gpio = BABBAGE_SD2_WP, | 349 | .wp_gpio = BABBAGE_SD2_WP, |
350 | .cd_type = ESDHC_CD_GPIO, | ||
351 | .wp_type = ESDHC_WP_GPIO, | ||
350 | }; | 352 | }; |
351 | 353 | ||
352 | /* | 354 | /* |
diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c index 54be525e2bd7..4e1d51d252dc 100644 --- a/arch/arm/mach-mx5/board-mx53_loco.c +++ b/arch/arm/mach-mx5/board-mx53_loco.c | |||
@@ -210,11 +210,15 @@ static const struct gpio_keys_platform_data loco_button_data __initconst = { | |||
210 | 210 | ||
211 | static const struct esdhc_platform_data mx53_loco_sd1_data __initconst = { | 211 | static const struct esdhc_platform_data mx53_loco_sd1_data __initconst = { |
212 | .cd_gpio = LOCO_SD1_CD, | 212 | .cd_gpio = LOCO_SD1_CD, |
213 | .cd_type = ESDHC_CD_GPIO, | ||
214 | .wp_type = ESDHC_WP_NONE, | ||
213 | }; | 215 | }; |
214 | 216 | ||
215 | static const struct esdhc_platform_data mx53_loco_sd3_data __initconst = { | 217 | static const struct esdhc_platform_data mx53_loco_sd3_data __initconst = { |
216 | .cd_gpio = LOCO_SD3_CD, | 218 | .cd_gpio = LOCO_SD3_CD, |
217 | .wp_gpio = LOCO_SD3_WP, | 219 | .wp_gpio = LOCO_SD3_WP, |
220 | .cd_type = ESDHC_CD_GPIO, | ||
221 | .wp_type = ESDHC_WP_GPIO, | ||
218 | }; | 222 | }; |
219 | 223 | ||
220 | static inline void mx53_loco_fec_reset(void) | 224 | static inline void mx53_loco_fec_reset(void) |
diff --git a/arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c b/arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c index 6b2940b93d94..79d6d711d123 100644 --- a/arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +++ b/arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c | |||
@@ -65,6 +65,11 @@ imx53_sdhci_esdhc_imx_data[] __initconst = { | |||
65 | }; | 65 | }; |
66 | #endif /* ifdef CONFIG_SOC_IMX53 */ | 66 | #endif /* ifdef CONFIG_SOC_IMX53 */ |
67 | 67 | ||
68 | static const struct esdhc_platform_data default_esdhc_pdata __initconst = { | ||
69 | .wp_type = ESDHC_WP_NONE, | ||
70 | .cd_type = ESDHC_CD_NONE, | ||
71 | }; | ||
72 | |||
68 | struct platform_device *__init imx_add_sdhci_esdhc_imx( | 73 | struct platform_device *__init imx_add_sdhci_esdhc_imx( |
69 | const struct imx_sdhci_esdhc_imx_data *data, | 74 | const struct imx_sdhci_esdhc_imx_data *data, |
70 | const struct esdhc_platform_data *pdata) | 75 | const struct esdhc_platform_data *pdata) |
@@ -81,6 +86,13 @@ struct platform_device *__init imx_add_sdhci_esdhc_imx( | |||
81 | }, | 86 | }, |
82 | }; | 87 | }; |
83 | 88 | ||
89 | /* | ||
90 | * If machine does not provide pdata, use the default one | ||
91 | * which means no WP/CD support | ||
92 | */ | ||
93 | if (!pdata) | ||
94 | pdata = &default_esdhc_pdata; | ||
95 | |||
84 | return imx_add_platform_device("sdhci-esdhc-imx", data->id, res, | 96 | return imx_add_platform_device("sdhci-esdhc-imx", data->id, res, |
85 | ARRAY_SIZE(res), pdata, sizeof(*pdata)); | 97 | ARRAY_SIZE(res), pdata, sizeof(*pdata)); |
86 | } | 98 | } |
diff --git a/arch/arm/plat-mxc/include/mach/esdhc.h b/arch/arm/plat-mxc/include/mach/esdhc.h index 86003f411755..aaf97481f413 100644 --- a/arch/arm/plat-mxc/include/mach/esdhc.h +++ b/arch/arm/plat-mxc/include/mach/esdhc.h | |||
@@ -10,17 +10,34 @@ | |||
10 | #ifndef __ASM_ARCH_IMX_ESDHC_H | 10 | #ifndef __ASM_ARCH_IMX_ESDHC_H |
11 | #define __ASM_ARCH_IMX_ESDHC_H | 11 | #define __ASM_ARCH_IMX_ESDHC_H |
12 | 12 | ||
13 | enum wp_types { | ||
14 | ESDHC_WP_NONE, /* no WP, neither controller nor gpio */ | ||
15 | ESDHC_WP_CONTROLLER, /* mmc controller internal WP */ | ||
16 | ESDHC_WP_GPIO, /* external gpio pin for WP */ | ||
17 | }; | ||
18 | |||
19 | enum cd_types { | ||
20 | ESDHC_CD_NONE, /* no CD, neither controller nor gpio */ | ||
21 | ESDHC_CD_CONTROLLER, /* mmc controller internal CD */ | ||
22 | ESDHC_CD_GPIO, /* external gpio pin for CD */ | ||
23 | ESDHC_CD_PERMANENT, /* no CD, card permanently wired to host */ | ||
24 | }; | ||
25 | |||
13 | /** | 26 | /** |
14 | * struct esdhc_platform_data - optional platform data for esdhc on i.MX | 27 | * struct esdhc_platform_data - platform data for esdhc on i.MX |
15 | * | 28 | * |
16 | * strongly recommended for i.MX25/35, not needed for other variants | 29 | * ESDHC_WP(CD)_CONTROLLER type is not available on i.MX25/35. |
17 | * | 30 | * |
18 | * @wp_gpio: gpio for write_protect (-EINVAL if unused) | 31 | * @wp_gpio: gpio for write_protect |
19 | * @cd_gpio: gpio for card_detect interrupt (-EINVAL if unused) | 32 | * @cd_gpio: gpio for card_detect interrupt |
33 | * @wp_type: type of write_protect method (see wp_types enum above) | ||
34 | * @cd_type: type of card_detect method (see cd_types enum above) | ||
20 | */ | 35 | */ |
21 | 36 | ||
22 | struct esdhc_platform_data { | 37 | struct esdhc_platform_data { |
23 | unsigned int wp_gpio; | 38 | unsigned int wp_gpio; |
24 | unsigned int cd_gpio; | 39 | unsigned int cd_gpio; |
40 | enum wp_types wp_type; | ||
41 | enum cd_types cd_type; | ||
25 | }; | 42 | }; |
26 | #endif /* __ASM_ARCH_IMX_ESDHC_H */ | 43 | #endif /* __ASM_ARCH_IMX_ESDHC_H */ |