2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 00/15] brcm80211: the rest of smac bcma switch series

Hi John,

This train contains the rest of patch series switching brcmsmac to use
bcma bus interface.
It depends on the following patch set:
[PATCH 00/23] brcm80211: fullmac 4430 support and softmac switch to bcma
Message-ID: <[email protected]>

Arend van Spriel (15):
brcm80211: smac: change ai_findcoreidx() to ai_findcore()
brcm80211: smac: use bcma core access functions in otp.c
brcm80211: smac: use bcma core access function in srom.c
brcm80211: smac: use bcma core access functions in pmu.c
brcm80211: smac: use bcma core access functions in aiutils.c
brcm80211: smac: remove register access macro definitions
brcm80211: smac: remove empty or unused functions from pmu.c
brcm80211: smac: INTROFF/INTRESTORE macros removed
brcm80211: smac: remove interrupt disable callback functionality
brcm80211: smac: remove ai_switch_core() function
brcm80211: smac: remove mapped core related function from aiutils.c
brcm80211: smac: cleanup si_info structure definition
brcm80211: smac: cleanup buscore handling in aiutils.c
brcm80211: smac: register with bcma for specific 802.11 core
revisions
brcm80211: smac: fix compilation issue with CONFIG_BCM47XX set

drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 512 +++++---------------
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 66 +--
drivers/net/wireless/brcm80211/brcmsmac/dma.c | 101 ++--
.../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 +-
drivers/net/wireless/brcm80211/brcmsmac/main.c | 40 +--
drivers/net/wireless/brcm80211/brcmsmac/nicpci.c | 3 +-
drivers/net/wireless/brcm80211/brcmsmac/otp.c | 68 +--
.../net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +-
.../net/wireless/brcm80211/brcmsmac/phy/phy_n.c | 7 +-
drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 224 +++------
drivers/net/wireless/brcm80211/brcmsmac/pmu.h | 5 +-
drivers/net/wireless/brcm80211/brcmsmac/srom.c | 50 +--
drivers/net/wireless/brcm80211/brcmsmac/srom.h | 2 +-
drivers/net/wireless/brcm80211/brcmsmac/types.h | 51 --
.../net/wireless/brcm80211/include/chipcommon.h | 2 +
15 files changed, 302 insertions(+), 835 deletions(-)

--
1.7.5.4




2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 13/15] brcm80211: smac: cleanup buscore handling in aiutils.c

From: Arend van Spriel <[email protected]>

Instead of storing the buscore information now the BCMA core device
is kept for quick reference in si_info structure.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 52 +++++++++------------
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 23 ++++-----
drivers/net/wireless/brcm80211/brcmsmac/nicpci.c | 3 +-
3 files changed, 34 insertions(+), 44 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index 34a5e02..372bee8 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -479,10 +479,9 @@ static bool ai_buscore_prep(struct si_info *sii)
static bool
ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
{
+ struct bcma_device *pci = NULL;
+ struct bcma_device *pcie = NULL;
struct bcma_device *core;
- bool pci, pcie;
- uint i;
- uint pciidx, pcieidx, pcirev, pcierev;


/* no cores found, bail out */
@@ -506,15 +505,7 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK;
}

- /* figure out bus/orignal core idx */
- sii->pub.buscoretype = NODEV_CORE_ID;
- sii->pub.buscorerev = NOREV;
- sii->buscoreidx = BADIDX;
-
- pci = pcie = false;
- pcirev = pcierev = NOREV;
- pciidx = pcieidx = BADIDX;
-
+ /* figure out buscore */
list_for_each_entry(core, &cc->bus->cores, list) {
uint cid, crev;

@@ -522,30 +513,22 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
crev = core->id.rev;

if (cid == PCI_CORE_ID) {
- pciidx = i;
- pcirev = crev;
- pci = true;
+ pci = core;
} else if (cid == PCIE_CORE_ID) {
- pcieidx = i;
- pcierev = crev;
- pcie = true;
+ pcie = core;
}
}

if (pci && pcie) {
if (ai_ispcie(sii))
- pci = false;
+ pci = NULL;
else
- pcie = false;
+ pcie = NULL;
}
if (pci) {
- sii->pub.buscoretype = PCI_CORE_ID;
- sii->pub.buscorerev = pcirev;
- sii->buscoreidx = pciidx;
+ sii->buscore = pci;
} else if (pcie) {
- sii->pub.buscoretype = PCIE_CORE_ID;
- sii->pub.buscorerev = pcierev;
- sii->buscoreidx = pcieidx;
+ sii->buscore = pcie;
}

/* fixup necessary chip/core configurations */
@@ -554,10 +537,8 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
if (sii->pch == NULL)
return false;
}
- if (ai_pci_fixcfg(&sii->pub)) {
- /* si_doattach: si_pci_fixcfg failed */
+ if (ai_pci_fixcfg(&sii->pub))
return false;
- }

return true;
}
@@ -589,7 +570,6 @@ static struct si_info *ai_doattach(struct si_info *sii,
savewin = 0;

sii->icbus = pbus;
- sii->buscoreidx = BADIDX;
sii->pcibus = pbus->host_pci;

/* switch to Chipcommon core */
@@ -1248,3 +1228,15 @@ bool ai_is_otp_disabled(struct si_pub *sih)
return false;
}
}
+
+uint ai_get_buscoretype(struct si_pub *sih)
+{
+ struct si_info *sii = (struct si_info *)sih;
+ return sii->buscore->id.id;
+}
+
+uint ai_get_buscorerev(struct si_pub *sih)
+{
+ struct si_info *sii = (struct si_info *)sih;
+ return sii->buscore->id.rev;
+}
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
index f9f88dd..f84c6f7 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
@@ -146,8 +146,6 @@
* public (read-only) portion of aiutils handle returned by si_attach()
*/
struct si_pub {
- uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */
- uint buscorerev; /* buscore rev */
int ccrev; /* chip common core rev */
u32 cccaps; /* chip common capabilities */
int pmurev; /* pmu core rev */
@@ -175,11 +173,10 @@ struct si_info {
struct bcma_bus *icbus; /* handle to soc interconnect bus */
struct pci_dev *pcibus; /* handle to pci bus */
struct pcicore_info *pch; /* PCI/E core handle */
-
+ struct bcma_device *buscore;
struct list_head var_list; /* list of srom variables */

u32 chipst; /* chip status */
- uint buscoreidx; /* buscore index */
};

/*
@@ -224,47 +221,49 @@ extern void ai_chipcontrl_epa4331(struct si_pub *sih, bool on);
/* Enable Ex-PA for 4313 */
extern void ai_epa_4313war(struct si_pub *sih);

-static inline uint ai_get_buscoretype(struct si_pub *sih)
-{
- return sih->buscoretype;
-}
+extern uint ai_get_buscoretype(struct si_pub *sih);
+extern uint ai_get_buscorerev(struct si_pub *sih);

-static inline uint ai_get_buscorerev(struct si_pub *sih)
-{
- return sih->buscorerev;
-}
static inline int ai_get_ccrev(struct si_pub *sih)
{
return sih->ccrev;
}
+
static inline u32 ai_get_cccaps(struct si_pub *sih)
{
return sih->cccaps;
}
+
static inline int ai_get_pmurev(struct si_pub *sih)
{
return sih->pmurev;
}
+
static inline u32 ai_get_pmucaps(struct si_pub *sih)
{
return sih->pmucaps;
}
+
static inline uint ai_get_boardtype(struct si_pub *sih)
{
return sih->boardtype;
}
+
static inline uint ai_get_boardvendor(struct si_pub *sih)
{
return sih->boardvendor;
}
+
static inline uint ai_get_chip_id(struct si_pub *sih)
{
return sih->chip;
}
+
static inline uint ai_get_chiprev(struct si_pub *sih)
{
return sih->chiprev;
}
+
static inline uint ai_get_chippkg(struct si_pub *sih)
{
return sih->chippkg;
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c
index a433041..7fad6dc 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c
@@ -408,7 +408,7 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write,
bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol),
MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL);

- if (pi->sih->buscorerev >= 10) {
+ if (ai_get_buscorerev(pi->sih) >= 10) {
/* new serdes is slower in rw,
* using two layers of reg address mapping
*/
@@ -782,7 +782,6 @@ void pcicore_down(struct pcicore_info *pi, int state)
pcie_extendL1timer(pi, false);
}

-/* precondition: current core is sii->buscoretype */
void pcicore_fixcfg(struct pcicore_info *pi)
{
struct bcma_device *core = pi->core;
--
1.7.5.4



2011-12-12 23:15:51

by Franky Lin

[permalink] [raw]
Subject: [PATCH 04/15] brcm80211: smac: use bcma core access functions in pmu.c

From: Arend van Spriel <[email protected]>

The code in pmu.c now uses the functions provided by BCMA to
access the core registers.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 153 ++++++++++++-------------
1 files changed, 73 insertions(+), 80 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
index ba319f3..9a4d367 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
@@ -140,7 +140,7 @@ static void si_pmu_res_masks(struct si_pub *sih, u32 * pmin, u32 * pmax)
}

static void
-si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs __iomem *cc,
+si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct bcma_device *core,
u8 spuravoid)
{
u32 tmp = 0;
@@ -149,58 +149,65 @@ si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs __iomem *cc,
case BCM43224_CHIP_ID:
case BCM43225_CHIP_ID:
if (spuravoid == 1) {
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
- W_REG(&cc->pllcontrol_data, 0x11500010);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
- W_REG(&cc->pllcontrol_data, 0x000C0C06);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
- W_REG(&cc->pllcontrol_data, 0x0F600a08);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
- W_REG(&cc->pllcontrol_data, 0x00000000);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
- W_REG(&cc->pllcontrol_data, 0x2001E920);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
- W_REG(&cc->pllcontrol_data, 0x88888815);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL0);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x11500010);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL1);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x000C0C06);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL2);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x0F600a08);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL3);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x00000000);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL4);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x2001E920);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL5);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x88888815);
} else {
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
- W_REG(&cc->pllcontrol_data, 0x11100010);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
- W_REG(&cc->pllcontrol_data, 0x000c0c06);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
- W_REG(&cc->pllcontrol_data, 0x03000a08);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
- W_REG(&cc->pllcontrol_data, 0x00000000);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
- W_REG(&cc->pllcontrol_data, 0x200005c0);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
- W_REG(&cc->pllcontrol_data, 0x88888815);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL0);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x11100010);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL1);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x000c0c06);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL2);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x03000a08);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL3);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x00000000);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL4);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x200005c0);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr),
+ PMU1_PLL0_PLLCTL5);
+ bcma_write32(core, CHIPCREGOFFS(pllcontrol_data),
+ 0x88888815);
}
tmp = 1 << 10;
break;

- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0);
- W_REG(&cc->pllcontrol_data, 0x11100008);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1);
- W_REG(&cc->pllcontrol_data, 0x0c000c06);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2);
- W_REG(&cc->pllcontrol_data, 0x03000a08);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3);
- W_REG(&cc->pllcontrol_data, 0x00000000);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4);
- W_REG(&cc->pllcontrol_data, 0x200005c0);
- W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5);
- W_REG(&cc->pllcontrol_data, 0x88888855);
-
- tmp = 1 << 10;
- break;
-
default:
/* bail out */
return;
}

- tmp |= R_REG(&cc->pmucontrol);
- W_REG(&cc->pmucontrol, tmp);
+ bcma_set32(core, CHIPCREGOFFS(pmucontrol), tmp);
}

u16 si_pmu_fast_pwrup_delay(struct si_pub *sih)
@@ -289,12 +296,12 @@ u32 si_pmu_alp_clock(struct si_pub *sih)

void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid)
{
- struct chipcregs __iomem *cc;
+ struct bcma_device *cc;
uint origidx, intr_val;

- /* Remember original core before switch to chipc */
- cc = (struct chipcregs __iomem *)
- ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val);
+ /* switch to chipc */
+ cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
+ ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val);

/* update the pll changes */
si_pmu_spuravoid_pllupdate(sih, cc, spuravoid);
@@ -306,20 +313,16 @@ void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid)
/* initialize PMU */
void si_pmu_init(struct si_pub *sih)
{
- struct chipcregs __iomem *cc;
- uint origidx;
+ struct bcma_device *core;

- /* Remember original core before switch to chipc */
- origidx = ai_coreidx(sih);
- cc = ai_setcoreidx(sih, SI_CC_IDX);
+ /* select chipc */
+ core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);

if (ai_get_pmurev(sih) == 1)
- AND_REG(&cc->pmucontrol, ~PCTL_NOILP_ON_WAIT);
+ bcma_mask32(core, CHIPCREGOFFS(pmucontrol),
+ ~PCTL_NOILP_ON_WAIT);
else if (ai_get_pmurev(sih) >= 2)
- OR_REG(&cc->pmucontrol, PCTL_NOILP_ON_WAIT);
-
- /* Return to original core */
- ai_setcoreidx(sih, origidx);
+ bcma_set32(core, CHIPCREGOFFS(pmucontrol), PCTL_NOILP_ON_WAIT);
}

/* initialize PMU chip controls and other chip level stuff */
@@ -369,13 +372,11 @@ void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq)
/* initialize PMU resources */
void si_pmu_res_init(struct si_pub *sih)
{
- struct chipcregs __iomem *cc;
- uint origidx;
+ struct bcma_device *core;
u32 min_mask = 0, max_mask = 0;

- /* Remember original core before switch to chipc */
- origidx = ai_coreidx(sih);
- cc = ai_setcoreidx(sih, SI_CC_IDX);
+ /* select to chipc */
+ core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);

/* Determine min/max rsrc masks */
si_pmu_res_masks(sih, &min_mask, &max_mask);
@@ -385,55 +386,50 @@ void si_pmu_res_init(struct si_pub *sih)
/* Program max resource mask */

if (max_mask)
- W_REG(&cc->max_res_mask, max_mask);
+ bcma_write32(core, CHIPCREGOFFS(max_res_mask), max_mask);

/* Program min resource mask */

if (min_mask)
- W_REG(&cc->min_res_mask, min_mask);
+ bcma_write32(core, CHIPCREGOFFS(min_res_mask), min_mask);

/* Add some delay; allow resources to come up and settle. */
mdelay(2);
-
- /* Return to original core */
- ai_setcoreidx(sih, origidx);
}

u32 si_pmu_measure_alpclk(struct si_pub *sih)
{
- struct chipcregs __iomem *cc;
- uint origidx;
+ struct bcma_device *core;
u32 alp_khz;

if (ai_get_pmurev(sih) < 10)
return 0;

/* Remember original core before switch to chipc */
- origidx = ai_coreidx(sih);
- cc = ai_setcoreidx(sih, SI_CC_IDX);
+ core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);

- if (R_REG(&cc->pmustatus) & PST_EXTLPOAVAIL) {
+ if (bcma_read32(core, CHIPCREGOFFS(pmustatus)) & PST_EXTLPOAVAIL) {
u32 ilp_ctr, alp_hz;

/*
* Enable the reg to measure the freq,
* in case it was disabled before
*/
- W_REG(&cc->pmu_xtalfreq,
- 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT);
+ bcma_write32(core, CHIPCREGOFFS(pmu_xtalfreq),
+ 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT);

/* Delay for well over 4 ILP clocks */
udelay(1000);

/* Read the latched number of ALP ticks per 4 ILP ticks */
- ilp_ctr =
- R_REG(&cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK;
+ ilp_ctr = bcma_read32(core, CHIPCREGOFFS(pmu_xtalfreq)) &
+ PMU_XTALFREQ_REG_ILPCTR_MASK;

/*
* Turn off the PMU_XTALFREQ_REG_MEASURE_SHIFT
* bit to save power
*/
- W_REG(&cc->pmu_xtalfreq, 0);
+ bcma_write32(core, CHIPCREGOFFS(pmu_xtalfreq), 0);

/* Calculate ALP frequency */
alp_hz = (ilp_ctr * EXT_ILP_HZ) / 4;
@@ -446,8 +442,5 @@ u32 si_pmu_measure_alpclk(struct si_pub *sih)
} else
alp_khz = 0;

- /* Return to original core */
- ai_setcoreidx(sih, origidx);
-
return alp_khz;
}
--
1.7.5.4



2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 02/15] brcm80211: smac: use bcma core access functions in otp.c

From: Arend van Spriel <[email protected]>

The code in otp.c now uses the bcma core access functions to
read the OTP information from the device.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/otp.c | 68 ++++++++------------
.../net/wireless/brcm80211/include/chipcommon.h | 2 +
2 files changed, 28 insertions(+), 42 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/otp.c b/drivers/net/wireless/brcm80211/brcmsmac/otp.c
index 612434e..f1ca126 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/otp.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/otp.c
@@ -77,7 +77,7 @@ struct otp_fn_s {
};

struct otpinfo {
- uint ccrev; /* chipc revision */
+ struct bcma_device *core; /* chipc core */
const struct otp_fn_s *fn; /* OTP functions */
struct si_pub *sih; /* Saved sb handle */

@@ -133,9 +133,10 @@ struct otpinfo {
#define OTP_SZ_FU_144 (144/8) /* 144 bits */

static u16
-ipxotp_otpr(struct otpinfo *oi, struct chipcregs __iomem *cc, uint wn)
+ipxotp_otpr(struct otpinfo *oi, uint wn)
{
- return R_REG(&cc->sromotp[wn]);
+ return bcma_read16(oi->core,
+ CHIPCREGOFFS(sromotp[wn]));
}

/*
@@ -161,19 +162,21 @@ static int ipxotp_max_rgnsz(struct si_pub *sih, int osizew)
return ret;
}

-static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc)
+static void _ipxotp_init(struct otpinfo *oi)
{
uint k;
u32 otpp, st;
+ int ccrev = ai_get_ccrev(oi->sih);
+

/*
* record word offset of General Use Region
* for various chipcommon revs
*/
- if (oi->ccrev == 21 || oi->ccrev == 24
- || oi->ccrev == 27) {
+ if (ccrev == 21 || ccrev == 24
+ || ccrev == 27) {
oi->otpgu_base = REVA4_OTPGU_BASE;
- } else if (oi->ccrev == 36) {
+ } else if (ccrev == 36) {
/*
* OTP size greater than equal to 2KB (128 words),
* otpgu_base is similar to rev23
@@ -182,7 +185,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc)
oi->otpgu_base = REVB8_OTPGU_BASE;
else
oi->otpgu_base = REV36_OTPGU_BASE;
- } else if (oi->ccrev == 23 || oi->ccrev >= 25) {
+ } else if (ccrev == 23 || ccrev >= 25) {
oi->otpgu_base = REVB8_OTPGU_BASE;
}

@@ -190,24 +193,21 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc)
otpp =
OTPP_START_BUSY | ((OTPPOC_INIT << OTPP_OC_SHIFT) & OTPP_OC_MASK);

- W_REG(&cc->otpprog, otpp);
- for (k = 0;
- ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY)
- && (k < OTPP_TRIES); k++)
- ;
+ bcma_write32(oi->core, CHIPCREGOFFS(otpprog), otpp);
+ st = bcma_read32(oi->core, CHIPCREGOFFS(otpprog));
+ for (k = 0; (st & OTPP_START_BUSY) && (k < OTPP_TRIES); k++)
+ st = bcma_read32(oi->core, CHIPCREGOFFS(otpprog));
if (k >= OTPP_TRIES)
return;

/* Read OTP lock bits and subregion programmed indication bits */
- oi->status = R_REG(&cc->otpstatus);
+ oi->status = bcma_read32(oi->core, CHIPCREGOFFS(otpstatus));

if ((ai_get_chip_id(oi->sih) == BCM43224_CHIP_ID)
|| (ai_get_chip_id(oi->sih) == BCM43225_CHIP_ID)) {
u32 p_bits;
- p_bits =
- (ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_P_OFF) &
- OTPGU_P_MSK)
- >> OTPGU_P_SHIFT;
+ p_bits = (ipxotp_otpr(oi, oi->otpgu_base + OTPGU_P_OFF) &
+ OTPGU_P_MSK) >> OTPGU_P_SHIFT;
oi->status |= (p_bits << OTPS_GUP_SHIFT);
}

@@ -220,7 +220,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc)
oi->hwlim = oi->wsize;
if (oi->status & OTPS_GUP_HW) {
oi->hwlim =
- ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_HSB_OFF) / 16;
+ ipxotp_otpr(oi, oi->otpgu_base + OTPGU_HSB_OFF) / 16;
oi->swbase = oi->hwlim;
} else
oi->swbase = oi->hwbase;
@@ -230,7 +230,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc)

if (oi->status & OTPS_GUP_SW) {
oi->swlim =
- ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_SFB_OFF) / 16;
+ ipxotp_otpr(oi, oi->otpgu_base + OTPGU_SFB_OFF) / 16;
oi->fbase = oi->swlim;
} else
oi->fbase = oi->swbase;
@@ -240,11 +240,8 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc)

static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi)
{
- uint idx;
- struct chipcregs __iomem *cc;
-
/* Make sure we're running IPX OTP */
- if (!OTPTYPE_IPX(oi->ccrev))
+ if (!OTPTYPE_IPX(ai_get_ccrev(sih)))
return -EBADE;

/* Make sure OTP is not disabled */
@@ -282,21 +279,13 @@ static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi)
}

/* Retrieve OTP region info */
- idx = ai_coreidx(sih);
- cc = ai_setcoreidx(sih, SI_CC_IDX);
-
- _ipxotp_init(oi, cc);
-
- ai_setcoreidx(sih, idx);
-
+ _ipxotp_init(oi);
return 0;
}

static int
ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen)
{
- uint idx;
- struct chipcregs __iomem *cc;
uint base, i, sz;

/* Validate region selection */
@@ -365,14 +354,10 @@ ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen)
return -EINVAL;
}

- idx = ai_coreidx(oi->sih);
- cc = ai_setcoreidx(oi->sih, SI_CC_IDX);
-
/* Read the data */
for (i = 0; i < sz; i++)
- data[i] = ipxotp_otpr(oi, cc, base + i);
+ data[i] = ipxotp_otpr(oi, base + i);

- ai_setcoreidx(oi->sih, idx);
*wlen = sz;
return 0;
}
@@ -384,14 +369,13 @@ static const struct otp_fn_s ipxotp_fn = {

static int otp_init(struct si_pub *sih, struct otpinfo *oi)
{
-
int ret;

memset(oi, 0, sizeof(struct otpinfo));

- oi->ccrev = ai_get_ccrev(sih);
+ oi->core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);

- if (OTPTYPE_IPX(oi->ccrev))
+ if (OTPTYPE_IPX(ai_get_ccrev(sih)))
oi->fn = &ipxotp_fn;

if (oi->fn == NULL)
@@ -399,7 +383,7 @@ static int otp_init(struct si_pub *sih, struct otpinfo *oi)

oi->sih = sih;

- ret = (oi->fn->init) (sih, oi);
+ ret = (oi->fn->init)(sih, oi);

return ret;
}
diff --git a/drivers/net/wireless/brcm80211/include/chipcommon.h b/drivers/net/wireless/brcm80211/include/chipcommon.h
index fefabc3..f96834a 100644
--- a/drivers/net/wireless/brcm80211/include/chipcommon.h
+++ b/drivers/net/wireless/brcm80211/include/chipcommon.h
@@ -19,6 +19,8 @@

#include "defs.h" /* for PAD macro */

+#define CHIPCREGOFFS(field) offsetof(struct chipcregs, field)
+
struct chipcregs {
u32 chipid; /* 0x0 */
u32 capabilities;
--
1.7.5.4



2011-12-13 20:00:24

by John W. Linville

[permalink] [raw]
Subject: Re: [PATCH 15/15] brcm80211: smac: fix compilation issue with CONFIG_BCM47XX set

To preserve bisectability (just in case!), I'm folding this into the
original patch.

John

On Mon, Dec 12, 2011 at 03:15:13PM -0800, Franky Lin wrote:
> From: Arend van Spriel <[email protected]>
>
> With the BCMA support patches a compilation issue was introduced
> with CONFIG_BCM47XX set. This patch fixes that issue.
>
> Reported-by: Hauke Mehrtens <[email protected]>
> Reviewed-by: Pieter-Paul Giesberts <[email protected]>
> Reviewed-by: Alwin Beukers <[email protected]>
> Signed-off-by: Arend van Spriel <[email protected]>
> Signed-off-by: Franky Lin <[email protected]>
> ---
> .../net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c
> index 687aafa..d2c7fb1 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c
> @@ -292,7 +292,7 @@ void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val)
> bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr);
> bcma_write16(pi->d11core, D11REGOFFS(phyregdata), val);
> if (addr == 0x72)
> - (void)bcma_read16(pi->d11core, D11REGOFFS(phyregdata), val);
> + (void)bcma_read16(pi->d11core, D11REGOFFS(phyregdata));
> #else
> bcma_write32(pi->d11core, D11REGOFFS(phyregaddr), addr | (val << 16));
> if (++pi->phy_wreg >= pi->phy_wreg_limit) {
> --
> 1.7.5.4
>
>
>

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2011-12-12 23:15:57

by Franky Lin

[permalink] [raw]
Subject: [PATCH 08/15] brcm80211: smac: INTROFF/INTRESTORE macros removed

From: Arend van Spriel <[email protected]>

The macros were used to assure that the correct core was accessed in
the ISR, but register access is now done giving the explicit core so
no need to change interrupt state.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 30 ++++----------------
1 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index 3d37b0a..3a78f5f 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -940,14 +940,11 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val)
struct bcma_device *cc;
uint origidx = 0;
u32 w;
- uint intr_val = 0;
struct si_info *sii;

sii = (struct si_info *)sih;
cc = sii->icbus->drv_cc.core;

- INTR_OFF(sii, intr_val);
-
/* save current core index */
origidx = ai_coreidx(&sii->pub);

@@ -962,8 +959,6 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val)
/* restore core index */
ai_setcoreidx(&sii->pub, origidx);

- INTR_RESTORE(sii, intr_val);
-
return w;
}

@@ -1086,13 +1081,10 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih)
struct bcma_device *cc;
uint slowminfreq;
u16 fpdelay;
- uint intr_val = 0;

sii = (struct si_info *)sih;
if (ai_get_cccaps(sih) & CC_CAP_PMU) {
- INTR_OFF(sii, intr_val);
fpdelay = si_pmu_fast_pwrup_delay(sih);
- INTR_RESTORE(sii, intr_val);
return fpdelay;
}

@@ -1100,18 +1092,12 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih)
return 0;

fpdelay = 0;
- INTR_OFF(sii, intr_val);
cc = ai_findcore(sih, CC_CORE_ID, 0);
- if (cc == NULL)
- goto done;
-
-
- slowminfreq = ai_slowclk_freq(sih, false, cc);
- fpdelay = (((bcma_read32(cc, CHIPCREGOFFS(pll_on_delay)) + 2) * 1000000)
- + (slowminfreq - 1)) / slowminfreq;
-
- done:
- INTR_RESTORE(sii, intr_val);
+ if (cc) {
+ slowminfreq = ai_slowclk_freq(sih, false, cc);
+ fpdelay = (((bcma_read32(cc, CHIPCREGOFFS(pll_on_delay)) + 2)
+ * 1000000) + (slowminfreq - 1)) / slowminfreq;
+ }
return fpdelay;
}

@@ -1183,18 +1169,16 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
{
struct bcma_device *cc;
u32 scc;
- uint intr_val = 0;

/* chipcommon cores prior to rev6 don't support dynamic clock control */
if (ai_get_ccrev(&sii->pub) < 6)
return false;

- INTR_OFF(sii, intr_val);
cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0);

if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) &&
(ai_get_ccrev(&sii->pub) < 20))
- goto done;
+ return mode == CLK_FAST;

switch (mode) {
case CLK_FAST: /* FORCEHT, fast (pll) clock */
@@ -1248,8 +1232,6 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
break;
}

- done:
- INTR_RESTORE(sii, intr_val);
return mode == CLK_FAST;
}

--
1.7.5.4



2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 11/15] brcm80211: smac: remove mapped core related function from aiutils.c

From: Arend van Spriel <[email protected]>

In aiutils.c the selected core was maintained by its index number. This
is obsolete using BCMA functions so several functions using that index
have been removed.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 121 +--------------------
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 7 --
drivers/net/wireless/brcm80211/brcmsmac/dma.c | 101 +++++++++---------
drivers/net/wireless/brcm80211/brcmsmac/main.c | 14 +--
4 files changed, 59 insertions(+), 184 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index a99a163..f78350a 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -477,50 +477,6 @@ static void ai_scan(struct si_pub *sih, struct bcma_bus *bus)
}
}

-static struct bcma_device *ai_find_bcma_core(struct si_pub *sih, uint coreidx)
-{
- struct si_info *sii = (struct si_info *)sih;
- struct bcma_device *core;
-
- list_for_each_entry(core, &sii->icbus->cores, list) {
- if (core->core_index == coreidx)
- return core;
- }
- return NULL;
-}
-/*
- * This function changes the logical "focus" to the indicated core.
- * Return the current core's virtual address. Since each core starts with the
- * same set of registers (BIST, clock control, etc), the returned address
- * contains the first register of this 'common' register block (not to be
- * confused with 'common core').
- */
-void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx)
-{
- struct si_info *sii = (struct si_info *)sih;
- struct bcma_device *core;
-
- if (sii->curidx != coreidx) {
- core = ai_find_bcma_core(sih, coreidx);
- if (core == NULL)
- return NULL;
-
- (void)bcma_aread32(core, BCMA_IOST);
- sii->curidx = coreidx;
- }
- return sii->curmap;
-}
-
-uint ai_corerev(struct si_pub *sih)
-{
- struct si_info *sii;
- u32 cib;
-
- sii = (struct si_info *)sih;
- cib = sii->cib[sii->curidx];
- return (cib & CIB_REV_MASK) >> CIB_REV_SHIFT;
-}
-
/* return true if PCIE capability exists in the pci config space */
static bool ai_ispcie(struct si_info *sii)
{
@@ -579,9 +535,8 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
for (i = 0; i < sii->numcores; i++) {
uint cid, crev;

- ai_setcoreidx(&sii->pub, i);
- cid = ai_coreid(&sii->pub);
- crev = ai_corerev(&sii->pub);
+ cid = sii->coreid[i];
+ crev = (sii->cib[i] & CIB_REV_MASK) >> CIB_REV_SHIFT;

if (cid == PCI_CORE_ID) {
pciidx = i;
@@ -804,22 +759,6 @@ void ai_detach(struct si_pub *sih)
kfree(sii);
}

-uint ai_coreid(struct si_pub *sih)
-{
- struct si_info *sii;
-
- sii = (struct si_info *)sih;
- return sii->coreid[sii->curidx];
-}
-
-uint ai_coreidx(struct si_pub *sih)
-{
- struct si_info *sii;
-
- sii = (struct si_info *)sih;
- return sii->curidx;
-}
-
/* return index of coreid or BADIDX if not found */
struct bcma_device *ai_findcore(struct si_pub *sih, u16 coreid, u16 coreunit)
{
@@ -842,45 +781,17 @@ struct bcma_device *ai_findcore(struct si_pub *sih, u16 coreid, u16 coreunit)
}

/*
- * This function changes logical "focus" to the indicated core;
- * must be called with interrupts off.
- * Moreover, callers should keep interrupts off during switching
- * out of and back to d11 core.
- */
-void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit)
-{
- struct bcma_device *core;
-
- core = ai_findcore(sih, coreid, coreunit);
- if (core == NULL)
- return NULL;
-
- return ai_setcoreidx(sih, core->core_index);
-}
-
-/*
- * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set
- * operation, switch back to the original core, and return the new value.
- *
- * When using the silicon backplane, no fiddling with interrupts or core
- * switches is needed.
- *
- * Also, when using pci/pcie, we can optimize away the core switching for pci
- * registers and (on newer pci cores) chipcommon registers.
+ * read/modify chipcommon core register.
*/
uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val)
{
struct bcma_device *cc;
- uint origidx = 0;
u32 w;
struct si_info *sii;

sii = (struct si_info *)sih;
cc = sii->icbus->drv_cc.core;

- /* save current core index */
- origidx = ai_coreidx(&sii->pub);
-
/* mask and set */
if (mask || val) {
bcma_maskset32(cc, regoff, ~mask, val);
@@ -889,9 +800,6 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val)
/* readback */
w = bcma_read32(cc, regoff);

- /* restore core index */
- ai_setcoreidx(&sii->pub, origidx);
-
return w;
}

@@ -1237,20 +1145,10 @@ void ai_pci_down(struct si_pub *sih)
void ai_pci_setup(struct si_pub *sih, uint coremask)
{
struct si_info *sii;
- struct sbpciregs __iomem *regs = NULL;
u32 w;
- uint idx = 0;

sii = (struct si_info *)sih;

- if (PCI(sih)) {
- /* get current core index */
- idx = sii->curidx;
-
- /* switch over to pci core */
- regs = ai_setcoreidx(sih, sii->buscoreidx);
- }
-
/*
* Enable sb->pci interrupts. Assume
* PCI rev 2.3 support was added in pci core rev 6 and things changed..
@@ -1264,9 +1162,6 @@ void ai_pci_setup(struct si_pub *sih, uint coremask)

if (PCI(sih)) {
pcicore_pci_setup(sii->pch);
-
- /* switch back to previous core */
- ai_setcoreidx(sih, idx);
}
}

@@ -1276,21 +1171,11 @@ void ai_pci_setup(struct si_pub *sih, uint coremask)
*/
int ai_pci_fixcfg(struct si_pub *sih)
{
- uint origidx;
- void __iomem *regs = NULL;
struct si_info *sii = (struct si_info *)sih;

/* Fixup PI in SROM shadow area to enable the correct PCI core access */
- /* save the current index */
- origidx = ai_coreidx(&sii->pub);
-
/* check 'pi' is correct and fix it if not */
- regs = ai_setcore(&sii->pub, ai_get_buscoretype(sih), 0);
pcicore_fixcfg(sii->pch);
-
- /* restore the original index */
- ai_setcoreidx(&sii->pub, origidx);
-
pcicore_hwup(sii->pch);
return 0;
}
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
index e37c9f4..6742758 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
@@ -221,19 +221,12 @@ struct si_info {
/* AMBA Interconnect exported externs */
extern struct bcma_device *ai_findcore(struct si_pub *sih,
u16 coreid, u16 coreunit);
-extern uint ai_coreidx(struct si_pub *sih);
-extern uint ai_corerev(struct si_pub *sih);
extern u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val);

/* === exported functions === */
extern struct si_pub *ai_attach(struct bcma_bus *pbus);
extern void ai_detach(struct si_pub *sih);
-extern uint ai_coreid(struct si_pub *sih);
-extern uint ai_corerev(struct si_pub *sih);
extern uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val);
-extern uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit);
-extern void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx);
-extern void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit);
extern void ai_pci_setup(struct si_pub *sih, uint coremask);
extern void ai_clkctl_init(struct si_pub *sih);
extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c
index dab04bb..b4cf617 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c
@@ -227,7 +227,7 @@ struct dma_info {
uint *msg_level; /* message level pointer */
char name[MAXNAMEL]; /* callers name for diag msgs */

- struct bcma_device *d11core;
+ struct bcma_device *core;
struct device *dmadev;

bool dma64; /* this dma engine is operating in 64-bit mode */
@@ -383,15 +383,15 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags)
if (dmactrlflags & DMA_CTRL_PEN) {
u32 control;

- control = bcma_read32(di->d11core, DMA64TXREGOFFS(di, control));
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, control),
+ control = bcma_read32(di->core, DMA64TXREGOFFS(di, control));
+ bcma_write32(di->core, DMA64TXREGOFFS(di, control),
control | D64_XC_PD);
- if (bcma_read32(di->d11core, DMA64TXREGOFFS(di, control)) &
+ if (bcma_read32(di->core, DMA64TXREGOFFS(di, control)) &
D64_XC_PD)
/* We *can* disable it so it is supported,
* restore control register
*/
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, control),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, control),
control);
else
/* Not supported, don't allow it to be enabled */
@@ -406,9 +406,9 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags)
static bool _dma64_addrext(struct dma_info *di, uint ctrl_offset)
{
u32 w;
- bcma_set32(di->d11core, ctrl_offset, D64_XC_AE);
- w = bcma_read32(di->d11core, ctrl_offset);
- bcma_mask32(di->d11core, ctrl_offset, ~D64_XC_AE);
+ bcma_set32(di->core, ctrl_offset, D64_XC_AE);
+ w = bcma_read32(di->core, ctrl_offset);
+ bcma_mask32(di->core, ctrl_offset, ~D64_XC_AE);
return (w & D64_XC_AE) == D64_XC_AE;
}

@@ -442,13 +442,13 @@ static bool _dma_descriptor_align(struct dma_info *di)

/* Check to see if the descriptors need to be aligned on 4K/8K or not */
if (di->d64txregbase != 0) {
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow), 0xff0);
- addrl = bcma_read32(di->d11core, DMA64TXREGOFFS(di, addrlow));
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow), 0xff0);
+ addrl = bcma_read32(di->core, DMA64TXREGOFFS(di, addrlow));
if (addrl != 0)
return false;
} else if (di->d64rxregbase != 0) {
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow), 0xff0);
- addrl = bcma_read32(di->d11core, DMA64RXREGOFFS(di, addrlow));
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow), 0xff0);
+ addrl = bcma_read32(di->core, DMA64RXREGOFFS(di, addrlow));
if (addrl != 0)
return false;
}
@@ -565,12 +565,13 @@ static bool _dma_alloc(struct dma_info *di, uint direction)
}

struct dma_pub *dma_attach(char *name, struct si_pub *sih,
- struct bcma_device *d11core,
+ struct bcma_device *core,
uint txregbase, uint rxregbase, uint ntxd, uint nrxd,
uint rxbufsize, int rxextheadroom,
uint nrxpost, uint rxoffset, uint *msg_level)
{
struct dma_info *di;
+ u8 rev = core->id.rev;
uint size;

/* allocate private info structure */
@@ -582,10 +583,10 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih,


di->dma64 =
- ((bcma_aread32(d11core, BCMA_IOST) & SISF_DMA64) == SISF_DMA64);
+ ((bcma_aread32(core, BCMA_IOST) & SISF_DMA64) == SISF_DMA64);

/* init dma reg info */
- di->d11core = d11core;
+ di->core = core;
di->d64txregbase = txregbase;
di->d64rxregbase = rxregbase;

@@ -606,7 +607,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih,
strncpy(di->name, name, MAXNAMEL);
di->name[MAXNAMEL - 1] = '\0';

- di->dmadev = d11core->dma_dev;
+ di->dmadev = core->dma_dev;

/* save tunables */
di->ntxd = (u16) ntxd;
@@ -638,11 +639,11 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih,
di->dataoffsetlow = di->ddoffsetlow;
di->dataoffsethigh = di->ddoffsethigh;
/* WAR64450 : DMACtl.Addr ext fields are not supported in SDIOD core. */
- if ((ai_coreid(sih) == SDIOD_CORE_ID)
- && ((ai_corerev(sih) > 0) && (ai_corerev(sih) <= 2)))
+ if ((core->id.id == SDIOD_CORE_ID)
+ && ((rev > 0) && (rev <= 2)))
di->addrext = 0;
- else if ((ai_coreid(sih) == I2S_CORE_ID) &&
- ((ai_corerev(sih) == 0) || (ai_corerev(sih) == 1)))
+ else if ((core->id.id == I2S_CORE_ID) &&
+ ((rev == 0) || (rev == 1)))
di->addrext = 0;
else
di->addrext = _dma_isaddrext(di);
@@ -792,14 +793,14 @@ _dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa)
if ((di->ddoffsetlow == 0)
|| !(pa & PCI32ADDR_HIGH)) {
if (direction == DMA_TX) {
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow),
pa + di->ddoffsetlow);
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrhigh),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrhigh),
di->ddoffsethigh);
} else {
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow),
pa + di->ddoffsetlow);
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrhigh),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrhigh),
di->ddoffsethigh);
}
} else {
@@ -811,18 +812,18 @@ _dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa)
pa &= ~PCI32ADDR_HIGH;

if (direction == DMA_TX) {
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow),
pa + di->ddoffsetlow);
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrhigh),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrhigh),
di->ddoffsethigh);
- bcma_maskset32(di->d11core, DMA64TXREGOFFS(di, control),
+ bcma_maskset32(di->core, DMA64TXREGOFFS(di, control),
D64_XC_AE, (ae << D64_XC_AE_SHIFT));
} else {
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow),
pa + di->ddoffsetlow);
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrhigh),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrhigh),
di->ddoffsethigh);
- bcma_maskset32(di->d11core, DMA64RXREGOFFS(di, control),
+ bcma_maskset32(di->core, DMA64RXREGOFFS(di, control),
D64_RC_AE, (ae << D64_RC_AE_SHIFT));
}
}
@@ -835,7 +836,7 @@ static void _dma_rxenable(struct dma_info *di)

DMA_TRACE("%s:\n", di->name);

- control = D64_RC_RE | (bcma_read32(di->d11core,
+ control = D64_RC_RE | (bcma_read32(di->core,
DMA64RXREGOFFS(di, control)) &
D64_RC_AE);

@@ -845,7 +846,7 @@ static void _dma_rxenable(struct dma_info *di)
if (dmactrlflags & DMA_CTRL_ROC)
control |= D64_RC_OC;

- bcma_write32(di->d11core, DMA64RXREGOFFS(di, control),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, control),
((di->rxoffset << D64_RC_RO_SHIFT) | control));
}

@@ -888,7 +889,7 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall)
return NULL;

curr =
- B2I(((bcma_read32(di->d11core,
+ B2I(((bcma_read32(di->core,
DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) -
di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc);

@@ -971,7 +972,7 @@ int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list)
if (resid > 0) {
uint cur;
cur =
- B2I(((bcma_read32(di->d11core,
+ B2I(((bcma_read32(di->core,
DMA64RXREGOFFS(di, status0)) &
D64_RS0_CD_MASK) - di->rcvptrbase) &
D64_RS0_CD_MASK, struct dma64desc);
@@ -1004,9 +1005,9 @@ static bool dma64_rxidle(struct dma_info *di)
if (di->nrxd == 0)
return true;

- return ((bcma_read32(di->d11core,
+ return ((bcma_read32(di->core,
DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) ==
- (bcma_read32(di->d11core, DMA64RXREGOFFS(di, ptr)) &
+ (bcma_read32(di->core, DMA64RXREGOFFS(di, ptr)) &
D64_RS0_CD_MASK));
}

@@ -1090,7 +1091,7 @@ bool dma_rxfill(struct dma_pub *pub)
di->rxout = rxout;

/* update the chip lastdscr pointer */
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, ptr),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, ptr),
di->rcvptrbase + I2B(rxout, struct dma64desc));

return ring_empty;
@@ -1151,7 +1152,7 @@ void dma_txinit(struct dma_pub *pub)

if ((di->dma.dmactrlflags & DMA_CTRL_PEN) == 0)
control |= D64_XC_PD;
- bcma_set32(di->d11core, DMA64TXREGOFFS(di, control), control);
+ bcma_set32(di->core, DMA64TXREGOFFS(di, control), control);

/* DMA engine with alignment requirement requires table to be inited
* before enabling the engine
@@ -1169,7 +1170,7 @@ void dma_txsuspend(struct dma_pub *pub)
if (di->ntxd == 0)
return;

- bcma_set32(di->d11core, DMA64TXREGOFFS(di, control), D64_XC_SE);
+ bcma_set32(di->core, DMA64TXREGOFFS(di, control), D64_XC_SE);
}

void dma_txresume(struct dma_pub *pub)
@@ -1181,7 +1182,7 @@ void dma_txresume(struct dma_pub *pub)
if (di->ntxd == 0)
return;

- bcma_mask32(di->d11core, DMA64TXREGOFFS(di, control), ~D64_XC_SE);
+ bcma_mask32(di->core, DMA64TXREGOFFS(di, control), ~D64_XC_SE);
}

bool dma_txsuspended(struct dma_pub *pub)
@@ -1189,7 +1190,7 @@ bool dma_txsuspended(struct dma_pub *pub)
struct dma_info *di = (struct dma_info *)pub;

return (di->ntxd == 0) ||
- ((bcma_read32(di->d11core,
+ ((bcma_read32(di->core,
DMA64TXREGOFFS(di, control)) & D64_XC_SE) ==
D64_XC_SE);
}
@@ -1224,16 +1225,16 @@ bool dma_txreset(struct dma_pub *pub)
return true;

/* suspend tx DMA first */
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), D64_XC_SE);
+ bcma_write32(di->core, DMA64TXREGOFFS(di, control), D64_XC_SE);
SPINWAIT(((status =
- (bcma_read32(di->d11core, DMA64TXREGOFFS(di, status0)) &
+ (bcma_read32(di->core, DMA64TXREGOFFS(di, status0)) &
D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED) &&
(status != D64_XS0_XS_IDLE) && (status != D64_XS0_XS_STOPPED),
10000);

- bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), 0);
+ bcma_write32(di->core, DMA64TXREGOFFS(di, control), 0);
SPINWAIT(((status =
- (bcma_read32(di->d11core, DMA64TXREGOFFS(di, status0)) &
+ (bcma_read32(di->core, DMA64TXREGOFFS(di, status0)) &
D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED), 10000);

/* wait for the last transaction to complete */
@@ -1250,9 +1251,9 @@ bool dma_rxreset(struct dma_pub *pub)
if (di->nrxd == 0)
return true;

- bcma_write32(di->d11core, DMA64RXREGOFFS(di, control), 0);
+ bcma_write32(di->core, DMA64RXREGOFFS(di, control), 0);
SPINWAIT(((status =
- (bcma_read32(di->d11core, DMA64RXREGOFFS(di, status0)) &
+ (bcma_read32(di->core, DMA64RXREGOFFS(di, status0)) &
D64_RS0_RS_MASK)) != D64_RS0_RS_DISABLED), 10000);

return status == D64_RS0_RS_DISABLED;
@@ -1315,7 +1316,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p, bool commit)

/* kick the chip */
if (commit)
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, ptr),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, ptr),
di->xmtptrbase + I2B(txout, struct dma64desc));

/* tx flow control */
@@ -1363,14 +1364,14 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range)
if (range == DMA_RANGE_ALL)
end = di->txout;
else {
- end = (u16) (B2I(((bcma_read32(di->d11core,
+ end = (u16) (B2I(((bcma_read32(di->core,
DMA64TXREGOFFS(di, status0)) &
D64_XS0_CD_MASK) - di->xmtptrbase) &
D64_XS0_CD_MASK, struct dma64desc));

if (range == DMA_RANGE_TRANSFERED) {
active_desc =
- (u16)(bcma_read32(di->d11core,
+ (u16)(bcma_read32(di->core,
DMA64TXREGOFFS(di, status1)) &
D64_XS1_AD_MASK);
active_desc =
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index 1c75e2f..f7ed340 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -1953,12 +1953,11 @@ static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw)
flags |= SICF_PCLKE;

/*
+ * TODO: test suspend/resume
+ *
* AI chip doesn't restore bar0win2 on
* hibernation/resume, need sw fixup
*/
- if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) ||
- (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID))
- (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0);

bcma_core_enable(wlc_hw->d11core, flags);
brcms_c_mctrl_reset(wlc_hw);
@@ -4484,8 +4483,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core,
wlc_hw->vendorid = pcidev->vendor;
wlc_hw->deviceid = pcidev->device;

- /* set bar0 window to point at D11 core */
- (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0);
wlc_hw->d11core = core;
wlc_hw->corerev = core->id.rev;

@@ -4606,7 +4603,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core,
wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G;
wlc->band->bandunit = j;
wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G;
- wlc->core->coreidx = ai_coreidx(wlc_hw->sih);
+ wlc->core->coreidx = core->core_index;

wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap));
wlc_hw->machwcap_backup = wlc_hw->machwcap;
@@ -5055,12 +5052,11 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw)
ai_pci_fixcfg(wlc_hw->sih);

/*
+ * TODO: test suspend/resume
+ *
* AI chip doesn't restore bar0win2 on
* hibernation/resume, need sw fixup
*/
- if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) ||
- (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID))
- (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0);

/*
* Inform phy that a POR reset has occurred so
--
1.7.5.4



2011-12-13 12:59:33

by Julian Wollrath

[permalink] [raw]
Subject: Re: [PATCH 00/15] brcm80211: the rest of smac bcma switch series

Hi,

> With this set of patches, my BCM43224 works with brcmsmac.
here its also working, with one exception, if I switch the BCM43224 with the
external switch on my laptop of and then start linux, the laptop freezes
quietly before completing the boot process. The only complaint a good while
before freezing is
[ 12.298798] brcms_module_init: register returned 0

This problem, without the message above, also occured without this two patch
series, which enable the use of bcma.


With best regards
Julian Wollrath

2011-12-14 01:12:05

by Franky Lin

[permalink] [raw]
Subject: Re: [PATCH 15/15] brcm80211: smac: fix compilation issue with CONFIG_BCM47XX set

On 12/13/2011 11:59 AM, John W. Linville wrote:
> To preserve bisectability (just in case!), I'm folding this into the
> original patch.
>
> John

Thanks John.

Franky


2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 03/15] brcm80211: smac: use bcma core access function in srom.c

From: Arend van Spriel <[email protected]>

The code in srom.c now uses the core access function provided by
BCMA so no need to pass __iomem pointer any longer.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 2 +-
drivers/net/wireless/brcm80211/brcmsmac/srom.c | 50 ++++++--------------
drivers/net/wireless/brcm80211/brcmsmac/srom.h | 2 +-
3 files changed, 17 insertions(+), 37 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index a54cf32..bb12ebc 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -725,7 +725,7 @@ static struct si_info *ai_doattach(struct si_info *sii,
goto exit;

/* Init nvram from sprom/otp if they exist */
- if (srom_var_init(&sii->pub, cc))
+ if (srom_var_init(&sii->pub))
goto exit;

ai_nvram_process(sii);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c
index 95eb620..6109215 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c
@@ -586,17 +586,6 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = {
* shared between devices. */
static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE];

-static u8 __iomem *
-srom_window_address(struct si_pub *sih, u8 __iomem *curmap)
-{
- if (ai_get_ccrev(sih) < 32)
- return curmap + PCI_BAR0_SPROM_OFFSET;
- if (ai_get_cccaps(sih) & CC_CAP_SROM)
- return curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP;
-
- return NULL;
-}
-
static uint mask_shift(u16 mask)
{
uint i;
@@ -779,17 +768,27 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list)
* Return 0 on success, nonzero on error.
*/
static int
-sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff,
- u16 *buf, uint nwords, bool check_crc)
+sprom_read_pci(struct si_pub *sih, u16 *buf, uint nwords, bool check_crc)
{
int err = 0;
uint i;
u8 *bbuf = (u8 *)buf; /* byte buffer */
uint nbytes = nwords << 1;
+ struct bcma_device *core;
+ uint sprom_offset;
+
+ /* determine core to read */
+ if (ai_get_ccrev(sih) < 32) {
+ core = ai_findcore(sih, BCMA_CORE_80211, 0);
+ sprom_offset = PCI_BAR0_SPROM_OFFSET;
+ } else {
+ core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
+ sprom_offset = CHIPCREGOFFS(sromotp);
+ }

/* read the sprom in bytes */
for (i = 0; i < nbytes; i++)
- bbuf[i] = readb(sprom+i);
+ bbuf[i] = bcma_read8(core, sprom_offset+i);

if (buf[0] == 0xffff)
/*
@@ -851,10 +850,9 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords)
* Initialize nonvolatile variable table from sprom.
* Return 0 on success, nonzero on error.
*/
-static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap)
+int srom_var_init(struct si_pub *sih)
{
u16 *srom;
- u8 __iomem *sromwindow;
u8 sromrev = 0;
u32 sr;
int err = 0;
@@ -866,12 +864,9 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap)
if (!srom)
return -ENOMEM;

- sromwindow = srom_window_address(sih, curmap);
-
crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY);
if (ai_is_sprom_available(sih)) {
- err = sprom_read_pci(sih, sromwindow, 0, srom,
- SROM4_WORDS, true);
+ err = sprom_read_pci(sih, srom, SROM4_WORDS, true);

if (err == 0)
/* srom read and passed crc */
@@ -921,21 +916,6 @@ void srom_free_vars(struct si_pub *sih)
kfree(entry);
}
}
-/*
- * Initialize local vars from the right source for this platform.
- * Return 0 on success, nonzero on error.
- */
-int srom_var_init(struct si_pub *sih, void __iomem *curmap)
-{
- uint len;
-
- len = 0;
-
- if (curmap != NULL)
- return initvars_srom_pci(sih, curmap);
-
- return -EINVAL;
-}

/*
* Search the name=value vars for a specific one and return its value.
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.h b/drivers/net/wireless/brcm80211/brcmsmac/srom.h
index c81df97..f2a58f2 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/srom.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.h
@@ -20,7 +20,7 @@
#include "types.h"

/* Prototypes */
-extern int srom_var_init(struct si_pub *sih, void __iomem *curmap);
+extern int srom_var_init(struct si_pub *sih);
extern void srom_free_vars(struct si_pub *sih);

extern int srom_read(struct si_pub *sih, uint bus, void *curmap,
--
1.7.5.4



2011-12-12 23:15:50

by Franky Lin

[permalink] [raw]
Subject: [PATCH 01/15] brcm80211: smac: change ai_findcoreidx() to ai_findcore()

From: Arend van Spriel <[email protected]>

Instead of returning the core index the function now returns
the bcma device for the requested core id. This function is
now exposed in the header file.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 14 +++++++-------
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 2 ++
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index 8d3829a..a54cf32 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -884,7 +884,7 @@ uint ai_coreidx(struct si_pub *sih)
}

/* return index of coreid or BADIDX if not found */
-uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit)
+struct bcma_device *ai_findcore(struct si_pub *sih, u16 coreid, u16 coreunit)
{
struct bcma_device *core;
struct si_info *sii;
@@ -897,11 +897,11 @@ uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit)
list_for_each_entry(core, &sii->icbus->cores, list)
if (core->id.id == coreid) {
if (found == coreunit)
- return core->core_index;
+ return core;
found++;
}

- return BADIDX;
+ return NULL;
}

/*
@@ -912,13 +912,13 @@ uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit)
*/
void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit)
{
- uint idx;
+ struct bcma_device *core;

- idx = ai_findcoreidx(sih, coreid, coreunit);
- if (idx >= SI_MAXCORES)
+ core = ai_findcore(sih, coreid, coreunit);
+ if (core == NULL)
return NULL;

- return ai_setcoreidx(sih, idx);
+ return ai_setcoreidx(sih, core->core_index);
}

/* Turn off interrupt as required by ai_setcore, before switch core */
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
index 67b378f..b0b0bff 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
@@ -219,6 +219,8 @@ struct si_info {


/* AMBA Interconnect exported externs */
+extern struct bcma_device *ai_findcore(struct si_pub *sih,
+ u16 coreid, u16 coreunit);
extern uint ai_coreidx(struct si_pub *sih);
extern uint ai_corerev(struct si_pub *sih);
extern u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val);
--
1.7.5.4



2011-12-13 04:41:15

by Franky Lin

[permalink] [raw]
Subject: Re: [PATCH 00/15] brcm80211: the rest of smac bcma switch series

On 12/12/2011 08:25 PM, Larry Finger wrote:
> On 12/12/2011 05:14 PM, Franky Lin wrote:
>> Hi John,
>>
>> This train contains the rest of patch series switching brcmsmac to use
>> bcma bus interface.
>> It depends on the following patch set:
>> [PATCH 00/23] brcm80211: fullmac 4430 support and softmac switch to bcma
>> Message-ID:<[email protected]>
>
> With this set of patches, my BCM43224 works with brcmsmac.
>
> Larry
>

Glad to hear that. Thanks for testing it.

Franky


2011-12-12 23:15:57

by Franky Lin

[permalink] [raw]
Subject: [PATCH 07/15] brcm80211: smac: remove empty or unused functions from pmu.c

From: Arend van Spriel <[email protected]>

A number of functions in pmu.c are not used or adding no functionality
at all. These have been removed.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 7 +--
drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 57 ---------------------
drivers/net/wireless/brcm80211/brcmsmac/pmu.h | 3 -
3 files changed, 1 insertions(+), 66 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index 7e5d41b..3d37b0a 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -721,14 +721,9 @@ static struct si_info *ai_doattach(struct si_info *sii,

/* PMU specific initializations */
if (ai_get_cccaps(sih) & CC_CAP_PMU) {
- u32 xtalfreq;
si_pmu_init(sih);
- si_pmu_chip_init(sih);
-
- xtalfreq = si_pmu_measure_alpclk(sih);
- si_pmu_pll_init(sih, xtalfreq);
+ (void)si_pmu_measure_alpclk(sih);
si_pmu_res_init(sih);
- si_pmu_swreg_init(sih);
}

/* setup the GPIO based LED powersave register */
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
index 9a4d367..d972e9c 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
@@ -227,19 +227,6 @@ u16 si_pmu_fast_pwrup_delay(struct si_pub *sih)
return (u16) delay;
}

-void si_pmu_sprom_enable(struct si_pub *sih, bool enable)
-{
- struct chipcregs __iomem *cc;
- uint origidx;
-
- /* Remember original core before switch to chipc */
- origidx = ai_coreidx(sih);
- cc = ai_setcoreidx(sih, SI_CC_IDX);
-
- /* Return to original core */
- ai_setcoreidx(sih, origidx);
-}
-
/* Read/write a chipcontrol reg */
u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val)
{
@@ -325,50 +312,6 @@ void si_pmu_init(struct si_pub *sih)
bcma_set32(core, CHIPCREGOFFS(pmucontrol), PCTL_NOILP_ON_WAIT);
}

-/* initialize PMU chip controls and other chip level stuff */
-void si_pmu_chip_init(struct si_pub *sih)
-{
- uint origidx;
-
- /* Gate off SPROM clock and chip select signals */
- si_pmu_sprom_enable(sih, false);
-
- /* Remember original core */
- origidx = ai_coreidx(sih);
-
- /* Return to original core */
- ai_setcoreidx(sih, origidx);
-}
-
-/* initialize PMU switch/regulators */
-void si_pmu_swreg_init(struct si_pub *sih)
-{
-}
-
-/* initialize PLL */
-void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq)
-{
- struct chipcregs __iomem *cc;
- uint origidx;
-
- /* Remember original core before switch to chipc */
- origidx = ai_coreidx(sih);
- cc = ai_setcoreidx(sih, SI_CC_IDX);
-
- switch (ai_get_chip_id(sih)) {
- case BCM4313_CHIP_ID:
- case BCM43224_CHIP_ID:
- case BCM43225_CHIP_ID:
- /* ??? */
- break;
- default:
- break;
- }
-
- /* Return to original core */
- ai_setcoreidx(sih, origidx);
-}
-
/* initialize PMU resources */
void si_pmu_res_init(struct si_pub *sih)
{
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
index 3a08c62..dcd893c 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
@@ -29,10 +29,7 @@ extern void si_pmu_pllupd(struct si_pub *sih);
extern void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid);
extern u32 si_pmu_pllcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val);
extern void si_pmu_init(struct si_pub *sih);
-extern void si_pmu_chip_init(struct si_pub *sih);
-extern void si_pmu_pll_init(struct si_pub *sih, u32 xtalfreq);
extern void si_pmu_res_init(struct si_pub *sih);
-extern void si_pmu_swreg_init(struct si_pub *sih);
extern u32 si_pmu_measure_alpclk(struct si_pub *sih);

#endif /* _BRCM_PMU_H_ */
--
1.7.5.4



2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 15/15] brcm80211: smac: fix compilation issue with CONFIG_BCM47XX set

From: Arend van Spriel <[email protected]>

With the BCMA support patches a compilation issue was introduced
with CONFIG_BCM47XX set. This patch fixes that issue.

Reported-by: Hauke Mehrtens <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
.../net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c
index 687aafa..d2c7fb1 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c
@@ -292,7 +292,7 @@ void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val)
bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr);
bcma_write16(pi->d11core, D11REGOFFS(phyregdata), val);
if (addr == 0x72)
- (void)bcma_read16(pi->d11core, D11REGOFFS(phyregdata), val);
+ (void)bcma_read16(pi->d11core, D11REGOFFS(phyregdata));
#else
bcma_write32(pi->d11core, D11REGOFFS(phyregaddr), addr | (val << 16));
if (++pi->phy_wreg >= pi->phy_wreg_limit) {
--
1.7.5.4



2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 09/15] brcm80211: smac: remove interrupt disable callback functionality

From: Arend van Spriel <[email protected]>

There is no need to interrupt disable/enable functionality any
longer due to BCMA usage assures the correct core is accessed
in any context.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 27 ---------------------
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 4 ---
drivers/net/wireless/brcm80211/brcmsmac/main.c | 26 --------------------
3 files changed, 0 insertions(+), 57 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index 3a78f5f..86e33f9 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -818,33 +818,6 @@ void ai_detach(struct si_pub *sih)
kfree(sii);
}

-/* register driver interrupt disabling and restoring callback functions */
-void
-ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn,
- void *intrsrestore_fn,
- void *intrsenabled_fn, void *intr_arg)
-{
- struct si_info *sii;
-
- sii = (struct si_info *)sih;
- sii->intr_arg = intr_arg;
- sii->intrsoff_fn = (u32 (*)(void *)) intrsoff_fn;
- sii->intrsrestore_fn = (void (*) (void *, u32)) intrsrestore_fn;
- sii->intrsenabled_fn = (bool (*)(void *)) intrsenabled_fn;
- /* save current core id. when this function called, the current core
- * must be the core which provides driver functions(il, et, wl, etc.)
- */
- sii->dev_coreid = sii->coreid[sii->curidx];
-}
-
-void ai_deregister_intr_callback(struct si_pub *sih)
-{
- struct si_info *sii;
-
- sii = (struct si_info *)sih;
- sii->intrsoff_fn = NULL;
-}
-
uint ai_coreid(struct si_pub *sih)
{
struct si_info *sii;
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
index b0b0bff..8c51345 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
@@ -238,10 +238,6 @@ extern void __iomem *ai_switch_core(struct si_pub *sih, uint coreid,
uint *origidx, uint *intr_val);
extern void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val);
extern void ai_pci_setup(struct si_pub *sih, uint coremask);
-extern void ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn,
- void *intrsrestore_fn,
- void *intrsenabled_fn, void *intr_arg);
-extern void ai_deregister_intr_callback(struct si_pub *sih);
extern void ai_clkctl_init(struct si_pub *sih);
extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih);
extern bool ai_clkctl_cc(struct si_pub *sih, uint mode);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index d974809..1c75e2f 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -2370,27 +2370,6 @@ void brcms_c_intrson(struct brcms_c_info *wlc)
bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask);
}

-/*
- * callback for siutils.c, which has only wlc handler, no wl they both check
- * up, not only because there is no need to off/restore d11 interrupt but also
- * because per-port code may require sync with valid interrupt.
- */
-static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc)
-{
- if (!wlc->hw->up)
- return 0;
-
- return brcms_intrsoff(wlc->wl);
-}
-
-static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask)
-{
- if (!wlc->hw->up)
- return;
-
- brcms_intrsrestore(wlc->wl, macintmask);
-}
-
u32 brcms_c_intrsoff(struct brcms_c_info *wlc)
{
struct brcms_hardware *wlc_hw = wlc->hw;
@@ -4712,10 +4691,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core,
/* Match driver "down" state */
ai_pci_down(wlc_hw->sih);

- /* register sb interrupt callback functions */
- ai_register_intr_callback(wlc_hw->sih, (void *)brcms_c_wlintrsoff,
- (void *)brcms_c_wlintrsrestore, NULL, wlc);
-
/* turn off pll and xtal to match driver "down" state */
brcms_b_xtal(wlc_hw, OFF);

@@ -4986,7 +4961,6 @@ static int brcms_b_detach(struct brcms_c_info *wlc)
* and per-port interrupt object may has been freed. this must
* be done before sb core switch
*/
- ai_deregister_intr_callback(wlc_hw->sih);
ai_pci_sleep(wlc_hw->sih);
}

--
1.7.5.4



2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 14/15] brcm80211: smac: register with bcma for specific 802.11 core revisions

From: Arend van Spriel <[email protected]>

The brcmsmac driver has been verified on chipsets that were supported
when it was a pci device driver, ie. bcm4313, bcm43224, and bcm43225.
This patch restricts the driver to 802.11 core revisions that are found
in these chipsets.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
.../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 30ac8b4..77fdc45 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -90,8 +90,8 @@ MODULE_LICENSE("Dual BSD/GPL");

/* recognized BCMA Core IDs */
static struct bcma_device_id brcms_coreid_table[] = {
- BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211,
- BCMA_ANY_REV, BCMA_ANY_CLASS),
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 23, BCMA_ANY_CLASS),
+ BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 24, BCMA_ANY_CLASS),
BCMA_CORETABLE_END
};
MODULE_DEVICE_TABLE(bcma, brcms_coreid_table);
--
1.7.5.4



2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 05/15] brcm80211: smac: use bcma core access functions in aiutils.c

From: Arend van Spriel <[email protected]>

The code in aiutils.c now uses the BCMA function for control the
registers in the device cores.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 190 ++++++++-------------
1 files changed, 70 insertions(+), 120 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index bb12ebc..7e5d41b 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -558,28 +558,26 @@ static bool ai_buscore_prep(struct si_info *sii)
}

static bool
-ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx)
+ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
{
bool pci, pcie;
uint i;
uint pciidx, pcieidx, pcirev, pcierev;
- struct chipcregs __iomem *cc;
-
- cc = ai_setcoreidx(&sii->pub, SI_CC_IDX);

/* get chipcommon rev */
- sii->pub.ccrev = (int)ai_corerev(&sii->pub);
+ sii->pub.ccrev = cc->id.rev;

/* get chipcommon chipstatus */
if (ai_get_ccrev(&sii->pub) >= 11)
- sii->chipst = R_REG(&cc->chipstatus);
+ sii->chipst = bcma_read32(cc, CHIPCREGOFFS(chipstatus));

/* get chipcommon capabilites */
- sii->pub.cccaps = R_REG(&cc->capabilities);
+ sii->pub.cccaps = bcma_read32(cc, CHIPCREGOFFS(capabilities));

/* get pmu rev and caps */
if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) {
- sii->pub.pmucaps = R_REG(&cc->pmucapabilities);
+ sii->pub.pmucaps = bcma_read32(cc,
+ CHIPCREGOFFS(pmucapabilities));
sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK;
}

@@ -608,11 +606,6 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx)
pcierev = crev;
pcie = true;
}
-
- /* find the core idx before entering this func. */
- if ((savewin && (savewin == sii->coresba[i])) ||
- (cc == sii->regs[i]))
- *origidx = i;
}

if (pci && pcie) {
@@ -642,9 +635,6 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx)
return false;
}

- /* return to the original core */
- ai_setcoreidx(&sii->pub, *origidx);
-
return true;
}

@@ -668,9 +658,8 @@ static struct si_info *ai_doattach(struct si_info *sii,
void __iomem *regs = pbus->mmio;
struct si_pub *sih = &sii->pub;
u32 w, savewin;
- struct chipcregs __iomem *cc;
+ struct bcma_device *cc;
uint socitype;
- uint origidx;

memset((unsigned char *) sii, 0, sizeof(struct si_info));

@@ -683,10 +672,7 @@ static struct si_info *ai_doattach(struct si_info *sii,
sii->curwrap = sii->curmap + SI_CORE_SIZE;

/* switch to Chipcommon core */
- bcma_read32(pbus->drv_cc.core, 0);
- savewin = SI_ENUM_BASE;
-
- cc = (struct chipcregs __iomem *) regs;
+ cc = pbus->drv_cc.core;

/* bus/core/clk setup for register access */
if (!ai_buscore_prep(sii))
@@ -699,7 +685,7 @@ static struct si_info *ai_doattach(struct si_info *sii,
* hosts w/o chipcommon), some way of recognizing them needs to
* be added here.
*/
- w = R_REG(&cc->chipid);
+ w = bcma_read32(cc, CHIPCREGOFFS(chipid));
socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
/* Might as wll fill in chip id rev & pkg */
sih->chip = w & CID_ID_MASK;
@@ -720,8 +706,7 @@ static struct si_info *ai_doattach(struct si_info *sii,
return NULL;

/* bus/core/clk setup */
- origidx = SI_CC_IDX;
- if (!ai_buscore_setup(sii, savewin, &origidx))
+ if (!ai_buscore_setup(sii, cc))
goto exit;

/* Init nvram from sprom/otp if they exist */
@@ -731,10 +716,8 @@ static struct si_info *ai_doattach(struct si_info *sii,
ai_nvram_process(sii);

/* === NVRAM, clock is ready === */
- cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0);
- W_REG(&cc->gpiopullup, 0);
- W_REG(&cc->gpiopulldown, 0);
- ai_setcoreidx(sih, origidx);
+ bcma_write32(cc, CHIPCREGOFFS(gpiopullup), 0);
+ bcma_write32(cc, CHIPCREGOFFS(gpiopulldown), 0);

/* PMU specific initializations */
if (ai_get_cccaps(sih) & CC_CAP_PMU) {
@@ -990,11 +973,12 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val)
}

/* return the slow clock source - LPO, XTAL, or PCI */
-static uint ai_slowclk_src(struct si_info *sii)
+static uint ai_slowclk_src(struct si_pub *sih, struct bcma_device *cc)
{
- struct chipcregs __iomem *cc;
+ struct si_info *sii;
u32 val;

+ sii = (struct si_info *)sih;
if (ai_get_ccrev(&sii->pub) < 6) {
pci_read_config_dword(sii->pcibus, PCI_GPIO_OUT,
&val);
@@ -1002,9 +986,8 @@ static uint ai_slowclk_src(struct si_info *sii)
return SCC_SS_PCI;
return SCC_SS_XTAL;
} else if (ai_get_ccrev(&sii->pub) < 10) {
- cc = (struct chipcregs __iomem *)
- ai_setcoreidx(&sii->pub, sii->curidx);
- return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK;
+ return bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)) &
+ SCC_SS_MASK;
} else /* Insta-clock */
return SCC_SS_XTAL;
}
@@ -1013,24 +996,24 @@ static uint ai_slowclk_src(struct si_info *sii)
* return the ILP (slowclock) min or max frequency
* precondition: we've established the chip has dynamic clk control
*/
-static uint ai_slowclk_freq(struct si_info *sii, bool max_freq,
- struct chipcregs __iomem *cc)
+static uint ai_slowclk_freq(struct si_pub *sih, bool max_freq,
+ struct bcma_device *cc)
{
u32 slowclk;
uint div;

- slowclk = ai_slowclk_src(sii);
- if (ai_get_ccrev(&sii->pub) < 6) {
+ slowclk = ai_slowclk_src(sih, cc);
+ if (ai_get_ccrev(sih) < 6) {
if (slowclk == SCC_SS_PCI)
return max_freq ? (PCIMAXFREQ / 64)
: (PCIMINFREQ / 64);
else
return max_freq ? (XTALMAXFREQ / 32)
: (XTALMINFREQ / 32);
- } else if (ai_get_ccrev(&sii->pub) < 10) {
+ } else if (ai_get_ccrev(sih) < 10) {
div = 4 *
- (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >>
- SCC_CD_SHIFT) + 1);
+ (((bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)) &
+ SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
if (slowclk == SCC_SS_LPO)
return max_freq ? LPOMAXFREQ : LPOMINFREQ;
else if (slowclk == SCC_SS_XTAL)
@@ -1041,15 +1024,15 @@ static uint ai_slowclk_freq(struct si_info *sii, bool max_freq,
: (PCIMINFREQ / div);
} else {
/* Chipc rev 10 is InstaClock */
- div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT;
- div = 4 * (div + 1);
+ div = bcma_read32(cc, CHIPCREGOFFS(system_clk_ctl));
+ div = 4 * ((div >> SYCC_CD_SHIFT) + 1);
return max_freq ? XTALMAXFREQ : (XTALMINFREQ / div);
}
return 0;
}

static void
-ai_clkctl_setdelay(struct si_info *sii, struct chipcregs __iomem *cc)
+ai_clkctl_setdelay(struct si_pub *sih, struct bcma_device *cc)
{
uint slowmaxfreq, pll_delay, slowclk;
uint pll_on_delay, fref_sel_delay;
@@ -1062,47 +1045,40 @@ ai_clkctl_setdelay(struct si_info *sii, struct chipcregs __iomem *cc)
* powered down by dynamic clk control logic.
*/

- slowclk = ai_slowclk_src(sii);
+ slowclk = ai_slowclk_src(sih, cc);
if (slowclk != SCC_SS_XTAL)
pll_delay += XTAL_ON_DELAY;

/* Starting with 4318 it is ILP that is used for the delays */
slowmaxfreq =
- ai_slowclk_freq(sii,
- (ai_get_ccrev(&sii->pub) >= 10) ? false : true, cc);
+ ai_slowclk_freq(sih,
+ (ai_get_ccrev(sih) >= 10) ? false : true, cc);

pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;

- W_REG(&cc->pll_on_delay, pll_on_delay);
- W_REG(&cc->fref_sel_delay, fref_sel_delay);
+ bcma_write32(cc, CHIPCREGOFFS(pll_on_delay), pll_on_delay);
+ bcma_write32(cc, CHIPCREGOFFS(fref_sel_delay), fref_sel_delay);
}

/* initialize power control delay registers */
void ai_clkctl_init(struct si_pub *sih)
{
- struct si_info *sii;
- uint origidx = 0;
- struct chipcregs __iomem *cc;
+ struct bcma_device *cc;

if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL))
return;

- sii = (struct si_info *)sih;
- origidx = sii->curidx;
- cc = (struct chipcregs __iomem *)
- ai_setcore(sih, CC_CORE_ID, 0);
+ cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
if (cc == NULL)
return;

/* set all Instaclk chip ILP to 1 MHz */
if (ai_get_ccrev(sih) >= 10)
- SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK,
- (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
-
- ai_clkctl_setdelay(sii, cc);
+ bcma_maskset32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_CD_MASK,
+ (ILP_DIV_1MHZ << SYCC_CD_SHIFT));

- ai_setcoreidx(sih, origidx);
+ ai_clkctl_setdelay(sih, cc);
}

/*
@@ -1112,8 +1088,7 @@ void ai_clkctl_init(struct si_pub *sih)
u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih)
{
struct si_info *sii;
- uint origidx = 0;
- struct chipcregs __iomem *cc;
+ struct bcma_device *cc;
uint slowminfreq;
u16 fpdelay;
uint intr_val = 0;
@@ -1130,19 +1105,17 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih)
return 0;

fpdelay = 0;
- origidx = sii->curidx;
INTR_OFF(sii, intr_val);
- cc = (struct chipcregs __iomem *)
- ai_setcore(sih, CC_CORE_ID, 0);
+ cc = ai_findcore(sih, CC_CORE_ID, 0);
if (cc == NULL)
goto done;

- slowminfreq = ai_slowclk_freq(sii, false, cc);
- fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) +
- (slowminfreq - 1)) / slowminfreq;
+
+ slowminfreq = ai_slowclk_freq(sih, false, cc);
+ fpdelay = (((bcma_read32(cc, CHIPCREGOFFS(pll_on_delay)) + 2) * 1000000)
+ + (slowminfreq - 1)) / slowminfreq;

done:
- ai_setcoreidx(sih, origidx);
INTR_RESTORE(sii, intr_val);
return fpdelay;
}
@@ -1213,8 +1186,7 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on)
/* clk control mechanism through chipcommon, no policy checking */
static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
{
- uint origidx = 0;
- struct chipcregs __iomem *cc;
+ struct bcma_device *cc;
u32 scc;
uint intr_val = 0;

@@ -1223,9 +1195,7 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
return false;

INTR_OFF(sii, intr_val);
- origidx = sii->curidx;
- cc = (struct chipcregs __iomem *)
- ai_setcore(&sii->pub, CC_CORE_ID, 0);
+ cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0);

if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) &&
(ai_get_ccrev(&sii->pub) < 20))
@@ -1239,19 +1209,19 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
* on before we clear SCC_DYN_XTAL..
*/
ai_clkctl_xtal(&sii->pub, XTAL, ON);
- SET_REG(&cc->slow_clk_ctl,
- (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
+ bcma_maskset32(cc, CHIPCREGOFFS(slow_clk_ctl),
+ (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
} else if (ai_get_ccrev(&sii->pub) < 20) {
- OR_REG(&cc->system_clk_ctl, SYCC_HR);
+ bcma_set32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_HR);
} else {
- OR_REG(&cc->clk_ctl_st, CCS_FORCEHT);
+ bcma_set32(cc, CHIPCREGOFFS(clk_ctl_st), CCS_FORCEHT);
}

/* wait for the PLL */
if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) {
u32 htavail = CCS_HTAVAIL;
- SPINWAIT(((R_REG(&cc->clk_ctl_st) & htavail)
- == 0), PMU_MAX_TRANSITION_DLY);
+ SPINWAIT(((bcma_read32(cc, CHIPCREGOFFS(clk_ctl_st)) &
+ htavail) == 0), PMU_MAX_TRANSITION_DLY);
} else {
udelay(PLL_DELAY);
}
@@ -1259,11 +1229,11 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)

case CLK_DYNAMIC: /* enable dynamic clock control */
if (ai_get_ccrev(&sii->pub) < 10) {
- scc = R_REG(&cc->slow_clk_ctl);
+ scc = bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl));
scc &= ~(SCC_FS | SCC_IP | SCC_XC);
if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
scc |= SCC_XC;
- W_REG(&cc->slow_clk_ctl, scc);
+ bcma_write32(cc, CHIPCREGOFFS(slow_clk_ctl), scc);

/*
* for dynamic control, we have to
@@ -1273,9 +1243,9 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
ai_clkctl_xtal(&sii->pub, XTAL, OFF);
} else if (ai_get_ccrev(&sii->pub) < 20) {
/* Instaclock */
- AND_REG(&cc->system_clk_ctl, ~SYCC_HR);
+ bcma_mask32(cc, CHIPCREGOFFS(system_clk_ctl), ~SYCC_HR);
} else {
- AND_REG(&cc->clk_ctl_st, ~CCS_FORCEHT);
+ bcma_mask32(cc, CHIPCREGOFFS(clk_ctl_st), ~CCS_FORCEHT);
}
break;

@@ -1284,7 +1254,6 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
}

done:
- ai_setcoreidx(&sii->pub, origidx);
INTR_RESTORE(sii, intr_val);
return mode == CLK_FAST;
}
@@ -1427,53 +1396,37 @@ u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, u8 priority)

void ai_chipcontrl_epa4331(struct si_pub *sih, bool on)
{
- struct si_info *sii;
- struct chipcregs __iomem *cc;
- uint origidx;
+ struct bcma_device *cc;
u32 val;

- sii = (struct si_info *)sih;
- origidx = ai_coreidx(sih);
-
- cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0);
-
- val = R_REG(&cc->chipcontrol);
+ cc = ai_findcore(sih, CC_CORE_ID, 0);

if (on) {
if (ai_get_chippkg(sih) == 9 || ai_get_chippkg(sih) == 0xb)
/* Ext PA Controls for 4331 12x9 Package */
- W_REG(&cc->chipcontrol, val |
- CCTRL4331_EXTPA_EN |
- CCTRL4331_EXTPA_ON_GPIO2_5);
+ bcma_set32(cc, CHIPCREGOFFS(chipcontrol),
+ CCTRL4331_EXTPA_EN |
+ CCTRL4331_EXTPA_ON_GPIO2_5);
else
/* Ext PA Controls for 4331 12x12 Package */
- W_REG(&cc->chipcontrol,
- val | CCTRL4331_EXTPA_EN);
+ bcma_set32(cc, CHIPCREGOFFS(chipcontrol),
+ CCTRL4331_EXTPA_EN);
} else {
val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5);
- W_REG(&cc->chipcontrol, val);
+ bcma_mask32(cc, CHIPCREGOFFS(chipcontrol),
+ ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5));
}
-
- ai_setcoreidx(sih, origidx);
}

/* Enable BT-COEX & Ex-PA for 4313 */
void ai_epa_4313war(struct si_pub *sih)
{
- struct si_info *sii;
- struct chipcregs __iomem *cc;
- uint origidx;
-
- sii = (struct si_info *)sih;
- origidx = ai_coreidx(sih);
+ struct bcma_device *cc;

- cc = ai_setcore(sih, CC_CORE_ID, 0);
+ cc = ai_findcore(sih, CC_CORE_ID, 0);

/* EPA Fix */
- W_REG(&cc->gpiocontrol,
- R_REG(&cc->gpiocontrol) | GPIO_CTRL_EPA_EN_MASK);
-
- ai_setcoreidx(sih, origidx);
+ bcma_set32(cc, CHIPCREGOFFS(gpiocontrol), GPIO_CTRL_EPA_EN_MASK);
}

/* check if the device is removed */
@@ -1496,17 +1449,14 @@ bool ai_is_sprom_available(struct si_pub *sih)
struct si_info *sii = (struct si_info *)sih;

if (ai_get_ccrev(sih) >= 31) {
- uint origidx;
- struct chipcregs __iomem *cc;
+ struct bcma_device *cc;
u32 sromctrl;

if ((ai_get_cccaps(sih) & CC_CAP_SROM) == 0)
return false;

- origidx = sii->curidx;
- cc = ai_setcoreidx(sih, SI_CC_IDX);
- sromctrl = R_REG(&cc->sromcontrol);
- ai_setcoreidx(sih, origidx);
+ cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
+ sromctrl = bcma_read32(cc, CHIPCREGOFFS(sromcontrol));
return sromctrl & SRC_PRESENT;
}

--
1.7.5.4



2011-12-13 04:24:59

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 00/15] brcm80211: the rest of smac bcma switch series

On 12/12/2011 05:14 PM, Franky Lin wrote:
> Hi John,
>
> This train contains the rest of patch series switching brcmsmac to use
> bcma bus interface.
> It depends on the following patch set:
> [PATCH 00/23] brcm80211: fullmac 4430 support and softmac switch to bcma
> Message-ID:<[email protected]>

With this set of patches, my BCM43224 works with brcmsmac.

Larry

2011-12-12 23:15:52

by Franky Lin

[permalink] [raw]
Subject: [PATCH 06/15] brcm80211: smac: remove register access macro definitions

From: Arend van Spriel <[email protected]>

The register access macros like R_REG/W_REG/etc. are no longer
needed as the driver uses the BCMA provided functions.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/types.h | 51 -----------------------
1 files changed, 0 insertions(+), 51 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/types.h b/drivers/net/wireless/brcm80211/brcmsmac/types.h
index e64971a..e11ae83 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/types.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/types.h
@@ -250,69 +250,18 @@ do { \
wiphy_err(dev, "%s: " fmt, __func__, ##args); \
} while (0)

-/*
- * Register access macros.
- *
- * These macro's take a pointer to the address to read as one of their
- * arguments. The macro itself deduces the size of the IO transaction (u8, u16
- * or u32). Advantage of this approach in combination with using a struct to
- * define the registers in a register block, is that access size and access
- * location are defined in only one spot. This reduces the risk of the
- * programmer trying to use an unsupported transaction size on a register.
- *
- */
-
-#define R_REG(r) \
- ({ \
- __typeof(*(r)) __osl_v; \
- switch (sizeof(*(r))) { \
- case sizeof(u8): \
- __osl_v = readb((u8 __iomem *)(r)); \
- break; \
- case sizeof(u16): \
- __osl_v = readw((u16 __iomem *)(r)); \
- break; \
- case sizeof(u32): \
- __osl_v = readl((u32 __iomem *)(r)); \
- break; \
- } \
- __osl_v; \
- })
-
-#define W_REG(r, v) do { \
- switch (sizeof(*(r))) { \
- case sizeof(u8): \
- writeb((u8)((v) & 0xFF), (u8 __iomem *)(r)); \
- break; \
- case sizeof(u16): \
- writew((u16)((v) & 0xFFFF), (u16 __iomem *)(r)); \
- break; \
- case sizeof(u32): \
- writel((u32)(v), (u32 __iomem *)(r)); \
- break; \
- } \
- } while (0)
-
#ifdef CONFIG_BCM47XX
/*
* bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
* transactions. As a fix, a read after write is performed on certain places
* in the code. Older chips and the newer 5357 family don't require this fix.
*/
-#define W_REG_FLUSH(r, v) ({ W_REG((r), (v)); (void)R_REG(r); })
#define bcma_wflush16(c, o, v) \
({ bcma_write16(c, o, v); (void)bcma_read16(c, o); })
#else
-#define W_REG_FLUSH(r, v) W_REG((r), (v))
#define bcma_wflush16(c, o, v) bcma_write16(c, o, v)
#endif /* CONFIG_BCM47XX */

-#define AND_REG(r, v) W_REG((r), R_REG(r) & (v))
-#define OR_REG(r, v) W_REG((r), R_REG(r) | (v))
-
-#define SET_REG(r, mask, val) \
- W_REG((r), ((R_REG(r) & ~(mask)) | (val)))
-
/* multi-bool data type: set of bools, mbool is true if any is set */

/* set one bool */
--
1.7.5.4



2011-12-12 23:15:46

by Franky Lin

[permalink] [raw]
Subject: [PATCH 12/15] brcm80211: smac: cleanup si_info structure definition

From: Arend van Spriel <[email protected]>

Number of fields are no longer needed as the BCMA provides it
or makes them redundant. These have been removed.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 51 +++++----------------
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 27 -----------
2 files changed, 11 insertions(+), 67 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index f78350a..34a5e02 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -454,29 +454,6 @@ struct aidmp {
u32 componentid3; /* 0xffc */
};

-/* parse the enumeration rom to identify all cores */
-static void ai_scan(struct si_pub *sih, struct bcma_bus *bus)
-{
- struct si_info *sii = (struct si_info *)sih;
- struct bcma_device *core;
- uint idx;
-
- list_for_each_entry(core, &bus->cores, list) {
- idx = core->core_index;
- sii->cia[idx] = core->id.manuf << CIA_MFG_SHIFT;
- sii->cia[idx] |= core->id.id << CIA_CID_SHIFT;
- sii->cia[idx] |= core->id.class << CIA_CCL_SHIFT;
- sii->cib[idx] = core->id.rev << CIB_REV_SHIFT;
- sii->coreid[idx] = core->id.id;
- sii->coresba[idx] = core->addr;
- sii->coresba_size[idx] = 0x1000;
- sii->coresba2[idx] = 0;
- sii->coresba2_size[idx] = 0;
- sii->wrapba[idx] = core->wrap;
- sii->numcores++;
- }
-}
-
/* return true if PCIE capability exists in the pci config space */
static bool ai_ispcie(struct si_info *sii)
{
@@ -502,10 +479,16 @@ static bool ai_buscore_prep(struct si_info *sii)
static bool
ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
{
+ struct bcma_device *core;
bool pci, pcie;
uint i;
uint pciidx, pcieidx, pcirev, pcierev;

+
+ /* no cores found, bail out */
+ if (cc->bus->nr_cores == 0)
+ return false;
+
/* get chipcommon rev */
sii->pub.ccrev = cc->id.rev;

@@ -532,11 +515,11 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
pcirev = pcierev = NOREV;
pciidx = pcieidx = BADIDX;

- for (i = 0; i < sii->numcores; i++) {
+ list_for_each_entry(core, &cc->bus->cores, list) {
uint cid, crev;

- cid = sii->coreid[i];
- crev = (sii->cib[i] & CIB_REV_MASK) >> CIB_REV_SHIFT;
+ cid = core->id.id;
+ crev = core->id.rev;

if (cid == PCI_CORE_ID) {
pciidx = i;
@@ -596,7 +579,6 @@ static __used void ai_nvram_process(struct si_info *sii)
static struct si_info *ai_doattach(struct si_info *sii,
struct bcma_bus *pbus)
{
- void __iomem *regs = pbus->mmio;
struct si_pub *sih = &sii->pub;
u32 w, savewin;
struct bcma_device *cc;
@@ -609,8 +591,6 @@ static struct si_info *ai_doattach(struct si_info *sii,
sii->icbus = pbus;
sii->buscoreidx = BADIDX;
sii->pcibus = pbus->host_pci;
- sii->curmap = regs;
- sii->curwrap = sii->curmap + SI_CORE_SIZE;

/* switch to Chipcommon core */
cc = pbus->drv_cc.core;
@@ -634,19 +614,10 @@ static struct si_info *ai_doattach(struct si_info *sii,
sih->chippkg = (w & CID_PKG_MASK) >> CID_PKG_SHIFT;

/* scan for cores */
- if (socitype == SOCI_AI) {
- SI_MSG("Found chip type AI (0x%08x)\n", w);
- /* pass chipc address instead of original core base */
- ai_scan(&sii->pub, pbus);
- } else {
- /* Found chip of unknown type */
- return NULL;
- }
- /* no cores found, bail out */
- if (sii->numcores == 0)
+ if (socitype != SOCI_AI)
return NULL;

- /* bus/core/clk setup */
+ SI_MSG("Found chip type AI (0x%08x)\n", w);
if (!ai_buscore_setup(sii, cc))
goto exit;

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
index 6742758..f9f88dd 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
@@ -174,39 +174,12 @@ struct si_info {
struct si_pub pub; /* back plane public state (must be first) */
struct bcma_bus *icbus; /* handle to soc interconnect bus */
struct pci_dev *pcibus; /* handle to pci bus */
- uint dev_coreid; /* the core provides driver functions */
- void *intr_arg; /* interrupt callback function arg */
- u32 (*intrsoff_fn) (void *intr_arg); /* turns chip interrupts off */
- /* restore chip interrupts */
- void (*intrsrestore_fn) (void *intr_arg, u32 arg);
- /* check if interrupts are enabled */
- bool (*intrsenabled_fn) (void *intr_arg);
-
struct pcicore_info *pch; /* PCI/E core handle */

struct list_head var_list; /* list of srom variables */

- void __iomem *curmap; /* current regs va */
- void __iomem *regs[SI_MAXCORES]; /* other regs va */
-
u32 chipst; /* chip status */
- uint curidx; /* current core index */
uint buscoreidx; /* buscore index */
- uint numcores; /* # discovered cores */
- uint coreid[SI_MAXCORES]; /* id of each core */
- u32 coresba[SI_MAXCORES]; /* backplane address of each core */
- void *regs2[SI_MAXCORES]; /* 2nd virtual address per core (usbh20) */
- u32 coresba2[SI_MAXCORES]; /* 2nd phys address per core (usbh20) */
- u32 coresba_size[SI_MAXCORES]; /* backplane address space size */
- u32 coresba2_size[SI_MAXCORES]; /* second address space size */
-
- void *curwrap; /* current wrapper va */
- void *wrappers[SI_MAXCORES]; /* other cores wrapper va */
- u32 wrapba[SI_MAXCORES]; /* address of controlling wrapper */
-
- u32 cia[SI_MAXCORES]; /* erom cia entry for each core */
- u32 cib[SI_MAXCORES]; /* erom cia entry for each core */
- u32 oob_router; /* oob router registers for axi */
};

/*
--
1.7.5.4



2011-12-12 23:15:51

by Franky Lin

[permalink] [raw]
Subject: [PATCH 10/15] brcm80211: smac: remove ai_switch_core() function

From: Arend van Spriel <[email protected]>

The function ai_switch_core() is no longer needed and its counterpart
ai_restore_core() as well, because interrupts disabling is not needed
anymore.

Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Reviewed-by: Alwin Beukers <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
Signed-off-by: Franky Lin <[email protected]>
---
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 40 --------------------
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 3 -
.../net/wireless/brcm80211/brcmsmac/phy/phy_n.c | 7 +---
drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 24 ++---------
drivers/net/wireless/brcm80211/brcmsmac/pmu.h | 2 +-
5 files changed, 7 insertions(+), 69 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index 86e33f9..a99a163 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -321,20 +321,6 @@
#define IS_SIM(chippkg) \
((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID))

-/*
- * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts
- * before after core switching to avoid invalid register accesss inside ISR.
- */
-#define INTR_OFF(si, intr_val) \
- if ((si)->intrsoff_fn && \
- (si)->coreid[(si)->curidx] == (si)->dev_coreid) \
- intr_val = (*(si)->intrsoff_fn)((si)->intr_arg)
-
-#define INTR_RESTORE(si, intr_val) \
- if ((si)->intrsrestore_fn && \
- (si)->coreid[(si)->curidx] == (si)->dev_coreid) \
- (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val)
-
#define PCI(sih) (ai_get_buscoretype(sih) == PCI_CORE_ID)
#define PCIE(sih) (ai_get_buscoretype(sih) == PCIE_CORE_ID)

@@ -872,32 +858,6 @@ void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit)
return ai_setcoreidx(sih, core->core_index);
}

-/* Turn off interrupt as required by ai_setcore, before switch core */
-void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx,
- uint *intr_val)
-{
- void __iomem *cc;
- struct si_info *sii;
-
- sii = (struct si_info *)sih;
-
- INTR_OFF(sii, *intr_val);
- *origidx = sii->curidx;
- cc = ai_setcore(sih, coreid, 0);
- return cc;
-}
-
-/* restore coreidx and restore interrupt */
-void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val)
-{
- struct si_info *sii;
-
- sii = (struct si_info *)sih;
-
- ai_setcoreidx(sih, coreid);
- INTR_RESTORE(sii, intr_val);
-}
-
/*
* Switch to 'coreidx', issue a single arbitrary 32bit register mask&set
* operation, switch back to the original core, and return the new value.
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
index 8c51345..e37c9f4 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
@@ -234,9 +234,6 @@ extern uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val);
extern uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit);
extern void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx);
extern void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit);
-extern void __iomem *ai_switch_core(struct si_pub *sih, uint coreid,
- uint *origidx, uint *intr_val);
-extern void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val);
extern void ai_pci_setup(struct si_pub *sih, uint coremask);
extern void ai_clkctl_init(struct si_pub *sih);
extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c
index e0237e4..a16f1ab 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c
@@ -19447,7 +19447,6 @@ void wlc_phy_init_nphy(struct brcms_phy *pi)
u8 tx_pwr_ctrl_state;
bool do_nphy_cal = false;
uint core;
- uint origidx, intr_val;
u32 d11_clk_ctl_st;
bool do_rssi_cal = false;

@@ -19469,8 +19468,6 @@ void wlc_phy_init_nphy(struct brcms_phy *pi)
if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) &&
CHSPEC_IS40(pi->radio_chanspec)) {

- ai_switch_core(pi->sh->sih, D11_CORE_ID, &origidx, &intr_val);
-
d11_clk_ctl_st = bcma_read32(pi->d11core,
D11REGOFFS(clk_ctl_st));
bcma_mask32(pi->d11core, D11REGOFFS(clk_ctl_st),
@@ -19478,8 +19475,6 @@ void wlc_phy_init_nphy(struct brcms_phy *pi)

bcma_write32(pi->d11core, D11REGOFFS(clk_ctl_st),
d11_clk_ctl_st);
-
- ai_restore_core(pi->sh->sih, origidx, intr_val);
}

pi->use_int_tx_iqlo_cal_nphy =
@@ -21342,7 +21337,7 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec,
spuravoid = 1;

wlapi_bmac_core_phypll_ctl(pi->sh->physhim, false);
- si_pmu_spuravoid(pi->sh->sih, spuravoid);
+ si_pmu_spuravoid_pllupdate(pi->sh->sih, spuravoid);
wlapi_bmac_core_phypll_ctl(pi->sh->physhim, true);

if ((pi->sh->chip == BCM43224_CHIP_ID) ||
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
index d972e9c..4931d29 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c
@@ -139,11 +139,13 @@ static void si_pmu_res_masks(struct si_pub *sih, u32 * pmin, u32 * pmax)
*pmax = max_mask;
}

-static void
-si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct bcma_device *core,
- u8 spuravoid)
+void si_pmu_spuravoid_pllupdate(struct si_pub *sih, u8 spuravoid)
{
u32 tmp = 0;
+ struct bcma_device *core;
+
+ /* switch to chipc */
+ core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);

switch (ai_get_chip_id(sih)) {
case BCM43224_CHIP_ID:
@@ -281,22 +283,6 @@ u32 si_pmu_alp_clock(struct si_pub *sih)
return clock;
}

-void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid)
-{
- struct bcma_device *cc;
- uint origidx, intr_val;
-
- /* switch to chipc */
- cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
- ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val);
-
- /* update the pll changes */
- si_pmu_spuravoid_pllupdate(sih, cc, spuravoid);
-
- /* Return to original core */
- ai_restore_core(sih, origidx, intr_val);
-}
-
/* initialize PMU */
void si_pmu_init(struct si_pub *sih)
{
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
index dcd893c..3e39c5e 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h
@@ -26,7 +26,7 @@ extern u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val);
extern u32 si_pmu_regcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val);
extern u32 si_pmu_alp_clock(struct si_pub *sih);
extern void si_pmu_pllupd(struct si_pub *sih);
-extern void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid);
+extern void si_pmu_spuravoid_pllupdate(struct si_pub *sih, u8 spuravoid);
extern u32 si_pmu_pllcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val);
extern void si_pmu_init(struct si_pub *sih);
extern void si_pmu_res_init(struct si_pub *sih);
--
1.7.5.4