mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
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 <[email protected]> Cc: Chris Ball <[email protected]> Acked-by: Wolfram Sang <[email protected]> Tested-by: Arnaud Patard <[email protected]> Acked-by: Chris Ball <[email protected]>
This commit is contained in:
parent
ca2cc33392
commit
913413c307
9 changed files with 140 additions and 63 deletions
|
|
@ -225,7 +225,8 @@ struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
|
|||
|
||||
static struct esdhc_platform_data sd1_pdata = {
|
||||
.cd_gpio = GPIO_SD1CD,
|
||||
.wp_gpio = -EINVAL,
|
||||
.cd_type = ESDHC_CD_GPIO,
|
||||
.wp_type = ESDHC_WP_NONE,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -236,7 +236,8 @@ struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
|
|||
|
||||
static struct esdhc_platform_data sd1_pdata = {
|
||||
.cd_gpio = GPIO_SD1CD,
|
||||
.wp_gpio = -EINVAL,
|
||||
.cd_type = ESDHC_CD_GPIO,
|
||||
.wp_type = ESDHC_WP_NONE,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -215,6 +215,8 @@ static const struct imxi2c_platform_data mx25_3ds_i2c0_data __initconst = {
|
|||
static const struct esdhc_platform_data mx25pdk_esdhc_pdata __initconst = {
|
||||
.wp_gpio = SD1_GPIO_WP,
|
||||
.cd_gpio = SD1_GPIO_CD,
|
||||
.wp_type = ESDHC_WP_GPIO,
|
||||
.cd_type = ESDHC_CD_GPIO,
|
||||
};
|
||||
|
||||
static void __init mx25pdk_init(void)
|
||||
|
|
|
|||
|
|
@ -349,6 +349,8 @@ __setup("otg_mode=", pcm043_otg_mode);
|
|||
static struct esdhc_platform_data sd1_pdata = {
|
||||
.wp_gpio = SD1_GPIO_WP,
|
||||
.cd_gpio = SD1_GPIO_CD,
|
||||
.wp_type = ESDHC_WP_GPIO,
|
||||
.cd_type = ESDHC_CD_GPIO,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@
|
|||
#define BABBAGE_POWER_KEY IMX_GPIO_NR(2, 21)
|
||||
#define BABBAGE_ECSPI1_CS0 IMX_GPIO_NR(4, 24)
|
||||
#define BABBAGE_ECSPI1_CS1 IMX_GPIO_NR(4, 25)
|
||||
#define BABBAGE_SD1_CD IMX_GPIO_NR(1, 0)
|
||||
#define BABBAGE_SD1_WP IMX_GPIO_NR(1, 1)
|
||||
#define BABBAGE_SD2_CD IMX_GPIO_NR(1, 6)
|
||||
#define BABBAGE_SD2_WP IMX_GPIO_NR(1, 5)
|
||||
|
||||
|
|
@ -146,8 +144,9 @@ static iomux_v3_cfg_t mx51babbage_pads[] = {
|
|||
MX51_PAD_SD1_DATA1__SD1_DATA1,
|
||||
MX51_PAD_SD1_DATA2__SD1_DATA2,
|
||||
MX51_PAD_SD1_DATA3__SD1_DATA3,
|
||||
MX51_PAD_GPIO1_0__GPIO1_0,
|
||||
MX51_PAD_GPIO1_1__GPIO1_1,
|
||||
/* CD/WP from controller */
|
||||
MX51_PAD_GPIO1_0__SD1_CD,
|
||||
MX51_PAD_GPIO1_1__SD1_WP,
|
||||
|
||||
/* SD 2 */
|
||||
MX51_PAD_SD2_CMD__SD2_CMD,
|
||||
|
|
@ -156,6 +155,7 @@ static iomux_v3_cfg_t mx51babbage_pads[] = {
|
|||
MX51_PAD_SD2_DATA1__SD2_DATA1,
|
||||
MX51_PAD_SD2_DATA2__SD2_DATA2,
|
||||
MX51_PAD_SD2_DATA3__SD2_DATA3,
|
||||
/* CD/WP gpio */
|
||||
MX51_PAD_GPIO1_6__GPIO1_6,
|
||||
MX51_PAD_GPIO1_5__GPIO1_5,
|
||||
|
||||
|
|
@ -340,13 +340,15 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = {
|
|||
};
|
||||
|
||||
static const struct esdhc_platform_data mx51_babbage_sd1_data __initconst = {
|
||||
.cd_gpio = BABBAGE_SD1_CD,
|
||||
.wp_gpio = BABBAGE_SD1_WP,
|
||||
.cd_type = ESDHC_CD_CONTROLLER,
|
||||
.wp_type = ESDHC_WP_CONTROLLER,
|
||||
};
|
||||
|
||||
static const struct esdhc_platform_data mx51_babbage_sd2_data __initconst = {
|
||||
.cd_gpio = BABBAGE_SD2_CD,
|
||||
.wp_gpio = BABBAGE_SD2_WP,
|
||||
.cd_type = ESDHC_CD_GPIO,
|
||||
.wp_type = ESDHC_WP_GPIO,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -210,11 +210,15 @@ static const struct gpio_keys_platform_data loco_button_data __initconst = {
|
|||
|
||||
static const struct esdhc_platform_data mx53_loco_sd1_data __initconst = {
|
||||
.cd_gpio = LOCO_SD1_CD,
|
||||
.cd_type = ESDHC_CD_GPIO,
|
||||
.wp_type = ESDHC_WP_NONE,
|
||||
};
|
||||
|
||||
static const struct esdhc_platform_data mx53_loco_sd3_data __initconst = {
|
||||
.cd_gpio = LOCO_SD3_CD,
|
||||
.wp_gpio = LOCO_SD3_WP,
|
||||
.cd_type = ESDHC_CD_GPIO,
|
||||
.wp_type = ESDHC_WP_GPIO,
|
||||
};
|
||||
|
||||
static inline void mx53_loco_fec_reset(void)
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ imx53_sdhci_esdhc_imx_data[] __initconst = {
|
|||
};
|
||||
#endif /* ifdef CONFIG_SOC_IMX53 */
|
||||
|
||||
static const struct esdhc_platform_data default_esdhc_pdata __initconst = {
|
||||
.wp_type = ESDHC_WP_NONE,
|
||||
.cd_type = ESDHC_CD_NONE,
|
||||
};
|
||||
|
||||
struct platform_device *__init imx_add_sdhci_esdhc_imx(
|
||||
const struct imx_sdhci_esdhc_imx_data *data,
|
||||
const struct esdhc_platform_data *pdata)
|
||||
|
|
@ -81,6 +86,13 @@ struct platform_device *__init imx_add_sdhci_esdhc_imx(
|
|||
},
|
||||
};
|
||||
|
||||
/*
|
||||
* If machine does not provide pdata, use the default one
|
||||
* which means no WP/CD support
|
||||
*/
|
||||
if (!pdata)
|
||||
pdata = &default_esdhc_pdata;
|
||||
|
||||
return imx_add_platform_device("sdhci-esdhc-imx", data->id, res,
|
||||
ARRAY_SIZE(res), pdata, sizeof(*pdata));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,17 +10,34 @@
|
|||
#ifndef __ASM_ARCH_IMX_ESDHC_H
|
||||
#define __ASM_ARCH_IMX_ESDHC_H
|
||||
|
||||
enum wp_types {
|
||||
ESDHC_WP_NONE, /* no WP, neither controller nor gpio */
|
||||
ESDHC_WP_CONTROLLER, /* mmc controller internal WP */
|
||||
ESDHC_WP_GPIO, /* external gpio pin for WP */
|
||||
};
|
||||
|
||||
enum cd_types {
|
||||
ESDHC_CD_NONE, /* no CD, neither controller nor gpio */
|
||||
ESDHC_CD_CONTROLLER, /* mmc controller internal CD */
|
||||
ESDHC_CD_GPIO, /* external gpio pin for CD */
|
||||
ESDHC_CD_PERMANENT, /* no CD, card permanently wired to host */
|
||||
};
|
||||
|
||||
/**
|
||||
* struct esdhc_platform_data - optional platform data for esdhc on i.MX
|
||||
* struct esdhc_platform_data - platform data for esdhc on i.MX
|
||||
*
|
||||
* strongly recommended for i.MX25/35, not needed for other variants
|
||||
* ESDHC_WP(CD)_CONTROLLER type is not available on i.MX25/35.
|
||||
*
|
||||
* @wp_gpio: gpio for write_protect (-EINVAL if unused)
|
||||
* @cd_gpio: gpio for card_detect interrupt (-EINVAL if unused)
|
||||
* @wp_gpio: gpio for write_protect
|
||||
* @cd_gpio: gpio for card_detect interrupt
|
||||
* @wp_type: type of write_protect method (see wp_types enum above)
|
||||
* @cd_type: type of card_detect method (see cd_types enum above)
|
||||
*/
|
||||
|
||||
struct esdhc_platform_data {
|
||||
unsigned int wp_gpio;
|
||||
unsigned int cd_gpio;
|
||||
enum wp_types wp_type;
|
||||
enum cd_types cd_type;
|
||||
};
|
||||
#endif /* __ASM_ARCH_IMX_ESDHC_H */
|
||||
|
|
|
|||
Loading…
Reference in a new issue