mmc: tmio: Implement SDIO IRQ
Subsystems (7)
PATCH 1/4 mmc: tmio: Implement SDIO IRQ
This patch implements SDIO IRQ support for mfds which announce the MMC_CAP_SDIO_IRQ capability for tmio_mmc. Tested with a b43-based wireless SDIO card and sh_mobile_sdhi.
This patch applies on top of:
mmc: tmio_mmc: allow multi-element scatter-gather lists
mmc: tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMA
--- drivers/mmc/host/tmio_mmc.c | 54 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 deletions(-)
drivers/mmc/host/tmio_mmc.c +53 -1
@@ -53,6 +53,8 @@#define CTL_SD_ERROR_DETAIL_STATUS 0x2c#define CTL_SD_DATA_PORT 0x30#define CTL_TRANSACTION_CTL 0x34 +#define CTL_SDIO_STATUS 0x36 +#define CTL_SDIO_IRQ_MASK 0x38#define CTL_RESET_SD 0xe0#define CTL_SDIO_REGS 0x100#define CTL_CLK_AND_WAIT_CTL 0x138
@@ -81,6 +83,12 @@#define TMIO_STAT_CMD_BUSY 0x40000000#define TMIO_STAT_ILL_ACCESS 0x80000000 +/* Definitions for values the CTRL_SDIO_STATUS register can take. */ +#define TMIO_SDIO_STAT_IOIRQ 0x0001 +#define TMIO_SDIO_STAT_EXPUB52 0x4000 +#define TMIO_SDIO_STAT_EXWT 0x8000 +#define TMIO_SDIO_MASK_ALL 0xc007 +/* Define some IRQ masks */ /* This is the mask used at reset by the chip */ #define TMIO_MASK_ALL 0x837f031d
@@ -122,6 +130,7 @@ struct tmio_mmc_host {struct mmc_data *data;struct mmc_host *mmc;int irq; +unsigned int sdio_irq_enabled;/* Callbacks for clock / power control */ void (*set_pwr)(struct platform_device *host,int state);
@@ -247,6 +256,22 @@ void pr_debug_status(u32 status)#define pr_debug_status (s) do { } while (0)#endif +static void tmio_mmc_enable_sdio_irq (struct mmc_host *mmc,int enable) +{ +struct tmio_mmc_host *host =mmc_priv (mmc); + +if (enable) { + host->sdio_irq_enabled =1 ; +sd_ctrl_write16 (host,CTL_TRANSACTION_CTL ,0x0001 ); +sd_ctrl_write16 (host,CTL_SDIO_IRQ_MASK , + (TMIO_SDIO_MASK_ALL & ~TMIO_SDIO_STAT_IOIRQ )); + }else { +sd_ctrl_write16 (host,CTL_SDIO_IRQ_MASK ,TMIO_SDIO_MASK_ALL ); +sd_ctrl_write16 (host,CTL_TRANSACTION_CTL ,0x0000 ); + host->sdio_irq_enabled =0 ; + } +} +static void tmio_mmc_set_clock (struct tmio_mmc_host *host,int new_clock) {u32 clk =0 , clock;
@@ -279,6 +304,9 @@ static void tmio_mmc_clk_start(struct tmio_mmc_host *host) sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));msleep (10 );sd_ctrl_write16 (host,CTL_CLK_AND_WAIT_CTL ,0x0100 ); +/* restore sdio irq state */ +if (host->mmc->caps &MMC_CAP_SDIO_IRQ ) +tmio_mmc_enable_sdio_irq (host->mmc, host->sdio_irq_enabled);msleep (10 ); }
@@ -557,6 +585,7 @@ static irqreturn_t tmio_mmc_irq(int irq, void *devid) {struct tmio_mmc_host *host = devid;unsigned int ireg, irq_mask, status; +unsigned int sdio_ireg, sdio_irq_mask, sdio_status;pr_debug ("MMC IRQ begin\n" );
@@ -564,10 +593,30 @@ static irqreturn_t tmio_mmc_irq(int irq, void *devid) irq_mask =sd_ctrl_read32 (host,CTL_IRQ_MASK ); ireg = status &TMIO_MASK_IRQ & ~irq_mask; + sdio_ireg =0 ; +if (host->mmc->caps &MMC_CAP_SDIO_IRQ ) { + sdio_status =sd_ctrl_read16 (host,CTL_SDIO_STATUS ); + sdio_irq_mask =sd_ctrl_read16 (host,CTL_SDIO_IRQ_MASK ); + sdio_ireg = sdio_status &TMIO_SDIO_MASK_ALL & ~sdio_irq_mask; + +if (sdio_ireg || (!ireg && !host->sdio_irq_enabled)) +pr_debug ("%s: sdio_i=0x%04x sdio_s=0x%04x " +"mask=0x%04x ireg=0x%08x spur=%u\n" , +mmc_hostname (host->mmc), + sdio_ireg, sdio_status, sdio_irq_mask, ireg, + !ireg && !host->sdio_irq_enabled); + +/* ack all sdio interrupts... */ +sd_ctrl_write16 (host,CTL_SDIO_STATUS , sdio_status & ~TMIO_SDIO_MASK_ALL ); + +if (sdio_ireg &TMIO_SDIO_STAT_IOIRQ ) +mmc_signal_sdio_irq (host->mmc); + } +pr_debug_status (status);pr_debug_status (ireg); -if (!ireg) { +if (!ireg && !sdio_ireg) {disable_mmc_irqs (host, status & ~irq_mask); pr_warning("tmio_mmc: Spurious irq, disabling! "
@@ -1033,6 +1082,7 @@ static const struct mmc_host_ops tmio_mmc_ops = { .set_ios = tmio_mmc_set_ios, .get_ro = tmio_mmc_get_ro, .get_cd = tmio_mmc_get_cd, + .enable_sdio_irq = tmio_mmc_enable_sdio_irq, };#ifdef CONFIG_PM
@@ -1147,6 +1197,8 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev) goto cell_disable;disable_mmc_irqs (host,TMIO_MASK_ALL ); +if (mmc->caps &MMC_CAP_SDIO_IRQ ) +tmio_mmc_enable_sdio_irq (mmc,0 ); ret =request_irq (host->irq, tmio_mmc_irq,IRQF_DISABLED |IRQF_TRIGGER_FALLING ,dev_name (&dev->dev), host);
Signature · 1 line
1.7.0.4
PATCH 2/4 ARM: mach-shmobile: sh7372 Enable SDIO IRQs
This patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the soc. To make sure interrupts are handled announce the MMC_CAP_SDIO_IRQ capability on AP4EVB. Tested with a b43-based SDIO wireless card.
--- arch/arm/mach-shmobile/board-ap4evb.c | 3 ++- arch/arm/mach-shmobile/intc-sh7372.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +2 -1
@@ -310,6 +310,7 @@ static u64 sdhi0_dma_mask = DMA_BIT_MASK(32);static struct sh_mobile_sdhi_info sdhi0_info = { .dma_slave_tx =SHDMA_SLAVE_SDHI0_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI0_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct resource sdhi0_resources[] = {
@@ -344,7 +345,7 @@ static struct sh_mobile_sdhi_info sdhi1_info = { .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, .tmio_ocr_mask = MMC_VDD_165_195, .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, - .tmio_caps = MMC_CAP_NEEDS_POLL, + .tmio_caps = MMC_CAP_NEEDS_POLL | MMC_CAP_SDIO_IRQ, .get_cd = slot_cn7_get_cd, };
arch/arm/mach-shmobile/intc-sh7372.c +2 -2
@@ -230,10 +230,10 @@ static struct intc_mask_reg intca_mask_registers[] __initdata = { {SCIFB ,SCIFA5 ,SCIFA4 ,MSIOF1 , 0, 0, MSIOF2, 0 } }, {0xe694009c ,0xe69400dc ,8 ,/* IMR7A / IMCR7A */ - { DISABLED, DISABLED, ENABLED, ENABLED, + { DISABLED, ENABLED, ENABLED, ENABLED, FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLTENDI, FLCTL_FLSTEI } }, { 0xe69400a0, 0xe69400e0, 8, /* IMR8A / IMCR8A */ - { 0, DISABLED, ENABLED, ENABLED, + { 0, ENABLED, ENABLED, ENABLED, TTI20, USBHSDMAC0_USHDMI, 0, 0 } }, { 0xe69400a4, 0xe69400e4, 8, /* IMR9A / IMCR9A */ { CMT1_CMT13, CMT1_CMT12, CMT1_CMT11, CMT1_CMT10,
Signature · 1 line
1.7.0.4
PATCH 3/4 sh: sh7724 Enable SDIO IRQs
In reply to Arnd HannemannThis patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the soc. To make sure interrupts are handled announce the MMC_CAP_SDIO_IRQ capability on ecovec, kfr2r09 and se7724.
Tested with a b43-based SDIO wireless card on ecovec.
--- arch/sh/boards/mach-ecovec24/setup.c | 2 ++ arch/sh/boards/mach-kfr2r09/setup.c | 1 + arch/sh/boards/mach-se/7724/setup.c | 2 ++ arch/sh/kernel/cpu/sh4a/setup-sh7724.c | 4 ++-- 4 files changed, 7 insertions(+), 2 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +2 -0
@@ -476,6 +476,7 @@ static struct sh_mobile_sdhi_info sdhi0_info = { .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, .set_pwr = sdhi0_set_pwr, + .tmio_caps = MMC_CAP_SDIO_IRQ, };static struct resource sdhi0_resources[] = {
@@ -517,6 +518,7 @@ static void sdhi1_set_pwr(struct platform_device *pdev, int state)static struct sh_mobile_sdhi_info sdhi1_info = { .dma_slave_tx =SHDMA_SLAVE_SDHI1_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI1_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , .set_pwr = sdhi1_set_pwr, };
arch/sh/boards/mach-kfr2r09/setup.c +1 -0
@@ -369,6 +369,7 @@ static struct sh_mobile_sdhi_info sh7724_sdhi0_data = { .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, + .tmio_caps = MMC_CAP_SDIO_IRQ, };static struct platform_device kfr2r09_sh_sdhi0_device = {
arch/sh/boards/mach-se/7724/setup.c +2 -0
@@ -470,6 +470,7 @@ static struct resource sdhi0_cn7_resources[] = {static struct sh_mobile_sdhi_info sh7724_sdhi0_data = { .dma_slave_tx =SHDMA_SLAVE_SDHI0_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI0_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct platform_device sdhi0_cn7_device = {
@@ -504,6 +505,7 @@ static struct resource sdhi1_cn8_resources[] = {static struct sh_mobile_sdhi_info sh7724_sdhi1_data = { .dma_slave_tx =SHDMA_SLAVE_SDHI1_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI1_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct platform_device sdhi1_cn8_device = {
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +2 -2
@@ -1144,7 +1144,7 @@ static struct intc_group groups[] __initdata = {static struct intc_mask_reg mask_registers[]__initdata = { {0xa4080080 ,0xa40800c0 ,8 ,/* IMR0 / IMCR0 */ {0 ,TMU1_TUNI2 ,TMU1_TUNI1 ,TMU1_TUNI0 , -0 ,DISABLED ,ENABLED ,ENABLED } }, +0 ,ENABLED ,ENABLED ,ENABLED } }, {0xa4080084 ,0xa40800c4 ,8 ,/* IMR1 / IMCR1 */ {VIO_VOU ,VIO_VEU1 ,VIO_BEU0 ,VIO_CEU0 ,DMAC0A_DEI3 ,DMAC0A_DEI2 ,DMAC0A_DEI1 ,DMAC0A_DEI0 } },
@@ -1166,7 +1166,7 @@ static struct intc_mask_reg mask_registers[] __initdata = { {I2C0_DTEI ,I2C0_WAITI ,I2C0_TACKI ,I2C0_ALI , I2C1_DTEI, I2C1_WAITI, I2C1_TACKI, I2C1_ALI } }, {0xa40800a0 ,0xa40800e0 ,8 ,/* IMR8 / IMCR8 */ - { DISABLED, DISABLED, ENABLED, ENABLED, + { DISABLED, ENABLED, ENABLED, ENABLED, 0, 0, SCIFA5, FSI } }, { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */ { 0, 0, 0, CMT, 0, USB1, USB0, 0 } },
Signature · 1 line
1.7.0.4
RFC PATCH 4/4 sh: sh7722 Enable SDIO IRQs
In reply to Arnd HannemannThis patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the soc. To make sure interrupts are handled announce the MMC_CAP_SDIO_IRQ capability on migor. Untested, therefore RFC.
--- arch/sh/boards/mach-migor/setup.c | 1 + arch/sh/kernel/cpu/sh4a/setup-sh7722.c | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)
arch/sh/boards/mach-migor/setup.c +1 -0
@@ -413,6 +413,7 @@ static struct resource sdhi_cn9_resources[] = {static struct sh_mobile_sdhi_info sh7724_sdhi_data = { .dma_slave_tx =SHDMA_SLAVE_SDHI0_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI0_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct platform_device sdhi_cn9_device = {
arch/sh/kernel/cpu/sh4a/setup-sh7722.c +1 -1
@@ -699,7 +699,7 @@ static struct intc_mask_reg mask_registers[] __initdata = { {I2C_DTEI ,I2C_WAITI ,I2C_TACKI ,I2C_ALI , FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLENDI, FLCTL_FLSTEI } }, {0xa40800a0 ,0xa40800e0 ,8 ,/* IMR8 / IMCR8 */ - { DISABLED, DISABLED, ENABLED, ENABLED, 0, 0, TWODG, SIU } }, + { DISABLED, ENABLED, ENABLED, ENABLED, 0, 0, TWODG, SIU } }, { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */ { 0, 0, 0, CMT, 0, USB_USBI1, USB_USBI0, } }, { 0xa40800a8, 0xa40800e8, 8, /* IMR10 / IMCR10 */
Signature · 1 line
1.7.0.4
Magnus Damm
maintainerHi Arnd,
Quoted 10 lines · Arnd Hannemann
This patch implements SDIO IRQ support for mfds which announce the
MMC_CAP_SDIO_IRQcapability fortmio_mmc. Tested with a b43-based wireless SDIO card andsh_mobile_sdhi.This patch applies on top of:
mmc:tmio_mmc: allow multi-element scatter-gather lists
mmc:tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMA
Quoted 7 lines
Signed-off-by Arnd Hannemann <[email protected]>CC Ian Molton <[email protected]>CC Samuel Ortiz <[email protected]>CC Guennadi Liakhovetski <[email protected]>---
drivers/mmc/host/tmio_mmc.c | 54 ++++++++++++++++++++++++++++++++++++++++++-1 files changed, 53 insertions(+), 1 deletions(-)
Thanks for your work on this!
Just curious, did you test this change in 4-bit mode and/or 1-bit mode? I believe that 1-bit mode support is rather simple, but 4-bit mode requires toggling between the IRQ and DATA function which happen to be using the same pin. It looks like the current code only deals with 1-bit mode - perhaps 4-bit mode isn't supported by the b43 driver?
Not sure how the Linux MMC stack supports 4-bit IRQs, but the S4MI bit in the CCCR should specify if it's allowed to enable interrupts in between data transfers or not. Perhaps that is something we need to deal with in the driver? Or maybe the framework needs to be extended?
Thanks,
/ magnus
Hi Magnus,
Am 07.12.2010 00:39, schrieb Magnus Damm:
Quoted 21 lines
Hi Arnd,
Quoted 10 lines · Arnd Hannemann
This patch implements SDIO IRQ support for mfds which announce the
MMC_CAP_SDIO_IRQcapability fortmio_mmc. Tested with a b43-based wireless SDIO card andsh_mobile_sdhi.This patch applies on top of:
mmc:tmio_mmc: allow multi-element scatter-gather lists
mmc:tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMAQuoted 7 lines
Signed-off-by Arnd Hannemann <[email protected]>CC Ian Molton <[email protected]>CC Samuel Ortiz <[email protected]>CC Guennadi Liakhovetski <[email protected]>--- drivers/mmc/host/tmio_mmc.c | 54 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 deletions(-)
Quoted 8 lines
Thanks for your work on this!
Just curious, did you test this change in 4-bit mode and/or 1-bit mode? I believe that 1-bit mode support is rather simple, but 4-bit mode requires toggling between the IRQ and DATA function which happen to be using the same pin. It looks like the current code only deals with 1-bit mode - perhaps 4-bit mode isn't supported by the b43 driver?
Yes, I tested this in 1-bit and 4-bit mode. At least the card claims it is using it, it says "width=2". I also read about the toggling, and expected to do something fancy, but when tests where successful I came to the conclusion that the controller does the toggling for us. Do you believe otherwise?
Quoted 4 lines
Not sure how the Linux MMC stack supports 4-bit IRQs, but the S4MI bit in the CCCR should specify if it's allowed to enable interrupts in between data transfers or not. Perhaps that is something we need to deal with in the driver? Or maybe the framework needs to be extended?
I quick grep shows that nobody seems to care about this bit until now...
Thanks,
Arnd
Magnus Damm
maintainerQuoted 29 lines · Arnd Hannemann
Am 07.12.2010 00:39, schrieb Magnus Damm:
Quoted 19 lines · Arnd Hannemann
Quoted 10 lines
This patch implements SDIO IRQ support for mfds which announce the
MMC_CAP_SDIO_IRQcapability fortmio_mmc. Tested with a b43-based wireless SDIO card andsh_mobile_sdhi.This patch applies on top of:
mmc:tmio_mmc: allow multi-element scatter-gather lists
mmc:tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMAQuoted 7 lines
Signed-off-by Arnd Hannemann <[email protected]>CC Ian Molton <[email protected]>CC Samuel Ortiz <[email protected]>CC Guennadi Liakhovetski <[email protected]>---
drivers/mmc/host/tmio_mmc.c | 54 ++++++++++++++++++++++++++++++++++++++++++-1 files changed, 53 insertions(+), 1 deletions(-)Quoted 8 lines
Thanks for your work on this!
Just curious, did you test this change in 4-bit mode and/or 1-bit mode? I believe that 1-bit mode support is rather simple, but 4-bit mode requires toggling between the IRQ and DATA function which happen to be using the same pin. It looks like the current code only deals with 1-bit mode - perhaps 4-bit mode isn't supported by the b43 driver?
Quoted 4 lines
Yes, I tested this in 1-bit and 4-bit mode. At least the card claims it is using it, it says "width=2". I also read about the toggling, and expected to do something fancy, but when tests where successful I came to the conclusion that the controller does the toggling for us. Do you believe otherwise?
Yes, I believe something more advanced is needed for 4-bit mode. But I don't really have any proof. I just know that I spent quite some time trying to get it to work and ended up staying in polling mode because enabling real IRQs seemed to require too much time. This was before some interrupt ack fixes so things may have improved since then. I also remember both testing on b43 hardware and AR6002.
There are a couple of things against us at this point:
a) b43 hardware may not be enough to test this
are you really sure 4-bit mode is enabled? =)
is the b43 driver doing multi-block data transfers? i believe IRQs work differently for multi-block data transfers and single-block.
b) we don't have any public data sheet for the SDHI hardware block
how good is that?
c) the simplified SDIO spec is not exactly full of details:
8.1.3
Interrupt Period Definition
This section is not included in the Simplified Specification. 8.1.4
Interrupt Period at the Data Block Gap in 4-bit SD Mode (Optional) This section is not included in the Simplified Specification. 8.1.5
Inhibited Interrupts (Removed Section)
This section is not included in the Simplified Specification. 8.1.6
End of Interrupt Cycles
This section is not included in the Simplified Specification.
Quoted 6 lines
Quoted 4 lines
Not sure how the Linux MMC stack supports 4-bit IRQs, but the S4MI bit in the CCCR should specify if it's allowed to enable interrupts in between data transfers or not. Perhaps that is something we need to deal with in the driver? Or maybe the framework needs to be extended?
I quick grep shows that nobody seems to care about this bit until now...
Yeah, that seems to be the case. I guess it's a non-issue then. =)
I'll try to find my AR6002 card, maybe that will shed some light...
Thanks,
/ magnus
Hi Magnus,
Am 07.12.2010 09:37, schrieb Magnus Damm:
Quoted 35 lines · Arnd Hannemann
Quoted 29 lines
Am 07.12.2010 00:39, schrieb Magnus Damm:
Quoted 19 lines · Arnd Hannemann
Quoted 10 lines
This patch implements SDIO IRQ support for mfds which announce the
MMC_CAP_SDIO_IRQcapability fortmio_mmc. Tested with a b43-based wireless SDIO card andsh_mobile_sdhi.This patch applies on top of:
mmc:tmio_mmc: allow multi-element scatter-gather lists
mmc:tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMAQuoted 7 lines
Signed-off-by Arnd Hannemann <[email protected]>CC Ian Molton <[email protected]>CC Samuel Ortiz <[email protected]>CC Guennadi Liakhovetski <[email protected]>--- drivers/mmc/host/tmio_mmc.c | 54 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 deletions(-)Quoted 8 lines
Thanks for your work on this!
Just curious, did you test this change in 4-bit mode and/or 1-bit mode? I believe that 1-bit mode support is rather simple, but 4-bit mode requires toggling between the IRQ and DATA function which happen to be using the same pin. It looks like the current code only deals with 1-bit mode - perhaps 4-bit mode isn't supported by the b43 driver?
Quoted 4 lines
Yes, I tested this in 1-bit and 4-bit mode. At least the card claims it is using it, it says "width=2". I also read about the toggling, and expected to do something fancy, but when tests where successful I came to the conclusion that the controller does the toggling for us. Do you believe otherwise?
Quoted 6 lines
Yes, I believe something more advanced is needed for 4-bit mode. But I don't really have any proof. I just know that I spent quite some time trying to get it to work and ended up staying in polling mode because enabling real IRQs seemed to require too much time. This was before some interrupt ack fixes so things may have improved since then. I also remember both testing on b43 hardware and AR6002.
There was also this nasty DMA issue Guennadi fixed recently...
Quoted 4 lines
There are a couple of things against us at this point:
a) b43 hardware may not be enough to test this
Ok, do you still have that AR6002 and could test with that by any chance?
Quoted 3 lines
are you really sure 4-bit mode is enabled? =)
is the b43 driver doing multi-block data transfers? i believe IRQs work differently for multi-block data transfers and single-block.
I'm pretty sure its using 4-bit mode, from the probe of the card:
mmc1: clock 0Hz busmode 1 powermode 1 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 1 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 1 powermode 2 cs 1 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 1 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 1 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 25000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 25000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 2 timing 0
Its doing probably not doing any multi-block data transfers, but I'll recheck. Actually most data transfers are very small.
Quoted 6 lines
b) we don't have any public data sheet for the SDHI hardware block
how good is that?
c) the simplified SDIO spec is not exactly full of details:
Quoted 12 lines
8.1.3
Interrupt Period Definition
This section is not included in the Simplified Specification. 8.1.4
Interrupt Period at the Data Block Gap in 4-bit SD Mode (Optional) This section is not included in the Simplified Specification. 8.1.5
Inhibited Interrupts (Removed Section)
This section is not included in the Simplified Specification. 8.1.6
End of Interrupt Cycles
This section is not included in the Simplified Specification.
Yes I read this too, but this is of course only interface between host and card, so we may be just lucky that the controller hides these details from us.
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Not sure how the Linux MMC stack supports 4-bit IRQs, but the S4MI bit in the CCCR should specify if it's allowed to enable interrupts in between data transfers or not. Perhaps that is something we need to deal with in the driver? Or maybe the framework needs to be extended?
I quick grep shows that nobody seems to care about this bit until now...
Yeah, that seems to be the case. I guess it's a non-issue then. =)
I'll try to find my AR6002 card, maybe that will shed some light...
Yeah, that would be really cool.
Thanks,
Arnd
Magnus Damm
maintainerHi Arnd,
Thanks a lot for your help so far. I've found a bit of time to test stuff now.
Quoted 36 lines · Arnd Hannemann
Am 07.12.2010 09:37, schrieb Magnus Damm:
Quoted 35 lines · Arnd Hannemann
Quoted 33 lines
Am 07.12.2010 00:39, schrieb Magnus Damm:
Quoted 19 lines · Arnd Hannemann
Quoted 10 lines
This patch implements SDIO IRQ support for mfds which announce the
MMC_CAP_SDIO_IRQcapability fortmio_mmc. Tested with a b43-based wireless SDIO card andsh_mobile_sdhi.This patch applies on top of:
mmc:tmio_mmc: allow multi-element scatter-gather lists
mmc:tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMAQuoted 7 lines
Signed-off-by Arnd Hannemann <[email protected]>CC Ian Molton <[email protected]>CC Samuel Ortiz <[email protected]>CC Guennadi Liakhovetski <[email protected]>---
drivers/mmc/host/tmio_mmc.c | 54 ++++++++++++++++++++++++++++++++++++++++++-1 files changed, 53 insertions(+), 1 deletions(-)Quoted 8 lines
Thanks for your work on this!
Just curious, did you test this change in 4-bit mode and/or 1-bit mode? I believe that 1-bit mode support is rather simple, but 4-bit mode requires toggling between the IRQ and DATA function which happen to be using the same pin. It looks like the current code only deals with 1-bit mode - perhaps 4-bit mode isn't supported by the b43 driver?
Yes, I tested this in 1-bit and 4-bit mode. At least the card claims it is using it, it says "width=2". I also read about the toggling, and expected to do something fancy, but when tests where successful I came to the conclusion that the controller does the toggling for us. Do you believe otherwise?
Quoted 8 lines
Quoted 6 lines
Yes, I believe something more advanced is needed for 4-bit mode. But I don't really have any proof. I just know that I spent quite some time trying to get it to work and ended up staying in polling mode because enabling real IRQs seemed to require too much time. This was before some interrupt ack fixes so things may have improved since then. I also remember both testing on b43 hardware and AR6002.
There was also this nasty DMA issue Guennadi fixed recently...
Good with issues fixed, we like that. =)
We also like fixes ending up in mainline - does someone need to resubmit their patches I wonder? =)
Quoted 5 lines
Quoted 3 lines
There are a couple of things against us at this point:
a) b43 hardware may not be enough to test this
Ok, do you still have that AR6002 and could test with that by any chance?
So I tried my AR6002 card - spent half an evening - but I couldn't get it working with the driver in staging.
I tested at least 3 different drivers last time around, and I ended up using the ar6k android driver:
http://armin762.wordpress.com/2010/05/24/nvidia-tegra2-getting-wifiatheros-6002-working/
I suppose I should retry with the out-of-tree driver above. Hm.
Quoted 6 lines
Quoted 3 lines
are you really sure 4-bit mode is enabled? =)
is the b43 driver doing multi-block data transfers? i believe IRQs work differently for multi-block data transfers and single-block.I'm pretty sure its using 4-bit mode, from the probe of the card:
Quoted 8 lines
mmc1: clock 0Hz busmode 1 powermode 1 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 1 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 1 powermode 2 cs 1 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 1 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 1 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 25000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 0 timing 0
mmc1: clock 25000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 2 timing 0
Ok, that looks good.
Quoted 2 lines
Its doing probably not doing any multi-block data transfers, but I'll recheck. Actually most data transfers are very small.
So I at least managed to test b43 with DMA enabled and your SDIO IRQ patch applied.
Your SDIO IRQ patch significantly decreases interrupt load. Without your SDIO IRQ patch about 100 interrupts per second are generated from the polling. Same test but with the SDIO IRQ patch applied (b43 wlan0 up but not associated) I receive no IRQs at all until I perform some kind of action like "iwlist wlan0 scan". I suppose this shows the benefit of IRQs vs polled mode. =)
Quoted 19 lines
Quoted 6 lines
b) we don't have any public data sheet for the SDHI hardware block
how good is that?
c) the simplified SDIO spec is not exactly full of details:
Quoted 12 lines
8.1.3
Interrupt Period Definition
This section is not included in the Simplified Specification. 8.1.4
Interrupt Period at the Data Block Gap in 4-bit SD Mode (Optional) This section is not included in the Simplified Specification. 8.1.5
Inhibited Interrupts (Removed Section)
This section is not included in the Simplified Specification. 8.1.6
End of Interrupt Cycles
This section is not included in the Simplified Specification.
Quoted 3 lines
Yes I read this too, but this is of course only interface between host and card, so we may be just lucky that the controller hides these details from us.
True, or that everyone just implements the same thing regardless of the spec.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Not sure how the Linux MMC stack supports 4-bit IRQs, but the S4MI bit in the CCCR should specify if it's allowed to enable interrupts in between data transfers or not. Perhaps that is something we need to deal with in the driver? Or maybe the framework needs to be extended?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I quick grep shows that nobody seems to care about this bit until now...
Yeah, that seems to be the case. I guess it's a non-issue then. =)
I'll try to find my AR6002 card, maybe that will shed some light...
Yeah, that would be really cool.
I'll try again next time I have a bit of time to spare. =)
Until then, is there any chance you can look into supporting INTC forwarding in ENABLED for the CPU code but not setting MMC_CAP_SDIO_IRQ? I wonder if there is any pending interrupt source that drowns the CPU with the current code?
Thanks,
/ magnus
Magnus Damm
maintainerHi again Arnd,
Quoted 24 lines · Magnus Damm
Quoted 22 lines · Arnd Hannemann
Am 07.12.2010 09:37, schrieb Magnus Damm:
Quoted 21 lines · Arnd Hannemann
Quoted 20 lines
Am 07.12.2010 00:39, schrieb Magnus Damm:
Quoted 19 lines · Arnd Hannemann
Quoted 17 lines
This patch implements SDIO IRQ support for mfds which announce the
MMC_CAP_SDIO_IRQcapability fortmio_mmc. Tested with a b43-based wireless SDIO card andsh_mobile_sdhi.This patch applies on top of:
mmc:tmio_mmc: allow multi-element scatter-gather lists
mmc:tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMASigned-off-by Arnd Hannemann <[email protected]>CC Ian Molton <[email protected]>CC Samuel Ortiz <[email protected]>CC Guennadi Liakhovetski <[email protected]>---
drivers/mmc/host/tmio_mmc.c | 54 ++++++++++++++++++++++++++++++++++++++++++-1 files changed, 53 insertions(+), 1 deletions(-)
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I'll try to find my AR6002 card, maybe that will shed some light...
Yeah, that would be really cool.
I'll try again next time I have a bit of time to spare. =)
Alright, now my AR6002-based card is working with your patches. At least it seems to be working - my antenna cable is broken so I can unfortunately not do any more proper than a simple "iwlist wlan0 scan". Good thing is that the SDIO IRQ mode and polling mode seem to behave about the same.
Please note that I did not test using the upstream driver. I couldn't get that one working last week, so today I reverted to using my last known working configuration - the out-of-tree "ar69_sdk" driver pointed out by the following instructions:
http://armin762.wordpress.com/2010/05/24/nvidia-tegra2-getting-wifiatheros-6002-working/
Anyway, I'm all for including your SDIO IRQ patches, but I think that they should be reworked a bit.
I propose using two flags:
1) A hardware-has-sdio-irq-support flag for include/linux/mfd/tmio.h, perhaps TMIO_MMC_SDIO_IRQ
The SDIO IRQ hardware registers are only touched when tmio-mmc is provided the TMIO_MMC_SDIO_IRQ flag. The default behavior would be to mask the SDIO IRQ interrupt source regardless of the MMC_CAP_SDIO_IRQ flag. This should allow us to always enable the SDIO IRQ interrupt source in INTC. The SDIO driver should set the TMIO_MMC_SDIO_IRQ flag to show that SDHI is known to support SDIO IRQ.
Hopefully this TMIO_MMC_SDIO_IRQ flag will make it easier for Ian to review the code and see that it doesn't break any other platforms that may or may not lack SDIO IRQ support.
2) The regular MMC_CAP_SDIO_IRQ flag.
This is enabled per board. If the SDIO IRQ feature doesn't work in some case then the system integrator can simply just simply go back to polled mode by not setting MMC_CAP_SIDO_IRQ.
I'm not sure if we can keep the SDIO IRQ interrupt source constantly enabled in INTC though. Your current patches require the board specific MMC_CAP_SDIO_IRQ flag to be paired with the cpu-specific INTC enable change. If someone wishes tho disable SDIO_IRQ support for their board then they must know that they also need to revert the INTC enable bits, otherwise they'll get endless interrupts when the tmio-mmc driver starts. I believe the two-flag approach above will solve this problem.
Thanks,
/ magnus
Hi Magnus,
Am 20.12.2010 04:58, schrieb Magnus Damm:
Quoted 39 lines
Hi again Arnd,
Quoted 24 lines · Magnus Damm
Quoted 22 lines · Arnd Hannemann
Am 07.12.2010 09:37, schrieb Magnus Damm:
Quoted 21 lines · Arnd Hannemann
Quoted 20 lines
Am 07.12.2010 00:39, schrieb Magnus Damm:
Quoted 19 lines · Arnd Hannemann
Quoted 17 lines
This patch implements SDIO IRQ support for mfds which announce the
MMC_CAP_SDIO_IRQcapability fortmio_mmc. Tested with a b43-based wireless SDIO card andsh_mobile_sdhi.This patch applies on top of:
mmc:tmio_mmc: allow multi-element scatter-gather lists
mmc:tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMASigned-off-by Arnd Hannemann <[email protected]>CC Ian Molton <[email protected]>CC Samuel Ortiz <[email protected]>CC Guennadi Liakhovetski <[email protected]>--- drivers/mmc/host/tmio_mmc.c | 54 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 deletions(-)Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I'll try to find my AR6002 card, maybe that will shed some light...
Yeah, that would be really cool.
I'll try again next time I have a bit of time to spare. =)
Alright, now my AR6002-based card is working with your patches. At least it seems to be working - my antenna cable is broken so I can unfortunately not do any more proper than a simple "iwlist wlan0 scan". Good thing is that the SDIO IRQ mode and polling mode seem to behave about the same.
Quoted 5 lines
Please note that I did not test using the upstream driver. I couldn't get that one working last week, so today I reverted to using my last known working configuration - the out-of-tree "
ar69_sdk" driver pointed out by the following instructions:
http://armin762.wordpress.com/2010/05/24/nvidia-tegra2-getting-wifiatheros-6002-working/
Thanks for testing!
Quoted 26 lines
Anyway, I'm all for including your SDIO IRQ patches, but I think that they should be reworked a bit.
I propose using two flags:
1) A hardware-has-sdio-irq-support flag for
include/linux/mfd/tmio.h, perhapsTMIO_MMC_SDIO_IRQreThe SDIO IRQ hardware registers are only touched when tmio-mmc is provided the
TMIO_MMC_SDIO_IRQflag. The default behavior would be to mask the SDIO IRQ interrupt source regardless of theMMC_CAP_SDIO_IRQflag. This should allow us to always enable the SDIO IRQ interrupt source in INTC. The SDIO driver should set theTMIO_MMC_SDIO_IRQflag to show that SDHI is known to support SDIO IRQ.Hopefully this
TMIO_MMC_SDIO_IRQflag will make it easier for Ian to review the code and see that it doesn't break any other platforms that may or may not lack SDIO IRQ support.2) The regular
MMC_CAP_SDIO_IRQflag.This is enabled per board. If the SDIO IRQ feature doesn't work in some case then the system integrator can simply just simply go back to polled mode by not setting
MMC_CAP_SIDO_IRQ.
Quoted 8 lines
I'm not sure if we can keep the SDIO IRQ interrupt source constantly enabled in INTC though. Your current patches require the board specific
MMC_CAP_SDIO_IRQflag to be paired with the cpu-specific INTC enable change. If someone wishes tho disableSDIO_IRQsupport for their board then they must know that they also need to revert the INTC enable bits, otherwise they'll get endless interrupts when the tmio-mmc driver starts. I believe the two-flag approach above will solve this problem.
This makes sense, I'll shortly post a revised patchset implementing your idea...
Thanks,
Arnd
v2 cover mmc: tmio: Add SDIO IRQ support
In reply to Magnus Damm[PATCH 1/6 v2] mmc: tmio: implement SDIO IRQ
[PATCH 2/6 v2] mfd: sh_mobile_sdhi: activate SDIO IRQ for tmio_mmc [PATCH 3/6 v2] mmc: tmio: disable IRQs early in remove [PATCH 4/6 v2] ARM: mach-shmobile: sh7372 Enable SDIO IRQs [PATCH 5/6 v2] sh: sh7724 Enable SDIO IRQs
[PATCH 6/6 v2] [RFC] sh: sh7722 Enable SDIO IRQs
These patches add SDIO IRQ support for the tmio mmc cell of the sh_mobile_sdhi mfd and activate the usage of SDIO IRQs on all SoCs where sh_mobile_sdhi is currently used.
Changes since the earlier patchset:
- Add TMIO_MMC_SDIO_IRQ flag, which expresses that the hardware is known to support SDIO IRQ as suggested by Magnus Damm
- Activate this flag for sh_mobile_sdhi
- Add a patch which disables IRQs early in remove
to avoid spurious SDIO IRQs, during module unload
- Patches 4-6 are unmodified but included for
completeness
Re: [PATCH 0/6 v2] mmc: tmio: Add SDIO IRQ support
Quoted 21 lines · Arnd Hannemann
[PATCH 1/6 v2] mmc: tmio: implement SDIO IRQ
[PATCH 2/6 v2] mfd:sh_mobile_sdhi: activate SDIO IRQ fortmio_mmc[PATCH 3/6 v2] mmc: tmio: disable IRQs early in remove [PATCH 4/6 v2] ARM: mach-shmobile: sh7372 Enable SDIO IRQs [PATCH 5/6 v2] sh: sh7724 Enable SDIO IRQs
[PATCH 6/6 v2] [RFC] sh: sh7722 Enable SDIO IRQsThese patches add SDIO IRQ support for the tmio mmc cell of the
sh_mobile_sdhimfd and activate the usage of SDIO IRQs on all SoCs wheresh_mobile_sdhiis currently used.Changes since the earlier patchset:
- AddTMIO_MMC_SDIO_IRQflag, which expresses that the hardware is known to support SDIO IRQ as suggested by Magnus Damm
- Activate this flag forsh_mobile_sdhi
- Add a patch which disables IRQs early in remove
to avoid spurious SDIO IRQs, during module unload
- Patches 4-6 are unmodified but included for
completeness
Quoted 1 line
Signed-off-by Arnd Hannemann <[email protected]>
Looking good, this patch series:
Feel free to hack up support for sh7723 as well if you have time! =)
Cheers,
/ magnus
RFC PATCH 1/1 sh: sh7723 / ap325rxa enable SDIO IRQs
This patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the SoC. To make sure SDIO IRQs are used announce the MMC_CAP_SDIO_IRQ capability on ap325rxa. Untested, therefore RFC.
--- arch/sh/boards/mach-ap325rxa/setup.c | 16 ++++++++++++++++ arch/sh/kernel/cpu/sh4a/setup-sh7723.c | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-)
arch/sh/boards/mach-ap325rxa/setup.c +16 -0
@@ -14,6 +14,8 @@#include <linux/device.h> #include <linux/interrupt.h> #include <linux/platform_device.h> +#include <linux/mfd/sh_mobile_sdhi.h> +#include <linux/mmc/host.h> #include <linux/mtd/physmap.h> #include <linux/mtd/sh_flctl.h> #include <linux/delay.h>
@@ -430,11 +432,18 @@ static struct resource sdhi0_cn3_resources[] = { }, }; +static struct sh_mobile_sdhi_info sdhi0_cn3_data = { + .tmio_caps =MMC_CAP_SDIO_IRQ , +}; +static struct platform_device sdhi0_cn3_device = { .name ="sh_mobile_sdhi" , .id =0 ,/* "sdhi0" clock */ .num_resources =ARRAY_SIZE (sdhi0_cn3_resources), .resource = sdhi0_cn3_resources, + .dev = { + .platform_data = &sdhi0_cn3_data, + }, .archdata = { .hwblk_id =HWBLK_SDHI0 , },
@@ -453,11 +462,18 @@ static struct resource sdhi1_cn7_resources[] = { }, }; +static struct sh_mobile_sdhi_info sdhi1_cn7_data = { + .tmio_caps =MMC_CAP_SDIO_IRQ , +}; +static struct platform_device sdhi1_cn7_device = { .name ="sh_mobile_sdhi" , .id =1 ,/* "sdhi1" clock */ .num_resources =ARRAY_SIZE (sdhi1_cn7_resources), .resource = sdhi1_cn7_resources, + .dev = { + .platform_data = &sdhi1_cn7_data, + }, .archdata = { .hwblk_id =HWBLK_SDHI1 , },
arch/sh/kernel/cpu/sh4a/setup-sh7723.c +2 -2
@@ -719,7 +719,7 @@ static struct intc_group groups[] __initdata = {static struct intc_mask_reg mask_registers[]__initdata = { {0xa4080080 ,0xa40800c0 ,8 ,/* IMR0 / IMCR0 */ {0 ,TMU1_TUNI2 ,TMU1_TUNI1 ,TMU1_TUNI0 , -0 ,DISABLED ,ENABLED ,ENABLED } }, +0 ,ENABLED ,ENABLED ,ENABLED } }, {0xa4080084 ,0xa40800c4 ,8 ,/* IMR1 / IMCR1 */ {VIO_VOUI ,VIO_VEU2HI ,VIO_BEUI ,VIO_CEUI ,DMAC0A_DEI3 ,DMAC0A_DEI2 ,DMAC0A_DEI1 ,DMAC0A_DEI0 } }, {0xa4080088 ,0xa40800c8 ,8 ,/* IMR2 / IMCR2 */
@@ -736,7 +736,7 @@ static struct intc_mask_reg mask_registers[] __initdata = { {I2C_DTEI ,I2C_WAITI ,I2C_TACKI ,I2C_ALI , FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLTENDI, FLCTL_FLSTEI } }, {0xa40800a0 ,0xa40800e0 ,8 ,/* IMR8 / IMCR8 */ - { 0, DISABLED, ENABLED, ENABLED, + { 0, ENABLED, ENABLED, ENABLED, 0, 0, SCIFA_SCIFA2, SIU_SIUI } }, { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */ { 0, 0, 0, CMT_CMTI, 0, 0, USB_USI0,0 } },
Signature · 1 line
1.7.2.3
Re: [PATCH] [RFC] sh: sh7723 / ap325rxa enable SDIO IRQs
Hi Arnd,
Quoted 6 lines · Arnd Hannemann
This patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the SoC. To make sure SDIO IRQs are used announce the
MMC_CAP_SDIO_IRQcapability on ap325rxa. Untested, therefore RFC.Signed-off-by Arnd Hannemann <[email protected]>
Looking good, thanks a lot!
PATCH v2 1/6 mmc: tmio: implement SDIO IRQ
In reply to Magnus DammThis patch implements SDIO IRQ support for mfds which announce the TMIO_MMC_SDIO_IRQ flag for tmio_mmc.
If MMC_CAP_SDIO_IRQ is also set SDIO IRQ signalling is activated. Tested with a b43-based wireless SDIO card and sh_mobile_sdhi.
This patch applies on top of:
mmc: tmio_mmc: allow multi-element scatter-gather lists
mmc: tmio_mmc: fix PIO fallback on DMA descriptor allocation failure
mmc: tmio: merge the private header into the driver
mmc: tmio: implement a bounce buffer for unaligned DMA
---
Changes in v2:
- added TMIO_MMC_SDIO_IRQ flag to support the case where SDIO IRQ interrupts are generated but SDIO IRQ signalling to the core should not be used
- rearranged code, so that either an SDIO IRQ or a normal IRQ is handled, this marginally increases interrupt load, but preserves the current timing, which seems to be crucial for DMA handling
drivers/mmc/host/tmio_mmc.c | 61 ++++++++++++++++++++++++++++++++++++++++++- include/linux/mfd/tmio.h | 4 +++ 2 files changed, 64 insertions(+), 1 deletions(-)
drivers/mmc/host/tmio_mmc.c +60 -0
@@ -53,6 +53,8 @@#define CTL_SD_ERROR_DETAIL_STATUS 0x2c#define CTL_SD_DATA_PORT 0x30#define CTL_TRANSACTION_CTL 0x34 +#define CTL_SDIO_STATUS 0x36 +#define CTL_SDIO_IRQ_MASK 0x38#define CTL_RESET_SD 0xe0#define CTL_SDIO_REGS 0x100#define CTL_CLK_AND_WAIT_CTL 0x138
@@ -81,6 +83,12 @@#define TMIO_STAT_CMD_BUSY 0x40000000#define TMIO_STAT_ILL_ACCESS 0x80000000 +/* Definitions for values the CTRL_SDIO_STATUS register can take. */ +#define TMIO_SDIO_STAT_IOIRQ 0x0001 +#define TMIO_SDIO_STAT_EXPUB52 0x4000 +#define TMIO_SDIO_STAT_EXWT 0x8000 +#define TMIO_SDIO_MASK_ALL 0xc007 +/* Define some IRQ masks */ /* This is the mask used at reset by the chip */ #define TMIO_MASK_ALL 0x837f031d
@@ -122,6 +130,7 @@ struct tmio_mmc_host {struct mmc_data *data;struct mmc_host *mmc;int irq; +unsigned int sdio_irq_enabled;/* Callbacks for clock / power control */ void (*set_pwr)(struct platform_device *host,int state);
@@ -247,6 +256,22 @@ void pr_debug_status(u32 status)#define pr_debug_status (s) do { } while (0)#endif +static void tmio_mmc_enable_sdio_irq (struct mmc_host *mmc,int enable) +{ +struct tmio_mmc_host *host =mmc_priv (mmc); + +if (enable) { + host->sdio_irq_enabled =1 ; +sd_ctrl_write16 (host,CTL_TRANSACTION_CTL ,0x0001 ); +sd_ctrl_write16 (host,CTL_SDIO_IRQ_MASK , + (TMIO_SDIO_MASK_ALL & ~TMIO_SDIO_STAT_IOIRQ )); + }else { +sd_ctrl_write16 (host,CTL_SDIO_IRQ_MASK ,TMIO_SDIO_MASK_ALL ); +sd_ctrl_write16 (host,CTL_TRANSACTION_CTL ,0x0000 ); + host->sdio_irq_enabled =0 ; + } +} +static void tmio_mmc_set_clock (struct tmio_mmc_host *host,int new_clock) {u32 clk =0 , clock;
@@ -275,10 +300,16 @@ static void tmio_mmc_clk_stop(struct tmio_mmc_host *host)static void tmio_mmc_clk_start (struct tmio_mmc_host *host) { +struct mfd_cell *cell = host->pdev->dev.platform_data; +struct tmio_mmc_data *pdata = cell->driver_data; +sd_ctrl_write16 (host,CTL_SD_CARD_CLK_CTL ,0x0100 |sd_ctrl_read16 (host,CTL_SD_CARD_CLK_CTL ));msleep (10 );sd_ctrl_write16 (host,CTL_CLK_AND_WAIT_CTL ,0x0100 ); +/* restore sdio irq state */ +if (pdata->flags &TMIO_MMC_SDIO_IRQ ) +tmio_mmc_enable_sdio_irq (host->mmc, host->sdio_irq_enabled);msleep (10 ); }
@@ -556,7 +587,10 @@ static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,static irqreturn_t tmio_mmc_irq (int irq,void *devid) {struct tmio_mmc_host *host = devid; +struct mfd_cell *cell = host->pdev->dev.platform_data; +struct tmio_mmc_data *pdata = cell->driver_data;unsigned int ireg, irq_mask, status; +unsigned int sdio_ireg, sdio_irq_mask, sdio_status;pr_debug ("MMC IRQ begin\n" );
@@ -564,10 +598,33 @@ static irqreturn_t tmio_mmc_irq(int irq, void *devid) irq_mask =sd_ctrl_read32 (host,CTL_IRQ_MASK ); ireg = status &TMIO_MASK_IRQ & ~irq_mask; + sdio_ireg =0 ; +if (!ireg && pdata->flags &TMIO_MMC_SDIO_IRQ ) { + sdio_status =sd_ctrl_read16 (host,CTL_SDIO_STATUS ); + sdio_irq_mask =sd_ctrl_read16 (host,CTL_SDIO_IRQ_MASK ); + sdio_ireg = sdio_status &TMIO_SDIO_MASK_ALL & ~sdio_irq_mask; + +sd_ctrl_write16 (host,CTL_SDIO_STATUS , sdio_status & ~TMIO_SDIO_MASK_ALL ); + +if (sdio_ireg && !host->sdio_irq_enabled) { +pr_warning ("tmio_mmc: Spurious SDIO IRQ, disabling! 0x%04x 0x%04x 0x%04x\n" , + sdio_status, sdio_irq_mask, sdio_ireg); +tmio_mmc_enable_sdio_irq (host,0 ); + goto out; + } + +if (host->mmc->caps &MMC_CAP_SDIO_IRQ && + sdio_ireg &TMIO_SDIO_STAT_IOIRQ ) +mmc_signal_sdio_irq (host->mmc); + +if (sdio_ireg) + goto out; + } +pr_debug_status (status);pr_debug_status (ireg);if (!ireg) {disable_mmc_irqs (host, status & ~irq_mask); pr_warning("tmio_mmc: Spurious irq, disabling! "
@@ -1033,6 +1089,7 @@ static const struct mmc_host_ops tmio_mmc_ops = { .set_ios = tmio_mmc_set_ios, .get_ro = tmio_mmc_get_ro, .get_cd = tmio_mmc_get_cd, + .enable_sdio_irq = tmio_mmc_enable_sdio_irq, };#ifdef CONFIG_PM
@@ -1147,6 +1204,8 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev) goto cell_disable;disable_mmc_irqs (host,TMIO_MASK_ALL ); +if (pdata->flags &TMIO_MMC_SDIO_IRQ ) +tmio_mmc_enable_sdio_irq (mmc,0 ); ret =request_irq (host->irq, tmio_mmc_irq,IRQF_DISABLED |IRQF_TRIGGER_FALLING ,dev_name (&dev->dev), host);
include/linux/mfd/tmio.h +4 -0
@@ -57,6 +57,10 @@* is configured in 4-bit mode. */ #define TMIO_MMC_BLKSZ_2BYTES (1 << 1) +/* +* Some controllers can support SDIO IRQ signalling. +*/ +#define TMIO_MMC_SDIO_IRQ (1 << 2)int tmio_core_mmc_enable (void __iomem *cnf,int shift,unsigned long base);int tmio_core_mmc_resume (void __iomem *cnf,int shift,unsigned long base);
Signature · 1 line
1.7.2.3
PATCH v2 2/6 mfd: sh_mobile_sdhi: activate SDIO IRQ for tmio_mmc
In reply to Magnus DammThe SDHI Controller on SH-Mobile SoCs supports SDIO IRQ signalling. This patch advertises this fact to the tmio_mmc driver.
--- drivers/mfd/sh_mobile_sdhi.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/mfd/sh_mobile_sdhi.c +5 -0
@@ -131,6 +131,11 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev)*/ mmc_data->flags |=TMIO_MMC_BLKSZ_2BYTES ; +/* +* All SDHI blocks support SDIO IRQ signalling. +*/ + mmc_data->flags |=TMIO_MMC_SDIO_IRQ ; +if (p && p->dma_slave_tx >=0 && p->dma_slave_rx >=0 ) { priv->param_tx.slave_id = p->dma_slave_tx; priv->param_rx.slave_id = p->dma_slave_rx;
Signature · 1 line
1.7.2.3
Re: [PATCH 2/6 v2] mfd: sh_mobile_sdhi: activate SDIO IRQ for tmio_mmc
Hi Arnd,
Quoted 4 lines · Arnd Hannemann
The SDHI Controller on SH-Mobile SoCs supports SDIO IRQ signalling. This patch advertises this fact to the
tmio_mmcdriver.Signed-off-by Arnd Hannemann <[email protected]>
Since this one depends on the first patch on the series, I won't be able to carry it. Please add my:
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
PATCH v2 3/6 mmc: tmio: disable IRQs early in remove
In reply to Magnus DammWith SDIO IRQ, spurious interrupts are generated on module unloading.
This patch fixes that by disabling IRQs early. Tested with a b43-based wireless SDIO card and sh_mobile_sdhi.
--- drivers/mmc/host/tmio_mmc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/host/tmio_mmc.c +1 -1
@@ -1249,9 +1249,9 @@ static int __devexit tmio_mmc_remove(struct platform_device *dev)if (mmc) {struct tmio_mmc_host *host =mmc_priv (mmc); -mmc_remove_host (mmc);tmio_mmc_release_dma (host);free_irq (host->irq, host); +mmc_remove_host (mmc);if (cell->disable) cell->disable (dev);iounmap (host->ctl);
Signature · 1 line
1.7.2.3
PATCH v2 4/6 ARM: mach-shmobile: sh7372 Enable SDIO IRQs
In reply to Magnus DammThis patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the SoC. To make sure interrupts are handled announce the MMC_CAP_SDIO_IRQ capability on AP4EVB. Tested with a b43-based SDIO wireless card.
--- arch/arm/mach-shmobile/board-ap4evb.c | 3 ++- arch/arm/mach-shmobile/intc-sh7372.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +2 -1
@@ -310,6 +310,7 @@ static u64 sdhi0_dma_mask = DMA_BIT_MASK(32);static struct sh_mobile_sdhi_info sdhi0_info = { .dma_slave_tx =SHDMA_SLAVE_SDHI0_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI0_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct resource sdhi0_resources[] = {
@@ -344,7 +345,7 @@ static struct sh_mobile_sdhi_info sdhi1_info = { .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, .tmio_ocr_mask = MMC_VDD_165_195, .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, - .tmio_caps = MMC_CAP_NEEDS_POLL, + .tmio_caps = MMC_CAP_NEEDS_POLL | MMC_CAP_SDIO_IRQ, .get_cd = slot_cn7_get_cd, };
arch/arm/mach-shmobile/intc-sh7372.c +2 -2
@@ -230,10 +230,10 @@ static struct intc_mask_reg intca_mask_registers[] __initdata = { {SCIFB ,SCIFA5 ,SCIFA4 ,MSIOF1 , 0, 0, MSIOF2, 0 } }, {0xe694009c ,0xe69400dc ,8 ,/* IMR7A / IMCR7A */ - { DISABLED, DISABLED, ENABLED, ENABLED, + { DISABLED, ENABLED, ENABLED, ENABLED, FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLTENDI, FLCTL_FLSTEI } }, { 0xe69400a0, 0xe69400e0, 8, /* IMR8A / IMCR8A */ - { 0, DISABLED, ENABLED, ENABLED, + { 0, ENABLED, ENABLED, ENABLED, TTI20, USBHSDMAC0_USHDMI, 0, 0 } }, { 0xe69400a4, 0xe69400e4, 8, /* IMR9A / IMCR9A */ { CMT1_CMT13, CMT1_CMT12, CMT1_CMT11, CMT1_CMT10,
Signature · 1 line
1.7.2.3
PATCH v2 5/6 sh: sh7724 Enable SDIO IRQs
In reply to Magnus DammThis patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the SoC. To make sure interrupt are handled announce the MMC_CAP_SDIO_IRQ capability on ecovec, kfr2r09 and se7724.
Tested with a b43-based SDIO wireless card on ecovec.
--- arch/sh/boards/mach-ecovec24/setup.c | 2 ++ arch/sh/boards/mach-kfr2r09/setup.c | 1 + arch/sh/boards/mach-se/7724/setup.c | 2 ++ arch/sh/kernel/cpu/sh4a/setup-sh7724.c | 4 ++-- 4 files changed, 7 insertions(+), 2 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +2 -0
@@ -476,6 +476,7 @@ static struct sh_mobile_sdhi_info sdhi0_info = { .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, .set_pwr = sdhi0_set_pwr, + .tmio_caps = MMC_CAP_SDIO_IRQ, };static struct resource sdhi0_resources[] = {
@@ -517,6 +518,7 @@ static void sdhi1_set_pwr(struct platform_device *pdev, int state)static struct sh_mobile_sdhi_info sdhi1_info = { .dma_slave_tx =SHDMA_SLAVE_SDHI1_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI1_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , .set_pwr = sdhi1_set_pwr, };
arch/sh/boards/mach-kfr2r09/setup.c +1 -0
@@ -369,6 +369,7 @@ static struct sh_mobile_sdhi_info sh7724_sdhi0_data = { .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, + .tmio_caps = MMC_CAP_SDIO_IRQ, };static struct platform_device kfr2r09_sh_sdhi0_device = {
arch/sh/boards/mach-se/7724/setup.c +2 -0
@@ -470,6 +470,7 @@ static struct resource sdhi0_cn7_resources[] = {static struct sh_mobile_sdhi_info sh7724_sdhi0_data = { .dma_slave_tx =SHDMA_SLAVE_SDHI0_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI0_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct platform_device sdhi0_cn7_device = {
@@ -504,6 +505,7 @@ static struct resource sdhi1_cn8_resources[] = {static struct sh_mobile_sdhi_info sh7724_sdhi1_data = { .dma_slave_tx =SHDMA_SLAVE_SDHI1_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI1_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct platform_device sdhi1_cn8_device = {
arch/sh/kernel/cpu/sh4a/setup-sh7724.c +2 -2
@@ -1144,7 +1144,7 @@ static struct intc_group groups[] __initdata = {static struct intc_mask_reg mask_registers[]__initdata = { {0xa4080080 ,0xa40800c0 ,8 ,/* IMR0 / IMCR0 */ {0 ,TMU1_TUNI2 ,TMU1_TUNI1 ,TMU1_TUNI0 , -0 ,DISABLED ,ENABLED ,ENABLED } }, +0 ,ENABLED ,ENABLED ,ENABLED } }, {0xa4080084 ,0xa40800c4 ,8 ,/* IMR1 / IMCR1 */ {VIO_VOU ,VIO_VEU1 ,VIO_BEU0 ,VIO_CEU0 ,DMAC0A_DEI3 ,DMAC0A_DEI2 ,DMAC0A_DEI1 ,DMAC0A_DEI0 } },
@@ -1166,7 +1166,7 @@ static struct intc_mask_reg mask_registers[] __initdata = { {I2C0_DTEI ,I2C0_WAITI ,I2C0_TACKI ,I2C0_ALI , I2C1_DTEI, I2C1_WAITI, I2C1_TACKI, I2C1_ALI } }, {0xa40800a0 ,0xa40800e0 ,8 ,/* IMR8 / IMCR8 */ - { DISABLED, DISABLED, ENABLED, ENABLED, + { DISABLED, ENABLED, ENABLED, ENABLED, 0, 0, SCIFA5, FSI } }, { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */ { 0, 0, 0, CMT, 0, USB1, USB0, 0 } },
Signature · 1 line
1.7.2.3
RFC PATCH v2 6/6 sh: sh7722 Enable SDIO IRQs
In reply to Magnus DammThis patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the soc. To make sure SDIO IRQs are used announce the MMC_CAP_SDIO_IRQ capability on migor. Untested, therefore RFC.
--- arch/sh/boards/mach-migor/setup.c | 1 + arch/sh/kernel/cpu/sh4a/setup-sh7722.c | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)
arch/sh/boards/mach-migor/setup.c +1 -0
@@ -413,6 +413,7 @@ static struct resource sdhi_cn9_resources[] = {static struct sh_mobile_sdhi_info sh7724_sdhi_data = { .dma_slave_tx =SHDMA_SLAVE_SDHI0_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI0_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct platform_device sdhi_cn9_device = {
arch/sh/kernel/cpu/sh4a/setup-sh7722.c +1 -1
@@ -699,7 +699,7 @@ static struct intc_mask_reg mask_registers[] __initdata = { {I2C_DTEI ,I2C_WAITI ,I2C_TACKI ,I2C_ALI , FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLENDI, FLCTL_FLSTEI } }, {0xa40800a0 ,0xa40800e0 ,8 ,/* IMR8 / IMCR8 */ - { DISABLED, DISABLED, ENABLED, ENABLED, 0, 0, TWODG, SIU } }, + { DISABLED, ENABLED, ENABLED, ENABLED, 0, 0, TWODG, SIU } }, { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */ { 0, 0, 0, CMT, 0, USB_USBI1, USB_USBI0, } }, { 0xa40800a8, 0xa40800e8, 8, /* IMR10 / IMCR10 */
Signature · 1 line
1.7.2.3
RFC PATCH v3 6/6 sh: sh7722 Enable SDIO IRQs
This patch enables the interrupt generation for SDIO IRQs of the sdhi controllers of the SoC. To make sure SDIO IRQs are used, announce the MMC_CAP_SDIO_IRQ capability on migor. Untested, therefore RFC.
---
Changes since v2:
- Added missing include
arch/sh/boards/mach-migor/setup.c | 2 ++ arch/sh/kernel/cpu/sh4a/setup-sh7722.c | 2 +- 2 files changed, 3 insertions(+), 1 deletions(-)
arch/sh/boards/mach-migor/setup.c +2 -0
@@ -14,6 +14,7 @@#include <linux/input.h> #include <linux/input/sh_keysc.h> #include <linux/mfd/sh_mobile_sdhi.h> +#include <linux/mmc/host.h> #include <linux/mtd/physmap.h> #include <linux/mtd/nand.h> #include <linux/i2c.h>
@@ -413,6 +414,7 @@ static struct resource sdhi_cn9_resources[] = {static struct sh_mobile_sdhi_info sh7724_sdhi_data = { .dma_slave_tx =SHDMA_SLAVE_SDHI0_TX , .dma_slave_rx =SHDMA_SLAVE_SDHI0_RX , + .tmio_caps =MMC_CAP_SDIO_IRQ , };static struct platform_device sdhi_cn9_device = {
arch/sh/kernel/cpu/sh4a/setup-sh7722.c +1 -1
@@ -699,7 +699,7 @@ static struct intc_mask_reg mask_registers[] __initdata = { {I2C_DTEI ,I2C_WAITI ,I2C_TACKI ,I2C_ALI , FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLENDI, FLCTL_FLSTEI } }, {0xa40800a0 ,0xa40800e0 ,8 ,/* IMR8 / IMCR8 */ - { DISABLED, DISABLED, ENABLED, ENABLED, 0, 0, TWODG, SIU } }, + { DISABLED, ENABLED, ENABLED, ENABLED, 0, 0, TWODG, SIU } }, { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */ { 0, 0, 0, CMT, 0, USB_USBI1, USB_USBI0, } }, { 0xa40800a8, 0xa40800e8, 8, /* IMR10 / IMCR10 */
Signature · 1 line
1.7.2.3