Skip to content

Commit 5561770

Browse files
jerome-pouillergregkh
authored andcommitted
staging: wfx: repair external IRQ for SDIO
When used over SDIO bus, device is able to use an external line to signal IRQs (also called Out-Of-Band IRQ). The current code have several problems: 1. The ISR cannot directly acknowledge IRQ since access to the bus is not atomic. This patch use a threaded IRQ to solve that issue. 2. On certain platforms, it is necessary to keep SDIO interruption enabled (with register SDIO_CCCR_IENx) (this part has inspired from the brcmfmac driver). Signed-off-by: Jérôme Pouiller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ba52edd commit 5561770

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

drivers/staging/wfx/bus_sdio.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
* Copyright (c) 2010, ST-Ericsson
77
*/
88
#include <linux/module.h>
9+
#include <linux/mmc/sdio.h>
910
#include <linux/mmc/sdio_func.h>
1011
#include <linux/mmc/card.h>
1112
#include <linux/interrupt.h>
1213
#include <linux/of_irq.h>
14+
#include <linux/irq.h>
1315

1416
#include "bus.h"
1517
#include "wfx.h"
@@ -106,31 +108,41 @@ static irqreturn_t wfx_sdio_irq_handler_ext(int irq, void *priv)
106108

107109
static int wfx_sdio_irq_subscribe(struct wfx_sdio_priv *bus)
108110
{
111+
u32 flags;
109112
int ret;
113+
u8 cccr;
110114

111-
if (bus->of_irq) {
112-
ret = request_irq(bus->of_irq, wfx_sdio_irq_handler_ext,
113-
IRQF_TRIGGER_RISING, "wfx", bus);
114-
} else {
115+
if (!bus->of_irq) {
115116
sdio_claim_host(bus->func);
116117
ret = sdio_claim_irq(bus->func, wfx_sdio_irq_handler);
117118
sdio_release_host(bus->func);
119+
return ret;
118120
}
119-
return ret;
121+
122+
sdio_claim_host(bus->func);
123+
cccr = sdio_f0_readb(bus->func, SDIO_CCCR_IENx, NULL);
124+
cccr |= BIT(0);
125+
cccr |= BIT(bus->func->num);
126+
sdio_f0_writeb(bus->func, cccr, SDIO_CCCR_IENx, NULL);
127+
sdio_release_host(bus->func);
128+
flags = irq_get_trigger_type(bus->of_irq);
129+
if (!flags)
130+
flags = IRQF_TRIGGER_HIGH;
131+
flags |= IRQF_ONESHOT;
132+
return devm_request_threaded_irq(&bus->func->dev, bus->of_irq, NULL,
133+
wfx_sdio_irq_handler_ext, flags,
134+
"wfx", bus);
120135
}
121136

122137
static int wfx_sdio_irq_unsubscribe(struct wfx_sdio_priv *bus)
123138
{
124139
int ret;
125140

126-
if (bus->of_irq) {
127-
free_irq(bus->of_irq, bus);
128-
ret = 0;
129-
} else {
130-
sdio_claim_host(bus->func);
131-
ret = sdio_release_irq(bus->func);
132-
sdio_release_host(bus->func);
133-
}
141+
if (bus->of_irq)
142+
devm_free_irq(&bus->func->dev, bus->of_irq, bus);
143+
sdio_claim_host(bus->func);
144+
ret = sdio_release_irq(bus->func);
145+
sdio_release_host(bus->func);
134146
return ret;
135147
}
136148

0 commit comments

Comments
 (0)