brcmfmac: memory size queury and cleanup
cover brcmfmac: memory size queury and cleanup
This patch series adds code to brcmfmac for querying the device about the RAM size. The driver needs that info to determine whether the firmware is up and running. All but one patch are related to this change. The last patch in this series fixes the fact that devices did not go to low-power mode anymore.
The series is intended for v4.1 kernel and applies to the wireless-drivers-next repository after the patches from the series posted on March 6th with
Message-ID: [email protected]
Arend van Spriel (7):
brcmfmac: remove duplication of ramsize info
brcmfmac: always perform cores checks
brcmfmac: rename chip download functions
brcmfmac: assure device is ready for download after
brcmf_chip_attach()
brcmfmac: extract ram size info from internal memory registers
brcmfmac: take save&restore memory into account for SDIO shared info
brcmfmac: fix watchdog timer regression
drivers/net/wireless/brcm80211/brcmfmac/chip.c | 296 +++++++++++++++++++------ drivers/net/wireless/brcm80211/brcmfmac/chip.h | 12 +- drivers/net/wireless/brcm80211/brcmfmac/pcie.c | 10 +- drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 72 +++--- 4 files changed, 276 insertions(+), 114 deletions(-)
--
1.9.1
PATCH 1/7 brcmfmac: remove duplication of ramsize info
Removing the ramsize from the brcmf_sdio structure to avoid duplication. The information is available in brcmf_chip structure.
--- drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/sdio.c +1 -10
@@ -432,8 +432,6 @@ struct brcmf_sdio {struct brcmf_sdio_dev *sdiodev;/* sdio device handler */ struct brcmf_chip *ci;/* Chip info struct */ -u32 ramsize;/* Size of RAM in SOCRAM (bytes) */ -u32 hostintmask;/* Copy of Host Interrupt Mask */ atomic_t intstatus;/* Intstatus bits (events) pending */ atomic_t fcstate;/* State of dongle flow-control */
@@ -1075,7 +1073,7 @@ static int brcmf_sdio_readshared(struct brcmf_sdio *bus,struct sdpcm_shared_le sh_le;__le32 addr_le; - shaddr = bus->ci->rambase + bus->ramsize -4 ; + shaddr = bus->ci->rambase + bus->ci->ramsize -4 ;/* * Read last word in socram to determine
@@ -3871,13 +3869,6 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus) drivestrength =DEFAULT_SDIO_DRIVE_STRENGTH ;brcmf_sdio_drivestrengthinit (bus->sdiodev, bus->ci, drivestrength); -/* Get info on the SOCRAM cores... */ - bus->ramsize = bus->ci->ramsize; -if (!(bus->ramsize)) { -brcmf_err ("failed to find SOCRAM memory!\n" ); - goto fail; - } -/* Set card control so an SDIO card reset does a WLAN backplane reset */ reg_val =brcmf_sdiod_regrb (bus->sdiodev,SDIO_CCCR_BRCM_CARDCTRL , &err);
Signature · 1 line
1.9.1
Re: [1/7] brcmfmac: remove duplication of ramsize info
Quoted 8 lines
Removing the ramsize from the
brcmf_sdiostructure to avoid duplication. The information is available inbrcmf_chipstructure.Reviewed-by Hante Meuleman <[email protected]>Reviewed-by Pieter-Paul Giesberts <[email protected]>Signed-off-by Arend van Spriel <[email protected]>
Thanks, 7 patches applied to wireless-drivers-next.git:
55b59fba0f0c brcmfmac: remove duplication of ramsize info5ded1c251f8e brcmfmac: always perform cores checksd380ebc9b6fb brcmfmac: rename chip download functions38f29e1f42b1 brcmfmac: assure device is ready for download after brcmf_chip_attach() 0da32ba4ee66 brcmfmac: extract ram size info from internal memory registers 9819a9024eab brcmfmac: take save&restore memory into account for SDIO shared info cf45932a74d4 brcmfmac: fix watchdog timer regression
Kalle Valo
PATCH 2/7 brcmfmac: always perform cores checks
In reply to Arend van SprielInstead of checking the cores in the chip only if CONFIG_BRCMDBG is selected perform the check always and extend it with more sanity checking.
--- drivers/net/wireless/brcm80211/brcmfmac/chip.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/chip.c +11 -7
@@ -419,13 +419,13 @@ static struct brcmf_core *brcmf_chip_add_core(struct brcmf_chip_priv *ci,return &core->pub; } -#ifdef DEBUG /* safety check for chipinfo */ static int brcmf_chip_cores_check (struct brcmf_chip_priv *ci) {struct brcmf_core_priv *core;bool need_socram = false;bool has_socram = false; +bool cpu_found = false;int idx =1 ;list_for_each_entry (core, &ci->cores, list) {
@@ -435,12 +435,14 @@ static int brcmf_chip_cores_check(struct brcmf_chip_priv *ci)switch (core->pub.id) {case BCMA_CORE_ARM_CM3 : + cpu_found = true; need_socram = true;break ;case BCMA_CORE_INTERNAL_MEM : has_socram = true;break ;case BCMA_CORE_ARM_CR4 : + cpu_found = true;if (ci->pub.rambase ==0 ) {brcmf_err ("RAM base not provided with ARM CR4 core\n" );return -ENOMEM ;
@@ -451,19 +453,21 @@ static int brcmf_chip_cores_check(struct brcmf_chip_priv *ci) } } +if (!cpu_found) { +brcmf_err ("CPU core not detected\n" ); +return -ENXIO ; + }/* check RAM core presence for ARM CM3 core */ if (need_socram && !has_socram) {brcmf_err ("RAM core not provided with ARM CM3 core\n" );return -ENODEV ; } +if (!ci->pub.ramsize) { +brcmf_err ("RAM size is undetermined\n" ); +return -ENOMEM ; + }return 0 ; } -#else /* DEBUG */ -static inline int brcmf_chip_cores_check (struct brcmf_chip_priv *ci) -{ -return 0 ; -} -#endif static void brcmf_chip_get_raminfo (struct brcmf_chip_priv *ci) {
Signature · 1 line
1.9.1
PATCH 3/7 brcmfmac: rename chip download functions
In reply to Arend van SprielThe functions brcmf_chip_[enter/exit]_download() are not exclusively used for firmware download so rename these more appropriate.
--- drivers/net/wireless/brcm80211/brcmfmac/chip.c | 26 +++++++++++++------------- drivers/net/wireless/brcm80211/brcmfmac/chip.h | 8 ++++---- drivers/net/wireless/brcm80211/brcmfmac/pcie.c | 10 +++++----- drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 17 ++++++++--------- 4 files changed, 30 insertions(+), 31 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/chip.c +13 -13
@@ -807,7 +807,7 @@ struct brcmf_chip *brcmf_chip_attach(void *ctx, err = -EINVAL ;if (WARN_ON (!ops->prepare)) err = -EINVAL ; -if (WARN_ON (!ops->exit_dl)) +if (WARN_ON (!ops->activate)) err = -EINVAL ;if (err <0 )return ERR_PTR (-EINVAL );
@@ -905,7 +905,7 @@ void brcmf_chip_resetcore(struct brcmf_core *pub, u32 prereset, u32 reset, }static void -brcmf_chip_cm3_enterdl (struct brcmf_chip_priv *chip) +brcmf_chip_cm3_set_passive (struct brcmf_chip_priv *chip) {struct brcmf_core *core;
@@ -919,7 +919,7 @@ brcmf_chip_cm3_enterdl(struct brcmf_chip_priv *chip)brcmf_chip_resetcore (core,0 ,0 ,0 ); } -static bool brcmf_chip_cm3_exitdl (struct brcmf_chip_priv *chip) +static bool brcmf_chip_cm3_set_active (struct brcmf_chip_priv *chip) {struct brcmf_core *core;
@@ -929,7 +929,7 @@ static bool brcmf_chip_cm3_exitdl(struct brcmf_chip_priv *chip)return false; } - chip->ops->exit_dl (chip->ctx, &chip->pub,0 ); + chip->ops->activate (chip->ctx, &chip->pub,0 ); core =brcmf_chip_get_core (&chip->pub,BCMA_CORE_ARM_CM3 );brcmf_chip_resetcore (core,0 ,0 ,0 );
@@ -938,7 +938,7 @@ static bool brcmf_chip_cm3_exitdl(struct brcmf_chip_priv *chip) }static inline void -brcmf_chip_cr4_enterdl (struct brcmf_chip_priv *chip) +brcmf_chip_cr4_set_passive (struct brcmf_chip_priv *chip) {struct brcmf_core *core;
@@ -951,11 +951,11 @@ brcmf_chip_cr4_enterdl(struct brcmf_chip_priv *chip) D11_BCMA_IOCTL_PHYCLOCKEN); } -static bool brcmf_chip_cr4_exitdl (struct brcmf_chip_priv *chip,u32 rstvec) +static bool brcmf_chip_cr4_set_active (struct brcmf_chip_priv *chip,u32 rstvec) {struct brcmf_core *core; - chip->ops->exit_dl (chip->ctx, &chip->pub, rstvec); + chip->ops->activate (chip->ctx, &chip->pub, rstvec);/* restore ARM */ core =brcmf_chip_get_core (&chip->pub,BCMA_CORE_ARM_CR4 );
@@ -964,7 +964,7 @@ static bool brcmf_chip_cr4_exitdl(struct brcmf_chip_priv *chip, u32 rstvec)return true; } -void brcmf_chip_enter_download (struct brcmf_chip *pub) +void brcmf_chip_set_passive (struct brcmf_chip *pub) {struct brcmf_chip_priv *chip;struct brcmf_core *arm;
@@ -974,14 +974,14 @@ void brcmf_chip_enter_download(struct brcmf_chip *pub) chip = container_of(pub, struct brcmf_chip_priv, pub); arm =brcmf_chip_get_core (pub,BCMA_CORE_ARM_CR4 );if (arm) { -brcmf_chip_cr4_enterdl (chip); +brcmf_chip_cr4_set_passive (chip);return ; } -brcmf_chip_cm3_enterdl (chip); +brcmf_chip_cm3_set_passive (chip); } -bool brcmf_chip_exit_download (struct brcmf_chip *pub,u32 rstvec) +bool brcmf_chip_set_active (struct brcmf_chip *pub,u32 rstvec) {struct brcmf_chip_priv *chip;struct brcmf_core *arm;
@@ -991,9 +991,9 @@ bool brcmf_chip_exit_download(struct brcmf_chip *pub, u32 rstvec) chip = container_of(pub, struct brcmf_chip_priv, pub); arm =brcmf_chip_get_core (pub,BCMA_CORE_ARM_CR4 );if (arm) -return brcmf_chip_cr4_exitdl (chip, rstvec); +return brcmf_chip_cr4_set_active (chip, rstvec); -return brcmf_chip_cm3_exitdl (chip); +return brcmf_chip_cm3_set_active (chip); }bool brcmf_chip_sr_capable (struct brcmf_chip *pub)
drivers/net/wireless/brcm80211/brcmfmac/chip.h +4 -4
@@ -64,7 +64,7 @@ struct brcmf_core {* @write32: write 32-bit value over bus. * @prepare: prepare bus for core configuration. * @setup: bus-specific core setup. -* @exit_dl: exit download state. +* @active: chip becomes active. * The callback should use the provided @rstvec when non-zero. */ struct brcmf_buscore_ops {
@@ -72,7 +72,7 @@ struct brcmf_buscore_ops {void (*write32)(void *ctx,u32 addr,u32 value);int (*prepare)(void *ctx);int (*setup)(void *ctx,struct brcmf_chip *chip); -void (*exit_dl)(void *ctx,struct brcmf_chip *chip,u32 rstvec); +void (*activate)(void *ctx,struct brcmf_chip *chip,u32 rstvec); }; struct brcmf_chip *brcmf_chip_attach(void *ctx,
@@ -84,8 +84,8 @@ bool brcmf_chip_iscoreup(struct brcmf_core *core);void brcmf_chip_coredisable (struct brcmf_core *core,u32 prereset,u32 reset);void brcmf_chip_resetcore (struct brcmf_core *core,u32 prereset,u32 reset,u32 postreset); -void brcmf_chip_enter_download (struct brcmf_chip *ci); -bool brcmf_chip_exit_download (struct brcmf_chip *ci,u32 rstvec); +void brcmf_chip_set_passive (struct brcmf_chip *ci); +bool brcmf_chip_set_active (struct brcmf_chip *ci,u32 rstvec);bool brcmf_chip_sr_capable (struct brcmf_chip *pub);#endif /* BRCMF_AXIDMP_H */
drivers/net/wireless/brcm80211/brcmfmac/pcie.c +5 -5
@@ -509,7 +509,7 @@ static void brcmf_pcie_attach(struct brcmf_pciedev_info *devinfo)static int brcmf_pcie_enter_download_state (struct brcmf_pciedev_info *devinfo) { -brcmf_chip_enter_download (devinfo->ci); +brcmf_chip_set_passive (devinfo->ci);if (devinfo->ci->chip ==BRCM_CC_43602_CHIP_ID ) {brcmf_pcie_select_core (devinfo,BCMA_CORE_ARM_CR4 );
@@ -536,7 +536,7 @@ static int brcmf_pcie_exit_download_state(struct brcmf_pciedev_info *devinfo,brcmf_chip_resetcore (core,0 ,0 ,0 ); } -return !brcmf_chip_exit_download (devinfo->ci, resetintr); +return !brcmf_chip_set_active (devinfo->ci, resetintr); }
@@ -1566,8 +1566,8 @@ static int brcmf_pcie_buscoreprep(void *ctx) } -static void brcmf_pcie_buscore_exitdl (void *ctx,struct brcmf_chip *chip, -u32 rstvec) +static void brcmf_pcie_buscore_activate (void *ctx,struct brcmf_chip *chip, +u32 rstvec) {struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)ctx;
@@ -1577,7 +1577,7 @@ static void brcmf_pcie_buscore_exitdl(void *ctx, struct brcmf_chip *chip,static const struct brcmf_buscore_ops brcmf_pcie_buscore_ops = { .prepare = brcmf_pcie_buscoreprep, - .exit_dl = brcmf_pcie_buscore_exitdl, + .activate = brcmf_pcie_buscore_activate, .read32 = brcmf_pcie_buscore_read32, .write32 = brcmf_pcie_buscore_write32, };
drivers/net/wireless/brcm80211/brcmfmac/sdio.c +8 -9
@@ -3357,7 +3357,7 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus,brcmf_sdio_clkctl (bus,CLK_AVAIL , false);/* Keep arm in reset */ -brcmf_chip_enter_download (bus->ci); +brcmf_chip_set_passive (bus->ci); rstvec =get_unaligned_le32 (fw->data);brcmf_dbg (SDIO ,"firmware rstvec: %x\n" , rstvec);
@@ -3378,7 +3378,7 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus, }/* Take arm out of reset */ -if (!brcmf_chip_exit_download (bus->ci, rstvec)) { +if (!brcmf_chip_set_active (bus->ci, rstvec)) {brcmf_err ("error getting out of ARM core reset\n" ); goto err; }
@@ -3771,8 +3771,8 @@ static int brcmf_sdio_buscoreprep(void *ctx)return 0 ; } -static void brcmf_sdio_buscore_exitdl (void *ctx,struct brcmf_chip *chip, -u32 rstvec) +static void brcmf_sdio_buscore_activate (void *ctx,struct brcmf_chip *chip, +u32 rstvec) {struct brcmf_sdio_dev *sdiodev = ctx;struct brcmf_core *core;
@@ -3815,7 +3815,7 @@ static void brcmf_sdio_buscore_write32(void *ctx, u32 addr, u32 val)static const struct brcmf_buscore_ops brcmf_sdio_buscore_ops = { .prepare = brcmf_sdio_buscoreprep, - .exit_dl = brcmf_sdio_buscore_exitdl, + .activate = brcmf_sdio_buscore_activate, .read32 = brcmf_sdio_buscore_read32, .write32 = brcmf_sdio_buscore_write32, };
@@ -4239,12 +4239,11 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)sdio_claim_host (bus->sdiodev->func[1 ]);brcmf_sdio_clkctl (bus,CLK_AVAIL , false);/* Leave the device in state where it is -* 'quiet'. This is done by putting it in -* download_state which essentially resets -* all necessary cores. +* 'passive'. This is done by resetting all +* necessary cores. */ msleep (20 ); -brcmf_chip_enter_download (bus->ci); +brcmf_chip_set_passive (bus->ci);brcmf_sdio_clkctl (bus,CLK_NONE , false);sdio_release_host (bus->sdiodev->func[1 ]); }
Signature · 1 line
1.9.1
PATCH 4/7 brcmfmac: assure device is ready for download after brcmf_chip_attach()
In reply to Arend van SprielMake the brcmf_chip_attach() function responsible for putting the device in a state where it is accessible for firmware download.
--- drivers/net/wireless/brcm80211/brcmfmac/chip.c | 8 ++------ drivers/net/wireless/brcm80211/brcmfmac/pcie.c | 2 -- drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 3 --- 3 files changed, 2 insertions(+), 11 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/chip.c +2 -6
@@ -786,12 +786,6 @@ static int brcmf_chip_setup(struct brcmf_chip_priv *chip)if (chip->ops->setup) ret = chip->ops->setup (chip->ctx, pub); -/* -* Make sure any on-chip ARM is off (in case strapping is wrong), -* or downloaded code was already running. -*/ -brcmf_chip_disable_arm (chip,BCMA_CORE_ARM_CM3 ); -brcmf_chip_disable_arm (chip,BCMA_CORE_ARM_CR4 );return ret; }
@@ -833,6 +827,8 @@ struct brcmf_chip *brcmf_chip_attach(void *ctx,if (err <0 ) goto fail; +/* assure chip is passive for download */ +brcmf_chip_set_passive (&chip->pub);return &chip->pub; fail:
drivers/net/wireless/brcm80211/brcmfmac/pcie.c +0 -2
@@ -509,8 +509,6 @@ static void brcmf_pcie_attach(struct brcmf_pciedev_info *devinfo)static int brcmf_pcie_enter_download_state (struct brcmf_pciedev_info *devinfo) { -brcmf_chip_set_passive (devinfo->ci); -if (devinfo->ci->chip ==BRCM_CC_43602_CHIP_ID ) {brcmf_pcie_select_core (devinfo,BCMA_CORE_ARM_CR4 ); brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_ARMCR4REG_BANKIDX,
drivers/net/wireless/brcm80211/brcmfmac/sdio.c +0 -3
@@ -3356,9 +3356,6 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus,sdio_claim_host (bus->sdiodev->func[1 ]);brcmf_sdio_clkctl (bus,CLK_AVAIL , false); -/* Keep arm in reset */ -brcmf_chip_set_passive (bus->ci); - rstvec =get_unaligned_le32 (fw->data);brcmf_dbg (SDIO ,"firmware rstvec: %x\n" , rstvec);
Signature · 1 line
1.9.1
PATCH 5/7 brcmfmac: extract ram size info from internal memory registers
In reply to Arend van SprielInstead of hard-coded memory sizes it is possible to obtain that information from the internal memory registers.
--- drivers/net/wireless/brcm80211/brcmfmac/chip.c | 260 ++++++++++++++++++++----- drivers/net/wireless/brcm80211/brcmfmac/chip.h | 4 +- 2 files changed, 217 insertions(+), 47 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/chip.c +214 -46
@@ -100,9 +100,6 @@#define BCM4329_CORE_SOCRAM_BASE 0x18003000/* ARM Cortex M3 core, ID 0x82a */ #define BCM4329_CORE_ARM_BASE 0x18002000 -#define BCM4329_RAMSIZE 0x48000 -/* bcm43143 */ -#define BCM43143_RAMSIZE 0x70000#define CORE_SB (base, field) \ (base + SBCONFIGOFF + offsetof(struct sbconfig, field))
@@ -150,6 +147,78 @@ struct sbconfig {u32 sbidhigh;/* identification */ }; +/* bankidx and bankinfo reg defines corerev >= 8 */ +#define SOCRAM_BANKINFO_RETNTRAM_MASK 0x00010000 +#define SOCRAM_BANKINFO_SZMASK 0x0000007f +#define SOCRAM_BANKIDX_ROM_MASK 0x00000100 + +#define SOCRAM_BANKIDX_MEMTYPE_SHIFT 8 +/* socram bankinfo memtype */ +#define SOCRAM_MEMTYPE_RAM 0 +#define SOCRAM_MEMTYPE_R0M 1 +#define SOCRAM_MEMTYPE_DEVRAM 2 + +#define SOCRAM_BANKINFO_SZBASE 8192 +#define SRCI_LSS_MASK 0x00f00000 +#define SRCI_LSS_SHIFT 20 +#define SRCI_SRNB_MASK 0xf0 +#define SRCI_SRNB_SHIFT 4 +#define SRCI_SRBSZ_MASK 0xf +#define SRCI_SRBSZ_SHIFT 0 +#define SR_BSZ_BASE 14 + +struct sbsocramregs { +u32 coreinfo; +u32 bwalloc; +u32 extracoreinfo; +u32 biststat; +u32 bankidx; +u32 standbyctrl; + +u32 errlogstatus;/* rev 6 */ +u32 errlogaddr;/* rev 6 */ +/* used for patching rev 3 & 5 */ +u32 cambankidx; +u32 cambankstandbyctrl; +u32 cambankpatchctrl; +u32 cambankpatchtblbaseaddr; +u32 cambankcmdreg; +u32 cambankdatareg; +u32 cambankmaskreg; +u32 PAD[1 ]; +u32 bankinfo;/* corev 8 */ +u32 bankpda; +u32 PAD[14 ]; +u32 extmemconfig; +u32 extmemparitycsr; +u32 extmemparityerrdata; +u32 extmemparityerrcnt; +u32 extmemwrctrlandsize; +u32 PAD[84 ]; +u32 workaround; +u32 pwrctl;/* corerev >= 2 */ +u32 PAD[133 ]; +u32 sr_control;/* corerev >= 15 */ +u32 sr_status;/* corerev >= 15 */ +u32 sr_address;/* corerev >= 15 */ +u32 sr_data;/* corerev >= 15 */ +}; + +#define SOCRAMREGOFFS (_f) offsetof(struct sbsocramregs, _f) + +#define ARMCR4_CAP (0x04) +#define ARMCR4_BANKIDX (0x40) +#define ARMCR4_BANKINFO (0x44) +#define ARMCR4_BANKPDA (0x4C) + +#define ARMCR4_TCBBNB_MASK 0xf0 +#define ARMCR4_TCBBNB_SHIFT 4 +#define ARMCR4_TCBANB_MASK 0xf +#define ARMCR4_TCBANB_SHIFT 0 + +#define ARMCR4_BSZ_MASK 0x3f +#define ARMCR4_BSZ_MULT 8192 +struct brcmf_core_priv {struct brcmf_core pub;u32 wrapbase;
@@ -443,10 +512,6 @@ static int brcmf_chip_cores_check(struct brcmf_chip_priv *ci)break ;case BCMA_CORE_ARM_CR4 : cpu_found = true; -if (ci->pub.rambase ==0 ) { -brcmf_err ("RAM base not provided with ARM CR4 core\n" ); -return -ENOMEM ; - }break ;default :break ;
@@ -462,60 +527,160 @@ static int brcmf_chip_cores_check(struct brcmf_chip_priv *ci)brcmf_err ("RAM core not provided with ARM CM3 core\n" );return -ENODEV ; } -if (!ci->pub.ramsize) { -brcmf_err ("RAM size is undetermined\n" ); -return -ENOMEM ; - }return 0 ; } -static void brcmf_chip_get_raminfo (struct brcmf_chip_priv *ci) +static u32 brcmf_chip_core_read32 (struct brcmf_core_priv *core,u16 reg) { -switch (ci->pub.chip) { -case BRCM_CC_4329_CHIP_ID : - ci->pub.ramsize =BCM4329_RAMSIZE ; -break ; -case BRCM_CC_43143_CHIP_ID : - ci->pub.ramsize =BCM43143_RAMSIZE ; -break ; -case BRCM_CC_43241_CHIP_ID : - ci->pub.ramsize =0x90000 ; -break ; -case BRCM_CC_4330_CHIP_ID : - ci->pub.ramsize =0x48000 ; -break ; +return core->chip->ops->read32 (core->chip->ctx, core->pub.base + reg); +} + +static void brcmf_chip_core_write32 (struct brcmf_core_priv *core, +u16 reg,u32 val) +{ + core->chip->ops->write32 (core->chip->ctx, core->pub.base + reg, val); +} + +static bool brcmf_chip_socram_banksize (struct brcmf_core_priv *core,u8 idx, +u32 *banksize) +{ +u32 bankinfo; +u32 bankidx = (SOCRAM_MEMTYPE_RAM <<SOCRAM_BANKIDX_MEMTYPE_SHIFT ); + + bankidx |= idx; +brcmf_chip_core_write32 (core,SOCRAMREGOFFS (bankidx), bankidx); + bankinfo =brcmf_chip_core_read32 (core,SOCRAMREGOFFS (bankinfo)); + *banksize = (bankinfo &SOCRAM_BANKINFO_SZMASK ) +1 ; + *banksize *=SOCRAM_BANKINFO_SZBASE ; +return !!(bankinfo &SOCRAM_BANKINFO_RETNTRAM_MASK ); +} + +static void brcmf_chip_socram_ramsize (struct brcmf_core_priv *sr,u32 *ramsize, +u32 *srsize) +{ +u32 coreinfo; +uint nb, banksize, lss; +bool retent; +int i; + + *ramsize =0 ; + *srsize =0 ; + +if (WARN_ON (sr->pub.rev <4 )) +return ; + +if (!brcmf_chip_iscoreup (&sr->pub)) +brcmf_chip_resetcore (&sr->pub,0 ,0 ,0 ); + +/* Get info for determining size */ + coreinfo =brcmf_chip_core_read32 (sr,SOCRAMREGOFFS (coreinfo)); + nb = (coreinfo &SRCI_SRNB_MASK ) >>SRCI_SRNB_SHIFT ; + +if ((sr->pub.rev <=7 ) || (sr->pub.rev ==12 )) { + banksize = (coreinfo &SRCI_SRBSZ_MASK ); + lss = (coreinfo &SRCI_LSS_MASK ) >>SRCI_LSS_SHIFT ; +if (lss !=0 ) + nb--; + *ramsize = nb * (1 << (banksize +SR_BSZ_BASE )); +if (lss !=0 ) + *ramsize += (1 << ((lss -1 ) +SR_BSZ_BASE )); + }else { + nb = (coreinfo &SRCI_SRNB_MASK ) >>SRCI_SRNB_SHIFT ; +for (i =0 ; i < nb; i++) { + retent =brcmf_chip_socram_banksize (sr, i, &banksize); + *ramsize += banksize; +if (retent) + *srsize += banksize; + } + } + +/* hardcoded save&restore memory sizes */ +switch (sr->chip->pub.chip) {case BRCM_CC_4334_CHIP_ID : -case BRCM_CC_43340_CHIP_ID : - ci->pub.ramsize =0x80000 ; -break ; -case BRCM_CC_4335_CHIP_ID : - ci->pub.ramsize =0xc0000 ; - ci->pub.rambase =0x180000 ; +if (sr->chip->pub.chiprev <2 ) + *srsize = (32 *1024 );break ; -case BRCM_CC_43362_CHIP_ID : - ci->pub.ramsize =0x3c000 ; +default :break ; + } +} + +/** Return the TCM-RAM size of the ARMCR4 core. */ +static u32 brcmf_chip_tcm_ramsize (struct brcmf_core_priv *cr4) +{ +u32 corecap; +u32 memsize =0 ; +u32 nab; +u32 nbb; +u32 totb; +u32 bxinfo; +u32 idx; + + corecap =brcmf_chip_core_read32 (cr4,ARMCR4_CAP ); + + nab = (corecap &ARMCR4_TCBANB_MASK ) >>ARMCR4_TCBANB_SHIFT ; + nbb = (corecap &ARMCR4_TCBBNB_MASK ) >>ARMCR4_TCBBNB_SHIFT ; + totb = nab + nbb; + +for (idx =0 ; idx < totb; idx++) { +brcmf_chip_core_write32 (cr4,ARMCR4_BANKIDX , idx); + bxinfo =brcmf_chip_core_read32 (cr4,ARMCR4_BANKINFO ); + memsize += ((bxinfo &ARMCR4_BSZ_MASK ) +1 ) *ARMCR4_BSZ_MULT ; + } + +return memsize; +} + +static u32 brcmf_chip_tcm_rambase (struct brcmf_chip_priv *ci) +{ +switch (ci->pub.chip) {case BRCM_CC_4345_CHIP_ID : - ci->pub.ramsize =0xc8000 ; - ci->pub.rambase =0x198000 ; -break ; +return 0x198000 ; +case BRCM_CC_4335_CHIP_ID :case BRCM_CC_4339_CHIP_ID :case BRCM_CC_4354_CHIP_ID :case BRCM_CC_4356_CHIP_ID :case BRCM_CC_43567_CHIP_ID :case BRCM_CC_43569_CHIP_ID :case BRCM_CC_43570_CHIP_ID : - ci->pub.ramsize =0xc0000 ; - ci->pub.rambase =0x180000 ; -break ;case BRCM_CC_43602_CHIP_ID : - ci->pub.ramsize =0xf0000 ; - ci->pub.rambase =0x180000 ; -break ; +return 0x180000 ;default :brcmf_err ("unknown chip: %s\n" , ci->pub.name);break ; } +return 0 ; +} + +static int brcmf_chip_get_raminfo (struct brcmf_chip_priv *ci) +{ +struct brcmf_core_priv *mem_core; +struct brcmf_core *mem; + + mem =brcmf_chip_get_core (&ci->pub,BCMA_CORE_ARM_CR4 ); +if (mem) { + mem_core = container_of(mem, struct brcmf_core_priv, pub); + ci->pub.ramsize =brcmf_chip_tcm_ramsize (mem_core); + ci->pub.rambase =brcmf_chip_tcm_rambase (ci); +if (!ci->pub.rambase) { +brcmf_err ("RAM base not provided with ARM CR4 core\n" ); +return -EINVAL ; + } + }else { + mem =brcmf_chip_get_core (&ci->pub,BCMA_CORE_INTERNAL_MEM ); + mem_core = container_of(mem, struct brcmf_core_priv, pub); +brcmf_chip_socram_ramsize (mem_core, &ci->pub.ramsize, + &ci->pub.srsize); + } +brcmf_dbg (INFO ,"RAM: base=0x%x size=%d (0x%x) sr=%d (0x%x)\n" , + ci->pub.rambase, ci->pub.ramsize, ci->pub.ramsize, + ci->pub.srsize, ci->pub.srsize); + +if (!ci->pub.ramsize) { +brcmf_err ("RAM size is undetermined\n" ); +return -ENOMEM ; + } +return 0 ; } static u32 brcmf_chip_dmp_get_desc(struct brcmf_chip_priv *ci, u32 *eromaddr,
@@ -668,6 +833,7 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)struct brcmf_core *core;u32 regdata;u32 socitype; +int ret;/* Get CC core rev * Chipid is assume to be at offset 0 from SI_ENUM_BASE
@@ -720,9 +886,13 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)return -ENODEV ; } -brcmf_chip_get_raminfo (ci); + ret =brcmf_chip_cores_check (ci); +if (ret) +return ret; -return brcmf_chip_cores_check (ci); +/* assure chip is passive for core access */ +brcmf_chip_set_passive (&ci->pub); +return brcmf_chip_get_raminfo (ci); }static void brcmf_chip_disable_arm (struct brcmf_chip_priv *chip,u16 id)
@@ -827,8 +997,6 @@ struct brcmf_chip *brcmf_chip_attach(void *ctx,if (err <0 ) goto fail; -/* assure chip is passive for download */ -brcmf_chip_set_passive (&chip->pub);return &chip->pub; fail:
drivers/net/wireless/brcm80211/brcmfmac/chip.h +3 -1
@@ -30,7 +30,8 @@* @pmucaps: PMU capabilities. * @pmurev: PMU revision. * @rambase: RAM base address (only applicable for ARM CR4 chips). -* @ramsize: amount of RAM on chip. +* @ramsize: amount of RAM on chip including retention. +* @srsize: amount of retention RAM on chip. * @name: string representation of the chip identifier. */ struct brcmf_chip {
@@ -41,6 +42,7 @@ struct brcmf_chip {u32 pmurev;u32 rambase;u32 ramsize; +u32 srsize;char name[8 ]; };
Signature · 1 line
1.9.1
PATCH 6/7 brcmfmac: take save&restore memory into account for SDIO shared info
In reply to Arend van SprielThe firmware provides pointer to SDIO shared information at end of RAM during firmware initialization. End of RAM is obviously determined by the actual ram size, but part of that may be used for save&restore memory. In that case another location in RAM will hold the pointer.
--- drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 40 +++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/sdio.c +24 -16
@@ -1067,44 +1067,47 @@ static inline bool brcmf_sdio_valid_shared_address(u32 addr)static int brcmf_sdio_readshared (struct brcmf_sdio *bus,struct sdpcm_shared *sh) { -u32 addr; +u32 addr =0 ;int rv;u32 shaddr =0 ;struct sdpcm_shared_le sh_le;__le32 addr_le; - shaddr = bus->ci->rambase + bus->ci->ramsize -4 ; +sdio_claim_host (bus->sdiodev->func[1 ]); +brcmf_sdio_bus_sleep (bus, false, false);/* * Read last word in socram to determine * address of sdpcm_shared structure */ -sdio_claim_host (bus->sdiodev->func[1 ]); -brcmf_sdio_bus_sleep (bus, false, false); - rv =brcmf_sdiod_ramrw (bus->sdiodev, false, shaddr, (u8 *)&addr_le,4 ); -sdio_release_host (bus->sdiodev->func[1 ]); + shaddr = bus->ci->rambase + bus->ci->ramsize -4 ; +if (!bus->ci->rambase &&brcmf_chip_sr_capable (bus->ci)) + shaddr -= bus->ci->srsize; + rv =brcmf_sdiod_ramrw (bus->sdiodev, false, shaddr, + (u8 *)&addr_le,4 );if (rv <0 ) -return rv; - - addr =le32_to_cpu (addr_le); - -brcmf_dbg (SDIO ,"sdpcm_shared address 0x%08X\n" , addr); + goto fail;/* * Check if addr is valid. * NVRAM length at the end of memory should have been overwritten. */ + addr =le32_to_cpu (addr_le);if (!brcmf_sdio_valid_shared_address (addr)) { -brcmf_err ("invalid sdpcm_shared address 0x%08X\n" , - addr); -return -EINVAL ; +brcmf_err ("invalid sdpcm_shared address 0x%08X\n" , addr); + rv = -EINVAL ; + goto fail; } +brcmf_dbg (INFO ,"sdpcm_shared address 0x%08X\n" , addr); +/* Read hndrte_shared structure */ rv =brcmf_sdiod_ramrw (bus->sdiodev, false, addr, (u8 *)&sh_le,sizeof (struct sdpcm_shared_le ));if (rv <0 ) -return rv; + goto fail; + +sdio_release_host (bus->sdiodev->func[1 ]);/* Endianness */ sh->flags =le32_to_cpu (sh_le.flags);
@@ -1121,8 +1124,13 @@ static int brcmf_sdio_readshared(struct brcmf_sdio *bus, sh->flags & SDPCM_SHARED_VERSION_MASK);return -EPROTO ; } -return 0 ; + +fail: +brcmf_err ("unable to obtain sdpcm_shared info: rv=%d (addr=0x%x)\n" , + rv, addr); +sdio_release_host (bus->sdiodev->func[1 ]); +return rv; }static void brcmf_sdio_get_console_addr (struct brcmf_sdio *bus)
Signature · 1 line
1.9.1
PATCH 7/7 brcmfmac: fix watchdog timer regression
In reply to Arend van SprielThe watchdog timer is used to put the device in a low-power mode when it is idle for some time. This timer is stopped during that mode and should be restarted upon activity. This has been broken by commit d4150fced0365 ("brcmfmac: Simplify watchdog sleep."). This patch restores the behaviour as it was before that commit.
--- drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/sdio.c +2 -3
@@ -972,7 +972,6 @@ static int brcmf_sdio_clkctl(struct brcmf_sdio *bus, uint target, bool pendok)brcmf_sdio_sdclk (bus, true);/* Now request HT Avail on the backplane */ brcmf_sdio_htclk (bus, true, pendok); -brcmf_sdio_wd_timer (bus,BRCMF_WD_POLL_MS );break ;case CLK_SDONLY :
@@ -984,7 +983,6 @@ static int brcmf_sdio_clkctl(struct brcmf_sdio *bus, uint target, bool pendok)else brcmf_err ("request for %d -> %d\n" , bus->clkstate, target); -brcmf_sdio_wd_timer (bus,BRCMF_WD_POLL_MS );break ;case CLK_NONE :
@@ -993,7 +991,6 @@ static int brcmf_sdio_clkctl(struct brcmf_sdio *bus, uint target, bool pendok)brcmf_sdio_htclk (bus, false, false);/* Now remove the SD clock */ brcmf_sdio_sdclk (bus, false); -brcmf_sdio_wd_timer (bus,0 );break ; }#ifdef DEBUG
@@ -1048,6 +1045,7 @@ end:brcmf_sdio_clkctl (bus,CLK_NONE , pendok); }else {brcmf_sdio_clkctl (bus,CLK_AVAIL , pendok); +brcmf_sdio_wd_timer (bus,BRCMF_WD_POLL_MS ); } bus->sleeping = sleep; brcmf_dbg(SDIO, "new state %s\n",
@@ -4242,6 +4240,7 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)if (bus->ci) {if (bus->sdiodev->state !=BRCMF_SDIOD_NOMEDIUM ) {sdio_claim_host (bus->sdiodev->func[1 ]); +brcmf_sdio_wd_timer (bus,0 );brcmf_sdio_clkctl (bus,CLK_AVAIL , false);/* Leave the device in state where it is * 'passive'. This is done by resetting all
Signature · 1 line
1.9.1