Skip to contentSkip to conversation

brcmfmac: introducing out of band interrupt support

PATCH New Franky Lin 1 participant 5 messages Apr 28, 2012 Networking drivers (wireless)

lore
Share & tools
lore

Franky Lin

author
#0 lore raw

cover brcmfmac: introducing out of band interrupt support

Hi John,

This patch series brings the out of band (OOB) interrupt support to brcmfmac for SDIO dongle. OOB interrupts implementation is intended to provide a faster interrupt mechanism for SDIO host controllers that don't support SDIO interrupt. Also it provides the possibility that dongle can wake up the application processor in deep sleep. So we can have more offloading features to improve the overall system power consumption especially for mobility platform.

Thanks,
Franky

Franky Lin (4):
brcmfmac: stop releasing sdio host in irq handler
brcmfmac: check bus state for status
brcmfmac: postpone interrupt register function
brcmfmac: add out of band interrupt support

 drivers/net/wireless/brcm80211/Kconfig             |    9 ++
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c   |   97 ++++++++++++++++--
 .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c |  105 +++++++++++++++++++-
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   39 ++++++--
 .../net/wireless/brcm80211/brcmfmac/sdio_host.h    |   22 +++-
 5 files changed, 245 insertions(+), 27 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/4 brcmfmac: stop releasing sdio host in irq handler

brcmf_sdbrcm_isr doesn't access to the dongle through SDIO bus. Stop releasing and claiming host in irq handler to eliminate any potential risk.

---
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c |    4 ----
 1 file changed, 4 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +0 -4
index e925290..ea35020 100644
@@ -45,11 +45,7 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func)
 
 	brcmf_dbg(TRACE, "***IRQHandler\n");
 
-	sdio_release_host(func);
-
 	brcmf_sdbrcm_isr(sdiodev->bus);
-
-	sdio_claim_host(func);
 }
 
 /* dummy handler for SDIO function 2 interrupt */
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/4 brcmfmac: check bus state for status

In reply to Franky Lin

Bus state should be the correct flag for bus status. Use it instead of result from previous function call for backplane clock switch.

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +1 -1
index 12d9dc9..46fc16f 100644
@@ -3508,7 +3508,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev)
 			       SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err);
 
 	/* If we didn't come up, turn off backplane clock */
-	if (!ret)
+	if (bus_if->state != BRCMF_BUS_DATA)
 		brcmf_sdbrcm_clkctl(bus, CLK_NONE, false);
 
 exit:
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH 3/4 brcmfmac: postpone interrupt register function

In reply to Franky Lin

For out of band interrupt which is going to be introduced shortly, the interrupt register function must be called after firmware is downloaded. This patch moves it from brcmf_sdbrcm_probe to brcmf_sdbrcm_bus_init.

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +6 -9
index 46fc16f..b82edaf 100644
@@ -3507,6 +3507,12 @@ static int brcmf_sdbrcm_bus_init(struct device *dev)
 	brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
 			       SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err);
 
+	if (ret == 0) {
+		ret = brcmf_sdcard_intr_reg(bus->sdiodev);
+		if (ret != 0)
+			brcmf_dbg(ERROR, "intr register failed:%d\n", ret);
+	}
+
 	/* If we didn't come up, turn off backplane clock */
 	if (bus_if->state != BRCMF_BUS_DATA)
 		brcmf_sdbrcm_clkctl(bus, CLK_NONE, false);
@@ -3967,15 +3973,6 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev)
 		goto fail;
 	}
 
-	/* Register interrupt callback, but mask it (not operational yet). */
-	brcmf_dbg(INTR, "disable SDIO interrupts (not interested yet)\n");
-	ret = brcmf_sdcard_intr_reg(bus->sdiodev);
-	if (ret != 0) {
-		brcmf_dbg(ERROR, "FAILED: sdcard_intr_reg returned %d\n", ret);
-		goto fail;
-	}
-	brcmf_dbg(INTR, "registered SDIO interrupt function ok\n");
-
 	brcmf_dbg(INFO, "completed!!\n");
 
 	/* if firmware path present try to download and bring up bus */
Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH 4/4 brcmfmac: add out of band interrupt support

In reply to Franky Lin

Some sdio host controllers do not support real in band interrupt. Software polling mode as a replacement is not fast enough for high throughput and new features. Also some in band interrupts do not support host wake up on embedded platform even when they are real physical interrupts. Therefore out of band (oob) interrupt mechanism is implemented for these scenarios.

To provide oob irq number and flags used for irq registration in brcmfmac, a platform device contains irq resource must be registered in board specific code.

Here is an example of platform device structure:

struct resource brcmf_sdio_res[] = {
	{
		.start	= GPIO_BRCMF_SDIO_OOB_NUM,
		.end	= GPIO_BRCMF_SDIO_OOB_NUM,
		.flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
	}
};
struct platform_device brcmf_sdio_device = {
	.name		= "brcmf_sdio_pd",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(brcmf_sdio_res),
	.resource	= brcmf_sdio_res,
};
---
 drivers/net/wireless/brcm80211/Kconfig             |    9 ++
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c   |   95 ++++++++++++++++--
 .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c |  105 +++++++++++++++++++-
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |   24 ++++-
 .../net/wireless/brcm80211/brcmfmac/sdio_host.h    |   22 +++-
 5 files changed, 240 insertions(+), 15 deletions(-)
drivers/net/wireless/brcm80211/Kconfig +9 -0
index c510453..b480088 100644
@@ -36,6 +36,15 @@ config BRCMFMAC_SDIO
 	  IEEE802.11n embedded FullMAC WLAN driver. Say Y if you want to
 	  use the driver for a SDIO wireless card.
 
+config BRCMFMAC_SDIO_OOB
+	bool "Out of band interrupt support for SDIO interface chipset"
+	depends on BRCMFMAC_SDIO
+	---help---
+	  This option enables out-of-band interrupt support for Broadcom
+	  SDIO Wifi chipset using fullmac in order to gain better
+	  performance and deep sleep wake up capability on certain
+	  platforms. Say N if you are unsure.
+
 config BRCMFMAC_USB
 	bool "USB bus interface support for FullMAC driver"
 	depends on USB
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +88 -7

127 lines not on this page · raw message

drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +104 -1

150 lines not on this page · raw message

drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +22 -2
index b82edaf..1f33b25 100644
@@ -2352,6 +2352,24 @@ static void brcmf_sdbrcm_bus_stop(struct device *dev)
 	up(&bus->sdsem);
 }
 
+#ifdef CONFIG_BRCMFMAC_SDIO_OOB
+static inline void brcmf_sdbrcm_clrintr(struct brcmf_sdio *bus)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&bus->sdiodev->irq_en_lock, flags);
+	if (!bus->sdiodev->irq_en && !bus->ipend) {
+		enable_irq(bus->sdiodev->irq);
+		bus->sdiodev->irq_en = true;
+	}
+	spin_unlock_irqrestore(&bus->sdiodev->irq_en_lock, flags);
+}
+#else
+static inline void brcmf_sdbrcm_clrintr(struct brcmf_sdio *bus)
+{
+}
+#endif		/* CONFIG_BRCMFMAC_SDIO_OOB */
+
 static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
 {
 	u32 intstatus, newstatus = 0;
@@ -2509,6 +2527,8 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
 	bus->intstatus = intstatus;
 
 clkwait:
+	brcmf_sdbrcm_clrintr(bus);
+
 	if (data_ok(bus) && bus->ctrl_frame_stat &&
 		(bus->clkstate == CLK_AVAIL)) {
 		int ret, i;
@@ -3508,7 +3528,7 @@ static int brcmf_sdbrcm_bus_init(struct device *dev)
 			       SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err);
 
 	if (ret == 0) {
-		ret = brcmf_sdcard_intr_reg(bus->sdiodev);
+		ret = brcmf_sdio_intr_register(bus->sdiodev);
 		if (ret != 0)
 			brcmf_dbg(ERROR, "intr register failed:%d\n", ret);
 	}
@@ -3872,7 +3892,7 @@ static void brcmf_sdbrcm_release(struct brcmf_sdio *bus)
 
 	if (bus) {
 		/* De-register interrupt handler */
-		brcmf_sdcard_intr_dereg(bus->sdiodev);
+		brcmf_sdio_intr_unregister(bus->sdiodev);
 
 		if (bus->sdiodev->bus_if->drvr) {
 			brcmf_detach(bus->sdiodev->dev);
drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +17 -5
index 0281d20..7010eaf 100644
@@ -43,6 +43,13 @@
 /* as of sdiod rev 0, supports 3 functions */
 #define SBSDIO_NUM_FUNCTION		3
 
+/* function 0 vendor specific CCCR registers */
+#define SDIO_CCCR_BRCM_SEPINT		0xf2
+
+#define  SDIO_SEPINT_MASK		0x01
+#define  SDIO_SEPINT_OE			0x02
+#define  SDIO_SEPINT_ACT_HI		0x04
+
 /* function 1 miscellaneous registers */
 
 /* sprom command and status */
@@ -144,13 +151,18 @@ struct brcmf_sdio_dev {
 	wait_queue_head_t request_buffer_wait;
 	struct device *dev;
 	struct brcmf_bus *bus_if;
+#ifdef CONFIG_BRCMFMAC_SDIO_OOB
+	unsigned int irq;		/* oob interrupt number */
+	unsigned long irq_flags;	/* board specific oob flags */
+	bool irq_en;			/* irq enable flags */
+	spinlock_t irq_en_lock;
+	bool irq_wake;			/* irq wake enable flags */
+#endif		/* CONFIG_BRCMFMAC_SDIO_OOB */
 };
 
-/* Register/deregister device interrupt handler. */
-extern int
-brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev);
-
-extern int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev);
+/* Register/deregister interrupt handler. */
+extern int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev);
+extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
 
 /* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
  *   fn:   function number
Signature · 1 line
1.7.9.5