Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
Subsystems (6)
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx card_detect and write_protect support to cover mx5 platforms, and solves above performance issues.
Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx: SDHCI_CARD_PRESENT does not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flag ESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extend card_detect and write_protect support
arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 3 +- arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 3 +- arch/arm/mach-imx/mach-mx25_3ds.c | 2 + arch/arm/mach-imx/mach-mx35_3ds.c | 7 +- arch/arm/mach-imx/mach-pcm043.c | 2 + arch/arm/mach-imx/mach-vpr200.c | 7 +- arch/arm/mach-mx5/board-mx51_3ds.c | 7 +- arch/arm/mach-mx5/board-mx51_babbage.c | 27 +++++- arch/arm/mach-mx5/board-mx51_efikamx.c | 7 +- arch/arm/mach-mx5/board-mx51_efikasb.c | 7 +- arch/arm/mach-mx5/board-mx53_evk.c | 14 +++- arch/arm/mach-mx5/board-mx53_loco.c | 14 +++- arch/arm/mach-mx5/board-mx53_smd.c | 21 ++++- arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c | 14 +++- arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c | 7 +- arch/arm/mach-mx5/mx51_efika.c | 7 +- arch/arm/plat-mxc/include/mach/esdhc.h | 25 ++++- drivers/mmc/host/sdhci-esdhc-imx.c | 117 +++++++++++++---------- drivers/mmc/host/sdhci.c | 13 ++- 19 files changed, 225 insertions(+), 79 deletions(-)
PATCH 1/4 mmc: sdhci: fix interrupt storm from card detection
The issue was initially found by Eric Benard as below.
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/108031
Not sure about other SDHCI based controller, but on Freescale eSDHC, the SDHCI_INT_CARD_INSERT bits will be immediately set again when it gets cleared, if a card is inserted. The driver need to mask the irq to prevent interrupt storm which will freeze the system. And the SDHCI_INT_CARD_REMOVE gets the same situation.
The patch fixes the problem based on the initial idea from Eric Benard.
--- drivers/mmc/host/sdhci.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +10 -3
@@ -2154,13 +2154,20 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) mmc_hostname(host->mmc), intmask);if (intmask & (SDHCI_INT_CARD_INSERT |SDHCI_INT_CARD_REMOVE )) { +u32 present =sdhci_readl (host,SDHCI_PRESENT_STATE ) & +SDHCI_CARD_PRESENT ; + +sdhci_mask_irqs (host, present ?SDHCI_INT_CARD_INSERT : +SDHCI_INT_CARD_REMOVE ); +sdhci_unmask_irqs (host, present ?SDHCI_INT_CARD_REMOVE : +SDHCI_INT_CARD_INSERT ); +sdhci_writel (host, intmask & (SDHCI_INT_CARD_INSERT | -SDHCI_INT_CARD_REMOVE ),SDHCI_INT_STATUS ); +SDHCI_INT_CARD_REMOVE ),SDHCI_INT_STATUS ); + intmask &= ~(SDHCI_INT_CARD_INSERT |SDHCI_INT_CARD_REMOVE );tasklet_schedule (&host->card_tasklet); } - intmask &= ~(SDHCI_INT_CARD_INSERT |SDHCI_INT_CARD_REMOVE ); -if (intmask &SDHCI_INT_CMD_MASK ) {sdhci_writel (host, intmask &SDHCI_INT_CMD_MASK ,SDHCI_INT_STATUS );
Signature · 1 line
1.7.4.1
PATCH 1/4 mmc: sdhci: fix interrupt storm from card detection
Quoted 10 lines · Shawn Guo
The issue was initially found by Eric Benard as below.
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/108031
Not sure about other SDHCI based controller, but on Freescale eSDHC, the
SDHCI_INT_CARD_INSERTbits will be immediately set again when it gets cleared, if a card is inserted. The driver need to mask the irq to prevent interrupt storm which will freeze the system. And theSDHCI_INT_CARD_REMOVEgets the same situation.
Quoted 5 lines
The patch fixes the problem based on the initial idea from Eric Benard.
Signed-off-by Shawn Guo <[email protected]>Cc Eric Benard <[email protected]>
Hmm, that should get enough testing on non-imx (and even non-ARM) devices. And a comment describing the situation.
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110614/43d260b1/attachment.sig>
PATCH 1/4 mmc: sdhci: fix interrupt storm from card detection
Quoted 11 lines · Wolfram Sang
Quoted 10 lines · Shawn Guo
The issue was initially found by Eric Benard as below.
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/108031
Not sure about other SDHCI based controller, but on Freescale eSDHC, the
SDHCI_INT_CARD_INSERTbits will be immediately set again when it gets cleared, if a card is inserted. The driver need to mask the irq to prevent interrupt storm which will freeze the system. And theSDHCI_INT_CARD_REMOVEgets the same situation.
Quoted 9 lines
Quoted 5 lines
The patch fixes the problem based on the initial idea from Eric Benard.
Signed-off-by Shawn Guo <[email protected]>Cc Eric Benard <[email protected]>Hmm, that should get enough testing on non-imx (and even non-ARM) devices. And a comment describing the situation.
Agreed. Will add something in commit message to mention the situation. That's why I hope we can get the patch on mmc-next at early stage of the cycle, so everyone can start testing it and report problems, if any.
Signature · 2 lines
Regards, Shawn
PATCH 1/4 mmc: sdhci: fix interrupt storm from card detection
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
The issue was initially found by Eric Benard as below.
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/108031
Not sure about other SDHCI based controller, but on Freescale eSDHC, the
SDHCI_INT_CARD_INSERTbits will be immediately set again when it gets cleared, if a card is inserted. The driver need to mask the irq to prevent interrupt storm which will freeze the system. And theSDHCI_INT_CARD_REMOVEgets the same situation.The patch fixes the problem based on the initial idea from Eric Benard.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Signed-off-by Shawn Guo <[email protected]>Cc Eric Benard <[email protected]>Hmm, that should get enough testing on non-imx (and even non-ARM) devices. And a comment describing the situation.
Agreed. Will add something in commit message to mention the situation. That's why I hope we can get the patch on mmc-next at
I actually meant a comment in the code, so it will be obvious for later hackers why the "extra" steps are in there...
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110614/3e3c9a65/attachment.sig>
PATCH 1/4 mmc: sdhci: fix interrupt storm from card detection
Quoted 17 lines · Wolfram Sang
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
The issue was initially found by Eric Benard as below.
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/108031
Not sure about other SDHCI based controller, but on Freescale eSDHC, the
SDHCI_INT_CARD_INSERTbits will be immediately set again when it gets cleared, if a card is inserted. The driver need to mask the irq to prevent interrupt storm which will freeze the system. And theSDHCI_INT_CARD_REMOVEgets the same situation.The patch fixes the problem based on the initial idea from Eric Benard.
Signed-off-by Shawn Guo <[email protected]>Cc Eric Benard <[email protected]>
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Hmm, that should get enough testing on non-imx (and even non-ARM) devices. And a comment describing the situation.
Agreed. Will add something in commit message to mention the situation. That's why I hope we can get the patch on mmc-next at
I actually meant a comment in the code, so it will be obvious for later hackers why the "extra" steps are in there...
OK.
Signature · 2 lines
Regards, Shawn
PATCH 2/4 mmc: sdhci-esdhc-imx: SDHCI_CARD_PRESENT does not get cleared
In reply to Shawn GuoThe function esdhc_readl_le intends to clear bit SDHCI_CARD_PRESENT, when the card detect gpio tells there is no card. But it does not clear the bit actually. The patch gives a fix on that.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
@@ -84,7 +84,7 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)if (boarddata &&gpio_is_valid (boarddata->cd_gpio) &&gpio_get_value (boarddata->cd_gpio))/* no card, if a valid gpio says so... */ - val &=SDHCI_CARD_PRESENT ; + val &= ~SDHCI_CARD_PRESENT ;else /* ... in all other cases assume card is present */ val |=SDHCI_CARD_PRESENT ;
Signature · 1 line
1.7.4.1
PATCH 2/4 mmc: sdhci-esdhc-imx: SDHCI_CARD_PRESENT does not get cleared
Quoted 5 lines · Shawn Guo
The function
esdhc_readl_leintends to clear bitSDHCI_CARD_PRESENT, when the card detect gpio tells there is no card. But it does not clear the bit actually. The patch gives a fix on that.Signed-off-by Shawn Guo <[email protected]>
Should go to stable, too.
Thanks for catching it!
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110614/65ad02ca/attachment.sig>
PATCH 3/4 mmc: sdhci-esdhc-imx: remove "WP" from flag ESDHC_FLAG_GPIO_FOR_CD_WP
In reply to Shawn GuoThe use of flag ESDHC_FLAG_GPIO_FOR_CD_WP is all CD related. It does not necessarily need to bother WP in the flag name.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +4 -4
@@ -29,7 +29,7 @@#define SDHCI_VENDOR_SPEC 0xC0#define SDHCI_VENDOR_SPEC_SDIO_QUIRK 0x00000002 -#define ESDHC_FLAG_GPIO_FOR_CD_WP (1 << 0) +#define ESDHC_FLAG_GPIO_FOR_CD (1 << 0)/* * The CMDTYPE of the CMD register (offset 0xE) should be set to * "11" when the STOP CMD12 is issued on imx53 to abort one
@@ -77,7 +77,7 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)u32 val =readl (host->ioaddr + reg);if (unlikely ((reg ==SDHCI_PRESENT_STATE ) - && (imx_data->flags &ESDHC_FLAG_GPIO_FOR_CD_WP ))) { + && (imx_data->flags &ESDHC_FLAG_GPIO_FOR_CD ))) {struct esdhc_platform_data *boarddata = host->mmc->parent->platform_data;
@@ -99,7 +99,7 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)struct pltfm_imx_data *imx_data = pltfm_host->priv;if (unlikely ((reg ==SDHCI_INT_ENABLE || reg ==SDHCI_SIGNAL_ENABLE ) - && (imx_data->flags &ESDHC_FLAG_GPIO_FOR_CD_WP ))) + && (imx_data->flags &ESDHC_FLAG_GPIO_FOR_CD )))/* * these interrupts won't work with a custom card_detect gpio * (only applied to mx25/35)
@@ -308,7 +308,7 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) goto no_card_detect_irq; } - imx_data->flags |=ESDHC_FLAG_GPIO_FOR_CD_WP ; + imx_data->flags |=ESDHC_FLAG_GPIO_FOR_CD ;/* Now we have a working card_detect again */ host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION ; }
Signature · 1 line
1.7.4.1
PATCH 3/4 mmc: sdhci-esdhc-imx: remove "WP" from flag ESDHC_FLAG_GPIO_FOR_CD_WP
Quoted 4 lines · Shawn Guo
The use of flag
ESDHC_FLAG_GPIO_FOR_CD_WPis all CD related. It does not necessarily need to bother WP in the flag name.Signed-off-by Shawn Guo <[email protected]>
I'd just squash it into the next one?
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110614/b61e9c87/attachment.sig>
PATCH 3/4 mmc: sdhci-esdhc-imx: remove "WP" from flag ESDHC_FLAG_GPIO_FOR_CD_WP
Quoted 8 lines · Wolfram Sang
Quoted 4 lines · Shawn Guo
The use of flag
ESDHC_FLAG_GPIO_FOR_CD_WPis all CD related. It does not necessarily need to bother WP in the flag name.Signed-off-by Shawn Guo <[email protected]>I'd just squash it into the next one?
I'd like to have this patch to give the exact meaning of the flag, and then the following patch removes the flag with proper CD only case handling.
Signature · 2 lines
Regards, Shawn
PATCH 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support
In reply to Shawn GuoThe 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 machine codes to adopt the platform_data changes
With this patch, card_detect and write_protect gets supported on mx51_babbage, and other mx5 machines can easily get there with the least board level configuration added.
--- arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 3 +- arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 3 +- arch/arm/mach-imx/mach-mx25_3ds.c | 2 + arch/arm/mach-imx/mach-mx35_3ds.c | 7 ++- arch/arm/mach-imx/mach-pcm043.c | 2 + arch/arm/mach-imx/mach-vpr200.c | 7 ++- arch/arm/mach-mx5/board-mx51_3ds.c | 7 ++- arch/arm/mach-mx5/board-mx51_babbage.c | 27 +++++- arch/arm/mach-mx5/board-mx51_efikamx.c | 7 ++- arch/arm/mach-mx5/board-mx51_efikasb.c | 7 ++- arch/arm/mach-mx5/board-mx53_evk.c | 14 +++- arch/arm/mach-mx5/board-mx53_loco.c | 14 +++- arch/arm/mach-mx5/board-mx53_smd.c | 21 ++++- arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c | 14 +++- arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c | 7 ++- arch/arm/mach-mx5/mx51_efika.c | 7 ++- arch/arm/plat-mxc/include/mach/esdhc.h | 25 ++++- drivers/mmc/host/sdhci-esdhc-imx.c | 115 +++++++++++++---------- 18 files changed, 214 insertions(+), 75 deletions(-)
arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c +2 -1
@@ -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 , };/*
arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c +2 -1
@@ -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 , };/*
arch/arm/mach-imx/mach-mx25_3ds.c +2 -0
@@ -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 )
arch/arm/mach-imx/mach-mx35_3ds.c +6 -1
@@ -174,6 +174,11 @@ static const struct imxi2c_platform_data mx35_3ds_i2c0_data __initconst = { .bitrate = 100000, }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +/* * Board specific initialization. */
@@ -198,7 +203,7 @@ static void __init mx35_3ds_init(void)imx35_add_fsl_usb2_udc (&usb_otg_pdata);imx35_add_mxc_nand (&mx35pdk_nand_board_info); -imx35_add_sdhci_esdhc_imx (0 ,NULL ); +imx35_add_sdhci_esdhc_imx (0 , &esdhc1_pdata);if (mxc_expio_init (MX35_CS5_BASE_ADDR ,EXPIO_PARENT_INT )) pr_warn("Init of the debugboard failed, all "
arch/arm/mach-imx/mach-pcm043.c +2 -0
@@ -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 , };/*
arch/arm/mach-imx/mach-vpr200.c +6 -1
@@ -262,6 +262,11 @@ static struct platform_device *devices[] __initdata = { &vpr200_flash, }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +/* * Board specific initialization. */
@@ -297,7 +302,7 @@ static void __init vpr200_board_init(void)imx35_add_mxc_ehci_hs (&usb_host_pdata);imx35_add_mxc_nand (&vpr200_nand_board_info); -imx35_add_sdhci_esdhc_imx (0 ,NULL ); +imx35_add_sdhci_esdhc_imx (0 , &esdhc1_pdata);i2c_register_board_info (0 , vpr200_i2c_devices,ARRAY_SIZE (vpr200_i2c_devices));
arch/arm/mach-mx5/board-mx51_3ds.c +6 -1
@@ -131,6 +131,11 @@ static struct spi_board_info mx51_3ds_spi_nor_device[] = { .platform_data = NULL,}, }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +/* * Board specific initialization. */
@@ -153,7 +158,7 @@ static void __init mx51_3ds_init(void)printk (KERN_WARNING "Init of the debugboard failed, all " "devices on the board are unusable.\n" ); -imx51_add_sdhci_esdhc_imx (0 ,NULL ); +imx51_add_sdhci_esdhc_imx (0 , &esdhc1_pdata);imx51_add_imx_keypad (&mx51_3ds_map_data);imx51_add_imx2_wdt (0 ,NULL ); }
arch/arm/mach-mx5/board-mx51_babbage.c +25 -2
@@ -34,6 +34,8 @@#include "devices.h" #include "cpu_op-mx51.h" +#define BABBAGE_ESDHC2_WP IMX_GPIO_NR(1, 5) +#define BABBAGE_ESDHC2_CD IMX_GPIO_NR(1, 6)#define BABBAGE_USB_HUB_RESET IMX_GPIO_NR(1, 7)#define BABBAGE_USBH1_STP IMX_GPIO_NR(1, 27)#define BABBAGE_USB_PHY_RESET IMX_GPIO_NR(2, 5)
@@ -142,6 +144,10 @@ 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 , +/* CD signal */ +MX51_PAD_GPIO1_0__SD1_CD , +/* WP signal */ +MX51_PAD_GPIO1_1__SD1_WP ,/* SD 2 */ MX51_PAD_SD2_CMD__SD2_CMD,
@@ -150,6 +156,11 @@ 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 , +/* WP gpio */ +MX51_PAD_GPIO1_5__GPIO1_5 , +/* CD gpio */ +MX51_PAD_GPIO1_6__GPIO1_6 , +/* eCSPI1 */ MX51_PAD_CSPI1_MISO__ECSPI1_MISO,
@@ -331,6 +342,18 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = { .num_chipselect = ARRAY_SIZE(mx51_babbage_spi_cs), }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_SIGNAL , + .cd_type =ESDHC_CD_SIGNAL , +}; + +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_gpio =BABBAGE_ESDHC2_WP , + .cd_gpio =BABBAGE_ESDHC2_CD , + .wp_type =ESDHC_WP_GPIO , + .cd_type =ESDHC_CD_GPIO , +}; +/* * Board specific initialization. */
@@ -376,8 +399,8 @@ static void __init mx51_babbage_init(void)mxc_iomux_v3_setup_pad (usbh1stp);babbage_usbhub_reset (); -imx51_add_sdhci_esdhc_imx (0 ,NULL ); -imx51_add_sdhci_esdhc_imx (1 ,NULL ); +imx51_add_sdhci_esdhc_imx (0 , &esdhc1_pdata); +imx51_add_sdhci_esdhc_imx (1 , &esdhc2_pdata);spi_register_board_info (mx51_babbage_spi_board_info,ARRAY_SIZE (mx51_babbage_spi_board_info));
arch/arm/mach-mx5/board-mx51_efikamx.c +6 -1
@@ -179,6 +179,11 @@ static const struct gpio_keys_platform_data mx51_efikamx_powerkey_data __initcon .nbuttons = ARRAY_SIZE(mx51_efikamx_powerkey), }; +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +void mx51_efikamx_reset (void ) {if (system_rev ==0x11 )
@@ -239,7 +244,7 @@ static void __init mx51_efikamx_init(void)/* on < 1.2 boards both SD controllers are used */ if (system_rev <0x12 ) { -imx51_add_sdhci_esdhc_imx (1 ,NULL ); +imx51_add_sdhci_esdhc_imx (1 , &esdhc2_pdata); mx51_efikamx_leds[2 ].default_trigger ="mmc1" ; }
arch/arm/mach-mx5/board-mx51_efikasb.c +6 -1
@@ -181,6 +181,11 @@ static const struct gpio_keys_platform_data mx51_efikasb_keys_data __initconst = .nbuttons = ARRAY_SIZE(mx51_efikasb_keys), }; +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +static struct regulator *pwgt1, *pwgt2;static void mx51_efikasb_power_off (void )
@@ -249,7 +254,7 @@ static void __init efikasb_board_init(void)mx51_efikasb_board_id ();mx51_efikasb_usb (); -imx51_add_sdhci_esdhc_imx (1 ,NULL ); +imx51_add_sdhci_esdhc_imx (1 , &esdhc2_pdata);gpio_led_register_device (-1 , &mx51_efikasb_leds_data);imx_add_gpio_keys (&mx51_efikasb_keys_data);
arch/arm/mach-mx5/board-mx53_evk.c +12 -2
@@ -131,6 +131,16 @@ static const struct spi_imx_master mx53_evk_spi_data __initconst = { .num_chipselect = ARRAY_SIZE(mx53_evk_spi_cs), }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; + +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +static void __init mx53_evk_board_init (void ) {imx53_soc_init ();
@@ -144,8 +154,8 @@ static void __init mx53_evk_board_init(void)imx53_add_imx_i2c (0 , &mx53_evk_i2c_data);imx53_add_imx_i2c (1 , &mx53_evk_i2c_data); -imx53_add_sdhci_esdhc_imx (0 ,NULL ); -imx53_add_sdhci_esdhc_imx (1 ,NULL ); +imx53_add_sdhci_esdhc_imx (0 , &esdhc1_pdata); +imx53_add_sdhci_esdhc_imx (1 , &esdhc2_pdata);spi_register_board_info (mx53_evk_spi_board_info,ARRAY_SIZE (mx53_evk_spi_board_info));
arch/arm/mach-mx5/board-mx53_loco.c +12 -2
@@ -239,6 +239,16 @@ static const struct gpio_led_platform_data mx53loco_leds_data __initconst = { .num_leds = ARRAY_SIZE(mx53loco_leds), }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; + +static const struct esdhc_platform_data esdhc3_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +static void __init mx53_loco_board_init (void ) {imx53_soc_init ();
@@ -251,8 +261,8 @@ static void __init mx53_loco_board_init(void)imx53_add_imx2_wdt (0 ,NULL );imx53_add_imx_i2c (0 , &mx53_loco_i2c_data);imx53_add_imx_i2c (1 , &mx53_loco_i2c_data); -imx53_add_sdhci_esdhc_imx (0 ,NULL ); -imx53_add_sdhci_esdhc_imx (2 ,NULL ); +imx53_add_sdhci_esdhc_imx (0 , &esdhc1_pdata); +imx53_add_sdhci_esdhc_imx (2 , &esdhc3_pdata);imx_add_gpio_keys (&loco_button_data);gpio_led_register_device (-1 , &mx53loco_leds_data); }
arch/arm/mach-mx5/board-mx53_smd.c +18 -3
@@ -111,6 +111,21 @@ static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = { .bitrate = 100000, }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; + +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; + +static const struct esdhc_platform_data esdhc3_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +static void __init mx53_smd_board_init (void ) {imx53_soc_init ();
@@ -122,9 +137,9 @@ static void __init mx53_smd_board_init(void)imx53_add_fec (&mx53_smd_fec_data);imx53_add_imx2_wdt (0 ,NULL );imx53_add_imx_i2c (0 , &mx53_smd_i2c_data); -imx53_add_sdhci_esdhc_imx (0 ,NULL ); -imx53_add_sdhci_esdhc_imx (1 ,NULL ); -imx53_add_sdhci_esdhc_imx (2 ,NULL ); +imx53_add_sdhci_esdhc_imx (0 , &esdhc1_pdata); +imx53_add_sdhci_esdhc_imx (1 , &esdhc2_pdata); +imx53_add_sdhci_esdhc_imx (2 , &esdhc3_pdata); }static void __init mx53_smd_timer_init (void )
arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c +12 -2
@@ -167,6 +167,16 @@ static struct i2c_board_info mbimx51_i2c_devices[] = { }, }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; + +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +/* * baseboard initialization. */
@@ -202,6 +212,6 @@ void __init eukrea_mbimx51_baseboard_init(void)i2c_register_board_info (1 , mbimx51_i2c_devices,ARRAY_SIZE (mbimx51_i2c_devices)); -imx51_add_sdhci_esdhc_imx (0 ,NULL ); -imx51_add_sdhci_esdhc_imx (1 ,NULL ); +imx51_add_sdhci_esdhc_imx (0 , &esdhc1_pdata); +imx51_add_sdhci_esdhc_imx (1 , &esdhc2_pdata); }
arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c +6 -1
@@ -115,6 +115,11 @@ static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = { }, }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +/* * system init for baseboard usage. Will be called by cpuimx51sd init. *
@@ -130,7 +135,7 @@ void __init eukrea_mbimxsd51_baseboard_init(void)imx51_add_imx_uart (1 ,NULL );imx51_add_imx_uart (2 , &uart_pdata); -imx51_add_sdhci_esdhc_imx (0 ,NULL ); +imx51_add_sdhci_esdhc_imx (0 , &esdhc1_pdata);gpio_request (GPIO_LED1 ,"LED1" );gpio_direction_output (GPIO_LED1 ,1 );
arch/arm/mach-mx5/mx51_efika.c +6 -1
@@ -603,13 +603,18 @@ static const struct spi_imx_master mx51_efika_spi_pdata __initconst = { .num_chipselect = ARRAY_SIZE(mx51_efika_spi_cs), }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_NONE , + .cd_type =ESDHC_CD_NONE , +}; +void __init efika_board_common_init (void ) {mxc_iomux_v3_setup_multiple_pads (mx51efika_pads,ARRAY_SIZE (mx51efika_pads));imx51_add_imx_uart (0 , &uart_pdata);mx51_efika_usb (); -imx51_add_sdhci_esdhc_imx (0 ,NULL ); +imx51_add_sdhci_esdhc_imx (0 , &esdhc1_pdata);/* FIXME: comes from original code. check this. */ if (mx51_revision () <IMX_CHIP_REVISION_2_0 )
arch/arm/plat-mxc/include/mach/esdhc.h +20 -5
@@ -10,17 +10,32 @@#ifndef __ASM_ARCH_IMX_ESDHC_H#define __ASM_ARCH_IMX_ESDHC_H +enum wp_types { +ESDHC_WP_NONE ,/* no WP, neither signal nor gpio */ +ESDHC_WP_SIGNAL ,/* mmc internal WP signal */ +ESDHC_WP_GPIO ,/* external gpio pin for WP */ +}; + +enum cd_types { +ESDHC_CD_NONE ,/* no CD, neither signal nor gpio */ +ESDHC_CD_SIGNAL ,/* mmc internal CD signal */ +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 -* -* strongly recommended for i.MX25/35, not needed for other variants +* struct esdhc_platform_data - platform data for esdhc on i.MX * -* @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 */
drivers/mmc/host/sdhci-esdhc-imx.c +65 -50
205 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support
Shawn Guo <[email protected]> writes:
Hi,
Quoted 8 lines
The patch extends
card_detectandwrite_protectsupport to get mx5 family and more scenarios supported. The changes include:* Turn
platform_datafrom optional to mandatory
* Addcd_typesandwp_typesintoplatform_datato cover more use cases
* Remove the use of flagESDHC_FLAG_GPIO_FOR_CD
* Adjust machine codes to adopt theplatform_datachanges
Before I go and test theses patches, I'd like to get some clarification. From what I see, you've modified all over the place the code to provide a platform_data, setting wp/cd type to type "NONE", as if it was the default you choose. Why this default and not considerer the "SIGNAL" type being the default ? Is this choice the safest one when one doesn't know what type to choose or can it have some bad side effects ?
Also, why didn't you modify the imx*_add_sdhci_esdhc_imx() functions to provide the default platform_data by themselves that if the 2nd argument was NULL instead of modifying all theses machines files ?
Last comment: How did you choose the platform_data values ? I mean, for that the cases I'm mainly take care of (efika mx and sb platforms), you choose NONE type, while the code has :
MX51_PAD_GPIO1_0__SD1_CD,
MX51_PAD_GPIO1_1__SD1_WP,
MX51_PAD_GPIO1_7__SD2_WP,
MX51_PAD_GPIO1_8__SD2_CD,which means that it would rather be the SIGNAL type if I got it right. Does this mean that you've set the type to NONE for all platforms you didn't know what the answer was ? (I guess/hope that theses 2 questions will be answered by your answers to my previous questions tbh).
Thanks,
Arnaud
PATCH 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support
Quoted 13 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 8 lines
The patch extends
card_detectandwrite_protectsupport to get mx5 family and more scenarios supported. The changes include:* Turn
platform_datafrom optional to mandatory
* Addcd_typesandwp_typesintoplatform_datato cover more use cases
* Remove the use of flagESDHC_FLAG_GPIO_FOR_CD
* Adjust machine codes to adopt theplatform_datachanges
Quoted 7 lines
Before I go and test theses patches, I'd like to get some clarification. From what I see, you've modified all over the place the code to provide a
platform_data, setting wp/cd type to type "NONE", as if it was the default you choose. Why this default and not considerer the "SIGNAL" type being the default ? Is this choice the safest one when one doesn't know what type to choose or can it have some bad side effects ?
The mx51_babbage is the only board support I'm concerned about in this patch. For other boards, I chose to translate the NULL pdata into "NONE" for both wp/cd types as the safest one, because I do not have (or care to check) the board schematics telling how wp/cd are routed on those boards. The patch ensures there is no regression for those boards, and let people who have schematics to set up wp/cd types later.
Quoted 4 lines
Also, why didn't you modify the imx*_add_sdhci_esdhc_imx() functions to provide the default
platform_databy themselves that if the 2nd argument was NULL instead of modifying all theses machines files ?
As I said above, the wp/cd "NONE" types translated from NULL pdata will be set up properly later by people who have schematics.
Quoted 10 lines
Last comment: How did you choose the
platform_datavalues ? I mean, for that the cases I'm mainly take care of (efika mx and sb platforms), you choose NONE type, while the code has :MX51_PAD_GPIO1_0__SD1_CD, MX51_PAD_GPIO1_1__SD1_WP, MX51_PAD_GPIO1_7__SD2_WP, MX51_PAD_GPIO1_8__SD2_CD,
Quoted 5 lines
which means that it would rather be the SIGNAL type if I got it right. Does this mean that you've set the type to NONE for all platforms you didn't know what the answer was ? (I guess/hope that theses 2 questions will be answered by your answers to my previous questions tbh).
I hope you have got the answers to these 2 questions from above answer. Otherwise, please let me know.
Signature · 2 lines
Regards, Shawn
PATCH 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support
Quoted 22 lines · Shawn Guo
Quoted 13 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 8 lines
The patch extends
card_detectandwrite_protectsupport to get mx5 family and more scenarios supported. The changes include:* Turn
platform_datafrom optional to mandatory
* Addcd_typesandwp_typesintoplatform_datato cover more use cases
* Remove the use of flagESDHC_FLAG_GPIO_FOR_CD
* Adjust machine codes to adopt theplatform_datachangesQuoted 7 lines
Before I go and test theses patches, I'd like to get some clarification. From what I see, you've modified all over the place the code to provide a
platform_data, setting wp/cd type to type "NONE", as if it was the default you choose. Why this default and not considerer the "SIGNAL" type being the default ? Is this choice the safest one when one doesn't know what type to choose or can it have some bad side effects ?
Quoted 7 lines
The
mx51_babbageis the only board support I'm concerned about in this patch. For other boards, I chose to translate the NULL pdata into "NONE" for both wp/cd types as the safest one, because I do not have (or care to check) the board schematics telling how wp/cd are routed on those boards. The patch ensures there is no regression for those boards, and let people who have schematics to set up wp/cd types later.
ok. Thanks for making things clear. I see some changes for loco/imx53qsb. Do you need testers for it too or you've tested it ?
Quoted 7 lines
Quoted 5 lines
Also, why didn't you modify the imx*_add_sdhci_esdhc_imx() functions to provide the default
platform_databy themselves that if the 2nd argument was NULL instead of modifying all theses machines files ?As I said above, the wp/cd "NONE" types translated from NULL pdata will be set up properly later by people who have schematics.
You're not answering my question about moving the NULL-> "NONE" type from *all* modified machine file into the imx*add_sdhci_esdhc_imx(). If it's the default, why all machines file have to be modified to set it ? Moreover, *nothing* AFAICS is preventing to call theses functions will NULL. What will happen ? An oops ? To me, a default is the value set when nothing is set, and clearly modifying all functions call site due to having to provide the default seems imho wrong.
Thanks,
Arnaud
PATCH 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support
Quoted 32 lines · Arnaud Patard
Quoted 22 lines · Shawn Guo
Quoted 13 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 8 lines
The patch extends
card_detectandwrite_protectsupport to get mx5 family and more scenarios supported. The changes include:* Turn
platform_datafrom optional to mandatory
* Addcd_typesandwp_typesintoplatform_datato cover more use cases
* Remove the use of flagESDHC_FLAG_GPIO_FOR_CD
* Adjust machine codes to adopt theplatform_datachangesQuoted 7 lines
Before I go and test theses patches, I'd like to get some clarification. From what I see, you've modified all over the place the code to provide a
platform_data, setting wp/cd type to type "NONE", as if it was the default you choose. Why this default and not considerer the "SIGNAL" type being the default ? Is this choice the safest one when one doesn't know what type to choose or can it have some bad side effects ?Quoted 7 lines
The
mx51_babbageis the only board support I'm concerned about in this patch. For other boards, I chose to translate the NULL pdata into "NONE" for both wp/cd types as the safest one, because I do not have (or care to check) the board schematics telling how wp/cd are routed on those boards. The patch ensures there is no regression for those boards, and let people who have schematics to set up wp/cd types later.
Quoted 3 lines
ok. Thanks for making things clear. I see some changes for loco/imx53qsb. Do you need testers for it too or you've tested it ?
I do not see changes for loco except NULL pdata -> "NONE" types. But testing are always welcomed and appreciated.
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Also, why didn't you modify the imx*_add_sdhci_esdhc_imx() functions to provide the default
platform_databy themselves that if the 2nd argument was NULL instead of modifying all theses machines files ?As I said above, the wp/cd "NONE" types translated from NULL pdata will be set up properly later by people who have schematics.
Quoted 8 lines
You're not answering my question about moving the NULL-> "NONE" type from *all* modified machine file into the imx*add_sdhci_esdhc_imx(). If it's the default, why all machines file have to be modified to set it ? Moreover, *nothing* AFAICS is preventing to call theses functions will NULL. What will happen ? An oops ? To me, a default is the value set when nothing is set, and clearly modifying all functions call site due to having to provide the default seems imho wrong.
Ah, good point. Please review changes below. If it looks good to you, I will incorporate it in the next version of the patch.
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +12 -0
@@ -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 a pdata, use the default one +* which means none 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)); }
Signature · 2 lines
Regards, Shawn
PATCH 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support
Quoted 33 lines · Shawn Guo
Quoted 32 lines · Arnaud Patard
Quoted 29 lines · Shawn Guo
Quoted 13 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 8 lines
The patch extends
card_detectandwrite_protectsupport to get mx5 family and more scenarios supported. The changes include:* Turn
platform_datafrom optional to mandatory
* Addcd_typesandwp_typesintoplatform_datato cover more use cases
* Remove the use of flagESDHC_FLAG_GPIO_FOR_CD
* Adjust machine codes to adopt theplatform_datachangesQuoted 7 lines
Before I go and test theses patches, I'd like to get some clarification. From what I see, you've modified all over the place the code to provide a
platform_data, setting wp/cd type to type "NONE", as if it was the default you choose. Why this default and not considerer the "SIGNAL" type being the default ? Is this choice the safest one when one doesn't know what type to choose or can it have some bad side effects ?The
mx51_babbageis the only board support I'm concerned about in this patch. For other boards, I chose to translate the NULL pdata into "NONE" for both wp/cd types as the safest one, because I do not have (or care to check) the board schematics telling how wp/cd are routed on those boards. The patch ensures there is no regression for those boards, and let people who have schematics to set up wp/cd types later.
Quoted 5 lines
Quoted 3 lines
ok. Thanks for making things clear. I see some changes for loco/imx53qsb. Do you need testers for it too or you've tested it ?
I do not see changes for loco except NULL pdata -> "NONE" types. But testing are always welcomed and appreciated.
oops, sorry. I mixed with the other patches sent today
(http://lists.infradead.org/pipermail/linux-arm-kernel/2011-June/052705.html)
Quoted 40 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Also, why didn't you modify the imx*_add_sdhci_esdhc_imx() functions to provide the default
platform_databy themselves that if the 2nd argument was NULL instead of modifying all theses machines files ?As I said above, the wp/cd "NONE" types translated from NULL pdata will be set up properly later by people who have schematics.
Quoted 8 lines
You're not answering my question about moving the NULL-> "NONE" type from *all* modified machine file into the imx*add_sdhci_esdhc_imx(). If it's the default, why all machines file have to be modified to set it ? Moreover, *nothing* AFAICS is preventing to call theses functions will NULL. What will happen ? An oops ? To me, a default is the value set when nothing is set, and clearly modifying all functions call site due to having to provide the default seems imho wrong.
Ah, good point. Please review changes below. If it looks good to you, I will incorporate it in the next version of the patch.
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +5
-0@@ -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( }, };
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c struct platform_device *__init imx_add_sdhci_esdhc_imx( · line 98
Quoted 10 lines
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +7
-0+/* +* If machine does not provide a pdata, use the default one +* which means none 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)); }
Great. I've still not tested it but it's exactly what I was thinking.
Thanks,
Arnaud
PATCH v2 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support for mx5
In reply to Shawn GuoThe 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
With this patch, card_detect and write_protect gets supported on mx51_babbage, and other mx5 machines can easily get there with the least board level configuration added.
---
Changes since v1:
* Took the suggestion from Arnaud Patard to add default pdata in imx_add_sdhci_esdhc_imx(), to avoid touching every single board file for the platform_data changes
arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 3 +- arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 3 +- arch/arm/mach-imx/mach-mx25_3ds.c | 2 + arch/arm/mach-imx/mach-pcm043.c | 2 + arch/arm/mach-mx5/board-mx51_babbage.c | 27 +++++- .../plat-mxc/devices/platform-sdhci-esdhc-imx.c | 12 ++ arch/arm/plat-mxc/include/mach/esdhc.h | 25 ++++- drivers/mmc/host/sdhci-esdhc-imx.c | 115 +++++++++++--------- 8 files changed, 130 insertions(+), 59 deletions(-)
arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c +2 -1
@@ -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 , };/*
arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c +2 -1
@@ -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 , };/*
arch/arm/mach-imx/mach-mx25_3ds.c +2 -0
@@ -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 )
arch/arm/mach-imx/mach-pcm043.c +2 -0
@@ -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 , };/*
arch/arm/mach-mx5/board-mx51_babbage.c +25 -2
@@ -34,6 +34,8 @@#include "devices.h" #include "cpu_op-mx51.h" +#define BABBAGE_ESDHC2_WP IMX_GPIO_NR(1, 5) +#define BABBAGE_ESDHC2_CD IMX_GPIO_NR(1, 6)#define BABBAGE_USB_HUB_RESET IMX_GPIO_NR(1, 7)#define BABBAGE_USBH1_STP IMX_GPIO_NR(1, 27)#define BABBAGE_USB_PHY_RESET IMX_GPIO_NR(2, 5)
@@ -142,6 +144,10 @@ 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 , +/* CD signal */ +MX51_PAD_GPIO1_0__SD1_CD , +/* WP signal */ +MX51_PAD_GPIO1_1__SD1_WP ,/* SD 2 */ MX51_PAD_SD2_CMD__SD2_CMD,
@@ -150,6 +156,11 @@ 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 , +/* WP gpio */ +MX51_PAD_GPIO1_5__GPIO1_5 , +/* CD gpio */ +MX51_PAD_GPIO1_6__GPIO1_6 , +/* eCSPI1 */ MX51_PAD_CSPI1_MISO__ECSPI1_MISO,
@@ -331,6 +342,18 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = { .num_chipselect = ARRAY_SIZE(mx51_babbage_spi_cs), }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_SIGNAL , + .cd_type =ESDHC_CD_SIGNAL , +}; + +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_gpio =BABBAGE_ESDHC2_WP , + .cd_gpio =BABBAGE_ESDHC2_CD , + .wp_type =ESDHC_WP_GPIO , + .cd_type =ESDHC_CD_GPIO , +}; +/* * Board specific initialization. */
@@ -376,8 +399,8 @@ static void __init mx51_babbage_init(void)mxc_iomux_v3_setup_pad (usbh1stp);babbage_usbhub_reset (); -imx51_add_sdhci_esdhc_imx (0 ,NULL ); -imx51_add_sdhci_esdhc_imx (1 ,NULL ); +imx51_add_sdhci_esdhc_imx (0 , &esdhc1_pdata); +imx51_add_sdhci_esdhc_imx (1 , &esdhc2_pdata);spi_register_board_info (mx51_babbage_spi_board_info,ARRAY_SIZE (mx51_babbage_spi_board_info));
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +12 -0
@@ -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 a pdata, use the default one +* which means none 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)); }
arch/arm/plat-mxc/include/mach/esdhc.h +20 -5
@@ -10,17 +10,32 @@#ifndef __ASM_ARCH_IMX_ESDHC_H#define __ASM_ARCH_IMX_ESDHC_H +enum wp_types { +ESDHC_WP_NONE ,/* no WP, neither signal nor gpio */ +ESDHC_WP_SIGNAL ,/* mmc internal WP signal */ +ESDHC_WP_GPIO ,/* external gpio pin for WP */ +}; + +enum cd_types { +ESDHC_CD_NONE ,/* no CD, neither signal nor gpio */ +ESDHC_CD_SIGNAL ,/* mmc internal CD signal */ +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 -* -* strongly recommended for i.MX25/35, not needed for other variants +* struct esdhc_platform_data - platform data for esdhc on i.MX * -* @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 */
drivers/mmc/host/sdhci-esdhc-imx.c +65 -50
205 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v2 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support for mx5
Quoted 9 lines · Shawn Guo
The patch extends
card_detectandwrite_protectsupport to get mx5 family and more scenarios supported. The changes include:* Turn
platform_datafrom optional to mandatory
* Addcd_typesandwp_typesintoplatform_datato cover more use cases
* Remove the use of flagESDHC_FLAG_GPIO_FOR_CD
* Adjust some machine codes to adopt theplatform_datachanges
Quoted 5 lines
With this patch,
card_detectandwrite_protectgets supported onmx51_babbage, and other mx5 machines can easily get there with the least board level configuration added.Signed-off-by Shawn Guo <[email protected]>
No time for a full review, but it looks a lot like going into the right direction. Thanks.
A few comments:
Quoted 153 lines
---
Changes since v1:
* Took the suggestion from Arnaud Patard to add default pdata inimx_add_sdhci_esdhc_imx(), to avoid touching every single board file for theplatform_datachangesarch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 3 +- arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 3 +- arch/arm/mach-imx/mach-mx25_3ds.c | 2 + arch/arm/mach-imx/mach-pcm043.c | 2 + arch/arm/mach-mx5/board-mx51_babbage.c | 27 +++++- .../plat-mxc/devices/platform-sdhci-esdhc-imx.c | 12 ++ arch/arm/plat-mxc/include/mach/esdhc.h | 25 ++++- drivers/mmc/host/sdhci-esdhc-imx.c | 115 +++++++++++--------- 8 files changed, 130 insertions(+), 59 deletions(-)arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c +2
-1@@ -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 , };/* arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c +2
-1@@ -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 , };/* arch/arm/mach-imx/mach-mx25_3ds.c +2
-0@@ -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 )arch/arm/mach-imx/mach-pcm043.c +2
-0@@ -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 , };/* arch/arm/mach-mx5/board-mx51_babbage.c +25
-2@@ -34,6 +34,8 @@#include "devices.h" #include "cpu_op-mx51.h" +#define BABBAGE_ESDHC2_WP IMX_GPIO_NR(1, 5) +#define BABBAGE_ESDHC2_CD IMX_GPIO_NR(1, 6)#define BABBAGE_USB_HUB_RESET IMX_GPIO_NR(1, 7)#define BABBAGE_USBH1_STP IMX_GPIO_NR(1, 27)#define BABBAGE_USB_PHY_RESET IMX_GPIO_NR(2, 5)@@ -142,6 +144,10 @@ 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 , +/* CD signal */ +MX51_PAD_GPIO1_0__SD1_CD , +/* WP signal */ +MX51_PAD_GPIO1_1__SD1_WP ,/* SD 2 */ MX51_PAD_SD2_CMD__SD2_CMD,@@ -150,6 +156,11 @@ 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 , +/* WP gpio */ +MX51_PAD_GPIO1_5__GPIO1_5 , +/* CD gpio */ +MX51_PAD_GPIO1_6__GPIO1_6 , +/* eCSPI1 */ MX51_PAD_CSPI1_MISO__ECSPI1_MISO,@@ -331,6 +342,18 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = { .num_chipselect = ARRAY_SIZE(mx51_babbage_spi_cs), }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_SIGNAL , + .cd_type =ESDHC_CD_SIGNAL , +}; + +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_gpio =BABBAGE_ESDHC2_WP , + .cd_gpio =BABBAGE_ESDHC2_CD , + .wp_type =ESDHC_WP_GPIO , + .cd_type =ESDHC_CD_GPIO , +}; +/* * Board specific initialization. */ @@ -376,8 +399,8 @@ static void __init mx51_babbage_init(void)mxc_iomux_v3_setup_pad (usbh1stp);babbage_usbhub_reset (); -imx51_add_sdhci_esdhc_imx (0 ,NULL ); -imx51_add_sdhci_esdhc_imx (1 ,NULL ); +imx51_add_sdhci_esdhc_imx (0 , &esdhc1_pdata); +imx51_add_sdhci_esdhc_imx (1 , &esdhc2_pdata);spi_register_board_info (mx51_babbage_spi_board_info,ARRAY_SIZE (mx51_babbage_spi_board_info));arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +5
-0@@ -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)
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c struct platform_device *__init imx_add_sdhci_esdhc_imx( · line 90
Quoted 5 lines
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +2
-0@@ -81,6 +86,13 @@ struct platform_device *__init imx_add_sdhci_esdhc_imx( }, }; +/* +* If machine does not provide a pdata, use the default one
s/a pdata/pdata/ (not 100% sure, though)
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c struct platform_device *__init imx_add_sdhci_esdhc_imx( · line 91
Quoted 1 line
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +1
-0+* which means none WP/CD support
s/none/no/
Quoted 12 lines
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +4
-0+*/ +if (!pdata) + pdata = &default_esdhc_pdata; +return imx_add_platform_device ("sdhci-esdhc-imx" , data->id, res,ARRAY_SIZE (res), pdata,sizeof (*pdata)); }arch/arm/plat-mxc/include/mach/esdhc.h +0
-0
arch/arm/plat-mxc/include/mach/esdhc.h line 15
Quoted 6 lines
arch/arm/plat-mxc/include/mach/esdhc.h +3
-0@@ -10,17 +10,32 @@#ifndef __ASM_ARCH_IMX_ESDHC_H#define __ASM_ARCH_IMX_ESDHC_H +enum wp_types { +ESDHC_WP_NONE ,/* no WP, neither signal nor gpio */ + ESDHC_WP_SIGNAL, /* mmc internal WP signal */
I think SIGNAL is not descriptive enough. Maybe
ESDHC_WP_INTERNAL /* WP routed directly to mmc controller */
? It should be mentioned on which SoCs this is not available?
arch/arm/plat-mxc/include/mach/esdhc.h line 21
Quoted 6 lines
arch/arm/plat-mxc/include/mach/esdhc.h +6
-0+ ESDHC_WP_GPIO, /* external gpio pin for WP */ +}; + +enum cd_types { +ESDHC_CD_NONE ,/* no CD, neither signal nor gpio */ +ESDHC_CD_SIGNAL ,/* mmc internal CD signal */
ditto
Quoted 83 lines
arch/arm/plat-mxc/include/mach/esdhc.h +11
-5+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 -* -* strongly recommended for i.MX25/35, not needed for other variants +* struct esdhc_platform_data - platform data for esdhc on i.MX * -* @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 */ drivers/mmc/host/sdhci-esdhc-imx.c +9
-12@@ -29,7 +29,6 @@#define SDHCI_VENDOR_SPEC 0xC0#define SDHCI_VENDOR_SPEC_SDIO_QUIRK 0x00000002 -#define ESDHC_FLAG_GPIO_FOR_CD (1 << 0)/* * The CMDTYPE of the CMD register (offset 0xE) should be set to * "11" when the STOP CMD12 is issued on imx53 to abort one @@ -70,19 +69,15 @@ static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, istatic u32 esdhc_readl_le (struct sdhci_host *host,int reg) { -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct pltfm_imx_data *imx_data = pltfm_host->priv; +struct esdhc_platform_data *boarddata = + host->mmc->parent->platform_data; -/* fake CARD_PRESENT flag on mx25/35 */ +/* fake CARD_PRESENT flag */ u32 val =readl (host->ioaddr + reg);if (unlikely ((reg ==SDHCI_PRESENT_STATE ) - && (imx_data->flags &ESDHC_FLAG_GPIO_FOR_CD ))) { -struct esdhc_platform_data *boarddata = - host->mmc->parent->platform_data; - -if (boarddata &&gpio_is_valid (boarddata->cd_gpio) - &&gpio_get_value (boarddata->cd_gpio)) + &&gpio_is_valid (boarddata->cd_gpio))) { +if (gpio_get_value (boarddata->cd_gpio))/* no card, if a valid gpio says so... */ val &= ~SDHCI_CARD_PRESENT ;else @@ -97,12 +92,13 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct pltfm_imx_data *imx_data = pltfm_host->priv; +struct esdhc_platform_data *boarddata = + host->mmc->parent->platform_data;if (unlikely ((reg ==SDHCI_INT_ENABLE || reg ==SDHCI_SIGNAL_ENABLE ) - && (imx_data->flags &ESDHC_FLAG_GPIO_FOR_CD ))) + && (boarddata->cd_type ==ESDHC_CD_GPIO )))/* * these interrupts won't work with a custom card_detect gpio -* (only applied to mx25/35) */ val &= ~(SDHCI_INT_CARD_REMOVE |SDHCI_INT_CARD_INSERT );@@ -201,6 +197,18 @@ static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)return clk_get_rate (pltfm_host->clk) /256 /16 ; } +static unsigned int esdhc_pltfm_get_ro (struct sdhci_host *host)
drivers/mmc/host/sdhci-esdhc-imx.c static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host) · line 210
Quoted 10 lines
drivers/mmc/host/sdhci-esdhc-imx.c +10
-0+{ +struct esdhc_platform_data *boarddata = + host->mmc->parent->platform_data; + +if (gpio_is_valid (boarddata->wp_gpio)) +return gpio_get_value (boarddata->wp_gpio); +else +return !(readl (host->ioaddr +SDHCI_PRESENT_STATE ) & +SDHCI_WRITE_PROTECT ); +}
Aren't you missing the NONE case here? Plus, I don't like having a get_ro-function for the SIGNAL case, because in that case it is superfluous. Though, I am not feeling strong about this if it makes the rest of the code messier.
Quoted 52 lines
drivers/mmc/host/sdhci-esdhc-imx.c +10
-17+static struct sdhci_ops sdhci_esdhc_ops = { .read_l = esdhc_readl_le, .read_w = esdhc_readw_le,@@ -212,6 +220,7 @@ static struct sdhci_ops sdhci_esdhc_ops = { .get_min_clock = esdhc_pltfm_get_min_clock, .get_max_blk_size = esdhc_pltfm_get_max_blk_size, .get_max_blk_count = esdhc_pltfm_get_max_blk_count, + .get_ro = esdhc_pltfm_get_ro, };static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {@@ -221,17 +230,6 @@ static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { .ops = &sdhci_esdhc_ops, }; -static unsigned int esdhc_pltfm_get_ro (struct sdhci_host *host) -{ -struct esdhc_platform_data *boarddata = - host->mmc->parent->platform_data; - -if (boarddata &&gpio_is_valid (boarddata->wp_gpio)) -return gpio_get_value (boarddata->wp_gpio); -else -return -ENOSYS ; -} -static irqreturn_t cd_irq (int irq,void *data) {struct sdhci_host *sdhost = (struct sdhci_host *)data;@@ -272,23 +270,33 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)if (!cpu_is_mx25 ()) host->quirks |=SDHCI_QUIRK_BROKEN_TIMEOUT_VAL ; -if (cpu_is_mx25 () ||cpu_is_mx35 ()) { -/* write_protect can't be routed to controller, use gpio */ - sdhci_esdhc_ops.get_ro = esdhc_pltfm_get_ro; - } -if (!(cpu_is_mx25 () ||cpu_is_mx35 () ||cpu_is_mx51 ())) imx_data->flags |=ESDHC_FLAG_MULTIBLK_NO_INT ; boarddata = host->mmc->parent->platform_data; -if (boarddata) { +if (!boarddata) { +dev_err (mmc_dev (host->mmc),"no board data!\n" ); + err = -EINVAL ; + goto no_board_data; + } + +/* write_protect */ +if (boarddata->wp_type ==ESDHC_WP_GPIO ) {
drivers/mmc/host/sdhci-esdhc-imx.c static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) · line 292
Quoted 10 lines
drivers/mmc/host/sdhci-esdhc-imx.c +4
-2err =gpio_request_one (boarddata->wp_gpio,GPIOF_IN ,"ESDHC_WP" );if (err) {dev_warn (mmc_dev (host->mmc), -"no write-protect pin available!\n" ); - boarddata->wp_gpio = err; +"no write-protect pin available!\n" ); + boarddata->wp_gpio = -EINVAL ; } + }else + boarddata->wp_gpio = -EINVAL ;
else-block needs braces
Quoted 97 lines
drivers/mmc/host/sdhci-esdhc-imx.c +32
-19+/* card_detect */ +if (boarddata->cd_type !=ESDHC_CD_GPIO ) + boarddata->cd_gpio = -EINVAL ; + +switch (boarddata->cd_type) { +case ESDHC_CD_GPIO : err =gpio_request_one (boarddata->cd_gpio,GPIOF_IN ,"ESDHC_CD" );if (err) { dev_warn(mmc_dev(host->mmc),@@ -296,10 +304,6 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) goto no_card_detect_pin; } -/* i.MX5x has issues to be researched */ -if (!cpu_is_mx25 () && !cpu_is_mx35 ()) - goto not_supported; - err =request_irq (gpio_to_irq (boarddata->cd_gpio), cd_irq,IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING ,mmc_hostname (host->mmc), host);@@ -307,10 +311,19 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)dev_warn (mmc_dev (host->mmc),"request irq error\n" ); goto no_card_detect_irq; } +/* fall through */ - imx_data->flags |=ESDHC_FLAG_GPIO_FOR_CD ; -/* Now we have a working card_detect again */ +case ESDHC_CD_SIGNAL : +/* we have a working card_detect back */ host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION ; +break ; + +case ESDHC_CD_PERMANENT : + host->mmc->caps =MMC_CAP_NONREMOVABLE ; +break ; + +case ESDHC_CD_NONE : +break ; } err =sdhci_add_host (host);@@ -319,16 +332,20 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)return 0 ; - no_card_detect_irq: -gpio_free (boarddata->cd_gpio); - no_card_detect_pin: - boarddata->cd_gpio = err; - not_supported: -kfree (imx_data); - err_add_host: +err_add_host: +if (gpio_is_valid (boarddata->cd_gpio)) +free_irq (gpio_to_irq (boarddata->cd_gpio), host); +no_card_detect_irq: +if (gpio_is_valid (boarddata->cd_gpio)) +gpio_free (boarddata->cd_gpio); +if (gpio_is_valid (boarddata->wp_gpio)) +gpio_free (boarddata->wp_gpio); +no_card_detect_pin: +no_board_data:clk_disable (pltfm_host->clk);clk_put (pltfm_host->clk); - err_clk_get: +err_clk_get: +kfree (imx_data);sdhci_pltfm_free (pdev);return err; }@@ -343,14 +360,12 @@ static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev)sdhci_remove_host (host, dead); -if (boarddata &&gpio_is_valid (boarddata->wp_gpio)) +if (gpio_is_valid (boarddata->wp_gpio))gpio_free (boarddata->wp_gpio); -if (boarddata &&gpio_is_valid (boarddata->cd_gpio)) { +if (gpio_is_valid (boarddata->cd_gpio)) { +free_irq (gpio_to_irq (boarddata->cd_gpio), host);gpio_free (boarddata->cd_gpio); - -if (!(host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION )) -free_irq (gpio_to_irq (boarddata->cd_gpio), host); }clk_disable (pltfm_host->clk);Signature · 6 lines
1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Regards,
Wolfram
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110614/92d43bf1/attachment-0001.sig>
PATCH v2 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support for mx5
Quoted 10 lines · Wolfram Sang
Quoted 9 lines · Shawn Guo
The patch extends
card_detectandwrite_protectsupport to get mx5 family and more scenarios supported. The changes include:* Turn
platform_datafrom optional to mandatory
* Addcd_typesandwp_typesintoplatform_datato cover more use cases
* Remove the use of flagESDHC_FLAG_GPIO_FOR_CD
* Adjust some machine codes to adopt theplatform_datachanges
Quoted 7 lines
Quoted 5 lines
With this patch,
card_detectandwrite_protectgets supported onmx51_babbage, and other mx5 machines can easily get there with the least board level configuration added.Signed-off-by Shawn Guo <[email protected]>No time for a full review, but it looks a lot like going into the right
The lack of CD support is causing critical system performance issue. There is monthly Linaro release coming shortly, and this is one important issue needs to be fixed in the release. Please find some time to do a full review, if possible. We need your ack to know if the patch stands :)
Quoted 160 lines
direction. Thanks.
A few comments:
Quoted 156 lines
---
Changes since v1:
* Took the suggestion from Arnaud Patard to add default pdata inimx_add_sdhci_esdhc_imx(), to avoid touching every single board file for theplatform_datachangesarch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c | 3 +- arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c | 3 +- arch/arm/mach-imx/mach-mx25_3ds.c | 2 + arch/arm/mach-imx/mach-pcm043.c | 2 + arch/arm/mach-mx5/board-mx51_babbage.c | 27 +++++- .../plat-mxc/devices/platform-sdhci-esdhc-imx.c | 12 ++ arch/arm/plat-mxc/include/mach/esdhc.h | 25 ++++- drivers/mmc/host/sdhci-esdhc-imx.c | 115 +++++++++++--------- 8 files changed, 130 insertions(+), 59 deletions(-)arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c +2
-1@@ -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 , };/* arch/arm/mach-imx/eukrea_mbimxsd35-baseboard.c +2
-1@@ -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 , };/* arch/arm/mach-imx/mach-mx25_3ds.c +2
-0@@ -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 )arch/arm/mach-imx/mach-pcm043.c +2
-0@@ -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 , };/* arch/arm/mach-mx5/board-mx51_babbage.c +25
-2@@ -34,6 +34,8 @@#include "devices.h" #include "cpu_op-mx51.h" +#define BABBAGE_ESDHC2_WP IMX_GPIO_NR(1, 5) +#define BABBAGE_ESDHC2_CD IMX_GPIO_NR(1, 6)#define BABBAGE_USB_HUB_RESET IMX_GPIO_NR(1, 7)#define BABBAGE_USBH1_STP IMX_GPIO_NR(1, 27)#define BABBAGE_USB_PHY_RESET IMX_GPIO_NR(2, 5)@@ -142,6 +144,10 @@ 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 , +/* CD signal */ +MX51_PAD_GPIO1_0__SD1_CD , +/* WP signal */ +MX51_PAD_GPIO1_1__SD1_WP ,/* SD 2 */ MX51_PAD_SD2_CMD__SD2_CMD,@@ -150,6 +156,11 @@ 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 , +/* WP gpio */ +MX51_PAD_GPIO1_5__GPIO1_5 , +/* CD gpio */ +MX51_PAD_GPIO1_6__GPIO1_6 , +/* eCSPI1 */ MX51_PAD_CSPI1_MISO__ECSPI1_MISO,@@ -331,6 +342,18 @@ static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = { .num_chipselect = ARRAY_SIZE(mx51_babbage_spi_cs), }; +static const struct esdhc_platform_data esdhc1_pdata__initconst = { + .wp_type =ESDHC_WP_SIGNAL , + .cd_type =ESDHC_CD_SIGNAL , +}; + +static const struct esdhc_platform_data esdhc2_pdata__initconst = { + .wp_gpio =BABBAGE_ESDHC2_WP , + .cd_gpio =BABBAGE_ESDHC2_CD , + .wp_type =ESDHC_WP_GPIO , + .cd_type =ESDHC_CD_GPIO , +}; +/* * Board specific initialization. */ @@ -376,8 +399,8 @@ static void __init mx51_babbage_init(void)mxc_iomux_v3_setup_pad (usbh1stp);babbage_usbhub_reset (); -imx51_add_sdhci_esdhc_imx (0 ,NULL ); -imx51_add_sdhci_esdhc_imx (1 ,NULL ); +imx51_add_sdhci_esdhc_imx (0 , &esdhc1_pdata); +imx51_add_sdhci_esdhc_imx (1 , &esdhc2_pdata);spi_register_board_info (mx51_babbage_spi_board_info,ARRAY_SIZE (mx51_babbage_spi_board_info));arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +5
-0@@ -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( }, };
Quoted 5 lines
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c struct platform_device *__init imx_add_sdhci_esdhc_imx( · line 90
Quoted 2 lines
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +2
-0+/* +* If machine does not provide a pdata, use the default one s/a pdata/pdata/ (not 100% sure, though)
OK
Quoted 4 lines
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c struct platform_device *__init imx_add_sdhci_esdhc_imx( · line 91
Quoted 1 line
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +1
-0+* which means none WP/CD support s/none/no/
OK
Quoted 15 lines
Quoted 15 lines
arch/arm/plat-mxc/devices/platform-sdhci-esdhc-imx.c +4
-0+*/ +if (!pdata) + pdata = &default_esdhc_pdata; +return imx_add_platform_device ("sdhci-esdhc-imx" , data->id, res,ARRAY_SIZE (res), pdata,sizeof (*pdata)); }arch/arm/plat-mxc/include/mach/esdhc.h +0
-0@@ -10,17 +10,32 @@#ifndef __ASM_ARCH_IMX_ESDHC_H#define __ASM_ARCH_IMX_ESDHC_H
Quoted 6 lines
arch/arm/plat-mxc/include/mach/esdhc.h line 15
Quoted 3 lines
arch/arm/plat-mxc/include/mach/esdhc.h +3
-0+enum wp_types { +ESDHC_WP_NONE ,/* no WP, neither signal nor gpio */ +ESDHC_WP_SIGNAL ,/* mmc internal WP signal */ I think SIGNAL is not descriptive enough. Maybe
We have the document telling it's internal.
Quoted 2 lines
ESDHC_WP_INTERNAL/* WP routed directly to mmc controller */
I thought about that. If we use ESDHC_WP_INTERNAL, ESDHC_WP_GPIO should probably be the ESDHC_WP_EXTERNAL for the couple naming. But I like ESDHC_WP_GPIO over ESDHC_WP_EXTERNAL, so chose the couple naming of ESDHC_WP_GPIO vs. ESDHC_WP_SIGNAL.
Quoted 3 lines
? It should be mentioned on which SoCs this is not available?
From SoC/controller POV, it's all available. It's really a board
design choice to connect card CD/WP to the pads or not, which the controller CD/WP signal/function is available on.
Quoted 9 lines
arch/arm/plat-mxc/include/mach/esdhc.h line 21
Quoted 6 lines
arch/arm/plat-mxc/include/mach/esdhc.h +6
-0+ ESDHC_WP_GPIO, /* external gpio pin for WP */ +}; + +enum cd_types { +ESDHC_CD_NONE ,/* no CD, neither signal nor gpio */ +ESDHC_CD_SIGNAL ,/* mmc internal CD signal */ ditto
ditto
Quoted 82 lines
Quoted 82 lines
arch/arm/plat-mxc/include/mach/esdhc.h +11
-5+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 -* -* strongly recommended for i.MX25/35, not needed for other variants +* struct esdhc_platform_data - platform data for esdhc on i.MX * -* @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 */ drivers/mmc/host/sdhci-esdhc-imx.c +8
-12@@ -29,7 +29,6 @@#define SDHCI_VENDOR_SPEC 0xC0#define SDHCI_VENDOR_SPEC_SDIO_QUIRK 0x00000002 -#define ESDHC_FLAG_GPIO_FOR_CD (1 << 0)/* * The CMDTYPE of the CMD register (offset 0xE) should be set to * "11" when the STOP CMD12 is issued on imx53 to abort one @@ -70,19 +69,15 @@ static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, istatic u32 esdhc_readl_le (struct sdhci_host *host,int reg) { -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -struct pltfm_imx_data *imx_data = pltfm_host->priv; +struct esdhc_platform_data *boarddata = + host->mmc->parent->platform_data; -/* fake CARD_PRESENT flag on mx25/35 */ +/* fake CARD_PRESENT flag */ u32 val =readl (host->ioaddr + reg);if (unlikely ((reg ==SDHCI_PRESENT_STATE ) - && (imx_data->flags &ESDHC_FLAG_GPIO_FOR_CD ))) { -struct esdhc_platform_data *boarddata = - host->mmc->parent->platform_data; - -if (boarddata &&gpio_is_valid (boarddata->cd_gpio) - &&gpio_get_value (boarddata->cd_gpio)) + &&gpio_is_valid (boarddata->cd_gpio))) { +if (gpio_get_value (boarddata->cd_gpio))/* no card, if a valid gpio says so... */ val &= ~SDHCI_CARD_PRESENT ;else @@ -97,12 +92,13 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct pltfm_imx_data *imx_data = pltfm_host->priv; +struct esdhc_platform_data *boarddata = + host->mmc->parent->platform_data;if (unlikely ((reg ==SDHCI_INT_ENABLE || reg ==SDHCI_SIGNAL_ENABLE ) - && (imx_data->flags &ESDHC_FLAG_GPIO_FOR_CD ))) + && (boarddata->cd_type ==ESDHC_CD_GPIO )))/* * these interrupts won't work with a custom card_detect gpio -* (only applied to mx25/35) */ val &= ~(SDHCI_INT_CARD_REMOVE |SDHCI_INT_CARD_INSERT );@@ -201,6 +197,18 @@ static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)return clk_get_rate (pltfm_host->clk) /256 /16 ; }
Quoted 17 lines
drivers/mmc/host/sdhci-esdhc-imx.c static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host) · line 210
Quoted 11 lines
drivers/mmc/host/sdhci-esdhc-imx.c +11
-0+static unsigned int esdhc_pltfm_get_ro (struct sdhci_host *host) +{ +struct esdhc_platform_data *boarddata = + host->mmc->parent->platform_data; + +if (gpio_is_valid (boarddata->wp_gpio)) +return gpio_get_value (boarddata->wp_gpio); +else +return !(readl (host->ioaddr +SDHCI_PRESENT_STATE ) & +SDHCI_WRITE_PROTECT ); +}Aren't you missing the NONE case here? Plus, I don't like having a get_ro-function for the SIGNAL case, because in that case it is superfluous. Though, I am not feeling strong about this if it makes the rest of the code messier.
OK, I will go back to the existing one, which only handles gpio case in esdhc_pltfm_get_ro and get it assigned to .get_ro only in case of ESDHC_WP_GPIO.
Quoted 56 lines
Quoted 56 lines
drivers/mmc/host/sdhci-esdhc-imx.c +10
-18+static struct sdhci_ops sdhci_esdhc_ops = { .read_l = esdhc_readl_le, .read_w = esdhc_readw_le,@@ -212,6 +220,7 @@ static struct sdhci_ops sdhci_esdhc_ops = { .get_min_clock = esdhc_pltfm_get_min_clock, .get_max_blk_size = esdhc_pltfm_get_max_blk_size, .get_max_blk_count = esdhc_pltfm_get_max_blk_count, + .get_ro = esdhc_pltfm_get_ro, };static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {@@ -221,17 +230,6 @@ static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { .ops = &sdhci_esdhc_ops, }; -static unsigned int esdhc_pltfm_get_ro (struct sdhci_host *host) -{ -struct esdhc_platform_data *boarddata = - host->mmc->parent->platform_data; - -if (boarddata &&gpio_is_valid (boarddata->wp_gpio)) -return gpio_get_value (boarddata->wp_gpio); -else -return -ENOSYS ; -} -static irqreturn_t cd_irq (int irq,void *data) {struct sdhci_host *sdhost = (struct sdhci_host *)data;@@ -272,23 +270,33 @@ static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)if (!cpu_is_mx25 ()) host->quirks |=SDHCI_QUIRK_BROKEN_TIMEOUT_VAL ; -if (cpu_is_mx25 () ||cpu_is_mx35 ()) { -/* write_protect can't be routed to controller, use gpio */ - sdhci_esdhc_ops.get_ro = esdhc_pltfm_get_ro; - } -if (!(cpu_is_mx25 () ||cpu_is_mx35 () ||cpu_is_mx51 ())) imx_data->flags |=ESDHC_FLAG_MULTIBLK_NO_INT ; boarddata = host->mmc->parent->platform_data; -if (boarddata) { +if (!boarddata) { +dev_err (mmc_dev (host->mmc),"no board data!\n" ); + err = -EINVAL ; + goto no_board_data; + } + +/* write_protect */ +if (boarddata->wp_type ==ESDHC_WP_GPIO ) { err =gpio_request_one (boarddata->wp_gpio,GPIOF_IN ,"ESDHC_WP" );if (err) { dev_warn(mmc_dev(host->mmc), -"no write-protect pin available!\n" );
Quoted 9 lines
drivers/mmc/host/sdhci-esdhc-imx.c static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev) · line 292
Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +4
-1- boarddata->wp_gpio = err; + "no write-protect pin available!\n"); + boarddata->wp_gpio = -EINVAL ; } + }else + boarddata->wp_gpio = -EINVAL ;else-block needs braces
OK
Signature · 2 lines
Regards, Shawn
PATCH v2 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support for mx5
Quoted 4 lines
important issue needs to be fixed in the release. Please find some time to do a full review, if possible. We need your ack to know if the patch stands :)
Huh, my ack is needed for the linaro-kernel? :) Isn't it possible to replace a V1 patch with a V2 patch in later kernels?
Quoted 14 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/plat-mxc/include/mach/esdhc.h +0
-0@@ -10,17 +10,32 @@#ifndef __ASM_ARCH_IMX_ESDHC_H#define __ASM_ARCH_IMX_ESDHC_HQuoted 6 lines
arch/arm/plat-mxc/include/mach/esdhc.h line 15
Quoted 3 lines
arch/arm/plat-mxc/include/mach/esdhc.h +3
-0+enum wp_types { +ESDHC_WP_NONE ,/* no WP, neither signal nor gpio */ +ESDHC_WP_SIGNAL ,/* mmc internal WP signal */ I think SIGNAL is not descriptive enough. Maybe
Quoted 8 lines
We have the document telling it's internal.
Quoted 2 lines
ESDHC_WP_INTERNAL/* WP routed directly to mmc controller */I thought about that. If we use
ESDHC_WP_INTERNAL,ESDHC_WP_GPIOshould probably be theESDHC_WP_EXTERNALfor the couple naming. But I likeESDHC_WP_GPIOoverESDHC_WP_EXTERNAL, so chose the couple naming ofESDHC_WP_GPIOvs.ESDHC_WP_SIGNAL.
ESDHC_WP_CONTROLLER? Or ESDHC_WP_CORE?
Quoted 5 lines
Quoted 2 lines
? It should be mentioned on which SoCs this is not available?
From SoC/controller POV, it's all available. It's really a board design choice to connect card CD/WP to the pads or not, which the controller CD/WP signal/function is available on.
For mx25/35, I tried to find muxer settings but couldn't find them. It seemed to me, GPIO is the only option there (I think I even asked Richard). Can you route them on mx25/35, too?
Regards,
Wolfram
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110614/08c5168d/attachment.sig>
PATCH v2 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support for mx5
Quoted 8 lines · Wolfram Sang
Quoted 4 lines
important issue needs to be fixed in the release. Please find some time to do a full review, if possible. We need your ack to know if the patch stands :)
Huh, my ack is needed for the linaro-kernel? :) Isn't it possible to replace a V1 patch with a V2 patch in later kernels?
The linaro-kernel tree only accepts patches that have been on upstream or are on the way to upstream (sitting on 'next' is a good proving). Also since we are touching sdhci.c a little bit, it should be good for us to get the patch on 'next' as early as we can, so that people can start testing it.
Anyway, I will post v2 shortly. Please help do a full review if possible. I'd appreciate it.
Quoted 16 lines
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/plat-mxc/include/mach/esdhc.h +0
-0@@ -10,17 +10,32 @@#ifndef __ASM_ARCH_IMX_ESDHC_H#define __ASM_ARCH_IMX_ESDHC_HQuoted 6 lines
arch/arm/plat-mxc/include/mach/esdhc.h line 15
Quoted 3 lines
arch/arm/plat-mxc/include/mach/esdhc.h +3
-0+enum wp_types { +ESDHC_WP_NONE ,/* no WP, neither signal nor gpio */ +ESDHC_WP_SIGNAL ,/* mmc internal WP signal */ I think SIGNAL is not descriptive enough. Maybe
We have the document telling it's internal.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
ESDHC_WP_INTERNAL/* WP routed directly to mmc controller */I thought about that. If we use
ESDHC_WP_INTERNAL,ESDHC_WP_GPIOshould probably be theESDHC_WP_EXTERNALfor the couple naming. But I likeESDHC_WP_GPIOoverESDHC_WP_EXTERNAL, so chose the couple naming ofESDHC_WP_GPIOvs.ESDHC_WP_SIGNAL.
ESDHC_WP_CONTROLLER? OrESDHC_WP_CORE?
Ok, going ESDHC_WP_CONTROLLER
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
? It should be mentioned on which SoCs this is not available?
From SoC/controller POV, it's all available. It's really a board design choice to connect card CD/WP to the pads or not, which the controller CD/WP signal/function is available on.
For mx25/35, I tried to find muxer settings but couldn't find them. It seemed to me, GPIO is the only option there (I think I even asked Richard). Can you route them on mx25/35, too?
Sorry for confusion here. It's all available from eSDHC controller POV. But no, it's not available on mx25/35 from SoC pinmux POV. So you are right.
Signature · 2 lines
Regards, Shawn
PATCH v2 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support for mx5
In reply to Shawn GuoOn Tue, Jun 14, 2011 at 09:06:11PM +0800, Shawn Guo wrote:
[...]
Quoted 18 lines
Quoted 18 lines
drivers/mmc/host/sdhci-esdhc-imx.c static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host) · line 210
Quoted 12 lines
drivers/mmc/host/sdhci-esdhc-imx.c +11
-0+static unsigned int esdhc_pltfm_get_ro (struct sdhci_host *host) +{ +struct esdhc_platform_data *boarddata = + host->mmc->parent->platform_data; + +if (gpio_is_valid (boarddata->wp_gpio)) +return gpio_get_value (boarddata->wp_gpio); +else +return !(readl (host->ioaddr +SDHCI_PRESENT_STATE ) & +SDHCI_WRITE_PROTECT ); +}Aren't you missing the NONE case here? Plus, I don't like having a get_ro-function for the SIGNAL case, because in that case it is superfluous. Though, I am not feeling strong about this if it makes the rest of the code messier.
Quoted 4 lines
OK, I will go back to the existing one, which only handles gpio case in
esdhc_pltfm_get_roand get it assigned to .get_ro only in case ofESDHC_WP_GPIO.
Sorry. I had some reason for moving esdhc_pltfm_get_ro around. We can not keep the existing approach (what I said above). For mx51 babbage example, esdhc1 uses internal WP while esdhc2 uses gpio WP. If we have esdhc_pltfm_get_ro handle gpio only and assign it to sdhci_esdhc_ops.get_ro in .probe only when wp_type is ESDHC_WP_GPIO, that works for esdhc2 but breaks esdhc1 WP function. So no, I will not change my code except adding NONE case handling there.
Signature · 2 lines
Regards, Shawn
PATCH v2 4/4 mmc: sdhci-esdhc-imx: extend card_detect and write_protect support for mx5
Quoted 7 lines
Sorry. I had some reason for moving
esdhc_pltfm_get_roaround. We can not keep the existing approach (what I said above). For mx51 babbage example, esdhc1 uses internal WP while esdhc2 uses gpio WP. If we haveesdhc_pltfm_get_rohandle gpio only and assign it to sdhci_esdhc_ops.get_ro in .probe only whenwp_typeisESDHC_WP_GPIO, that works for esdhc2 but breaks esdhc1 WP function. So no, I will not change my code except adding NONE case handling there.
Ok, fine with me. Thanks for checking!
Signature · 9 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110615/d5cff7fc/attachment.sig>
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
In reply to Shawn GuoQuoted 9 lines · Shawn Guo
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx
card_detectandwrite_protectsupport to cover mx5 platforms, and solves above performance issues.
Quoted 6 lines
Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx:SDHCI_CARD_PRESENTdoes not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flagESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extendcard_detectandwrite_protectsupport
Hi Arnaud,
Any chance to play with it yet?
Hi Wolfram,
Any comment?
Signature · 2 lines
Regards, Shawn
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
Shawn Guo <[email protected]> writes:
Hi,
Quoted 16 lines · Shawn Guo
Quoted 9 lines
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx
card_detectandwrite_protectsupport to cover mx5 platforms, and solves above performance issues.Quoted 6 lines
Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx:SDHCI_CARD_PRESENTdoes not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flagESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extendcard_detectandwrite_protectsupport
Quoted 3 lines
Hi Arnaud,
Any chance to play with it yet?
I tried applying the patch 4 (v2) on mmc git and Sascha Hauer's for-next branch and failed. Can you please tell me on which tree should I apply it ?
Thanks,
Arnaud
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
Quoted 20 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 16 lines · Shawn Guo
Quoted 15 lines
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx
card_detectandwrite_protectsupport to cover mx5 platforms, and solves above performance issues.Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx:SDHCI_CARD_PRESENTdoes not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flagESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extendcard_detectandwrite_protectsupport
Quoted 8 lines
Quoted 3 lines
Hi Arnaud,
Any chance to play with it yet?
I tried applying the patch 4 (v2) on mmc git and Sascha Hauer's for-next branch and failed. Can you please tell me on which tree should I apply it ?
Sascha really should not picked up the following 3 patches. They are nonsense when driver is not even ready for the support. These 3 patches have conflict with my patch set. You should be able to apply with these 3 removed.
commit 954548c68c2d478bf8ec0ca9d9eea2a7c45a4fcd
Author: Andre Silva <[email protected]>
ARM:mach-mx5/board-mx51_babbage: Add CD and WP GPIOs
commit ba0c5064cb55aaac4cb5202ecad5afe9385139fc
Author: Andre Silva <[email protected]>
ARM:mach-mx5/board-mx53_loco: Add CD and WP GPIOs
commit fabef7b7c62ba58604da22b6f79b7e9ad5ae8d74
Author: Andre Silva <[email protected]>
ARM: mach-mx5/mx53_ard: Add support for i.MX53 ARD board
Signature · 2 lines
Regards, Shawn
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
Quoted 42 lines · Shawn Guo
Quoted 20 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 16 lines · Shawn Guo
Quoted 15 lines
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx
card_detectandwrite_protectsupport to cover mx5 platforms, and solves above performance issues.Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx:SDHCI_CARD_PRESENTdoes not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flagESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extendcard_detectandwrite_protectsupportQuoted 8 lines
Quoted 3 lines
Hi Arnaud,
Any chance to play with it yet?
I tried applying the patch 4 (v2) on mmc git and Sascha Hauer's for-next branch and failed. Can you please tell me on which tree should I apply it ?
Sascha really should not picked up the following 3 patches. They are nonsense when driver is not even ready for the support. These 3 patches have conflict with my patch set. You should be able to apply with these 3 removed.
commit
954548c68c2d478bf8ec0ca9d9eea2a7c45a4fcd
Author: Andre Silva <[email protected]>ARM:mach-mx5/board-mx51_babbage: Add CD and WP GPIOs
commit
ba0c5064cb55aaac4cb5202ecad5afe9385139fc
Author: Andre Silva <[email protected]>
Quoted 7 lines
ARM:mach-mx5/board-mx53_loco: Add CD and WP GPIOs
commit
fabef7b7c62ba58604da22b6f79b7e9ad5ae8d74
Author: Andre Silva <[email protected]>ARM: mach-mx5/mx53_ard: Add support for i.MX53 ARD board
Sascha,
Since these 3 patches are still sitting on top of your tree, would you mind backing out them? Or you want me to do a rebase on your tree? I'm fine with either one.
Signature · 2 lines
Regards, Shawn
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
In reply to Shawn GuoQuoted 25 lines · Shawn Guo
Quoted 24 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 19 lines · Shawn Guo
Quoted 9 lines
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx
card_detectandwrite_protectsupport to cover mx5 platforms, and solves above performance issues.Quoted 6 lines
Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx:SDHCI_CARD_PRESENTdoes not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flagESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extendcard_detectandwrite_protectsupportHi Arnaud,
Any chance to play with it yet?
Quoted 8 lines
Quoted 4 lines
I tried applying the patch 4 (v2) on mmc git and Sascha Hauer's for-next branch and failed. Can you please tell me on which tree should I apply it ?
Sascha really should not picked up the following 3 patches. They are nonsense when driver is not even ready for the support. These 3 patches have conflict with my patch set. You should be able to apply with these 3 removed.
They're still not applying. It's failing to failing sdhci-esdhc-imx.c. I'm currently trying t make sure I didn't miss something but it looks like the patch is not against for-next. For instance, look at :
http://git.pengutronix.de/?p=imx/linux-2.6.git;a=blob;f=drivers/mmc/host/sdhci-esdhc-imx.c;h=a19967d0bfc48b0ce8216de0d1a727093ee9fa03;hb=refs/heads/for-next
It's already adding a esdhc_pltfm_get_ro() function, so I fail to see how a patch adding a function with same name can work.
Thanks,
Arnaud
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
Quoted 36 lines · Arnaud Patard
Quoted 25 lines · Shawn Guo
Quoted 24 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 19 lines · Shawn Guo
Quoted 9 lines
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx
card_detectandwrite_protectsupport to cover mx5 platforms, and solves above performance issues.Quoted 6 lines
Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx:SDHCI_CARD_PRESENTdoes not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flagESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extendcard_detectandwrite_protectsupportHi Arnaud,
Any chance to play with it yet?
Quoted 8 lines
Quoted 4 lines
I tried applying the patch 4 (v2) on mmc git and Sascha Hauer's for-next branch and failed. Can you please tell me on which tree should I apply it ?
Sascha really should not picked up the following 3 patches. They are nonsense when driver is not even ready for the support. These 3 patches have conflict with my patch set. You should be able to apply with these 3 removed.
Quoted 9 lines
They're still not applying. It's failing to failing
sdhci-esdhc-imx.c. I'm currently trying t make sure I didn't miss something but it looks like the patch is not against for-next. For instance, look at :
http://git.pengutronix.de/?p=imx/linux-2.6.git;a=blob;f=drivers/mmc/host/sdhci-esdhc-imx.c;h=a19967d0bfc48b0ce8216de0d1a727093ee9fa03;hb=refs/heads/for-nextIt's already adding a
esdhc_pltfm_get_ro()function, so I fail to see how a patch adding a function with same name can work.
My patch did not add esdhc_pltfm_get_ro() function but moved it a little bit. Anyway, I will go ahead to rebase the patch set on the latest 'next' and send it as v2 shortly, since we have not heard anything from Sascha.
Signature · 2 lines
Regards, Shawn
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
In reply to Shawn GuoShawn Guo <[email protected]> writes:
Hi,
Quoted 16 lines · Shawn Guo
Quoted 9 lines
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx
card_detectandwrite_protectsupport to cover mx5 platforms, and solves above performance issues.Quoted 6 lines
Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx:SDHCI_CARD_PRESENTdoes not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flagESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extendcard_detectandwrite_protectsupport
Quoted 3 lines
Hi Arnaud,
Any chance to play with it yet?
Finally managed to build a kernel with this version of the patchset. While I'm not polling anymore, I'm getting a lot of interrupts if the card is not inserted. Theses interrupts are not happening if the card is inserted. I can see things like this in the logs :
sdhci [sdhci_irq()]: *** mmc0 got interrupt: 0x00000080
[ of course, the bit of the present state register indicating card presence is equal to 0 ]
I've tested the SIGNAL case only. Don't know if switch to GPIO may help. Do you have same kind of issue on your side ?
Thanks,
Arnaud
cover Extend sdhci-esdhc-imx card_detect and write_protect support for mx5
Hi Arnaud,
Sorry for the late replying. Somehow I missed the message.
Quoted 30 lines · Arnaud Patard
Shawn Guo <[email protected]> writes:
Hi,
Quoted 16 lines · Shawn Guo
Quoted 9 lines
The card-present polling within sdhci based driver is very expensive in terms of the impact to system performance. We observe a few system performance issues from Freescale and Linaro on mx5 platforms, which have been proved card polling related.
The patch set extends the current sdhci-esdhc-imx
card_detectandwrite_protectsupport to cover mx5 platforms, and solves above performance issues.Quoted 6 lines
Shawn Guo (4):
mmc: sdhci: fix interrupt storm from card detection
mmc: sdhci-esdhc-imx:SDHCI_CARD_PRESENTdoes not get cleared
mmc: sdhci-esdhc-imx: remove "WP" from flagESDHC_FLAG_GPIO_FOR_CD_WP
mmc: sdhci-esdhc-imx: extendcard_detectandwrite_protectsupportQuoted 3 lines
Hi Arnaud,
Any chance to play with it yet?
Finally managed to build a kernel with this version of the patchset. While I'm not polling anymore, I'm getting a lot of interrupts if the card is not inserted. Theses interrupts are not happening if the card is inserted. I can see things like this in the logs :
sdhci [sdhci_irq()]: *** mmc0 got interrupt:0x00000080
Quoted 6 lines
[ of course, the bit of the present state register indicating card presence is equal to 0 ]
I've tested the SIGNAL case only. Don't know if switch to GPIO may help. Do you have same kind of issue on your side ?
I reproduced the issue on my side with turn on debug switch (I should do so from the beginning).
GPIO mode does not have this issue. But you do not have to switch to GPIO, as I have got it fixed in the v3 of the patch set (posted out a few minutes ago). It can apply on linux-next cleanly. You need to note that naming 'SIGNAL' has been changed to 'CONTROLLER' per Wolfram's comment.
Thanks for testing.
Signature · 2 lines
Regards, Shawn