Skip to contentSkip to conversation

staging: brcm80211: remove si sb utils dependency from brcmfmac

PATCH In review Franky Lin 2 participants 7 messages Apr 26, 2011 Staging

lore
Share & tools
lore

Franky Lin

author
#0 lore raw

v2 cover staging: brcm80211: remove si sb utils dependency from brcmfmac

Hi Greg,

I fix the apply error issue of the rest 5 patches. The original path series intends to remove si and sb utility from broadcom fullmac driver.

Thanks
Franky

Franky Lin (5):
staging: brcm80211: Remove siutils dependency of
dhdsdio_download_state
staging: brcm80211: Move sdiod strength init to dhd_sdio.c
staging: brcm80211: Add dhdsdio_chip_detach in dhd_sdio.c
staging: brcm80211: Remove siutils dependence from dhd_sdio.c
staging: brcm80211: Remove si sb utils from brcmfmac

 drivers/staging/brcm80211/brcmfmac/Makefile   |    6 +-
 drivers/staging/brcm80211/brcmfmac/bcmchip.h  |    1 +
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c   |    1 -
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |  325 +++++++++++-------
 drivers/staging/brcm80211/brcmfmac/hndpmu.c   |    1 -
 drivers/staging/brcm80211/brcmfmac/sbutils.c  |    1 -
 drivers/staging/brcm80211/brcmfmac/siutils.c  |    1 -
 drivers/staging/brcm80211/util/bcmutils.c     |    1 -
 drivers/staging/brcm80211/util/sbutils.c      |  476 -------------------------
 9 files changed, 206 insertions(+), 607 deletions(-)
 delete mode 100644 drivers/staging/brcm80211/brcmfmac/hndpmu.c
 delete mode 100644 drivers/staging/brcm80211/brcmfmac/sbutils.c
 delete mode 100644 drivers/staging/brcm80211/brcmfmac/siutils.c
 delete mode 100644 drivers/staging/brcm80211/util/sbutils.c
author
#3 lore raw

PATCH v2 3/5 staging: brcm80211: Add dhdsdio_chip_detach in dhd_sdio.c

Add dhdsdio_chip_detach to replace si_detach for si/sb utils removal

---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +12 -3
index e2d5aa5..74d7935 100644
@@ -487,6 +487,7 @@ static int dhdsdio_chip_attach(struct dhd_bus *bus, void *regs);
 static void dhdsdio_chip_resetcore(bcmsdh_info_t *sdh, u32 corebase);
 static void dhdsdio_sdiod_drive_strength_init(struct dhd_bus *bus,
 					u32 drivestrength);
+static void dhdsdio_chip_detach(struct dhd_bus *bus);
 
 static void dhd_dongle_setmemsize(struct dhd_bus *bus, int mem_size)
 {
@@ -5484,10 +5485,8 @@ static void dhdsdio_release(dhd_bus_t *bus)
 		bcmsdh_intr_dereg(bus->sdh);
 
 		if (bus->dhd) {
-
-			dhdsdio_release_dongle(bus);
-
 			dhd_detach(bus->dhd);
+			dhdsdio_release_dongle(bus);
 			bus->dhd = NULL;
 		}
 
@@ -5530,6 +5529,7 @@ static void dhdsdio_release_dongle(dhd_bus_t *bus)
 #endif				/* !defined(BCMLXSDMMC) */
 		dhdsdio_clkctl(bus, CLK_NONE, false);
 		si_detach(bus->sih);
+		dhdsdio_chip_detach(bus);
 		if (bus->vars && bus->varsz)
 			kfree(bus->vars);
 		bus->vars = NULL;
@@ -6426,3 +6426,12 @@ dhdsdio_sdiod_drive_strength_init(struct dhd_bus *bus, u32 drivestrength) {
 			drivestrength, cc_data_temp));
 	}
 }
+
+static void
+dhdsdio_chip_detach(struct dhd_bus *bus)
+{
+	DHD_TRACE(("%s: Enter\n", __func__));
+
+	kfree(bus->ci);
+	bus->ci = NULL;
+}
Signature · 1 line
1.7.1
author
#5 lore raw

PATCH v2 5/5 staging: brcm80211: Remove si sb utils from brcmfmac

In reply to Franky Lin

si/sb utility is removed from Broadcom fullmac driver. All unused files are removed.

---
 drivers/staging/brcm80211/brcmfmac/Makefile   |    6 +-
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c   |    1 -
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |    3 -
 drivers/staging/brcm80211/brcmfmac/hndpmu.c   |    1 -
 drivers/staging/brcm80211/brcmfmac/sbutils.c  |    1 -
 drivers/staging/brcm80211/brcmfmac/siutils.c  |    1 -
 drivers/staging/brcm80211/util/bcmutils.c     |    1 -
 drivers/staging/brcm80211/util/sbutils.c      |  476 -------------------------
 8 files changed, 1 insertions(+), 489 deletions(-)
 delete mode 100644 drivers/staging/brcm80211/brcmfmac/hndpmu.c
 delete mode 100644 drivers/staging/brcm80211/brcmfmac/sbutils.c
 delete mode 100644 drivers/staging/brcm80211/brcmfmac/siutils.c
 delete mode 100644 drivers/staging/brcm80211/util/sbutils.c
drivers/staging/brcm80211/brcmfmac/Makefile +1 -5
index ac5a7d4..4adbc4e 100644
@@ -52,12 +52,8 @@ DHDOFILES = \
 	bcmsdh_linux.o	\
 	bcmsdh_sdmmc.o \
 	bcmsdh_sdmmc_linux.o \
-	aiutils.o \
-	siutils.o \
-	sbutils.o \
 	bcmutils.o \
-	bcmwifi.o \
-	hndpmu.o
+	bcmwifi.o
 
 obj-m += brcmfmac.o
 brcmfmac-objs += $(DHDOFILES)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +0 -1
index f15ee63..0627b7d 100644
@@ -22,7 +22,6 @@
 #include <bcmdevs.h>
 #include <bcmutils.h>
 #include <hndsoc.h>
-#include <siutils.h>
 
 #include <bcmsdh.h>		/* BRCM API for SDIO
 			 clients (such as wl, dhd) */
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +0 -3
index dc80e27..6debc1e 100644
@@ -28,8 +28,6 @@
 #include <bcmutils.h>
 #include <bcmdevs.h>
 
-#include <siutils.h>
-#include <hndpmu.h>
 #include <hndsoc.h>
 #ifdef DHD_DEBUG
 #include <hndrte_armtrap.h>
@@ -52,7 +50,6 @@
 #include <dhd_dbg.h>
 #include <dhdioctl.h>
 #include <sdiovar.h>
-#include <siutils_priv.h>
 #include <bcmchip.h>
 
 #ifndef DHDSDIO_MEM_DUMP_FNAME
drivers/staging/brcm80211/brcmfmac/hndpmu.c deleted +0 -1
deleted file mode 100644
index e841da6..0000000
@@ -1 +0,0 @@
-#include "../util/hndpmu.c"
drivers/staging/brcm80211/brcmfmac/sbutils.c deleted +0 -1
deleted file mode 100644
index 64496b8..0000000
@@ -1 +0,0 @@
-#include "../util/sbutils.c"
drivers/staging/brcm80211/brcmfmac/siutils.c deleted +0 -1
deleted file mode 100644
index f428e99..0000000
@@ -1 +0,0 @@
-#include "../util/siutils.c"
drivers/staging/brcm80211/util/bcmutils.c +0 -1
index fb0bccc..387fd5d 100644
@@ -24,7 +24,6 @@
 #include <bcmdefs.h>
 #include <stdarg.h>
 #include <bcmutils.h>
-#include <siutils.h>
 #include <bcmnvram.h>
 #include <bcmdevs.h>
 #include <proto/802.11.h>
drivers/staging/brcm80211/util/sbutils.c deleted +0 -476

476 lines not on this page · raw message

Signature · 1 line
1.7.1
author
#1 lore raw

PATCH v2 1/5 staging: brcm80211: Remove siutils dependency of dhdsdio_download_state

In reply to Franky Lin

Use dhdsdio_chip_disablecore and dhd_sdio_chip_resetcore to replace siutils functions used in dhdsdio_download_state

---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |  114 ++++++++++++-------------
 1 files changed, 53 insertions(+), 61 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +53 -61
index 14f4703..2827af2 100644
@@ -482,7 +482,9 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus);
 #ifdef BCMEMBEDIMAGE
 static int dhdsdio_download_code_array(struct dhd_bus *bus);
 #endif
+static void dhdsdio_chip_disablecore(bcmsdh_info_t *sdh, u32 corebase);
 static int dhdsdio_chip_attach(struct dhd_bus *bus, void *regs);
+static void dhdsdio_chip_resetcore(bcmsdh_info_t *sdh, u32 corebase);
 
 static void dhd_dongle_setmemsize(struct dhd_bus *bus, int mem_size)
 {
@@ -2615,42 +2617,18 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 static int dhdsdio_download_state(dhd_bus_t *bus, bool enter)
 {
 	uint retries;
+	u32 regdata;
 	int bcmerror = 0;
 
 	/* To enter download state, disable ARM and reset SOCRAM.
 	 * To exit download state, simply reset ARM (default is RAM boot).
 	 */
 	if (enter) {
-
 		bus->alp_only = true;
 
-		if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) &&
-		    !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) {
-			DHD_ERROR(("%s: Failed to find ARM core!\n", __func__));
-			bcmerror = BCME_ERROR;
-			goto fail;
-		}
+		dhdsdio_chip_disablecore(bus->sdh, bus->ci->armcorebase);
 
-		si_core_disable(bus->sih, 0);
-		if (bcmsdh_regfail(bus->sdh)) {
-			bcmerror = BCME_SDIO_ERROR;
-			goto fail;
-		}
-
-		if (!(si_setcore(bus->sih, SOCRAM_CORE_ID, 0))) {
-			DHD_ERROR(("%s: Failed to find SOCRAM core!\n",
-				   __func__));
-			bcmerror = BCME_ERROR;
-			goto fail;
-		}
-
-		si_core_reset(bus->sih, 0, 0);
-		if (bcmsdh_regfail(bus->sdh)) {
-			DHD_ERROR(("%s: Failure trying reset SOCRAM core?\n",
-				   __func__));
-			bcmerror = BCME_SDIO_ERROR;
-			goto fail;
-		}
+		dhdsdio_chip_resetcore(bus->sdh, bus->ci->ramcorebase);
 
 		/* Clear the top bit of memory */
 		if (bus->ramsize) {
@@ -2659,14 +2637,11 @@ static int dhdsdio_download_state(dhd_bus_t *bus, bool enter)
 					 (u8 *)&zeros, 4);
 		}
 	} else {
-		if (!(si_setcore(bus->sih, SOCRAM_CORE_ID, 0))) {
-			DHD_ERROR(("%s: Failed to find SOCRAM core!\n",
-				   __func__));
-			bcmerror = BCME_ERROR;
-			goto fail;
-		}
-
-		if (!si_iscoreup(bus->sih)) {
+		regdata = bcmsdh_reg_read(bus->sdh,
+			CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4);
+		regdata &= (SBTML_RESET | SBTML_REJ_MASK |
+			(SICF_CLOCK_EN << SBTML_SICF_SHIFT));
+		if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) {
 			DHD_ERROR(("%s: SOCRAM core is down after reset?\n",
 				   __func__));
 			bcmerror = BCME_ERROR;
@@ -2679,41 +2654,16 @@ static int dhdsdio_download_state(dhd_bus_t *bus, bool enter)
 			bcmerror = 0;
 		}
 
-		if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0) &&
-		    !si_setcore(bus->sih, SDIOD_CORE_ID, 0)) {
-			DHD_ERROR(("%s: Can't change back to SDIO core?\n",
-				   __func__));
-			bcmerror = BCME_ERROR;
-			goto fail;
-		}
 		W_SDREG(0xFFFFFFFF, &bus->regs->intstatus, retries);
 
-		if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) &&
-		    !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) {
-			DHD_ERROR(("%s: Failed to find ARM core!\n", __func__));
-			bcmerror = BCME_ERROR;
-			goto fail;
-		}
-
-		si_core_reset(bus->sih, 0, 0);
-		if (bcmsdh_regfail(bus->sdh)) {
-			DHD_ERROR(("%s: Failure trying to reset ARM core?\n",
-				   __func__));
-			bcmerror = BCME_SDIO_ERROR;
-			goto fail;
-		}
+		dhdsdio_chip_resetcore(bus->sdh, bus->ci->armcorebase);
 
 		/* Allow HT Clock now that the ARM is running. */
 		bus->alp_only = false;
 
 		bus->dhd->busstate = DHD_BUS_LOAD;
 	}
-
 fail:
-	/* Always return to SDIOD core */
-	if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0))
-		si_setcore(bus->sih, SDIOD_CORE_ID, 0);
-
 	return bcmerror;
 }
 
@@ -6324,3 +6274,45 @@ fail:
 	kfree(ci);
 	return err;
 }
+
+static void
+dhdsdio_chip_resetcore(bcmsdh_info_t *sdh, u32 corebase)
+{
+	u32 regdata;
+
+	/*
+	 * Must do the disable sequence first to work for
+	 * arbitrary current core state.
+	 */
+	dhdsdio_chip_disablecore(sdh, corebase);
+
+	/*
+	 * Now do the initialization sequence.
+	 * set reset while enabling the clock and
+	 * forcing them on throughout the core
+	 */
+	bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4,
+		((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) |
+		SBTML_RESET);
+	udelay(1);
+
+	regdata = bcmsdh_reg_read(sdh, CORE_SB(corebase, sbtmstatehigh), 4);
+	if (regdata & SBTMH_SERR)
+		bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatehigh), 4, 0);
+
+	regdata = bcmsdh_reg_read(sdh, CORE_SB(corebase, sbimstate), 4);
+	if (regdata & (SBIM_IBE | SBIM_TO))
+		bcmsdh_reg_write(sdh, CORE_SB(corebase, sbimstate), 4,
+			regdata & ~(SBIM_IBE | SBIM_TO));
+
+	/* clear reset and allow it to propagate throughout the core */
+	bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4,
+		(SICF_FGC << SBTML_SICF_SHIFT) |
+		(SICF_CLOCK_EN << SBTML_SICF_SHIFT));
+	udelay(1);
+
+	/* leave clock enabled */
+	bcmsdh_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4,
+		(SICF_CLOCK_EN << SBTML_SICF_SHIFT));
+	udelay(1);
+}
Signature · 1 line
1.7.1
author
#2 lore raw

PATCH v2 2/5 staging: brcm80211: Move sdiod strength init to dhd_sdio.c

In reply to Franky Lin

Move si_sdiod_drive_strength_init to dhd_sdio and rename to dhdsdio_sdiod_drive_strength_init for dhd_pmu.c removal

---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |  114 ++++++++++++++++++++++++-
 1 files changed, 112 insertions(+), 2 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +112 -2
index 2827af2..e2d5aa5 100644
@@ -485,6 +485,8 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus);
 static void dhdsdio_chip_disablecore(bcmsdh_info_t *sdh, u32 corebase);
 static int dhdsdio_chip_attach(struct dhd_bus *bus, void *regs);
 static void dhdsdio_chip_resetcore(bcmsdh_info_t *sdh, u32 corebase);
+static void dhdsdio_sdiod_drive_strength_init(struct dhd_bus *bus,
+					u32 drivestrength);
 
 static void dhd_dongle_setmemsize(struct dhd_bus *bus, int mem_size)
 {
@@ -2292,7 +2294,7 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
 
 	case IOV_SVAL(IOV_SDIOD_DRIVE):
 		dhd_sdiod_drive_strength = int_val;
-		si_sdiod_drive_strength_init(bus->sih,
+		dhdsdio_sdiod_drive_strength_init(bus,
 					     dhd_sdiod_drive_strength);
 		break;
 
@@ -5270,7 +5272,7 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
 		goto fail;
 	}
 
-	si_sdiod_drive_strength_init(bus->sih, dhd_sdiod_drive_strength);
+	dhdsdio_sdiod_drive_strength_init(bus, dhd_sdiod_drive_strength);
 
 	/* Get info on the ARM and SOCRAM cores... */
 	if (!DHD_NOPMU(bus)) {
@@ -6316,3 +6318,111 @@ dhdsdio_chip_resetcore(bcmsdh_info_t *sdh, u32 corebase)
 		(SICF_CLOCK_EN << SBTML_SICF_SHIFT));
 	udelay(1);
 }
+
+/* SDIO Pad drive strength to select value mappings */
+struct sdiod_drive_str {
+	u8 strength;	/* Pad Drive Strength in mA */
+	u8 sel;		/* Chip-specific select value */
+};
+
+/* SDIO Drive Strength to sel value table for PMU Rev 1 */
+static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = {
+	{
+	4, 0x2}, {
+	2, 0x3}, {
+	1, 0x0}, {
+	0, 0x0}
+	};
+
+/* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */
+static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = {
+	{
+	12, 0x7}, {
+	10, 0x6}, {
+	8, 0x5}, {
+	6, 0x4}, {
+	4, 0x2}, {
+	2, 0x1}, {
+	0, 0x0}
+	};
+
+/* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */
+static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = {
+	{
+	32, 0x7}, {
+	26, 0x6}, {
+	22, 0x5}, {
+	16, 0x4}, {
+	12, 0x3}, {
+	8, 0x2}, {
+	4, 0x1}, {
+	0, 0x0}
+	};
+
+#define SDIOD_DRVSTR_KEY(chip, pmu)     (((chip) << 16) | (pmu))
+
+static void
+dhdsdio_sdiod_drive_strength_init(struct dhd_bus *bus, u32 drivestrength) {
+	struct sdiod_drive_str *str_tab = NULL;
+	u32 str_mask = 0;
+	u32 str_shift = 0;
+#ifdef BCMDBG
+	char chn[8];
+#endif
+
+	if (!(bus->ci->cccaps & CC_CAP_PMU))
+		return;
+
+	switch (SDIOD_DRVSTR_KEY(bus->ci->chip, bus->ci->pmurev)) {
+	case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1):
+		str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1;
+		str_mask = 0x30000000;
+		str_shift = 28;
+		break;
+	case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2):
+	case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3):
+		str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2;
+		str_mask = 0x00003800;
+		str_shift = 11;
+		break;
+	case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8):
+		str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3;
+		str_mask = 0x00003800;
+		str_shift = 11;
+		break;
+	default:
+		DHD_ERROR(("No SDIO Drive strength init"
+			"done for chip %s rev %d pmurev %d\n",
+			bcm_chipname(bus->ci->chip, chn, 8),
+			bus->ci->chiprev, bus->ci->pmurev));
+		break;
+	}
+
+	if (str_tab != NULL) {
+		u32 drivestrength_sel = 0;
+		u32 cc_data_temp;
+		int i;
+
+		for (i = 0; str_tab[i].strength != 0; i++) {
+			if (drivestrength >= str_tab[i].strength) {
+				drivestrength_sel = str_tab[i].sel;
+				break;
+			}
+		}
+
+		bcmsdh_reg_write(bus->sdh,
+			CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr),
+			4, 1);
+		cc_data_temp = bcmsdh_reg_read(bus->sdh,
+			CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4);
+		cc_data_temp &= ~str_mask;
+		drivestrength_sel <<= str_shift;
+		cc_data_temp |= drivestrength_sel;
+		bcmsdh_reg_write(bus->sdh,
+			CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr),
+			4, cc_data_temp);
+
+		DHD_INFO(("SDIO: %dmA drive strength selected, set to 0x%08x\n",
+			drivestrength, cc_data_temp));
+	}
+}
Signature · 1 line
1.7.1
author
#4 lore raw

PATCH v2 4/5 staging: brcm80211: Remove siutils dependence from dhd_sdio.c

In reply to Franky Lin

Remove siutils related functions and resources from dhd_sdio.c

---
 drivers/staging/brcm80211/brcmfmac/bcmchip.h  |    1 +
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |   79 +++++++++----------------
 2 files changed, 28 insertions(+), 52 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmchip.h +1 -0
index 29eeee2..c0d4c3b 100644
@@ -30,5 +30,6 @@
 #define BCM4329_CORE_SOCRAM_BASE	0x18003000
 /* ARM Cortex M3 core, ID 0x82a */
 #define BCM4329_CORE_ARM_BASE		0x18002000
+#define BCM4329_RAMSIZE			0x48000
 
 #endif				/* _bcmchip_h_ */
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +27 -52

174 lines not on this page · raw message

Signature · 1 line
1.7.1
#6 lore raw
In reply to Franky Lin
Quoted 4 lines · Franky Lin

Hi Greg,

I fix the apply error issue of the rest 5 patches. The original path series intends to remove si and sb utility from broadcom fullmac driver.

That worked much better, thanks.

greg k-h