brcmfmac: prepare for new device support
Arend van Spriel
maintainercover brcmfmac: prepare for new device support
Here are some patches needed for newer chipsets that do things just a bit differently. Should not affect currently supported devices.
This series applies to the master branch of the wireless-drivers-next repository.
Arend van Spriel (4):
brcmfmac: use different error value for invalid ram base address
brcmfmac: increase core revision column aligning core list
brcmfmac: add xtlv support to firmware interface layer
brcmfmac: support chipsets with different core enumeration space
.../broadcom/brcm80211/brcmfmac/Makefile | 3 +- .../broadcom/brcm80211/brcmfmac/bcmsdh.c | 3 +- .../broadcom/brcm80211/brcmfmac/chip.c | 26 ++-- .../broadcom/brcm80211/brcmfmac/chip.h | 5 +- .../broadcom/brcm80211/brcmfmac/fwil.c | 126 +++++++++++++++++- .../broadcom/brcm80211/brcmfmac/fwil.h | 8 ++ .../broadcom/brcm80211/brcmfmac/pcie.c | 3 +- .../broadcom/brcm80211/brcmfmac/sdio.c | 12 +- .../broadcom/brcm80211/brcmfmac/xtlv.c | 82 ++++++++++++ .../broadcom/brcm80211/brcmfmac/xtlv.h | 31 +++++ .../wireless/broadcom/brcm80211/include/soc.h | 2 +- 11 files changed, 279 insertions(+), 22 deletions(-) create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.c create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.h
Signature · 1 line
2.27.0
Arend van Spriel
maintainerPATCH 1/4 brcmfmac: use different error value for invalid ram base address
The function brcmf_chip_tcm_rambase() returns 0 as invalid ram base address. However, upcoming chips have ram base address starting at zero so we have to find a more appropriate invalid value to return.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +5 -3
@@ -139,6 +139,8 @@ struct sbconfig {u32 sbidhigh;/* identification */ }; +#define INVALID_RAMBASE ((u32)(~0)) +/* bankidx and bankinfo reg defines corerev >= 8 */ #define SOCRAM_BANKINFO_RETNTRAM_MASK 0x00010000#define SOCRAM_BANKINFO_SZMASK 0x0000007f
@@ -731,7 +733,7 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)brcmf_err ("unknown chip: %s\n" , ci->pub.name);break ; } -return 0 ; +return INVALID_RAMBASE ; }int brcmf_chip_get_raminfo (struct brcmf_chip *pub)
@@ -746,7 +748,7 @@ int brcmf_chip_get_raminfo(struct brcmf_chip *pub) 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) { +if (ci->pub.rambase ==INVALID_RAMBASE ) {brcmf_err ("RAM base not provided with ARM CR4 core\n" );return -EINVAL ; }
@@ -757,7 +759,7 @@ int brcmf_chip_get_raminfo(struct brcmf_chip *pub) pub); ci->pub.ramsize =brcmf_chip_sysmem_ramsize (mem_core); ci->pub.rambase =brcmf_chip_tcm_rambase (ci); -if (!ci->pub.rambase) { +if (ci->pub.rambase ==INVALID_RAMBASE ) {brcmf_err ("RAM base not provided with ARM CA7 core\n" );return -EINVAL ; }
Signature · 1 line
2.27.0
Re: [PATCH 1/4] brcmfmac: use different error value for invalid ram base address
Quoted 8 lines · Arend van Spriel
The function
brcmf_chip_tcm_rambase()returns 0 as invalid ram base address. However, upcoming chips have ram base address starting at zero so we have to find a more appropriate invalid value to return.Reviewed-by Hante Meuleman <[email protected]>Reviewed-by Pieter-Paul Giesberts <[email protected]>Reviewed-by Franky Lin <[email protected]>Signed-off-by Arend van Spriel <[email protected]>
4 patches applied to wireless-drivers-next.git, thanks.
2c4fa29eceb3 brcmfmac: use different error value for invalid ram base address 8e73facb9b80 brcmfmac: increase core revision column aligning core list a7dd0ac94544 brcmfmac: add xtlv support to firmware interface layer 1ce050c15952 brcmfmac: support chipsets with different core enumeration space
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Arend van Spriel
maintainerPATCH 2/4 brcmfmac: increase core revision column aligning core list
In reply to Arend van SprielSome cores are getting a revision greater that 99 thus messing up the column alignment in the list of cores. So adding a digit for the core revision.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +1 -1
@@ -529,7 +529,7 @@ static int brcmf_chip_cores_check(struct brcmf_chip_priv *ci)int idx =1 ;list_for_each_entry (core, &ci->cores, list) { -brcmf_dbg (INFO ," [%-2d] core 0x%x:%-2d base 0x%08x wrap 0x%08x\n" , +brcmf_dbg (INFO ," [%-2d] core 0x%x:%-3d base 0x%08x wrap 0x%08x\n" , idx++, core->pub.id, core->pub.rev, core->pub.base, core->wrapbase);
Signature · 1 line
2.27.0
Arend van Spriel
maintainerPATCH 3/4 brcmfmac: add xtlv support to firmware interface layer
In reply to Arend van SprielNewer firmware API require commands to use xtlv format. Add support for that in the firmware interface layer.
--- .../broadcom/brcm80211/brcmfmac/Makefile | 3 +- .../broadcom/brcm80211/brcmfmac/fwil.c | 126 +++++++++++++++++- .../broadcom/brcm80211/brcmfmac/fwil.h | 8 ++ .../broadcom/brcm80211/brcmfmac/xtlv.c | 82 ++++++++++++ .../broadcom/brcm80211/brcmfmac/xtlv.h | 31 +++++ 5 files changed, 244 insertions(+), 6 deletions(-) create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.c create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.h
drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile +2 -1
@@ -23,7 +23,8 @@ brcmfmac-objs += \ feature.o \ btcoex.o \ vendor.o \ - pno.o + pno.o \ + xtlv.o brcmfmac-$(CONFIG_BRCMFMAC_PROTO_BCDC) += \ bcdc.o \ fwsignal.o
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c +121 -5
158 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h +8 -0
@@ -97,5 +97,13 @@ s32 brcmf_fil_bsscfg_data_get(struct brcmf_if *ifp, char *name, void *data, u32 len);s32 brcmf_fil_bsscfg_int_set (struct brcmf_if *ifp,char *name,u32 data);s32 brcmf_fil_bsscfg_int_get (struct brcmf_if *ifp,char *name,u32 *data); +s32 brcmf_fil_xtlv_data_set (struct brcmf_if *ifp,char *name,u16 id, +void *data,u32 len); +s32 brcmf_fil_xtlv_data_get (struct brcmf_if *ifp,char *name,u16 id, +void *data,u32 len); +s32 brcmf_fil_xtlv_int_set (struct brcmf_if *ifp,char *name,u16 id,u32 data); +s32 brcmf_fil_xtlv_int_get (struct brcmf_if *ifp,char *name,u16 id,u32 *data); +s32 brcmf_fil_xtlv_int8_get (struct brcmf_if *ifp,char *name,u16 id,u8 *data); +s32 brcmf_fil_xtlv_int16_get (struct brcmf_if *ifp,char *name,u16 id,u16 *data);#endif /* _fwil_h_ */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.c new file +82 -0
82 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmfmac/xtlv.h new file +31 -0
@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: ISC +/* +* Copyright (c) 2019 Broadcom +*/ +#ifndef __BRCMF_XTLV_H +#define __BRCMF_XTLV_H + +#include <linux/types.h> +#include <linux/bits.h> + +/* bcm type(id), length, value with w/16 bit id/len. The structure below +* is nominal, and is used to support variable length id and type. See +* xtlv options below. +*/ +struct brcmf_xtlv { +u16 id; +u16 len; +u8 data[0 ]; +}; + +enum brcmf_xtlv_option { +BRCMF_XTLV_OPTION_ALIGN32 =BIT (0 ), +BRCMF_XTLV_OPTION_IDU8 =BIT (1 ), +BRCMF_XTLV_OPTION_LENU8 =BIT (2 ), +}; + +int brcmf_xtlv_data_size (int dlen,u16 opts); +void brcmf_xtlv_pack_header (struct brcmf_xtlv *xtlv,u16 id,u16 len, +const u8 *data,u16 opts); + +#endif /* __BRCMF_XTLV_H */
Signature · 1 line
2.27.0
Arend van Spriel
maintainerPATCH 4/4 brcmfmac: support chipsets with different core enumeration space
In reply to Arend van SprielHistorically the broadcom wifi chipsets always had enumeration space containing all core information at same place. However, for new chipsets the ASIC developers moved away from that given fact. So we have to accommodate that it can differ per chipset.
--- .../broadcom/brcm80211/brcmfmac/bcmsdh.c | 3 ++- .../wireless/broadcom/brcm80211/brcmfmac/chip.c | 16 ++++++++++++---- .../wireless/broadcom/brcm80211/brcmfmac/chip.h | 5 ++++- .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 3 ++- .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 12 ++++++++---- .../wireless/broadcom/brcm80211/include/soc.h | 2 +- 6 files changed, 29 insertions(+), 12 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +2 -1
@@ -128,7 +128,8 @@ int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)if (sdiodev->bus_if->chip ==BRCM_CC_43362_CHIP_ID ) {/* assign GPIO to SDIO core */ - addr =CORE_CC_REG (SI_ENUM_BASE , gpiocontrol); + addr =brcmf_chip_enum_base (sdiodev->func1->device); + addr =CORE_CC_REG (addr, gpiocontrol); gpiocontrol =brcmf_sdiod_readl (sdiodev, addr, &ret); gpiocontrol |=0x2 ;brcmf_sdiod_writel (sdiodev, addr, gpiocontrol, &ret);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +12 -4
@@ -896,7 +896,8 @@ int brcmf_chip_dmp_erom_scan(struct brcmf_chip_priv *ci)u32 base, wrap;int err; - eromaddr = ci->ops->read32 (ci->ctx,CORE_CC_REG (SI_ENUM_BASE , eromptr)); + eromaddr = ci->ops->read32 (ci->ctx, +CORE_CC_REG (ci->pub.enum_base, eromptr));while (desc_type !=DMP_DESC_EOT ) { val =brcmf_chip_dmp_get_desc (ci, &eromaddr, &desc_type);
@@ -944,6 +945,11 @@ int brcmf_chip_dmp_erom_scan(struct brcmf_chip_priv *ci)return 0 ; } +u32 brcmf_chip_enum_base (u16 devid) +{ +return SI_ENUM_BASE_DEFAULT ; +} +static int brcmf_chip_recognition (struct brcmf_chip_priv *ci) {struct brcmf_core *core;
@@ -956,7 +962,8 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)* For different chiptypes or old sdio hosts w/o chipcommon, * other ways of recognition should be added here. */ - regdata = ci->ops->read32 (ci->ctx,CORE_CC_REG (SI_ENUM_BASE , chipid)); + regdata = ci->ops->read32 (ci->ctx, +CORE_CC_REG (ci->pub.enum_base, chipid)); ci->pub.chip = regdata &CID_ID_MASK ; ci->pub.chiprev = (regdata &CID_REV_MASK ) >>CID_REV_SHIFT ; socitype = (regdata &CID_TYPE_MASK ) >>CID_TYPE_SHIFT ;
@@ -976,7 +983,7 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci) ci->resetcore = brcmf_chip_sb_resetcore; core =brcmf_chip_add_core (ci,BCMA_CORE_CHIPCOMMON , -SI_ENUM_BASE ,0 ); +SI_ENUM_BASE_DEFAULT ,0 );brcmf_chip_sb_corerev (ci, core); core =brcmf_chip_add_core (ci,BCMA_CORE_SDIO_DEV ,BCM4329_CORE_BUS_BASE ,0 );
@@ -1090,7 +1097,7 @@ static int brcmf_chip_setup(struct brcmf_chip_priv *chip)return ret; } -struct brcmf_chip *brcmf_chip_attach (void *ctx, +struct brcmf_chip *brcmf_chip_attach (void *ctx,u16 devid,const struct brcmf_buscore_ops *ops) {struct brcmf_chip_priv *chip;
@@ -1115,6 +1122,7 @@ struct brcmf_chip *brcmf_chip_attach(void *ctx, chip->num_cores =0 ; chip->ops = ops; chip->ctx = ctx; + chip->pub.enum_base =brcmf_chip_enum_base (devid); err = ops->prepare (ctx);if (err <0 )
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h +4 -1
@@ -15,6 +15,7 @@* * @chip: chip identifier. * @chiprev: chip revision. +* @enum_base: base address of core enumeration space. * @cc_caps: chipcommon core capabilities. * @cc_caps_ext: chipcommon core extended capabilities. * @pmucaps: PMU capabilities.
@@ -27,6 +28,7 @@struct brcmf_chip {u32 chip;u32 chiprev; +u32 enum_base;u32 cc_caps;u32 cc_caps_ext;u32 pmucaps;
@@ -70,7 +72,7 @@ struct brcmf_buscore_ops { };int brcmf_chip_get_raminfo (struct brcmf_chip *pub); -struct brcmf_chip *brcmf_chip_attach (void *ctx, +struct brcmf_chip *brcmf_chip_attach (void *ctx,u16 devid,const struct brcmf_buscore_ops *ops);void brcmf_chip_detach (struct brcmf_chip *chip);struct brcmf_core *brcmf_chip_get_core (struct brcmf_chip *chip,u16 coreid);
@@ -85,5 +87,6 @@ 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);char *brcmf_chip_name (u32 chipid,u32 chiprev,char *buf,uint len); +u32 brcmf_chip_enum_base (u16 devid);#endif /* BRCMF_AXIDMP_H */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +2 -1
@@ -1886,7 +1886,8 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) devinfo->pdev = pdev; pcie_bus_dev =NULL ; - devinfo->ci =brcmf_chip_attach (devinfo, &brcmf_pcie_buscore_ops); + devinfo->ci =brcmf_chip_attach (devinfo, pdev->device, + &brcmf_pcie_buscore_ops);if (IS_ERR (devinfo->ci)) { ret =PTR_ERR (devinfo->ci); devinfo->ci =NULL ;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +8 -4
@@ -3907,7 +3907,7 @@ static u32 brcmf_sdio_buscore_read32(void *ctx, u32 addr)* It can be identified as 4339 by looking at the chip revision. It * is corrected here so the chip.c module has the right info. */ -if (addr ==CORE_CC_REG (SI_ENUM_BASE , chipid) && +if (addr ==CORE_CC_REG (SI_ENUM_BASE_DEFAULT , chipid) && (sdiodev->func1->device ==SDIO_DEVICE_ID_BROADCOM_4339 || sdiodev->func1->device ==SDIO_DEVICE_ID_BROADCOM_4335_4339 )) { rev = (val &CID_REV_MASK ) >>CID_REV_SHIFT ;
@@ -3943,12 +3943,15 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus)int reg_addr;u32 reg_val;u32 drivestrength; +u32 enum_base; sdiodev = bus->sdiodev;sdio_claim_host (sdiodev->func1); -pr_debug ("F1 signature read @0x18000000=0x%4x\n" , -brcmf_sdiod_readl (sdiodev,SI_ENUM_BASE ,NULL )); + enum_base =brcmf_chip_enum_base (sdiodev->func1->device); + +pr_debug ("F1 signature read @0x%08x=0x%4x\n" , enum_base, +brcmf_sdiod_readl (sdiodev, enum_base,NULL ));/* * Force PLL off until brcmf_chip_attach()
@@ -3967,7 +3970,8 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus) goto fail; } - bus->ci =brcmf_chip_attach (sdiodev, &brcmf_sdio_buscore_ops); + bus->ci =brcmf_chip_attach (sdiodev, sdiodev->func1->device, + &brcmf_sdio_buscore_ops);if (IS_ERR (bus->ci)) {brcmf_err ("brcmf_chip_attach failed!\n" ); bus->ci =NULL ;
drivers/net/wireless/broadcom/brcm80211/include/soc.h +1 -1
@@ -6,7 +6,7 @@#ifndef _BRCM_SOC_H#define _BRCM_SOC_H -#define SI_ENUM_BASE 0x18000000/* Enumeration space base */ +#define SI_ENUM_BASE_DEFAULT 0x18000000/* Common core control flags */ #define SICF_BIST_EN 0x8000
Signature · 1 line
2.27.0