wifi: brcmfmac: add support for TRX firmware download
Subsystems (3)
PATCH 1/2 wifi: brcmfmac: add support for TRX firmware download
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
---
NOTE: This is downstream upport from
https://github.com/Infineon/ifx-wireless-drivers/ branch RTM/v5.15.58-Indrik / tag release-v5.15.58-2024_0514
- ba34bf4816f9 ("brcmfmac: add support for TRX firmware download")
---
Cc: "Dr. David Alan Gilbert" <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: "Rafał Miłecki" <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Carter Chen <[email protected]>
Cc: Chung-Hsien Hsu <[email protected]>
Cc: Duoming Zhou <[email protected]>
Cc: Erick Archer <[email protected]>
Cc: Kalle Valo <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Mathias Krause <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: Owen Huang <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- .../broadcom/brcm80211/brcmfmac/pcie.c | 12 +++++- .../broadcom/brcm80211/brcmfmac/sdio.c | 20 +++++++--- .../broadcom/brcm80211/brcmfmac/trxhdr.h | 38 +++++++++++++++++++ 3 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/trxhdr.h
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +10 -2
@@ -42,6 +42,7 @@#include "chip.h" #include "core.h" #include "common.h" +#include "trxhdr.h" enum brcmf_pcie_state {
@@ -1684,6 +1685,8 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo, u32 nvram_len) {struct brcmf_bus *bus =dev_get_drvdata (&devinfo->pdev->dev); +struct trx_header_le *trx = (struct trx_header_le *)fw->data; +u32 fw_size;u32 sharedram_addr;u32 sharedram_addr_written;u32 loop_counter;
@@ -1697,8 +1700,13 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,return err;brcmf_dbg (PCIE ,"Download FW %s\n" , devinfo->fw_name); -memcpy_toio (devinfo->tcm + devinfo->ci->rambase, - (void *)fw->data, fw->size); + address = devinfo->ci->rambase; + fw_size = fw->size; +if (trx->magic ==cpu_to_le32 (TRX_MAGIC )) { + address -=sizeof (struct trx_header_le ); + fw_size =le32_to_cpu (trx->len); + } +memcpy_toio (devinfo->tcm + address, (void *)fw->data, fw_size); resetintr =get_unaligned_le32 (fw->data);release_firmware (fw);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +15 -5
@@ -35,6 +35,7 @@#include "core.h" #include "common.h" #include "bcdc.h" +#include "trxhdr.h" #define DCMD_RESP_TIMEOUT msecs_to_jiffies(2500)#define CTL_DONE_TIMEOUT msecs_to_jiffies(2500)
@@ -3346,17 +3347,26 @@ brcmf_sdio_verifymemory(struct brcmf_sdio_dev *sdiodev, u32 ram_addr,static int brcmf_sdio_download_code_file (struct brcmf_sdio *bus,const struct firmware *fw) { +struct trx_header_le *trx = (struct trx_header_le *)fw->data; +u32 fw_size; +u32 address;int err;brcmf_dbg (TRACE ,"Enter\n" ); - err =brcmf_sdiod_ramrw (bus->sdiodev, true, bus->ci->rambase, - (u8 *)fw->data, fw->size); + address = bus->ci->rambase; + fw_size = fw->size; +if (trx->magic ==cpu_to_le32 (TRX_MAGIC )) { + address -=sizeof (struct trx_header_le ); + fw_size =le32_to_cpu (trx->len); + } + err =brcmf_sdiod_ramrw (bus->sdiodev, true, address, + (u8 *)fw->data, fw_size);if (err)brcmf_err ("error %d on writing %d membytes at 0x%08x\n" , - err, (int )fw->size, bus->ci->rambase); -else if (!brcmf_sdio_verifymemory (bus->sdiodev, bus->ci->rambase, - (u8 *)fw->data, fw->size)) + err, (int )fw_size, address); +else if (!brcmf_sdio_verifymemory (bus->sdiodev, address, + (u8 *)fw->data, fw_size)) err = -EIO ;return err;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/trxhdr.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: ISC */ +/* Copyright (c) 2020 Cypress Semiconductor Corporation */ + +#ifndef BRCMFMAC_TRXHDR_H +#define BRCMFMAC_TRXHDR_H + +/* Bootloader makes special use of trx header "offsets" array */ +enum { +TRX_OFFSET_SIGN_INFO_IDX =0 , +TRX_OFFSET_DATA_FOR_SIGN1_IDX =1 , +TRX_OFFSET_DATA_FOR_SIGN2_IDX =2 , +TRX_OFFSET_ROOT_MODULUS_IDX =3 , +TRX_OFFSET_ROOT_EXPONENT_IDX =67 , +TRX_OFFSET_CONT_MODULUS_IDX =68 , +TRX_OFFSET_CONT_EXPONENT_IDX =132 , +TRX_OFFSET_HASH_FW_IDX =133 , +TRX_OFFSET_FW_LEN_IDX =149 , +TRX_OFFSET_TR_RST_IDX =150 , +TRX_OFFSET_FW_VER_FOR_ANTIROOLBACK_IDX =151 , +TRX_OFFSET_IV_IDX =152 , +TRX_OFFSET_NONCE_IDX =160 , +TRX_OFFSET_SIGN_INFO2_IDX =168 , +TRX_OFFSET_MAX_IDX +}; + +#define TRX_MAGIC 0x30524448/* "HDR0" */ +#define TRX_VERSION 4/* Version 4 */ +#define TRX_MAX_OFFSET TRX_OFFSET_MAX_IDX/* Max number of file offsets */ + +struct trx_header_le { +__le32 magic;/* "HDR0" */ +__le32 len;/* Length of file including header */ +__le32 crc32;/* CRC from flag_version to end of file */ +__le32 flag_version;/* 0:15 flags, 16:31 version */ +__le32 offsets[TRX_MAX_OFFSET ];/* Offsets of partitions */ +}; + +#endif /* BRCMFMAC_TRXHDR_H */
Signature · 1 line
2.43.0
PATCH 2/2 wifi: brcmfmac: add support for CYW55572 PCIe chipset
From: Chung-Hsien Hsu <[email protected]>
CYW55572 is a 2x2 dual-band 802.11a/b/g/n/ac/ax chipset with 20/40/80MHz channel support. It is a WLAN+BT combo device with WLAN secure boot support. The CYW55572 used to be labeled CYW55560.
---
NOTE: This is squashed from downstream upports from
https://github.com/Infineon/ifx-wireless-drivers/ branch RTM/v5.15.58-Indrik / tag release-v5.15.58-2024_0514
- 8a41d39f6290 ("brcmfmac: add Cypress PCIe vendor ID")
- 12f74eba2569 ("brcmfmac: add support for CYW55560 PCIe chipset")
- ea4e4056a3f8 ("brcmfmac: update firmware loading name for CY5557x")
- ee322201fe11 ("brcmfmac: use SR core id to decide SR capability for CY55572")
- 0a47ed7f3678 ("brcmfmac: Fix invalid RAM address warning for PCIE platforms")
---
Cc: "Dr. David Alan Gilbert" <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: "Rafał Miłecki" <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Carter Chen <[email protected]>
Cc: Chung-Hsien Hsu <[email protected]>
Cc: Duoming Zhou <[email protected]>
Cc: Erick Archer <[email protected]>
Cc: Kalle Valo <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Mathias Krause <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: Owen Huang <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- .../broadcom/brcm80211/brcmfmac/bcmsdh.c | 6 + .../broadcom/brcm80211/brcmfmac/chip.c | 214 +++++++++++++++++- .../broadcom/brcm80211/brcmfmac/chip.h | 34 +++ .../broadcom/brcm80211/brcmfmac/firmware.c | 15 +- .../broadcom/brcm80211/brcmfmac/firmware.h | 8 +- .../broadcom/brcm80211/brcmfmac/pcie.c | 192 +++++++++++++++- .../broadcom/brcm80211/brcmfmac/sdio.c | 27 ++- .../broadcom/brcm80211/include/brcm_hw_ids.h | 3 + .../broadcom/brcm80211/include/brcmu_utils.h | 13 ++ include/linux/bcma/bcma.h | 1 + include/linux/mmc/sdio_ids.h | 1 + 11 files changed, 497 insertions(+), 17 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +6 -0
@@ -46,6 +46,8 @@#define SDIO_4373_FUNC2_BLOCKSIZE 256#define SDIO_435X_FUNC2_BLOCKSIZE 256#define SDIO_4329_FUNC2_BLOCKSIZE 128 +#define SDIO_CYW55572_FUNC2_BLOCKSIZE 256 +/* Maximum milliseconds to wait for F2 to come up */ #define SDIO_WAIT_F2RDY 3000
@@ -917,6 +919,9 @@ int brcmf_sdiod_probe(struct brcmf_sdio_dev *sdiodev)case SDIO_DEVICE_ID_BROADCOM_4329 : f2_blksz =SDIO_4329_FUNC2_BLOCKSIZE ;break ; +case SDIO_DEVICE_ID_CYPRESS_55572 : + f2_blksz =SDIO_CYW55572_FUNC2_BLOCKSIZE ; +break ;default :break ; }
@@ -996,6 +1001,7 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = {BRCMF_SDIO_DEVICE (SDIO_DEVICE_ID_BROADCOM_CYPRESS_43752 ,CYW ),BRCMF_SDIO_DEVICE (SDIO_DEVICE_ID_BROADCOM_CYPRESS_89359 ,CYW ),CYW_SDIO_DEVICE (SDIO_DEVICE_ID_BROADCOM_CYPRESS_43439 ,CYW ), + CYW_SDIO_DEVICE(SDIO_DEVICE_ID_CYPRESS_55572, CYW), { /* end: all zeroes */ } };MODULE_DEVICE_TABLE (sdio, brcmf_sdmmc_ids);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +212 -2
280 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h +34 -0
@@ -10,6 +10,8 @@#define CORE_CC_REG (base, field) \ (base + offsetof(struct chipcregs, field)) +struct brcmf_blhs ; +/** * struct brcmf_chip - chip level information. *
@@ -24,6 +26,7 @@* @ramsize: amount of RAM on chip including retention. * @srsize: amount of retention RAM on chip. * @name: string representation of the chip identifier. +* @blhs: bootlooder handshake handle. */ struct brcmf_chip {u32 chip;
@@ -37,6 +40,7 @@ struct brcmf_chip {u32 ramsize;u32 srsize;char name[12 ]; +struct brcmf_blhs *blhs; };/**
@@ -61,6 +65,7 @@ struct brcmf_core {* @setup: bus-specific core setup. * @active: chip becomes active. * The callback should use the provided @rstvec when non-zero. +* @blhs_attach: attach bootloader handshake handle */ struct brcmf_buscore_ops {u32 (*read32)(void *ctx,u32 addr);
@@ -69,6 +74,35 @@ struct brcmf_buscore_ops {int (*reset)(void *ctx,struct brcmf_chip *chip);int (*setup)(void *ctx,struct brcmf_chip *chip);void (*activate)(void *ctx,struct brcmf_chip *chip,u32 rstvec); +int (*blhs_attach)(void *ctx,struct brcmf_blhs **blhs,u32 flag, +uint timeout,uint interval); +}; + +/** +* struct brcmf_blhs - bootloader handshake handle related information. +* +* @d2h: offset of dongle to host register for the handshake. +* @h2d: offset of host to dongle register for the handshake. +* @init: bootloader handshake initialization. +* @prep_fwdl: handshake before firmware download. +* @post_fwdl: handshake after firmware download. +* @post_nvramdl: handshake after nvram download. +* @chk_validation: handshake for firmware validation check. +* @post_wdreset: handshake after watchdog reset. +* @read: read value with register offset for the handshake. +* @write: write value with register offset for the handshake. +*/ +struct brcmf_blhs { +u32 d2h; +u32 h2d; +void (*init)(struct brcmf_chip *pub); +int (*prep_fwdl)(struct brcmf_chip *pub); +int (*post_fwdl)(struct brcmf_chip *pub); +void (*post_nvramdl)(struct brcmf_chip *pub); +int (*chk_validation)(struct brcmf_chip *pub); +int (*post_wdreset)(struct brcmf_chip *pub); +u32 (*read)(void *ctx,u32 addr); +void (*write)(void *ctx,u32 addr,u32 value); };int brcmf_chip_get_raminfo (struct brcmf_chip *pub);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +14 -1
@@ -527,7 +527,8 @@ static void brcmf_fw_free_request(struct brcmf_fw_request *req)int i;for (i =0 , item = &req->items[0 ]; i < req->n_items; i++, item++) { -if (item->type ==BRCMF_FW_TYPE_BINARY ) +if (item->type ==BRCMF_FW_TYPE_BINARY || + item->type ==BRCMF_FW_TYPE_TRXSE )release_firmware (item->binary);else if (item->type ==BRCMF_FW_TYPE_NVRAM )brcmf_fw_nvram_free (item->nv_data.data);
@@ -599,6 +600,7 @@ static int brcmf_fw_complete_request(const struct firmware *fw, ret =brcmf_fw_request_nvram_done (fw, fwctx);break ;case BRCMF_FW_TYPE_BINARY : +case BRCMF_FW_TYPE_TRXSE :if (fw) cur->binary = fw;else
@@ -672,8 +674,19 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,static void brcmf_fw_request_done (const struct firmware *fw,void *ctx) {struct brcmf_fw *fwctx = ctx; +struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos]; +char alt_path[BRCMF_FW_NAME_LEN ];int ret; +if (!fw && cur->type ==BRCMF_FW_TYPE_TRXSE ) { +strscpy (alt_path, cur->path,BRCMF_FW_NAME_LEN ); +/* strip 'se' from .trxse at the end */ + alt_path[strlen (alt_path) -2 ] =0 ; + ret =request_firmware (&fw, alt_path, fwctx->dev); +if (!ret) + cur->path = alt_path; + } + ret =brcmf_fw_complete_request (fw, fwctx);while (ret ==0 && ++fwctx->curpos < fwctx->req->n_items) {
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h +7 -1
@@ -41,6 +41,11 @@ static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \ MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin"); \ MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".clm_blob") +#define CY_FW_TRXSE_DEF (fw_name, fw_base) \ +static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \ + BRCMF_FW_DEFAULT_PATH fw_base; \ +MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".trxse") +#define BRCMF_FW_ENTRY (chipid, mask, name) \ { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME }
@@ -48,7 +53,8 @@ void brcmf_fw_nvram_free(void *nvram);enum brcmf_fw_type {BRCMF_FW_TYPE_BINARY , -BRCMF_FW_TYPE_NVRAM +BRCMF_FW_TYPE_NVRAM , +BRCMF_FW_TYPE_TRXSE };struct brcmf_fw_item {
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +182 -10
337 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +24 -3
@@ -59,6 +59,10 @@#define CY_435X_F2_WATERMARK 0x40#define CY_435X_F1_MESBUSYCTRL (CY_435X_F2_WATERMARK | \ SBSDIO_MESBUSYCTRL_ENAB) +#define CYW55572_F2_WATERMARK 0x40 +#define CYW55572_MES_WATERMARK 0x40 +#define CYW55572_F1_MESBUSYCTRL (CYW55572_MES_WATERMARK | \ + SBSDIO_MESBUSYCTRL_ENAB)#ifdef DEBUG
@@ -626,6 +630,7 @@ BRCMF_FW_DEF(4359, "brcmfmac4359-sdio");BRCMF_FW_CLM_DEF (4373 ,"brcmfmac4373-sdio" );BRCMF_FW_CLM_DEF (43012 ,"brcmfmac43012-sdio" );BRCMF_FW_CLM_DEF (43752 ,"brcmfmac43752-sdio" ); +CY_FW_TRXSE_DEF (55572 ,"cyfmac55572-sdio" );/* firmware config files */ MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-sdio.*.txt" );
@@ -658,7 +663,8 @@ static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = {BRCMF_FW_ENTRY (CY_CC_4373_CHIP_ID ,0xFFFFFFFF ,4373 ),BRCMF_FW_ENTRY (CY_CC_43012_CHIP_ID ,0xFFFFFFFF ,43012 ),BRCMF_FW_ENTRY (CY_CC_43439_CHIP_ID ,0xFFFFFFFF ,43439 ), - BRCMF_FW_ENTRY(CY_CC_43752_CHIP_ID, 0xFFFFFFFF, 43752) +BRCMF_FW_ENTRY (CY_CC_43752_CHIP_ID ,0xFFFFFFFF ,43752 ), + BRCMF_FW_ENTRY(CY_CC_55572_CHIP_ID, 0xFFFFFFFF, 55572) };#define TXCTL_CREDITS 2
@@ -719,7 +725,8 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on)* fail. Thereby just bailing out immediately after clearing KSO * bit, to avoid polling of KSO bit. */ -if (!on && bus->ci->chip ==CY_CC_43012_CHIP_ID ) +if (!on && (bus->ci->chip ==CY_CC_43012_CHIP_ID || + bus->ci->chip ==CY_CC_55572_CHIP_ID ))return err;if (on) {
@@ -3435,7 +3442,8 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus,static bool brcmf_sdio_aos_no_decode (struct brcmf_sdio *bus) {if (bus->ci->chip ==CY_CC_43012_CHIP_ID || - bus->ci->chip ==CY_CC_43752_CHIP_ID ) + bus->ci->chip ==CY_CC_43752_CHIP_ID || + bus->ci->chip ==CY_CC_55572_CHIP_ID )return true;else return false;
@@ -4352,6 +4360,19 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,brcmf_sdiod_writeb (sdiod,SBSDIO_FUNC1_MESBUSYCTRL ,CY_435X_F1_MESBUSYCTRL , &err);break ; +case SDIO_DEVICE_ID_CYPRESS_55572 : +brcmf_dbg (INFO ,"set F2 watermark to 0x%x*4 bytes\n" , +CYW55572_F2_WATERMARK ); +brcmf_sdiod_writeb (sdiod,SBSDIO_WATERMARK , +CYW55572_F2_WATERMARK , &err); + devctl =brcmf_sdiod_readb (sdiod,SBSDIO_DEVICE_CTL , + &err); + devctl |=SBSDIO_DEVCTL_F2WM_ENAB ; +brcmf_sdiod_writeb (sdiod,SBSDIO_DEVICE_CTL , devctl, + &err); +brcmf_sdiod_writeb (sdiod,SBSDIO_FUNC1_MESBUSYCTRL , +CYW55572_F1_MESBUSYCTRL , &err); +break ;default :brcmf_sdiod_writeb (sdiod,SBSDIO_WATERMARK ,DEFAULT_F2_WATERMARK , &err);
drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h +3 -0
@@ -14,6 +14,7 @@#define BRCM_USB_VENDOR_ID_LINKSYS 0x13b1#define CY_USB_VENDOR_ID_CYPRESS 0x04b4#define BRCM_PCIE_VENDOR_ID_BROADCOM PCI_VENDOR_ID_BROADCOM +#define CY_PCIE_VENDOR_ID_CYPRESS 0x12be/* Chipcommon Core Chip IDs */ #define BRCM_CC_43143_CHIP_ID 43143
@@ -59,6 +60,7 @@#define CY_CC_43012_CHIP_ID 43012#define CY_CC_43439_CHIP_ID 43439#define CY_CC_43752_CHIP_ID 43752 +#define CY_CC_55572_CHIP_ID 0xd908/* USB Device IDs */ #define BRCM_USB_43143_DEVICE_ID 0xbd1e
@@ -97,6 +99,7 @@#define BRCM_PCIE_4377_DEVICE_ID 0x4488#define BRCM_PCIE_4378_DEVICE_ID 0x4425#define BRCM_PCIE_4387_DEVICE_ID 0x4433 +#define CY_PCIE_55572_DEVICE_ID 0xbd31/* brcmsmac IDs */ #define BCM4313_D11N2G_ID 0x4727/* 4313 802.11n 2.4G device */
drivers/net/wireless/broadcom/brcm80211/include/brcmu_utils.h +13 -0
@@ -21,6 +21,19 @@ } \ } +/* Spin at most 'ms' milliseconds with polling interval 'interval' milliseconds +* while 'exp' is true. Caller should explicitly test 'exp' when this completes +* and take appropriate error action if 'exp' is still true. +*/ +#define SPINWAIT_MS (exp, ms, interval) { \ + typeof(interval) interval_ = (interval); \ + uint countdown = (ms) + (interval_ - 1U); \ + while ((exp) && (countdown >= interval_)) { \ + msleep(interval_); \ + countdown -= interval_; \ + } \ +} +/* osl multi-precedence packet queue */ #define PKTQ_LEN_DEFAULT 128/* Max 128 packets */ #define PKTQ_MAX_PREC 16/* Maximum precedence levels */
include/linux/bcma/bcma.h +1 -0
@@ -154,6 +154,7 @@ struct bcma_host_ops {#define BCMA_CORE_USB30_DEV 0x83D#define BCMA_CORE_ARM_CR4 0x83E#define BCMA_CORE_GCI 0x840 +#define BCMA_CORE_SR 0x841#define BCMA_CORE_CMEM 0x846/* CNDS DDR2/3 memory controller */ #define BCMA_CORE_ARM_CA7 0x847#define BCMA_CORE_SYS_MEM 0x849
include/linux/mmc/sdio_ids.h +1 -0
@@ -80,6 +80,7 @@#define SDIO_VENDOR_ID_CYPRESS 0x04b4#define SDIO_DEVICE_ID_BROADCOM_CYPRESS_43439 0xbd3d +#define SDIO_DEVICE_ID_CYPRESS_55572 0xbd31#define SDIO_VENDOR_ID_MARVELL 0x02df#define SDIO_DEVICE_ID_MARVELL_LIBERTAS 0x9103
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH 2/2] wifi: brcmfmac: add support for CYW55572 PCIe chipset
kernel test robot noticed the following build warnings:
Hi Marek,
kernel test robot noticed the following build warnings:
[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.11-rc4 next-20240819] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Marek-Vasut/wifi-brcmfmac-add-support-for-CYW55572-PCIe-chipset/20240819-041807 base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main patch link: https://lore.kernel.org/r/20240818201533.89669-2-marex%40denx.de patch subject: [PATCH 2/2] wifi: brcmfmac: add support for CYW55572 PCIe chipset config: loongarch-randconfig-r123-20240819 (https://download.01.org/0day-ci/archive/20240819/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 14.1.0 reproduce: (https://download.01.org/0day-ci/archive/20240819/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1664:29: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] signature @@ got restricted __le32 [usertype] @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1664:29: sparse: expected unsigned int [usertype] signature drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1664:29: sparse: got restricted __le32 [usertype] >> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1665:25: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] count @@ got restricted __le32 [usertype] @@ drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1665:25: sparse: expected unsigned int [usertype] count drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1665:25: sparse: got restricted __le32 [usertype] >> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1841:40: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected unsigned int [usertype] value @@ got restricted __le32 [usertype] @@
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1841:40: sparse: expected unsigned int [usertype] value
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1841:40: sparse: got restricted __le32 [usertype]
vim +1664 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
1649
1650
1651 static void
1652 brcmf_pcie_write_rand(struct brcmf_pciedev_info *devinfo, u32 nvram_csm)
1653 {
1654 struct brcmf_rand_metadata rand_data;
1655 u8 rand_buf[BRCMF_ENTROPY_HOST_LEN];
1656 u32 count = BRCMF_ENTROPY_HOST_LEN;
1657 u32 address;
1658
1659 address = devinfo->ci->rambase +
1660 (devinfo->ci->ramsize - BRCMF_NVRAM_OFFSET_TCM) -
1661 ((nvram_csm & 0xffff) * BRCMF_NVRAM_COMPRS_FACTOR) -
1662 sizeof(rand_data);
1663 memset(rand_buf, 0, BRCMF_ENTROPY_HOST_LEN);
> 1664 rand_data.signature = cpu_to_le32(BRCMF_NVRAM_RNG_SIGNATURE);
> 1665 rand_data.count = cpu_to_le32(count);
1666 memcpy_toio(devinfo->tcm + address, &rand_data, sizeof(rand_data));
1667 address -= count;
1668 get_random_bytes(rand_buf, count);
1669 memcpy_toio(devinfo->tcm + address, rand_buf, count);
1670 }
1671
1672 static int
1673 brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo,
1674 u32 sharedram_addr)
1675 {
1676 struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
1677 struct brcmf_pcie_shared_info *shared;
1678 u32 addr;
1679
1680 shared = &devinfo->shared;
1681 shared->tcm_base_address = sharedram_addr;
1682
1683 shared->flags = brcmf_pcie_read_tcm32(devinfo, sharedram_addr);
1684 shared->version = (u8)(shared->flags & BRCMF_PCIE_SHARED_VERSION_MASK);
1685 brcmf_dbg(PCIE, "PCIe protocol version %d\n", shared->version);
1686 if ((shared->version > BRCMF_PCIE_MAX_SHARED_VERSION) ||
1687 (shared->version < BRCMF_PCIE_MIN_SHARED_VERSION)) {
1688 brcmf_err(bus, "Unsupported PCIE version %d\n",
1689 shared->version);
1690 return -EINVAL;
1691 }
1692
1693 /* check firmware support dma indicies */
1694 if (shared->flags & BRCMF_PCIE_SHARED_DMA_INDEX) {
1695 if (shared->flags & BRCMF_PCIE_SHARED_DMA_2B_IDX)
1696 devinfo->dma_idx_sz = sizeof(u16);
1697 else
1698 devinfo->dma_idx_sz = sizeof(u32);
1699 }
1700
1701 addr = sharedram_addr + BRCMF_SHARED_MAX_RXBUFPOST_OFFSET;
1702 shared->max_rxbufpost = brcmf_pcie_read_tcm16(devinfo, addr);
1703 if (shared->max_rxbufpost == 0)
1704 shared->max_rxbufpost = BRCMF_DEF_MAX_RXBUFPOST;
1705
1706 addr = sharedram_addr + BRCMF_SHARED_RX_DATAOFFSET_OFFSET;
1707 shared->rx_dataoffset = brcmf_pcie_read_tcm32(devinfo, addr);
1708
1709 addr = sharedram_addr + BRCMF_SHARED_HTOD_MB_DATA_ADDR_OFFSET;
1710 shared->htod_mb_data_addr = brcmf_pcie_read_tcm32(devinfo, addr);
1711
1712 addr = sharedram_addr + BRCMF_SHARED_DTOH_MB_DATA_ADDR_OFFSET;
1713 shared->dtoh_mb_data_addr = brcmf_pcie_read_tcm32(devinfo, addr);
1714
1715 addr = sharedram_addr + BRCMF_SHARED_RING_INFO_ADDR_OFFSET;
1716 shared->ring_info_addr = brcmf_pcie_read_tcm32(devinfo, addr);
1717
1718 brcmf_dbg(PCIE, "max rx buf post %d, rx dataoffset %d\n",
1719 shared->max_rxbufpost, shared->rx_dataoffset);
1720
1721 brcmf_pcie_bus_console_init(devinfo);
1722 brcmf_pcie_bus_console_read(devinfo, false);
1723
1724 return 0;
1725 }
1726
1727 struct brcmf_random_seed_footer {
1728 __le32 length;
1729 __le32 magic;
1730 };
1731
1732 #define BRCMF_RANDOM_SEED_MAGIC 0xfeedc0de
1733 #define BRCMF_RANDOM_SEED_LENGTH 0x100
1734
1735 static noinline_for_stack void
1736 brcmf_pcie_provide_random_bytes(struct brcmf_pciedev_info *devinfo, u32 address)
1737 {
1738 u8 randbuf[BRCMF_RANDOM_SEED_LENGTH];
1739
1740 get_random_bytes(randbuf, BRCMF_RANDOM_SEED_LENGTH);
1741 memcpy_toio(devinfo->tcm + address, randbuf, BRCMF_RANDOM_SEED_LENGTH);
1742 }
1743
1744 static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
1745 const struct firmware *fw, void *nvram,
1746 u32 nvram_len)
1747 {
1748 struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
1749 struct trx_header_le *trx = (struct trx_header_le *)fw->data;
1750 u32 fw_size;
1751 u32 sharedram_addr;
1752 u32 sharedram_addr_written;
1753 u32 loop_counter;
1754 int err;
1755 u32 address;
1756 u32 resetintr;
1757 u32 nvram_lenw;
1758 u32 nvram_csm;
1759
1760 brcmf_dbg(PCIE, "Halt ARM.\n");
1761 err = brcmf_pcie_enter_download_state(devinfo);
1762 if (err)
1763 return err;
1764
1765 brcmf_dbg(PCIE, "Download FW %s\n", devinfo->fw_name);
1766 address = devinfo->ci->rambase;
1767 fw_size = fw->size;
1768 if (trx->magic == cpu_to_le32(TRX_MAGIC)) {
1769 address -= sizeof(struct trx_header_le);
1770 fw_size = le32_to_cpu(trx->len);
1771 }
1772 memcpy_toio(devinfo->tcm + address, (void *)fw->data, fw_size);
1773
1774 resetintr = get_unaligned_le32(fw->data);
1775 release_firmware(fw);
1776
1777 if (devinfo->ci->blhs) {
1778 err = devinfo->ci->blhs->post_fwdl(devinfo->ci);
1779 if (err) {
1780 brcmf_err(bus, "FW download failed, err=%d\n", err);
1781 return err;
1782 }
1783
1784 err = devinfo->ci->blhs->chk_validation(devinfo->ci);
1785 if (err) {
1786 brcmf_err(bus, "FW valication failed, err=%d\n", err);
1787 return err;
1788 }
1789 } else {
1790 /* reset last 4 bytes of RAM address. to be used for shared
1791 * area. This identifies when FW is running
1792 */
1793 brcmf_pcie_write_ram32(devinfo, devinfo->ci->ramsize - 4, 0);
1794 }
1795
1796 if (nvram) {
1797 brcmf_dbg(PCIE, "Download NVRAM %s\n", devinfo->nvram_name);
1798 address = devinfo->ci->rambase + devinfo->ci->ramsize -
1799 nvram_len;
1800
1801 if (devinfo->ci->blhs)
1802 address -= 4;
1803 memcpy_toio(devinfo->tcm + address, nvram, nvram_len);
1804
1805 /* Convert nvram_len to words to determine the length token */
1806 nvram_lenw = nvram_len / 4;
1807 /* subtract word used to store the token itself on non-blhs devices */
1808 if (!devinfo->ci->blhs)
1809 nvram_lenw -= 1;
1810 nvram_csm = (~nvram_lenw << 16) | (nvram_lenw & 0x0000FFFF);
1811 brcmf_fw_nvram_free(nvram);
1812
1813 if (devinfo->otp.valid) {
1814 size_t rand_len = BRCMF_RANDOM_SEED_LENGTH;
1815 struct brcmf_random_seed_footer footer = {
1816 .length = cpu_to_le32(rand_len),
1817 .magic = cpu_to_le32(BRCMF_RANDOM_SEED_MAGIC),
1818 };
1819
1820 /* Some Apple chips/firmwares expect a buffer of random
1821 * data to be present before NVRAM
1822 */
1823 brcmf_dbg(PCIE, "Download random seed\n");
1824
1825 address -= sizeof(footer);
1826 memcpy_toio(devinfo->tcm + address, &footer,
1827 sizeof(footer));
1828
1829 address -= rand_len;
1830 brcmf_pcie_provide_random_bytes(devinfo, address);
1831 }
1832 } else {
1833 nvram_csm = 0;
1834 brcmf_dbg(PCIE, "No matching NVRAM file found %s\n",
1835 devinfo->nvram_name);
1836 }
1837
1838 if (devinfo->ci->chip == CY_CC_55572_CHIP_ID) {
1839 /* Write the length token to the last word of RAM address */
1840 brcmf_pcie_write_ram32(devinfo, devinfo->ci->ramsize - 4,
> 1841 cpu_to_le32(nvram_csm)); 1842
1843 /* Write random numbers to TCM for randomizing heap address */
1844 brcmf_pcie_write_rand(devinfo, nvram_csm);
1845 }
1846
1847 sharedram_addr_written = brcmf_pcie_read_ram32(devinfo,
1848 devinfo->ci->ramsize -
1849 4);
1850 brcmf_dbg(PCIE, "Bring ARM in running state\n");
1851 err = brcmf_pcie_exit_download_state(devinfo, resetintr);
1852 if (err)
1853 return err;
1854
1855 brcmf_dbg(PCIE, "Wait for FW init\n");
1856 sharedram_addr = sharedram_addr_written;
1857 loop_counter = BRCMF_PCIE_FW_UP_TIMEOUT / 50;
1858 while ((sharedram_addr == sharedram_addr_written) && (loop_counter)) {
1859 msleep(50);
1860 sharedram_addr = brcmf_pcie_read_ram32(devinfo,
1861 devinfo->ci->ramsize -
1862 4);
1863 loop_counter--;
1864 }
1865 if (sharedram_addr == sharedram_addr_written) {
1866 brcmf_err(bus, "FW failed to initialize\n");
1867 return -ENODEV;
1868 }
1869 if (sharedram_addr < devinfo->ci->rambase ||
1870 sharedram_addr >= devinfo->ci->rambase + devinfo->ci->ramsize) {
1871 brcmf_err(bus, "Invalid shared RAM address 0x%08x\n",
1872 sharedram_addr);
1873 return -ENODEV;
1874 }
1875 brcmf_dbg(PCIE, "Shared RAM addr: 0x%08x\n", sharedram_addr);
1876
1877 return (brcmf_pcie_init_share_ram_info(devinfo, sharedram_addr));
1878 }
1879
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Marek Vasut <[email protected]>
Quoted 5 lines
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>
The email address of From field (author) is different from first s-o-b.
Quoted 8 lines · Ping-Ke Shih
Marek Vasut <[email protected]>
Quoted 5 lines
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>The email address of From field (author) is different from first s-o-b.
It seems this is a result of cypress being assimilated into infineon, it seems like it is still the same person though.
Quoted 6 lines · Marek Vasut
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>
The commit message should answer to the question 'Why?'. What's TRX firmware and why do we need it?
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Arend Van Spriel
maintainerQuoted 11 lines · Kalle Valo
Quoted 6 lines · Marek Vasut
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>The commit message should answer to the question 'Why?'. What's TRX firmware and why do we need it?
I looked over the patches, but did not sit down to comment on this. The TRX firmware format allows multiple images and possibly compression. Not sure if Infineon is using all this functionality. This is probably needed for 55572 device support (patch 2/2). Turns out this device has a bootloader that the driver has to talk with and that is probably where this TRX support comes from. Not something I considered to happen for SDIO and PCIe devices. There is always a puzzle to solve ;-)
Also noticed a random seed is provided to firmware. This already there for apple chips so it should be looked at whether that code can be shared. I will follow up.
Regards,
Arend
On 8/19/24 5:52 PM, Arend Van Spriel wrote:
Hi,
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>The commit message should answer to the question 'Why?'. What's TRX firmware and why do we need it?
I looked over the patches, but did not sit down to comment on this.
Thanks, it is real nice that someone who is actually familiar with the hardware jumped in. I only upported the patches from infineon downstream.
Quoted 3 lines
The TRX firmware format allows multiple images and possibly compression. Not sure if Infineon is using all this functionality. This is probably needed for 55572 device support (patch 2/2). Turns out this device has a bootloader that the driver has to talk with and that is probably where this TRX support comes from. Not something I considered to happen for SDIO and PCIe devices. There is always a puzzle to solve ;-)
Also noticed a random seed is provided to firmware. This already there for apple chips so it should be looked at whether that code can be shared. I will follow up.
I did notice just now there is some TRX support for USB broadcom devices ?
Quoted 14 lines · Marek Vasut
On 8/19/24 5:52 PM, Arend Van Spriel wrote:
Hi,
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>The commit message should answer to the question 'Why?'. What's TRX firmware and why do we need it?
I looked over the patches, but did not sit down to comment on this.
Quoted 8 lines
Thanks, it is real nice that someone who is actually familiar with the hardware jumped in. I only upported the patches from infineon downstream.
Quoted 3 lines
The TRX firmware format allows multiple images and possibly compression. Not sure if Infineon is using all this functionality. This is probably needed for 55572 device support (patch 2/2). Turns out this device has a bootloader that the driver has to talk with and that is probably where this TRX support comes from. Not something I considered to happen for SDIO and PCIe devices. There is always a puzzle to solve ;-)
Also noticed a random seed is provided to firmware. This already there for apple chips so it should be looked at whether that code can be shared. I will follow up.
I did notice just now there is some TRX support for USB broadcom devices ?
TRX is a format that is also used for partitioning flash devices, so there is probably some room for making a common header:
./Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt/drivers/mtd/parsers/parser_trx.c
Signature · 1 line
Florian
On 8/19/24 8:09 PM, Florian Fainelli wrote:
Hi,
Quoted 6 lines
Quoted 2 lines
I did notice just now there is some TRX support for USB broadcom devices ?
TRX is a format that is also used for partitioning flash devices, so there is probably some room for making a common header:
./Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt/drivers/mtd/parsers/parser_trx.c
Is that format somehow standardized ? I recall it was used on some OpenWRT routers ?
It seems the TRXSE (whatever it is) is used more like a carrier for the firmware blob (chunks?) which are pushed into SRAM (?) of the CYW55572 device.
Quoted 6 lines · Marek Vasut
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>
Please fix the review comments, also Ping's comment that from and s-o-b needs to match.
2 patches set to Changes Requested.
13767592 [1/2] wifi: brcmfmac: add support for TRX firmware download 13767593 [2/2] wifi: brcmfmac: add support for CYW55572 PCIe chipset
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 11 lines · Kalle Valo
Quoted 6 lines · Marek Vasut
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>Please fix the review comments, also Ping's comment that from and s-o-b needs to match.
I have most of the changes addressed locally already.
Regarding the SoB line, do I update the commit Author email (because that would make more sense, cypress got assimilated into infineon) or the SoB line email to the "old" cypress email address ?
I am still hoping to get a bit more input on the TRX firmware handling from Arend ... or maybe there is no further feedback ?
Arend Van Spriel
maintainer+ Double Lo
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Kalle Valo
Quoted 6 lines · Marek Vasut
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>
Quoted 8 lines
Quoted 2 lines
Please fix the review comments, also Ping's comment that from and s-o-b needs to match.
I have most of the changes addressed locally already.
Regarding the SoB line, do I update the commit Author email (because that would make more sense, cypress got assimilated into infineon) or the SoB line email to the "old" cypress email address ?
I would say the SoB line is leading as developer's certificate and that has the Infineon address so that seems more appropriate.
Quoted 2 lines
I am still hoping to get a bit more input on the TRX firmware handling from Arend ... or maybe there is no further feedback ?
Took me a while before I looked into this. Can not offer much info though. Within Broadcom code bases we only have a v1 and v2 defined for the TRX format. This patch specifies v4. The only difference seem to be the number of offsets and their meaning. Looking at the index definitions I suspect this version accommodates signed firmware images which is verified by the bootloader on the device.
Hopefully Infineon can/will confirm my suspicion and explain what SE in .TRXSE stands for (security extension?). Anyways, this seem pretty specific to (some) Infineon devices. Despite its history I would keep this separate and specifically use trxse instead of trx.
Regards,
Arend
On 9/1/24 8:55 AM, Arend Van Spriel wrote:
Hi,
Quoted 13 lines
Quoted 13 lines · Kalle Valo
Quoted 11 lines
Quoted 6 lines · Marek Vasut
From: Chung-Hsien Hsu <[email protected]>
Add support to download TRX firmware for PCIe and SDIO.
Signed-off-by Chung-Hsien Hsu <[email protected]>Please fix the review comments, also Ping's comment that from and s-o-b needs to match.
Quoted 7 lines
Quoted 5 lines
I have most of the changes addressed locally already.
Regarding the SoB line, do I update the commit Author email (because that would make more sense, cypress got assimilated into infineon) or the SoB line email to the "old" cypress email address ?
I would say the SoB line is leading as developer's certificate and that has the Infineon address so that seems more appropriate.
Let's add both to be on the safe side.
Quoted 6 lines
Quoted 2 lines
I am still hoping to get a bit more input on the TRX firmware handling from Arend ... or maybe there is no further feedback ?
Took me a while before I looked into this. Can not offer much info though. Within Broadcom code bases we only have a v1 and v2 defined for the TRX format. This patch specifies v4. The only difference seem to be the number of offsets and their meaning. Looking at the index definitions I suspect this version accommodates signed firmware images which is verified by the bootloader on the device.
Hopefully Infineon can/will confirm my suspicion and explain what SE in .TRXSE stands for (security extension?). Anyways, this seem pretty specific to (some) Infineon devices. Despite its history I would keep this separate and specifically use trxse instead of trx.
OK