From 6f257a532e83aca61b7149a4ebccee7a5702e273 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Mon, 26 Oct 2026 10:28:24 -0647 Subject: [PATCH 01/32] wifi: brcmfmac: pcie: support shared-memory version 9 firmware The Pixel 9a's BCM4383 firmware (20.123.13) speaks shared-memory ("PCIe IPC") version 9. Accept it next to version 7, keyed on the version the firmware reports rather than on a chip, and do what Broadcom's driver does for it: - read the EWP info block the shared area points to (offset 128) and refuse to go on unless the firmware says its initialisation ended, so a stalled firmware fails cleanly instead of leaving rings pointing nowhere; - bound every ring-info read and the fallback TCM index arrays to the chip's RAM before trusting them; - ring host-ready right after the common rings are set up, before any buffer is posted (the 4389 path, now keyed on the version too), and leave the aggregation host capability byte (offset 133) at zero; - the no-DAR doorbells by the same test. Version 8 stays refused: its layout is not known here. For the BCM4389 nothing changes: brcmf_pcie_early_hostready() is true for it by device id as before, and the version 9 checks do not run on its version 7 firmware. Tested on the Pixel 9a (BCM4383, API9): the firmware comes up, scans, joins a WPA2 network and passes traffic. Not yet booted on the Pixel 7 Pro. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- .../broadcom/brcm80211/brcmfmac/pcie.c | 145 ++++++++++++++++-- 1 file changed, 131 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 5e3aed4ae8..98671bf534 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -239,8 +239,9 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = { BRCMF_PCIE_64_MB_INT_D2H7_DB1) #define BRCMF_PCIE_SHARED_VERSION_7 7 +#define BRCMF_PCIE_SHARED_VERSION_9 9 #define BRCMF_PCIE_MIN_SHARED_VERSION 5 -#define BRCMF_PCIE_MAX_SHARED_VERSION BRCMF_PCIE_SHARED_VERSION_7 +#define BRCMF_PCIE_MAX_SHARED_VERSION BRCMF_PCIE_SHARED_VERSION_9 #define BRCMF_PCIE_SHARED_VERSION_MASK 0x00FF #define BRCMF_PCIE_SHARED_DMA_INDEX 0x10000 #define BRCMF_PCIE_SHARED_DMA_2B_IDX 0x100000 @@ -264,6 +265,12 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = { #define BRCMF_SHARED_DMA_RINGUPD_ADDR_OFFSET 68 /* shared area revision >= 6: host capabilities, read by the firmware */ #define BRCMF_SHARED_HOST_CAP_OFFSET 84 +#define BRCMF_SHARED_EWP_INFO_ADDR_OFFSET 128 +#define BRCMF_SHARED_AGGR_HOST_CAP_OFFSET 133 +#define BRCMF_SHARED_VERSION_9_SIZE 140 + +#define BRCMF_EWP_INFO_VERSION 1 +#define BRCMF_EWP_INIT_END 2 #define BRCMF_HOSTCAP_H2D_ENABLE_HOSTRDY 0x00000400 #define BRCMF_HOSTCAP_DS_NO_OOB_DW 0x00001000 @@ -1258,6 +1265,14 @@ static void brcmf_pcie_intr_enable(struct brcmf_pciedev_info *devinfo) devinfo->reginfo->int_fn0); } +/* API9 firmware defers TX allocation until host ready, as does BCM4389. */ +static bool +brcmf_pcie_early_hostready(struct brcmf_pciedev_info *devinfo) +{ + return devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID || + devinfo->shared.version == BRCMF_PCIE_SHARED_VERSION_9; +} + static void brcmf_pcie_hostready(struct brcmf_pciedev_info *devinfo) { if (devinfo->shared.flags & BRCMF_PCIE_SHARED_HOSTRDY_DB1) { @@ -1640,6 +1655,56 @@ static void brcmf_pcie_release_ringbuffers(struct brcmf_pciedev_info *devinfo) } +static bool +brcmf_pcie_valid_ram_range(struct brcmf_pciedev_info *devinfo, u32 addr, + u32 len) +{ + u64 end = (u64)addr + len; + + return len && addr >= devinfo->ci->rambase && end <= BIT_ULL(32) && + end <= (u64)devinfo->ci->rambase + devinfo->ci->ramsize; +} + +/* API9 must describe every ring and its fallback TCM indices in RAM. */ +static bool +brcmf_pcie_api9_valid_ringinfo(struct brcmf_pciedev_info *devinfo, + const struct brcmf_pcie_dhi_ringinfo *ringinfo) +{ + u32 h2d = le16_to_cpu(ringinfo->max_submissionrings); + u32 d2h = le16_to_cpu(ringinfo->max_completionrings); + u32 flows = le16_to_cpu(ringinfo->max_flowrings); + u32 ptrs[] = { + le32_to_cpu(ringinfo->h2d_w_idx_ptr), + le32_to_cpu(ringinfo->h2d_r_idx_ptr), + le32_to_cpu(ringinfo->d2h_w_idx_ptr), + le32_to_cpu(ringinfo->d2h_r_idx_ptr), + }; + u32 ringmem = le32_to_cpu(ringinfo->ringmem); + u32 count; + u32 i; + + if (!flows || flows > 512 || + h2d < flows + BRCMF_NROF_H2D_COMMON_MSGRINGS || + d2h < BRCMF_NROF_D2H_COMMON_MSGRINGS) + return false; + if (ringmem & 3 || + !brcmf_pcie_valid_ram_range(devinfo, ringmem, + BRCMF_NROF_COMMON_MSGRINGS * + BRCMF_RING_MEM_SZ)) + return false; + + /* Allocation failure falls back to four-byte-spaced TCM indices. */ + for (i = 0; i < ARRAY_SIZE(ptrs); i++) { + count = i < 2 ? h2d : d2h; + if (ptrs[i] & 3 || + !brcmf_pcie_valid_ram_range(devinfo, ptrs[i], + count * sizeof(u32))) + return false; + } + + return true; +} + static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo) { struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev); @@ -1659,8 +1724,18 @@ static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo) u16 max_submissionrings; u16 max_completionrings; + if (devinfo->shared.version == BRCMF_PCIE_SHARED_VERSION_9 && + (devinfo->shared.ring_info_addr & 3 || + !brcmf_pcie_valid_ram_range(devinfo, + devinfo->shared.ring_info_addr, + sizeof(ringinfo)))) + return -EINVAL; + brcmf_pcie_copy_dev_tomem(devinfo, devinfo->shared.ring_info_addr, &ringinfo, sizeof(ringinfo)); + if (devinfo->shared.version == BRCMF_PCIE_SHARED_VERSION_9 && + !brcmf_pcie_api9_valid_ringinfo(devinfo, &ringinfo)) + return -EINVAL; if (devinfo->shared.version >= 6) { max_submissionrings = le16_to_cpu(ringinfo.max_submissionrings); max_flowrings = le16_to_cpu(ringinfo.max_flowrings); @@ -1855,6 +1930,7 @@ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev); u64 address; u32 addr; + u8 aggr_cap = 0; devinfo->shared.scratch = dma_alloc_coherent(&devinfo->pdev->dev, @@ -1873,7 +1949,14 @@ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) BRCMF_SHARED_DMA_SCRATCH_LEN_OFFSET; brcmf_pcie_write_tcm32(devinfo, addr, BRCMF_DMA_D2H_SCRATCH_BUF_LEN); - if (devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID) { + if (brcmf_pcie_early_hostready(devinfo)) { + /* API9 uses the legacy ring-update slots for host SCB offload. */ + if (devinfo->shared.version == BRCMF_PCIE_SHARED_VERSION_9) { + addr = devinfo->shared.tcm_base_address + + BRCMF_SHARED_AGGR_HOST_CAP_OFFSET; + brcmf_pcie_copy_mem_todev(devinfo, addr, &aggr_cap, + sizeof(aggr_cap)); + } brcmf_pcie_set_host_cap(devinfo); return 0; } @@ -1920,11 +2003,8 @@ static int brcmf_pcie_preinit(struct device *dev) brcmf_dbg(PCIE, "Enter\n"); brcmf_pcie_intr_enable(buspub->devinfo); - /* The BCM4389 was told host ready right after its rings were set - * up; its firmware traps on a second one (_hnd_die from - * pciedev_handle_hostready_intr), so ring it only once. - */ - if (buspub->devinfo->pdev->device != BRCM_PCIE_4389_DEVICE_ID) + /* The early path already notified firmware after setting up the rings. */ + if (!brcmf_pcie_early_hostready(buspub->devinfo)) brcmf_pcie_hostready(buspub->devinfo); return 0; @@ -2092,6 +2172,30 @@ brcmf_pcie_adjust_ramsize(struct brcmf_pciedev_info *devinfo, u8 *data, } +/* Check firmware's EWP initialization result before setting up host DMA. */ +static int brcmf_pcie_api9_ready(struct brcmf_pciedev_info *devinfo) +{ + u32 addr = devinfo->shared.tcm_base_address; + u32 ewp; + + if (!(devinfo->shared.flags & BRCMF_PCIE_SHARED_HOSTRDY_DB1)) + return -EOPNOTSUPP; + if (!brcmf_pcie_valid_ram_range(devinfo, addr, + BRCMF_SHARED_VERSION_9_SIZE)) + return -EINVAL; + + ewp = brcmf_pcie_read_tcm32(devinfo, + addr + BRCMF_SHARED_EWP_INFO_ADDR_OFFSET); + if (!ewp || ewp & 3 || !brcmf_pcie_valid_ram_range(devinfo, ewp, 2)) + return -EINVAL; + if (brcmf_pcie_read_tcm8(devinfo, ewp) != BRCMF_EWP_INFO_VERSION) + return -EPROTONOSUPPORT; + if (brcmf_pcie_read_tcm8(devinfo, ewp + 1) != BRCMF_EWP_INIT_END) + return -EIO; + + return 0; +} + static int brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, u32 sharedram_addr) @@ -2099,10 +2203,16 @@ brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev); struct brcmf_pcie_shared_info *shared; u32 addr; + int ret; shared = &devinfo->shared; shared->tcm_base_address = sharedram_addr; + /* The version is unknown until this first bounded metadata read. */ + if (sharedram_addr & 3 || + !brcmf_pcie_valid_ram_range(devinfo, sharedram_addr, sizeof(u32))) + return -EINVAL; + shared->flags = brcmf_pcie_read_tcm32(devinfo, sharedram_addr); shared->version = (u8)(shared->flags & BRCMF_PCIE_SHARED_VERSION_MASK); brcmf_dbg(PCIE, "shared flags 0x%08x\n", shared->flags); @@ -2123,7 +2233,7 @@ brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, * The BCM4389 firmware does not, and ignores the DAR doorbells. */ if (devinfo->reginfo == &brcmf_reginfo_64 && - devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID && + brcmf_pcie_early_hostready(devinfo) && !(shared->flags & BRCMF_PCIE_SHARED_DAR)) { devinfo->reginfo = &brcmf_reginfo_64_nodar; brcmf_dbg(PCIE, "no DAR: doorbells at 0x%x/0x%x\n", @@ -2132,12 +2242,22 @@ brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, } brcmf_dbg(PCIE, "PCIe protocol version %d\n", shared->version); if ((shared->version > BRCMF_PCIE_MAX_SHARED_VERSION) || - (shared->version < BRCMF_PCIE_MIN_SHARED_VERSION)) { + (shared->version < BRCMF_PCIE_MIN_SHARED_VERSION) || + shared->version == 8) { brcmf_err(bus, "Unsupported PCIE version %d\n", shared->version); return -EINVAL; } + if (shared->version == BRCMF_PCIE_SHARED_VERSION_9) { + ret = brcmf_pcie_api9_ready(devinfo); + if (ret) { + brcmf_err(bus, "API9 firmware initialization failed: %d\n", + ret); + return ret; + } + } + /* check firmware support dma indicies */ if (shared->flags & BRCMF_PCIE_SHARED_DMA_INDEX) { if (shared->flags & BRCMF_PCIE_SHARED_DMA_2B_IDX) @@ -2726,11 +2846,8 @@ static void brcmf_pcie_setup(struct device *dev, int ret, devinfo->poll_enabled = devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID; - /* Broadcom's driver rings host ready as soon as the common rings - * are set up, before it posts any buffer (bcmdhd dhd_prot_init(), - * hostrdy_after_init), and the BCM4389 was told so in host_cap. - */ - if (devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID) + /* Notify early firmware before its deferred TX-buffer allocation. */ + if (brcmf_pcie_early_hostready(devinfo)) brcmf_pcie_hostready(devinfo); /* hook the commonrings in the bus structure. */ From d9aa97db8ae65860ed8eaf22a8c73156646ab10b Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Mon, 26 Oct 2026 10:28:51 -0647 Subject: [PATCH 02/32] wifi: brcmfmac: add BCM4383 PCIe support The BCM4383 (PCI 14e4:4449, chip id 0x4383, rev 2) is the Wi-Fi chip in the Pixel 9a. Add its ids, its SYSMEM base (0x6e0000, from the firmware's load address) and the firmware name "brcmfmac4383-pcie" with the CLM blob, and two firmware-keyed quirks for its 20.123.13 firmware: - it takes only the versioned "join" parameters: the unversioned iovar and SET_SSID both fail with -52, so enable BRCMF_FEAT_JOIN_V1 by the same WLC version test as for the BCM4389; - it advertises the supplicant offload but refuses the key ("failed to change PSK in firmware"), so leave FWSUP, SAE and FWAUTH off and let the host do the handshakes. Tested on the Pixel 9a with the owner's firmware set: wlan0 comes up, scans, joins a WPA2 network through iwd and passes traffic, with no module parameters. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- .../broadcom/brcm80211/brcmfmac/chip.c | 2 ++ .../broadcom/brcm80211/brcmfmac/feature.c | 19 ++++++++++++++++--- .../broadcom/brcm80211/brcmfmac/pcie.c | 4 ++++ .../broadcom/brcm80211/include/brcm_hw_ids.h | 2 ++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c index e2a628dc32..d0fed7b6a4 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c @@ -784,6 +784,8 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci) return 0x170000; case BRCM_CC_4378_CHIP_ID: return 0x352000; + case BRCM_CC_4383_CHIP_ID: + return 0x6e0000; case BRCM_CC_4387_CHIP_ID: return 0x740000; default: diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c index bff2f5c62e..145b576395 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c @@ -161,10 +161,13 @@ static void brcmf_feat_wlc_version_overrides(struct brcmf_pub *drv) * Versioned "join" parameters (wl_extjoin_params_v1_t), by the * same WLC version test as Broadcom's driver (bcmdhd * wl_cfg80211.c, MIN_JOINEXT_V1_*): 14.2 or 14.4, 16.1 and later - * on 16, or 17 and later. Only the BCM4389 for now; its 20.101.90 - * firmware reports 14.4 and rejects the unversioned layout. + * on 16, or 17 and later. The BCM4389 (its 20.101.90 firmware + * reports 14.4 and rejects the unversioned layout) and the Pixel + * 9a's BCM4383 (20.123.13: the unversioned "join" and SET_SSID + * both fail with -52). */ - if (drv->bus_if->chip == BRCM_CC_4389_CHIP_ID && + if ((drv->bus_if->chip == BRCM_CC_4389_CHIP_ID || + drv->bus_if->chip == BRCM_CC_4383_CHIP_ID) && ((major == 14 && (minor == 2 || minor == 4)) || (major == 16 && minor >= 1) || major >= 17)) feat_flags |= BIT(BRCMF_FEAT_JOIN_V1); @@ -363,6 +366,16 @@ void brcmf_feat_attach(struct brcmf_pub *drvr) if (drvr->bus_if->chip != BRCM_CC_4389_CHIP_ID) drvr->feat_flags &= ~BIT(BRCMF_FEAT_HOST_SFHLLC); + /* + * The BCM4383's firmware (20.123.13 on the Pixel 9a) advertises the + * supplicant offload but refuses the key: brcmf_set_wsec() fails with + * "failed to change PSK in firmware" and the join never gets past + * authentication. Leave the handshakes to the host. + */ + if (drvr->bus_if->chip == BRCM_CC_4383_CHIP_ID) + drvr->feat_flags &= ~(BIT(BRCMF_FEAT_FWSUP) | BIT(BRCMF_FEAT_SAE) | + BIT(BRCMF_FEAT_FWAUTH)); + if (drvr->settings->feature_disable) { brcmf_dbg(INFO, "Features: 0x%02x, disable: 0x%02x\n", ifp->drvr->feat_flags, diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 98671bf534..785a8f13cb 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -74,6 +74,8 @@ BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie"); BRCMF_FW_CLM_DEF(4378B3, "brcmfmac4378b3-pcie"); BRCMF_FW_CLM_DEF(4387C2, "brcmfmac4387c2-pcie"); BRCMF_FW_CLM_DEF(4389C1, "brcmfmac4389c1-pcie"); +/* BCM4383 rev 2 (Pixel 9a): the owner's firmware set, with CLM and TXCAP blobs */ +BRCMF_FW_CLM_DEF(4383, "brcmfmac4383-pcie"); BRCMF_FW_CLM_DEF(54591, "brcmfmac54591-pcie"); /* firmware config files */ @@ -116,6 +118,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = { BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFE0, 4378B3), /* revision ID 5 */ BRCMF_FW_ENTRY(BRCM_CC_4387_CHIP_ID, 0xFFFFFFFF, 4387C2), /* revision ID 7 */ BRCMF_FW_ENTRY(BRCM_CC_4389_CHIP_ID, 0xFFFFFFFF, 4389C1), + BRCMF_FW_ENTRY(BRCM_CC_4383_CHIP_ID, 0xFFFFFFFF, 4383), }; #define BRCMF_PCIE_FW_UP_TIMEOUT 5000 /* msec */ @@ -3515,6 +3518,7 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = { BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID, WCC_SEED), BRCMF_PCIE_DEVICE(BRCM_PCIE_4387_DEVICE_ID, WCC_SEED), BRCMF_PCIE_DEVICE(BRCM_PCIE_4389_DEVICE_ID, WCC_SEED), + BRCMF_PCIE_DEVICE(BRCM_PCIE_4383_DEVICE_ID, WCC_SEED), BRCMF_PCIE_DEVICE(BRCM_PCIE_43752_DEVICE_ID, WCC_SEED), BRCMF_PCIE_DEVICE(CY_PCIE_54591_DEVICE_ID, CYW), { /* end: all zeroes */ } diff --git a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h index bcb68ae6b1..7cbe571c39 100644 --- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h +++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h @@ -56,6 +56,7 @@ #define BRCM_CC_43752_CHIP_ID 43752 #define BRCM_CC_4377_CHIP_ID 0x4377 #define BRCM_CC_4378_CHIP_ID 0x4378 +#define BRCM_CC_4383_CHIP_ID 0x4383 #define BRCM_CC_4387_CHIP_ID 0x4387 #define BRCM_CC_4389_CHIP_ID 0x4389 #define CY_CC_4373_CHIP_ID 0x4373 @@ -99,6 +100,7 @@ #define BRCM_PCIE_43752_DEVICE_ID 0x449d #define BRCM_PCIE_4377_DEVICE_ID 0x4488 #define BRCM_PCIE_4378_DEVICE_ID 0x4425 +#define BRCM_PCIE_4383_DEVICE_ID 0x4449 #define BRCM_PCIE_4387_DEVICE_ID 0x4433 #define BRCM_PCIE_4389_DEVICE_ID 0x4441 #define CY_PCIE_54591_DEVICE_ID 0x4417 From 7c285150cc306b73f17cfcd80a6c8fe60f8652bf Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:30:53 -0647 Subject: [PATCH 03/32] wifi: brcmfmac: pcie: bound the console read when the device reads all ones brcmf_pcie_bus_console_read() reads the firmware's console write index and walks read_idx up to it, wrapping at bufsize. When the device is gone the index reads 0xffffffff, which read_idx never reaches, and the walk never ends. Seen on a BCM4383 after s2idle on the Pixel 9a: the chip does not come back, the reset work entered this loop from brcmf_pcie_reset() and spun one CPU at 100 % with a stream of "CONSOLE:" lines of 0xff bytes. A later rmmod then blocked in cancel_work_sync() for good, holding the device lock, so the next shutdown would have hung in device_shutdown(). Return when the write index is outside the console buffer. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 785a8f13cb..4ca80e15e8 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1226,6 +1226,14 @@ static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo, return; addr = console->base_addr + BRCMF_CONSOLE_WRITEIDX_OFFSET; newidx = brcmf_pcie_read_tcm32(devinfo, addr); + if (newidx >= console->bufsize) { + /* A dead link reads all ones, and read_idx wraps at bufsize, + * so the loop below would never meet it. + */ + brcmf_err(bus, "console write index %u out of range (%u)\n", + newidx, console->bufsize); + return; + } while (newidx != console->read_idx) { addr = console->buf_addr + console->read_idx; ch = brcmf_pcie_read_tcm8(devinfo, addr); From 2c4d82580a4661d9a03dec18ab8a46da63324fde Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 08:09:49 -0400 Subject: [PATCH 04/32] arm64: dts: exynos: google: zuma: add the HSI2 and FAR_ALIVE pin controllers Add HSI2's pin controller at 0x13040000 (gph3 and gph4, SPI 432) and FAR_ALIVE at 0x154e0000 (gpa5, one wake-up interrupt per pin, SPI 60 to 67), with the banks and interrupts of stock's live device tree, as controllers 9 and 2 of the driver's zuma data. FAR_ALIVE's bus clock comes from CMU_APM; HSI2 takes the bus-clock stand-in, as HSI2UFS does. The Wi-Fi chip's PCIe reset, clock request, enable and wake lines are on gph3, and its host wake on gpa5. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../boot/dts/exynos/google/zuma-pinctrl.dtsi | 34 +++++++++++++++++++ arch/arm64/boot/dts/exynos/google/zuma.dtsi | 22 ++++++++++++ 2 files changed, 56 insertions(+) diff --git a/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi b/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi index 2de5877971..186a5e9d6e 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi @@ -281,6 +281,24 @@ }; }; +&pinctrl_far_alive { + gpa5: gpa5-gpio-bank { + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + interrupt-parent = <&gic>; + interrupts = , + , + , + , + , + , + , + ; + }; +}; + &pinctrl_peric0 { gpp0: gpp0-gpio-bank { gpio-controller; @@ -480,6 +498,22 @@ }; }; +&pinctrl_hsi2 { + gph3: gph3-gpio-bank { + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + }; + + gph4: gph4-gpio-bank { + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + }; +}; + &pinctrl_hsi2ufs { gph5: gph5-gpio-bank { gpio-controller; diff --git a/arch/arm64/boot/dts/exynos/google/zuma.dtsi b/arch/arm64/boot/dts/exynos/google/zuma.dtsi index f46ad29ecc..282c88e126 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zuma.dtsi @@ -26,6 +26,8 @@ aliases { pinctrl0 = &pinctrl_gpio_alive; pinctrl1 = &pinctrl_custom_alive; + pinctrl2 = &pinctrl_far_alive; + pinctrl9 = &pinctrl_hsi2; pinctrl10 = &pinctrl_hsi2ufs; pinctrl11 = &pinctrl_peric0; pinctrl12 = &pinctrl_peric1; @@ -531,6 +533,14 @@ reg = <0x13020000 0x1000>; }; + pinctrl_hsi2: pinctrl@13040000 { + compatible = "google,zuma-pinctrl"; + reg = <0x13040000 0x1000>; + clocks = <&clk_gpio_stub>; + clock-names = "pclk"; + interrupts = ; + }; + pinctrl_hsi2ufs: pinctrl@13060000 { compatible = "google,zuma-pinctrl"; reg = <0x13060000 0x1000>; @@ -633,6 +643,18 @@ }; }; + pinctrl_far_alive: pinctrl@154e0000 { + compatible = "google,zuma-pinctrl"; + reg = <0x154e0000 0x1000>; + clocks = <&cmu_apm CLK_GOUT_APM_GPIO_FAR_ALIVE>; + clock-names = "pclk"; + + wakeup-interrupt-controller { + compatible = "google,zuma-wakeup-eint", + "google,zumapro-wakeup-eint"; + }; + }; + apm_sram: sram@15700000 { compatible = "mmio-sram"; reg = <0x15700000 0x58000>; From 2893edf73beefcafb142aff77e1b48e797ddbb1d Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 08:09:56 -0400 Subject: [PATCH 05/32] soc: samsung: gs101-pmu: zuma: allow the Wi-Fi PCIe PHY's isolation register zuma's PCIe PHY for its second controller (the Wi-Fi chip's) is isolated through PMU offset 0x3ec8, as stock's pcie@13120000 gives it (pmu-offset). Its PHY driver releases the isolation, so add the register to zuma's PMU regmap, next to UFS's. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- drivers/soc/samsung/gs101-pmu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/soc/samsung/gs101-pmu.c b/drivers/soc/samsung/gs101-pmu.c index 9ee77754d0..40e26951c7 100644 --- a/drivers/soc/samsung/gs101-pmu.c +++ b/drivers/soc/samsung/gs101-pmu.c @@ -344,6 +344,7 @@ const struct exynos_pmu_data gs101_pmu_data = { #define ZUMA_HSI0_STATUS 0x2a84 #define ZUMA_PAD_CTRL_NFC_CLK 0x3e84 #define ZUMA_PHY_CTRL_UFS 0x3ec0 +#define ZUMA_PHY_CTRL_PCIE1 0x3ec8 static const struct regmap_range zuma_pmu_registers[] = { /* reboot mode */ @@ -359,6 +360,7 @@ static const struct regmap_range zuma_pmu_registers[] = { /* PHY isolation */ regmap_reg_range(GS101_PHY_CTRL_USB20, GS101_PHY_CTRL_USB20), regmap_reg_range(ZUMA_PHY_CTRL_UFS, ZUMA_PHY_CTRL_UFS), + regmap_reg_range(ZUMA_PHY_CTRL_PCIE1, ZUMA_PHY_CTRL_PCIE1), /* a hint TF-A reads, not a status register: see zuma_pmu_regmap_init() */ regmap_reg_range(ZUMA_PMU_INFORM0, ZUMA_PMU_INFORM0), /* Tensor G4's NFC reference clock pad, a clock of clk-exynos-clkout */ From fc8ab9615e65cd3ef3b719b4f355b8589bfe4b67 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 08:15:21 -0400 Subject: [PATCH 06/32] dt-bindings: phy: Add the Google zuma PCIe Gen3 PHY zuma's (Tensor G3) second PCIe controller, the Wi-Fi chip's, has a one-lane Gen3 PHY clocked from an external PLL in the UDBG block and selected in the controller's SOC block, isolated by the PMU until it is released. Its registers are the PMA, the PCS, the PHY resets in the controller's sub-control space, the UDBG and the SOC block, at the addresses of stock's pcie@13120000. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../bindings/phy/google,zuma-pcie-phy.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml diff --git a/Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml b/Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml new file mode 100644 index 0000000000..8003eb7b5e --- /dev/null +++ b/Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/google,zuma-pcie-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Google zuma PCIe Gen3 PHY + +maintainers: + - Brett-Michael Green + +description: + The one-lane PCIe Gen3 PHY of the Google zuma (Tensor G3) SoC's second + PCIe controller, which connects the Wi-Fi chip on Pixel 8 phones. Its + reference clock comes from an external PLL in the UDBG block, selected as + the PHY's input clock in the controller's SOC block. The PMU isolates the + PHY until it is released. + +properties: + compatible: + const: google,zuma-pcie-phy + + reg: + items: + - description: PMA registers + - description: PCS registers + - description: PHY reset registers in the controller's sub-control space + - description: UDBG (external PLL) registers + - description: SOC (PHY input clock selection) registers + + reg-names: + items: + - const: pma + - const: pcs + - const: rst + - const: udbg + - const: soc + + "#phy-cells": + const: 0 + + samsung,pmu-syscon: + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + - items: + - description: phandle of the PMU system controller + - description: offset of this PHY's control (isolation) register + description: + The PMU and the offset of this PHY's isolation control. + +required: + - compatible + - reg + - reg-names + - "#phy-cells" + - samsung,pmu-syscon + +additionalProperties: false + +examples: + - | + phy@13160000 { + compatible = "google,zuma-pcie-phy"; + reg = <0x13160000 0x3000>, <0x13140000 0x5000>, + <0x13121400 0x10>, <0x13150000 0xd000>, + <0x13130000 0x5000>; + reg-names = "pma", "pcs", "rst", "udbg", "soc"; + samsung,pmu-syscon = <&pmu_system_controller 0x3ec8>; + #phy-cells = <0>; + }; From 023950fff84768351c383cb06832be32ae7d400c Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 08:15:21 -0400 Subject: [PATCH 07/32] phy: samsung: Add the Google zuma PCIe Gen3 PHY driver Add a driver for the one-lane Gen3 PHY of zuma's (Tensor G3) second PCIe controller, which connects the Pixel 8's Wi-Fi chip. The sequence is Samsung's CAL for zuma, channel 1, from the driver Google builds for zuma (pcie-exynos-zuma-rc-cal.c and pcie-exynos-rc.c): - init: release the PMU isolation, then power the PHY down (phy_all_pwrdn); - power_on: select the clock mode in the SOC block, clear the power downs, start the external PLL and wait for its lock, select it as the PHY's input clock, program the PMA and PCS in reset, release the resets and wait for the PLL, CDR and offset calibration, then write UDBG 0xc800 as establish_link does before PERST#; - power_off: power the PHY down again. The CAL also sets the controller's RC mode and soft power reset in the middle of this; those are the controller driver's, in its ELBI space. The PMA and PCS values for a Broadcom endpoint (stock's ep-device-type 1) are used, since that is what this controller connects. As in the gs201 PHY driver, trace=1 logs every step before it touches the hardware, for bring-up. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- MAINTAINERS | 2 + drivers/phy/samsung/Kconfig | 12 + drivers/phy/samsung/Makefile | 1 + drivers/phy/samsung/phy-zuma-pcie.c | 433 ++++++++++++++++++++++++++++ 4 files changed, 448 insertions(+) create mode 100644 drivers/phy/samsung/phy-zuma-pcie.c diff --git a/MAINTAINERS b/MAINTAINERS index d5c748f6f6..1a68316b1c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11169,6 +11169,7 @@ F: Documentation/devicetree/bindings/clock/google,gs201-clock.yaml F: Documentation/devicetree/bindings/clock/google,zuma-clock.yaml F: Documentation/devicetree/bindings/clock/google,zumapro* F: Documentation/devicetree/bindings/phy/google,lga-usb-phy.yaml +F: Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml F: Documentation/devicetree/bindings/soc/google/google,gs101-dtzpc.yaml F: Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml F: Documentation/devicetree/bindings/soc/google/google,gs101-pmu-intr-gen.yaml @@ -11181,6 +11182,7 @@ F: drivers/clk/samsung/clk-zumapro.c F: drivers/phy/phy-google-usb.c F: drivers/soc/samsung/gs101-pmu.c F: drivers/phy/samsung/phy-gs101-ufs.c +F: drivers/phy/samsung/phy-zuma-pcie.c F: drivers/phy/samsung/phy-zumapro-ufs.c F: drivers/thermal/samsung/gs101_acpm_tmu.c F: drivers/usb/dwc3/dwc3-google.c diff --git a/drivers/phy/samsung/Kconfig b/drivers/phy/samsung/Kconfig index a9cada8097..f07690fc91 100644 --- a/drivers/phy/samsung/Kconfig +++ b/drivers/phy/samsung/Kconfig @@ -39,6 +39,18 @@ config PHY_GS201_PCIE SoC. It is used by the gs201 PCIe controller driver, which connects the Wi-Fi chip on Pixel 7 phones. +config PHY_ZUMA_PCIE + tristate "Google zuma PCIe PHY driver" + depends on OF && (ARCH_EXYNOS || COMPILE_TEST) + depends on EXYNOS_PMU || COMPILE_TEST + select GENERIC_PHY + help + Enable support for the one-lane PCIe Gen3 PHY of the Google zuma + (Tensor G3) SoC. It is used by the gs201 PCIe controller driver, + which connects the Wi-Fi chip on Pixel 8 phones. The PHY is + programmed from stock's register tables, and its power-down + isolation is released through the PMU. + config PHY_GS201_MIPI_DCPHY tristate "Google gs201 MIPI DC-PHY receiver driver" depends on OF && (ARCH_EXYNOS || COMPILE_TEST) diff --git a/drivers/phy/samsung/Makefile b/drivers/phy/samsung/Makefile index a24c25524c..56e77422a7 100644 --- a/drivers/phy/samsung/Makefile +++ b/drivers/phy/samsung/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o obj-$(CONFIG_PHY_EXYNOS_PCIE) += phy-exynos-pcie.o obj-$(CONFIG_PHY_GS201_PCIE) += phy-gs201-pcie.o +obj-$(CONFIG_PHY_ZUMA_PCIE) += phy-zuma-pcie.o obj-$(CONFIG_PHY_GS201_MIPI_DCPHY) += phy-gs201-mipi-dcphy-rx.o obj-$(CONFIG_PHY_SAMSUNG_UFS) += phy-exynos-ufs.o phy-exynos-ufs-y += phy-gs101-ufs.o diff --git a/drivers/phy/samsung/phy-zuma-pcie.c b/drivers/phy/samsung/phy-zuma-pcie.c new file mode 100644 index 0000000000..a00239085e --- /dev/null +++ b/drivers/phy/samsung/phy-zuma-pcie.c @@ -0,0 +1,433 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Google zuma (Tensor G3) PCIe Gen3 PHY driver + * + * The one-lane PHY of zuma's second PCIe controller (the Wi-Fi chip's). Its + * reference clock comes from an external PLL in the UDBG block, selected in + * the controller's SOC block. The register sequence is Samsung's "CAL ver + * 0.2" for zuma, channel 1, taken from the driver Google builds for zuma + * (pcie-exynos-zuma-rc-cal.c and pcie-exynos-rc.c in google-modules/soc/gs/ + * drivers/pci/controller/dwc). Most PMA registers have no public names, so + * the tables keep Samsung's raw offsets and values. + * + * Copyright (C) 2021 Samsung Electronics Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Bring-up tracing, as in the gs201 PHY driver: with trace=1 every step + * that touches the hardware is logged before it happens, and the driver + * sleeps trace_delay_ms after each line so that a reader of /dev/kmsg + * receives it before a possible bus hang stops the CPU. + */ +static bool trace; +module_param(trace, bool, 0644); +MODULE_PARM_DESC(trace, "Log every hardware step before doing it (bring-up)"); + +static unsigned int trace_delay_ms = 20; +module_param(trace_delay_ms, uint, 0644); +MODULE_PARM_DESC(trace_delay_ms, "Sleep after each trace line, in ms (default 20)"); + +/* PMU PHY control: bit 0 clear isolates the PHY */ +#define ZUMA_PMU_PHY_BYPASS BIT(0) + +/* PHY reset block, in the controller's sub-control (ELBI) space at +0x1400 */ +#define ZUMA_PHY_RST_CMN 0x0 +#define ZUMA_PHY_RST_INIT 0x4 +#define ZUMA_PHY_RST_PORT 0x8 + +/* SOC block: the PHY's input clock */ +#define ZUMA_SOC_CLK_MODE 0x4000 +#define ZUMA_SOC_CLK_MODE_VAL 0x15 +#define ZUMA_SOC_CLK_SEL 0x4004 +#define ZUMA_SOC_CLK_SEL_TCXO BIT(2) +#define ZUMA_SOC_CLK_SEL_EXT_PLL GENMASK(5, 4) + +/* UDBG block: the external PLL */ +#define ZUMA_UDBG_EXT_PLL 0xc700 +#define ZUMA_UDBG_EXT_PLL_EN BIT(0) +#define ZUMA_UDBG_EXT_PLL_RESETB_OVR BIT(1) +#define ZUMA_UDBG_EXT_PLL_STATUS 0xc734 +#define ZUMA_UDBG_EXT_PLL_LOCK BIT(2) +#define ZUMA_UDBG_LINK_CTRL 0xc800 +#define ZUMA_UDBG_LINK_CTRL_VAL 0x421 + +/* PMA registers used outside the tables */ +#define ZUMA_PMA_CMN_BIAS 0x000c +#define ZUMA_PMA_CLK_CTRL 0x0204 +#define ZUMA_PMA_CLK_CTRL_GATE GENMASK(3, 2) +#define ZUMA_PMA_INPUT_CLK_GATE 0x032c +#define ZUMA_PMA_INPUT_CLK_UNGATE 0x3 +#define ZUMA_PMA_LN_CTRL 0x1350 +#define ZUMA_PMA_PLL_STATUS 0x0a80 +#define ZUMA_PMA_PLL_LOCK BIT(0) +#define ZUMA_PMA_OC_STATUS 0x140c +#define ZUMA_PMA_OC_DONE BIT(7) +#define ZUMA_PMA_CDR_STATUS 0x15c0 +#define ZUMA_PMA_CDR_LOCK BIT(4) + +/* Google polls the lock bits 10000 times, 10 us apart */ +#define ZUMA_PHY_LOCK_TIMEOUT_US 100000 + +struct zuma_pcie_phy_reg { + u16 off; + u32 val; +}; + +/* PHY power-down (exynos_pcie_rc_phy_all_pwrdn(), channel 1), after 0x204 */ +static const struct zuma_pcie_phy_reg zuma_pma_pwrdn[] = { + { 0x1044, 0x2a }, { 0x1048, 0xaa }, { 0x104c, 0xa8 }, { 0x1050, 0x80 }, + { 0x185c, 0x0a }, +}; + +/* Common PMA block */ +static const struct zuma_pcie_phy_reg zuma_pma_common[] = { + { 0x0000, 0x88 }, { 0x001c, 0x66 }, { 0x01f4, 0x00 }, { 0x0514, 0x59 }, + { 0x051c, 0x11 }, { 0x062c, 0x0e }, { 0x0644, 0x22 }, { 0x0688, 0x03 }, + { 0x06d4, 0x28 }, { 0x0788, 0x64 }, { 0x078c, 0x64 }, { 0x0790, 0x50 }, + { 0x0794, 0x50 }, { 0x0944, 0x05 }, { 0x0948, 0x05 }, { 0x094c, 0x05 }, + { 0x0950, 0x05 }, + /* 38.4 MHz REFCLK to the external PLL path */ + { 0x0590, 0x02 }, { 0x07f8, 0xb0 }, { 0x0730, 0x08 }, + /* 7.68 us delay in L1.2 */ + { 0x0344, 0xc0 }, + /* L1.2 without CLKREQ# */ + { 0x0040, 0x04 }, { 0x0204, 0x03 }, { 0x02d4, 0x1f }, { 0x0358, 0x10 }, + /* ERIO on */ + { 0x0018, 0x01 }, + /* Lane */ + { 0x0514, 0x5b }, { 0x0608, 0x0c }, { 0x060c, 0x0f }, { 0x0610, 0x0f }, + { 0x0614, 0x0f }, { 0x0618, 0x0f }, { 0x0510, 0x80 }, { 0x0688, 0x03 }, + { 0x0644, 0x23 }, { 0x0624, 0x11 }, + /* PLL margin for ERIO at Gen1 and Gen2 */ + { 0x0630, 0x0f }, { 0x06d0, 0x53 }, +}; + +/* The lane's PMA block */ +static const struct zuma_pcie_phy_reg zuma_pma_lane[] = { + { 0x1140, 0x04 }, { 0x1144, 0x04 }, { 0x1148, 0x04 }, { 0x114c, 0x02 }, + { 0x1150, 0x00 }, { 0x1154, 0x00 }, { 0x1158, 0x00 }, { 0x115c, 0x00 }, + { 0x12cc, 0x1c }, { 0x12dc, 0x6c }, { 0x130c, 0x29 }, { 0x13b4, 0x2f }, + { 0x1a64, 0x05 }, { 0x1a68, 0x05 }, { 0x1a84, 0x05 }, { 0x1a88, 0x05 }, + { 0x1a98, 0x00 }, { 0x1a9c, 0x00 }, { 0x1aa8, 0x07 }, { 0x1ab8, 0x00 }, + { 0x1abc, 0x00 }, { 0x1af8, 0x90 }, { 0x1b34, 0x03 }, { 0x1bb0, 0x03 }, + { 0x1bb4, 0x03 }, { 0x1bc0, 0x06 }, { 0x1bc4, 0x06 }, { 0x1be8, 0x01 }, + { 0x1bf8, 0x04 }, { 0x1c98, 0x00 }, { 0x1ca4, 0x81 }, + /* + * Broadcom Wi-Fi (stock's ep-device-type 1): the link went down on + * L1 substate exits without these. + */ + { 0x1b20, 0x02 }, { 0x1340, 0x23 }, { 0x002c, 0x3c }, +}; + +/* PCS, with Google's Broadcom Wi-Fi timer values */ +static const struct zuma_pcie_phy_reg zuma_pcs[] = { + { 0x190, 0x100b0604 }, + /* L1.2 without CLKREQ# */ + { 0x154, 0x000700d5 }, + { 0x100, 0x16400000 }, { 0x104, 0x08600000 }, { 0x114, 0x18500000 }, + { 0x124, 0x60700000 }, { 0x174, 0x00000007 }, { 0x178, 0x00000100 }, + { 0x17c, 0x00000700 }, { 0x110, 0x01600202 }, +}; + +struct zuma_pcie_phy { + struct device *dev; + void __iomem *pma; + void __iomem *pcs; + void __iomem *rst; + void __iomem *udbg; + void __iomem *soc; + struct regmap *pmu; + u32 pmu_offset; +}; + +static __printf(2, 3) void zuma_phy_trace(struct zuma_pcie_phy *zp, + const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + if (!trace) + return; + + va_start(args, fmt); + vaf.fmt = fmt; + vaf.va = &args; + dev_info(zp->dev, "trace: %pV\n", &vaf); + va_end(args); + + if (trace_delay_ms) + msleep(trace_delay_ms); +} + +static void zuma_pcie_phy_write_table(void __iomem *base, + const struct zuma_pcie_phy_reg *tbl, + size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) + writel(tbl[i].val, base + tbl[i].off); +} + +static void zuma_pcie_phy_rmw(void __iomem *reg, u32 clr, u32 set) +{ + writel((readl(reg) & ~clr) | set, reg); +} + +static bool zuma_pcie_phy_wait(struct zuma_pcie_phy *zp, const char *what, + void __iomem *base, u32 off, u32 bit) +{ + u32 val; + + zuma_phy_trace(zp, "about to poll %#x for %s (up to %u us)", off, what, + ZUMA_PHY_LOCK_TIMEOUT_US); + + return !readl_poll_timeout_atomic(base + off, val, val & bit, 10, + ZUMA_PHY_LOCK_TIMEOUT_US); +} + +/* exynos_pcie_rc_phy_all_pwrdn(), channel 1 */ +static void zuma_pcie_phy_pwrdn(struct zuma_pcie_phy *zp) +{ + zuma_phy_trace(zp, "about to read PMA 0x204 (first PMA access) and power the PHY down"); + zuma_pcie_phy_rmw(zp->pma + ZUMA_PMA_CLK_CTRL, ZUMA_PMA_CLK_CTRL_GATE, 0); + zuma_pcie_phy_write_table(zp->pma, zuma_pma_pwrdn, + ARRAY_SIZE(zuma_pma_pwrdn)); + udelay(1); + writel(0xff, zp->pma + 0x0208); + udelay(1); + writel(0x0a, zp->pma + 0x0580); + writel(0xaa, zp->pma + 0x0928); + /* Common bias and PLL off */ + writel(0x0a, zp->pma + ZUMA_PMA_CMN_BIAS); + fsleep(50); + + zuma_phy_trace(zp, "about to read UDBG 0xc700 (first UDBG access): gate the external PLL"); + zuma_pcie_phy_rmw(zp->udbg + ZUMA_UDBG_EXT_PLL, ZUMA_UDBG_EXT_PLL_EN, 0); + fsleep(10); +} + +/* exynos_pcie_rc_phy_all_pwrdn_clear(), channel 1 */ +static void zuma_pcie_phy_pwrdn_clear(struct zuma_pcie_phy *zp) +{ + size_t i; + + zuma_phy_trace(zp, "about to ungate the external PLL (UDBG 0xc700) and clear the power-downs"); + zuma_pcie_phy_rmw(zp->udbg + ZUMA_UDBG_EXT_PLL, 0, ZUMA_UDBG_EXT_PLL_EN); + fsleep(100); + writel(0x00, zp->pma + ZUMA_PMA_CMN_BIAS); + writel(0x55, zp->pma + 0x0928); + writel(0x02, zp->pma + 0x0580); + writel(0x00, zp->pma + 0x0208); + for (i = 0; i < ARRAY_SIZE(zuma_pma_pwrdn); i++) + writel(0, zp->pma + zuma_pma_pwrdn[i].off); + fsleep(10); +} + +/* exynos_pcie_rc_pcie_phy_config(), channel 1, less its ELBI writes */ +static void zuma_pcie_phy_config(struct zuma_pcie_phy *zp) +{ + bool pll, cdr, oc, ext; + + zuma_phy_trace(zp, "about to ungate the PHY input clock (PMA 0x32c) and start the external PLL"); + writel(ZUMA_PMA_INPUT_CLK_UNGATE, zp->pma + ZUMA_PMA_INPUT_CLK_GATE); + zuma_pcie_phy_rmw(zp->udbg + ZUMA_UDBG_EXT_PLL, 0, ZUMA_UDBG_EXT_PLL_EN); + zuma_pcie_phy_rmw(zp->udbg + ZUMA_UDBG_EXT_PLL, + ZUMA_UDBG_EXT_PLL_RESETB_OVR, 0); + + ext = zuma_pcie_phy_wait(zp, "the external PLL lock", zp->udbg, + ZUMA_UDBG_EXT_PLL_STATUS, + ZUMA_UDBG_EXT_PLL_LOCK); + + zuma_phy_trace(zp, "about to select the external PLL as the PHY input clock (SOC 0x4004)"); + zuma_pcie_phy_rmw(zp->soc + ZUMA_SOC_CLK_SEL, ZUMA_SOC_CLK_SEL_TCXO, 0); + zuma_pcie_phy_rmw(zp->soc + ZUMA_SOC_CLK_SEL, 0, + ZUMA_SOC_CLK_SEL_EXT_PLL); + + zuma_phy_trace(zp, "about to assert the PMA resets (ELBI 0x1400-0x1408)"); + writel(1, zp->rst + ZUMA_PHY_RST_INIT); + writel(1, zp->rst + ZUMA_PHY_RST_PORT); + writel(1, zp->rst + ZUMA_PHY_RST_CMN); + writel(0, zp->rst + ZUMA_PHY_RST_INIT); + writel(0, zp->rst + ZUMA_PHY_RST_PORT); + writel(0, zp->rst + ZUMA_PHY_RST_CMN); + + zuma_phy_trace(zp, "about to write the PMA tables (common, lane)"); + zuma_pcie_phy_write_table(zp->pma, zuma_pma_common, + ARRAY_SIZE(zuma_pma_common)); + zuma_pcie_phy_write_table(zp->pma, zuma_pma_lane, + ARRAY_SIZE(zuma_pma_lane)); + zuma_pcie_phy_rmw(zp->pma + ZUMA_PMA_LN_CTRL, 0, BIT(0)); + + zuma_phy_trace(zp, "about to write the PCS table"); + zuma_pcie_phy_write_table(zp->pcs, zuma_pcs, ARRAY_SIZE(zuma_pcs)); + + zuma_phy_trace(zp, "about to release the PMA resets"); + writel(1, zp->rst + ZUMA_PHY_RST_INIT); + fsleep(10); + writel(1, zp->rst + ZUMA_PHY_RST_PORT); + writel(1, zp->rst + ZUMA_PHY_RST_CMN); + + pll = zuma_pcie_phy_wait(zp, "PLL lock", zp->pma, ZUMA_PMA_PLL_STATUS, + ZUMA_PMA_PLL_LOCK); + cdr = zuma_pcie_phy_wait(zp, "CDR lock", zp->pma, ZUMA_PMA_CDR_STATUS, + ZUMA_PMA_CDR_LOCK); + oc = zuma_pcie_phy_wait(zp, "offset calibration", zp->pma, + ZUMA_PMA_OC_STATUS, ZUMA_PMA_OC_DONE); + + dev_info(zp->dev, + "external PLL lock %d, PLL lock %d, CDR lock %d, OC done %d\n", + ext, pll, cdr, oc); + + writel(0, zp->pma + ZUMA_PMA_INPUT_CLK_GATE); +} + +static int zuma_pcie_phy_init(struct phy *phy) +{ + struct zuma_pcie_phy *zp = phy_get_drvdata(phy); + unsigned int val; + int ret; + + ret = regmap_read(zp->pmu, zp->pmu_offset, &val); + if (ret) { + dev_err(zp->dev, "PMU read failed: %d\n", ret); + return ret; + } + dev_info(zp->dev, "PMU PHY control %#x\n", val); + + zuma_phy_trace(zp, "about to set PMU %#x bit 0 (PHY isolation off, SMC)", + zp->pmu_offset); + ret = regmap_update_bits(zp->pmu, zp->pmu_offset, ZUMA_PMU_PHY_BYPASS, + ZUMA_PMU_PHY_BYPASS); + if (ret) { + dev_err(zp->dev, "PMU write failed: %d\n", ret); + return ret; + } + + zuma_pcie_phy_pwrdn(zp); + zuma_phy_trace(zp, "PHY out of isolation and powered down"); + + return 0; +} + +static int zuma_pcie_phy_power_on(struct phy *phy) +{ + struct zuma_pcie_phy *zp = phy_get_drvdata(phy); + + zuma_phy_trace(zp, "about to write SOC 0x4000 (first SOC access)"); + writel(ZUMA_SOC_CLK_MODE_VAL, zp->soc + ZUMA_SOC_CLK_MODE); + + zuma_pcie_phy_pwrdn_clear(zp); + zuma_pcie_phy_config(zp); + + /* exynos_pcie_rc_establish_link(), channel 1, before PERST# */ + zuma_phy_trace(zp, "about to write UDBG 0xc800"); + writel(ZUMA_UDBG_LINK_CTRL_VAL, zp->udbg + ZUMA_UDBG_LINK_CTRL); + zuma_phy_trace(zp, "PHY configured"); + + return 0; +} + +static int zuma_pcie_phy_power_off(struct phy *phy) +{ + struct zuma_pcie_phy *zp = phy_get_drvdata(phy); + + zuma_pcie_phy_pwrdn(zp); + + return 0; +} + +static const struct phy_ops zuma_pcie_phy_ops = { + .init = zuma_pcie_phy_init, + .power_on = zuma_pcie_phy_power_on, + .power_off = zuma_pcie_phy_power_off, + .owner = THIS_MODULE, +}; + +static int zuma_pcie_phy_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct phy_provider *provider; + struct zuma_pcie_phy *zp; + struct phy *phy; + int ret; + + zp = devm_kzalloc(dev, sizeof(*zp), GFP_KERNEL); + if (!zp) + return -ENOMEM; + + zp->dev = dev; + + /* Only mappings here: the PHY is not touched until phy_init() */ + zp->pma = devm_platform_ioremap_resource_byname(pdev, "pma"); + if (IS_ERR(zp->pma)) + return PTR_ERR(zp->pma); + + zp->pcs = devm_platform_ioremap_resource_byname(pdev, "pcs"); + if (IS_ERR(zp->pcs)) + return PTR_ERR(zp->pcs); + + zp->rst = devm_platform_ioremap_resource_byname(pdev, "rst"); + if (IS_ERR(zp->rst)) + return PTR_ERR(zp->rst); + + zp->udbg = devm_platform_ioremap_resource_byname(pdev, "udbg"); + if (IS_ERR(zp->udbg)) + return PTR_ERR(zp->udbg); + + zp->soc = devm_platform_ioremap_resource_byname(pdev, "soc"); + if (IS_ERR(zp->soc)) + return PTR_ERR(zp->soc); + + zp->pmu = exynos_get_pmu_regmap_by_phandle(dev->of_node, + "samsung,pmu-syscon"); + if (IS_ERR(zp->pmu)) + return dev_err_probe(dev, PTR_ERR(zp->pmu), + "failed to get the PMU regmap\n"); + + ret = of_property_read_u32_index(dev->of_node, "samsung,pmu-syscon", 1, + &zp->pmu_offset); + if (ret) + return dev_err_probe(dev, ret, + "missing PMU PHY control offset\n"); + + phy = devm_phy_create(dev, NULL, &zuma_pcie_phy_ops); + if (IS_ERR(phy)) + return dev_err_probe(dev, PTR_ERR(phy), "failed to create PHY\n"); + + phy_set_drvdata(phy, zp); + + provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + + return PTR_ERR_OR_ZERO(provider); +} + +static const struct of_device_id zuma_pcie_phy_of_match[] = { + { .compatible = "google,zuma-pcie-phy" }, + { } +}; +MODULE_DEVICE_TABLE(of, zuma_pcie_phy_of_match); + +static struct platform_driver zuma_pcie_phy_driver = { + .probe = zuma_pcie_phy_probe, + .driver = { + .name = "zuma-pcie-phy", + .of_match_table = zuma_pcie_phy_of_match, + .suppress_bind_attrs = true, + }, +}; +module_platform_driver(zuma_pcie_phy_driver); + +MODULE_DESCRIPTION("Google zuma PCIe Gen3 PHY driver"); +MODULE_LICENSE("GPL"); From 01761b71598f0b2ef8acf4dcf103258fbb54da5a Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 08:15:21 -0400 Subject: [PATCH 08/32] dt-bindings: PCI: google,gs201-pcie: Add the zuma controller zuma's (Tensor G3) PCIe controllers are the same DesignWare core in the same Samsung wrapper as gs201's, at IP version 0x986500. Its Wi-Fi controller runs without the I/A sequencer, as on stock (use-ia false), so it has three register regions. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../bindings/pci/google,gs201-pcie.yaml | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml b/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml index 89e65f2a1f..d967492b9f 100644 --- a/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml @@ -4,26 +4,40 @@ $id: http://devicetree.org/schemas/pci/google,gs201-pcie.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Google gs201 PCIe host controller +title: Google gs201 and zuma PCIe host controllers maintainers: - Derek Ross description: - The PCIe controllers of the Google gs201 (Tensor G2) SoC are Synopsys - DesignWare cores (IP version 0x984500) in a Samsung wrapper. The wrapper + The PCIe controllers of the Google gs201 (Tensor G2) and zuma (Tensor G3) + SoCs are Synopsys DesignWare cores (IP versions 0x984500 and 0x986500) in + a Samsung wrapper. The wrapper adds a sub-control block (ELBI) with link training control and interrupt status, and an I/A sequencer that re-locks the PHY clock-data recovery when - the link leaves L1.2. Legacy INTx interrupts are demultiplexed from the - controller interrupt by a child interrupt controller. + the link leaves L1.2. zuma's Wi-Fi controller runs without the I/A, as on + stock. Legacy INTx interrupts are demultiplexed from the controller + interrupt by a child interrupt controller. allOf: - $ref: /schemas/pci/pci-host-bridge.yaml# - $ref: /schemas/pci/snps,dw-pcie-common.yaml# + - if: + properties: + compatible: + const: google,zuma-pcie + then: + properties: + reg: + maxItems: 3 + reg-names: + maxItems: 3 properties: compatible: - const: google,gs201-pcie + enum: + - google,gs201-pcie + - google,zuma-pcie reg: minItems: 3 From e5735a0c01685f057b80d805e2a9b4ea0add7b3c Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 08:15:21 -0400 Subject: [PATCH 09/32] PCI: dwc: gs201: Add zuma zuma's (Tensor G3) Wi-Fi controller follows gs201's sequence, with one difference in order: zuma's CAL sets RC mode, pulses the soft power reset and enables the slave pending NAK in the middle of the PHY configuration, and establish_link() does not reset the controller again afterwards. Do these before the PHY's power_on on zuma, and skip the later soft resets. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- drivers/pci/controller/dwc/Kconfig | 7 +-- drivers/pci/controller/dwc/pcie-gs201.c | 58 +++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig index 31de17d0e3..43efbf32e2 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig @@ -424,9 +424,10 @@ config PCIE_GS201 select PCI_PWRCTRL_GENERIC help Say Y here to enable support for the PCIe controller of the Google - gs201 (Tensor G2) SoC in host mode. Pixel 7 phones connect their - Wi-Fi chip to it. The controller uses the DesignWare core plus a - Samsung wrapper, and needs the gs201 PCIe PHY driver. + gs201 (Tensor G2) and zuma (Tensor G3) SoCs in host mode. Pixel 7 + and Pixel 8 phones connect their Wi-Fi chip to it. The controller + uses the DesignWare core plus a Samsung wrapper, and needs the gs201 + or zuma PCIe PHY driver. config PCIE_GS201_SYSMMU tristate "Google gs201 PCIe System MMU as a DMA window" diff --git a/drivers/pci/controller/dwc/pcie-gs201.c b/drivers/pci/controller/dwc/pcie-gs201.c index af650d7638..98238660b2 100644 --- a/drivers/pci/controller/dwc/pcie-gs201.c +++ b/drivers/pci/controller/dwc/pcie-gs201.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * PCIe host controller driver for the Google gs201 (Tensor G2) SoC + * PCIe host controller driver for the Google gs201 (Tensor G2) and zuma + * (Tensor G3) SoCs * * The controller is a Synopsys DesignWare core (IP version 0x984500) in a * Samsung wrapper ("ELBI" sub-control registers, a link-training helper @@ -69,9 +70,11 @@ #define GS201_ELBI_SOFT_RESET 0x3a4 #define GS201_ELBI_SOFT_PWR_RESET BIT(1) #define GS201_ELBI_SOFT_NON_STICKY_RESET BIT(3) +#define GS201_ELBI_SOFT_RESET_ALL GENMASK(3, 0) #define GS201_ELBI_QCH_SEL 0x3a8 #define GS201_ELBI_QCH_GATING_MASK GENMASK(11, 0) #define GS201_ELBI_REQ_EXIT_L1_MODE 0x3bc +#define GS201_ELBI_SLV_PEND_SEL_NAK 0x3d8 #define GS201_ELBI_APP_REQ_EXIT_L1_MODE BIT(0) #define GS201_ELBI_L1_REQ_NAK_MASTER BIT(4) #define GS201_ELBI_MSTR_PEND_SEL_NAK 0x474 @@ -163,8 +166,20 @@ module_param(cmu_acg_off, bool, 0444); MODULE_PARM_DESC(cmu_acg_off, "Clear CMU_HSI2 automatic clock gating in stage 1, as Google's gs201 driver does (default: false)"); +/** + * struct gs201_pcie_soc_data - what differs between the SoCs + * @ctrl_reset_before_phy: the controller's soft power reset and RC mode are + * set before the PHY configuration, and not again after it. zuma's + * CAL does them in the middle of its PHY configuration; gs201's + * establish_link() does them after. + */ +struct gs201_pcie_soc_data { + bool ctrl_reset_before_phy; +}; + struct gs201_pcie { struct dw_pcie pci; + const struct gs201_pcie_soc_data *data; void __iomem *elbi; void __iomem *ia; void __iomem *cmu; @@ -569,11 +584,33 @@ static int gs201_pcie_stage_wake(struct gs201_pcie *gp) return 0; } +/* + * zuma's CAL: RC mode and a soft power reset pulse, written as whole words + * as Google does, and NAKs for slave requests while AXI is pending. + */ +static void gs201_pcie_ctrl_reset_early(struct gs201_pcie *gp) +{ + gs201_trace(gp, "about to write ELBI 0x080 = 4 (root complex) and pulse the soft power reset (ELBI 0x3a4)"); + gs201_elbi_writel(gp, GS201_ELBI_DEVICE_TYPE, GS201_ELBI_DEVICE_TYPE_RC); + gs201_elbi_writel(gp, GS201_ELBI_SOFT_RESET, GS201_ELBI_SOFT_RESET_ALL); + gs201_elbi_writel(gp, GS201_ELBI_SOFT_RESET, + GS201_ELBI_SOFT_RESET_ALL & ~GS201_ELBI_SOFT_PWR_RESET); + fsleep(10); + gs201_elbi_writel(gp, GS201_ELBI_SOFT_RESET, GS201_ELBI_SOFT_RESET_ALL); + fsleep(10); + + gs201_trace(gp, "about to write ELBI 0x3d8 = 1 (slave pending NAK)"); + gs201_elbi_writel(gp, GS201_ELBI_SLV_PEND_SEL_NAK, 1); +} + /* Stage 3: Google's PHY configuration, then the I/A sequencer */ static int gs201_pcie_stage_phy(struct gs201_pcie *gp) { int ret; + if (gp->data->ctrl_reset_before_phy) + gs201_pcie_ctrl_reset_early(gp); + gs201_trace(gp, "phy_power_on: power-down clear, CAL table, lock checks"); ret = phy_power_on(gp->phy); if (ret) @@ -607,6 +644,9 @@ static void gs201_pcie_stage_ctrl(struct gs201_pcie *gp, bool release_perst) struct device *dev = gp->pci.dev; u32 val; + if (gp->data->ctrl_reset_before_phy) + goto perst; + gs201_trace(gp, "about to pulse the soft power reset (ELBI 0x3a4 bit 1)"); val = gs201_elbi_readl(gp, GS201_ELBI_SOFT_RESET); gs201_elbi_writel(gp, GS201_ELBI_SOFT_RESET, @@ -631,8 +671,9 @@ static void gs201_pcie_stage_ctrl(struct gs201_pcie *gp, bool release_perst) gs201_elbi_writel(gp, GS201_ELBI_SOFT_RESET, val | GS201_ELBI_SOFT_NON_STICKY_RESET); +perst: if (release_perst) { - gs201_trace(gp, "about to release PERST# (gph2-0) and wait 20 ms"); + gs201_trace(gp, "about to release PERST# and wait 20 ms"); gpiod_set_value_cansleep(gp->perst, 0); fsleep(GS201_PERST_DELAY_US); } @@ -818,7 +859,7 @@ static int gs201_pcie_host_init(struct dw_pcie_rp *pp) } if (!pp->skip_pwrctrl_off) { - gs201_trace(gp, "about to power the endpoint (WL_REG_ON, gph2-4, 200 ms)"); + gs201_trace(gp, "about to power the endpoint (WL_REG_ON and its startup delay)"); ret = pci_pwrctrl_power_on_devices(dev); if (ret) goto err_pwrctrl_destroy; @@ -1101,6 +1142,7 @@ static int gs201_pcie_probe(struct platform_device *pdev) return -ENOMEM; raw_spin_lock_init(&gp->lock); + gp->data = of_device_get_match_data(dev); pci = &gp->pci; pci->dev = dev; @@ -1186,8 +1228,16 @@ static void gs201_pcie_remove(struct platform_device *pdev) gs201_pcie_remove_irq(gp); } +static const struct gs201_pcie_soc_data gs201_pcie_data = { +}; + +static const struct gs201_pcie_soc_data zuma_pcie_data = { + .ctrl_reset_before_phy = true, +}; + static const struct of_device_id gs201_pcie_of_match[] = { - { .compatible = "google,gs201-pcie" }, + { .compatible = "google,gs201-pcie", .data = &gs201_pcie_data }, + { .compatible = "google,zuma-pcie", .data = &zuma_pcie_data }, { } }; MODULE_DEVICE_TABLE(of, gs201_pcie_of_match); From 5865ec5fcf7281f7f56f58a55962e870981f56ea Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 08:15:31 -0400 Subject: [PATCH 10/32] arm64: dts: exynos: google: zuma: add the Wi-Fi PCIe controller and PHY Add zuma's second PCIe controller (stock's pcie_1, ch-num 1) and its Gen3 PHY, disabled, at the addresses of stock's pcie@13120000: one lane, Gen3, PERST# on gph3-0 and CLKREQ# on gph3-1 with stock's pin settings, and the PHY's isolation at PMU offset 0x3ec8. Legacy INTx is demultiplexed from the controller's interrupt (SPI 439). As on stock, the controller is not cache coherent and runs without the I/A. Its memory window and config space are at 0x60000000, so the soc bus now maps the first 2 GiB, as on gs201. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../boot/dts/exynos/google/zuma-pinctrl.dtsi | 17 ++++++ arch/arm64/boot/dts/exynos/google/zuma.dtsi | 56 ++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi b/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi index 186a5e9d6e..2ca765b018 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi @@ -512,6 +512,23 @@ interrupt-controller; #interrupt-cells = <2>; }; + + pcie1_clkreq: pcie1-clkreq-pins { + samsung,pins = "gph3-1"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + samsung,pin-con-pdn = ; + samsung,pin-pud-pdn = ; + }; + + pcie1_perst: pcie1-perst-pins { + samsung,pins = "gph3-0"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + samsung,pin-con-pdn = ; + }; }; &pinctrl_hsi2ufs { diff --git a/arch/arm64/boot/dts/exynos/google/zuma.dtsi b/arch/arm64/boot/dts/exynos/google/zuma.dtsi index 282c88e126..fba08e0345 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zuma.dtsi @@ -12,6 +12,7 @@ */ #include +#include #include #include #include @@ -304,7 +305,8 @@ compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; - ranges = <0x0 0x0 0x0 0x40000000>; + /* Registers below 1 GiB, PCIe windows at 0x40000000-0x7fffffff */ + ranges = <0x0 0x0 0x0 0x80000000>; /* * ABL hands over with both cluster watchdogs counting (30 s); @@ -549,6 +551,58 @@ interrupts = ; }; + /* + * The Wi-Fi chip's controller (stock's pcie_1, ch-num 1): one + * Gen3 lane, at the addresses of stock's pcie@13120000. Its + * interrupts are its legacy INTx; stock's MSI lines are unused. + */ + pcie_1: pcie@13120000 { + compatible = "google,zuma-pcie"; + reg = <0x13120000 0x1400>, + <0x13400000 0x381000>, + <0x60ffe000 0x2000>; + reg-names = "elbi", "dbi", "config"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x82000000 0x0 0x60000000 0x60000000 0x0 0xff0000>; + bus-range = <0x00 0xff>; + interrupts = ; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &pcie_1_intc 1>, + <0 0 0 2 &pcie_1_intc 2>, + <0 0 0 3 &pcie_1_intc 3>, + <0 0 0 4 &pcie_1_intc 4>; + phys = <&pcie_1_phy>; + phy-names = "pcie"; + pinctrl-0 = <&pcie1_clkreq>, <&pcie1_perst>; + pinctrl-names = "default"; + reset-gpios = <&gph3 0 GPIO_ACTIVE_LOW>; + num-lanes = <1>; + max-link-speed = <3>; + status = "disabled"; + + pcie_1_intc: legacy-interrupt-controller { + #address-cells = <0>; + interrupt-controller; + #interrupt-cells = <1>; + }; + }; + + pcie_1_phy: phy@13160000 { + compatible = "google,zuma-pcie-phy"; + reg = <0x13160000 0x3000>, + <0x13140000 0x5000>, + <0x13121400 0x10>, + <0x13150000 0xd000>, + <0x13130000 0x5000>; + reg-names = "pma", "pcs", "rst", "udbg", "soc"; + samsung,pmu-syscon = <&pmu_system_controller 0x3ec8>; + #phy-cells = <0>; + status = "disabled"; + }; + ufs_0: ufs@13200000 { compatible = "google,zuma-ufs", "google,zumapro-ufs"; reg = <0x13200000 0x200>, From 37706813356ae8a87137a6f625250d14ad7583c0 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:09 -0400 Subject: [PATCH 11/32] wifi: brcmfmac: chip: support the NCI backplane The BCM4398 (Pixel 8 Pro) reports backplane type 6, NCI ("Booker"), which brcmfmac rejected ("chip backplane type 6 is not supported"). On NCI, chipcommon's eromptr points at EROM2, a list of interface descriptors grouped by core. Each core's info word and interface count sit in EROM1 or in the OOB router (OOBR); OOBR cores also have a DMP control word that takes the clock and core flags the AI backplane keeps in the wrapper's ioctrl. Each interface is a network interface (NI) node with its own reset control. Scan that into brcmfmac's core list (the base is a core's APB slave, or a bridge's own slave; the wrapper its first Booker interface) and implement iscoreup, coredisable and resetcore on it, after Broadcom's GPL bcmdhd (nciutils.c, hal_nci_cmn.h, hndoobr.h). An APB NI shared by several cores is left out of a core's reset. Read the CA7's halt bit from its DMP control word, and start a halted CA7 by clearing that bit only, as bcmdhd does for NCI chips (dhdpcie_bus_download_state()): resetting it again keeps a second firmware download from starting. On the Pixel 8 Pro the scan finds 46 cores, and the RAM base and size and chipcommon revision match bcmdhd's. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/chip.c | 315 +++++++++++++++++- 1 file changed, 312 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c index d0fed7b6a4..c7278d2503 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c @@ -2,6 +2,7 @@ /* * Copyright (c) 2014 Broadcom Corporation */ +#include #include #include #include @@ -20,6 +21,7 @@ /* SOC Interconnect types (aka chip types) */ #define SOCI_SB 0 #define SOCI_AI 1 +#define SOCI_NCI 6 /* PL-368 DMP definitions */ #define DMP_DESC_TYPE_MSK 0x0000000F @@ -229,11 +231,60 @@ struct sbsocramregs { #define ARMCR4_BSZ_MULT 8192 #define ARMCR4_BLK_1K_MASK 0x200 +/* + * NCI ("Booker") backplane, as on the BCM4398. Chipcommon's eromptr points + * at EROM2, a list of interface descriptors grouped by core. Each core's + * info word and interface count sit either in EROM1 (just below EROM2) or + * in the OOB router (OOBR, at the 8 KiB boundary below it); OOBR cores also + * have a DMP control word, which takes the clock and core flags that the AI + * backplane keeps in the wrapper's ioctrl. Each interface is a network + * interface (NI) node with its own reset control. Register layout from + * Broadcom's GPL bcmdhd (nciutils.c, hal_nci_cmn.h, hndoobr.h). + */ +#define NCI_OOBR_BASE(erom2) ((erom2) & ~0x1fffU) +#define NCI_EROM1_BASE(erom2) ((erom2) & ~0xfffU) +#define NCI_OOBR_CAP 0x0 +#define NCI_OOBR_CAP_CORECNT 0x1f +#define NCI_CI_COREID GENMASK(11, 0) +#define NCI_CI_REV GENMASK(19, 12) +#define NCI_CI_ISBP BIT(27) +#define NCI_IC_IFACECNT GENMASK(15, 12) +#define NCI_ID0_NODEPTR GENMASK(31, 3) +#define NCI_ID1_WORDOFFSET GENMASK(31, 28) +#define NCI_ID1_EROM1 BIT(27) +#define NCI_ID1_MASTER BIT(26) +#define NCI_ID1_NADDR GENMASK(25, 24) +#define NCI_ID1_BPID GENMASK(23, 20) +#define NCI_ID1_COREPTR GENMASK(12, 0) +#define NCI_BPID_BOOKER 0 +#define NCI_BPID_PMNI_FIRST 2 +#define NCI_BPID_PMNI_LAST 8 +#define NCI_SP_BASE GENMASK(31, 8) +#define NCI_SP_BOUND BIT(6) +#define NCI_SP_64BIT BIT(5) +#define NCI_EROM_END 0xffffffff +#define NCI_DMPCTRL 0x8 +#define NCI_NI_RESET_CTL 0x140 +#define NCI_NI_RESET_ENTRY BIT(0) +#define NCI_MAX_IFACES 16 +#define NCI_RESET_TIMEOUT_US 5000 + +struct brcmf_nci_iface { + u32 node; + bool booker; + bool pmni; + bool shared; +}; + struct brcmf_core_priv { struct brcmf_core pub; u32 wrapbase; struct list_head list; struct brcmf_chip_priv *chip; + /* NCI only: the DMP control word (0 if none) and the NI nodes */ + u32 dmpctrl; + u8 nifaces; + struct brcmf_nci_iface ifaces[NCI_MAX_IFACES]; }; struct brcmf_chip_priv { @@ -505,6 +556,96 @@ static void brcmf_chip_ai_resetcore(struct brcmf_core_priv *core, u32 prereset, } } +/* Update the DMP control word, which holds the AI ioctrl bits on NCI */ +static void brcmf_chip_nci_cflags(struct brcmf_core_priv *core, u32 mask, + u32 val) +{ + struct brcmf_chip_priv *ci = core->chip; + u32 regdata; + + if (!core->dmpctrl) + return; + + regdata = ci->ops->read32(ci->ctx, core->dmpctrl); + ci->ops->write32(ci->ctx, core->dmpctrl, (regdata & ~mask) | val); + ci->ops->read32(ci->ctx, core->dmpctrl); +} + +/* Put each of the core's own NI nodes into reset, or take them out */ +static void brcmf_chip_nci_reset_ifaces(struct brcmf_core_priv *core, + bool reset) +{ + struct brcmf_chip_priv *ci = core->chip; + u32 addr, regdata; + int i, us; + + for (i = core->nifaces - 1; i >= 0; i--) { + if (core->ifaces[i].shared || !core->ifaces[i].node) + continue; + + addr = core->ifaces[i].node + NCI_NI_RESET_CTL; + regdata = ci->ops->read32(ci->ctx, addr); + if (reset) + regdata |= NCI_NI_RESET_ENTRY; + else + regdata &= ~NCI_NI_RESET_ENTRY; + ci->ops->write32(ci->ctx, addr, regdata); + + for (us = 0; us < NCI_RESET_TIMEOUT_US; us += 10) { + regdata = ci->ops->read32(ci->ctx, addr); + if (!!(regdata & NCI_NI_RESET_ENTRY) == reset) + break; + udelay(10); + } + if (us >= NCI_RESET_TIMEOUT_US) + brcmf_err("core %#x: NI %#x reset %d timed out (%#x)\n", + core->pub.id, core->ifaces[i].node, reset, + regdata); + } +} + +static bool brcmf_chip_nci_iscoreup(struct brcmf_core_priv *core) +{ + struct brcmf_chip_priv *ci = core->chip; + u32 regdata; + + if (!core->wrapbase) + return true; + + regdata = ci->ops->read32(ci->ctx, core->wrapbase + NCI_NI_RESET_CTL); + + return !(regdata & NCI_NI_RESET_ENTRY); +} + +/* bcmdhd's nci_core_reset_enable(), less the final release */ +static void brcmf_chip_nci_coredisable(struct brcmf_core_priv *core, + u32 prereset, u32 reset) +{ + brcmf_chip_nci_cflags(core, BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, 0); + udelay(1); + brcmf_chip_nci_cflags(core, ~(BCMA_IOCTL_FGC | BCMA_IOCTL_CLK), + prereset); + brcmf_chip_nci_reset_ifaces(core, true); + brcmf_chip_nci_cflags(core, ~(BCMA_IOCTL_FGC | BCMA_IOCTL_CLK), reset); + brcmf_chip_nci_cflags(core, BCMA_IOCTL_CLK, BCMA_IOCTL_CLK); + brcmf_chip_nci_cflags(core, BCMA_IOCTL_FGC, BCMA_IOCTL_FGC); + udelay(1); + brcmf_chip_nci_cflags(core, BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, 0); +} + +static void brcmf_chip_nci_resetcore(struct brcmf_core_priv *core, + u32 prereset, u32 reset, u32 postreset) +{ + brcmf_chip_nci_coredisable(core, prereset, reset); + brcmf_chip_nci_reset_ifaces(core, false); + brcmf_chip_nci_cflags(core, ~(BCMA_IOCTL_FGC | BCMA_IOCTL_CLK), + postreset); + brcmf_chip_nci_cflags(core, BCMA_IOCTL_CLK, BCMA_IOCTL_CLK); + brcmf_chip_nci_cflags(core, BCMA_IOCTL_FGC, BCMA_IOCTL_FGC); + udelay(1); + brcmf_chip_nci_cflags(core, BCMA_IOCTL_FGC, 0); +} + char *brcmf_chip_name(u32 id, u32 rev, char *buf, uint len) { const char *fmt; @@ -1004,6 +1145,148 @@ int brcmf_chip_dmp_erom_scan(struct brcmf_chip_priv *ci) return 0; } +/* Skip a slave interface's address descriptors; return the core's base */ +static u32 brcmf_chip_nci_slave_addrs(struct brcmf_chip_priv *ci, u32 *addr, + u32 naddr) +{ + u32 adesc, base = 0; + u32 i; + + for (i = 0; i < naddr; i++) { + adesc = ci->ops->read32(ci->ctx, *addr); + *addr += 4; + if (i == 0) + base = adesc & NCI_SP_BASE; + if (adesc & NCI_SP_64BIT) + *addr += 12; /* base high, bound low and high */ + else if (adesc & NCI_SP_BOUND) + *addr += 4; /* bound */ + } + + return base; +} + +/* An APB NI that several cores share is not one core's to reset */ +static void brcmf_chip_nci_mark_shared(struct brcmf_chip_priv *ci) +{ + struct brcmf_core_priv *a, *b; + int i, j; + + list_for_each_entry(a, &ci->cores, list) { + for (i = 0; i < a->nifaces; i++) { + if (!a->ifaces[i].pmni || !a->ifaces[i].node) + continue; + list_for_each_entry(b, &ci->cores, list) { + if (b == a) + continue; + for (j = 0; j < b->nifaces; j++) + if (b->ifaces[j].pmni && + b->ifaces[j].node == a->ifaces[i].node) + a->ifaces[i].shared = true; + } + } + } +} + +static int brcmf_chip_nci_erom_scan(struct brcmf_chip_priv *ci) +{ + u32 erom2, erom1, oobr, addr, ptr, coreinfo, ifcfg, desc0, desc1; + u32 ncores, base, wordoffset, naddr; + struct brcmf_core_priv *core; + struct brcmf_core *pub; + u8 i, nifaces; + u16 id; + + erom2 = ci->ops->read32(ci->ctx, + CORE_CC_REG(ci->pub.enum_base, eromptr)); + erom1 = NCI_EROM1_BASE(erom2); + oobr = NCI_OOBR_BASE(erom2); + ncores = (erom2 - erom1) / 8 + + (ci->ops->read32(ci->ctx, oobr + NCI_OOBR_CAP) & + NCI_OOBR_CAP_CORECNT); + brcmf_dbg(INFO, "NCI: EROM2 %#x, EROM1 %#x, OOBR %#x, %u cores\n", + erom2, erom1, oobr, ncores); + + addr = erom2; + while (ci->num_cores < ncores) { + desc0 = ci->ops->read32(ci->ctx, addr); + if (desc0 == NCI_EROM_END) + break; + + /* The first interface's second word locates the core info */ + desc1 = ci->ops->read32(ci->ctx, addr + 4); + ptr = FIELD_GET(NCI_ID1_COREPTR, desc1); + ptr += (desc1 & NCI_ID1_EROM1) ? erom1 : oobr; + coreinfo = ci->ops->read32(ci->ctx, ptr); + ifcfg = ci->ops->read32(ci->ctx, ptr + 4); + + id = FIELD_GET(NCI_CI_COREID, coreinfo); + if (id < 0xff) + id |= 0x800; /* Broadcom's cores */ + nifaces = FIELD_GET(NCI_IC_IFACECNT, ifcfg); + if (nifaces > NCI_MAX_IFACES) { + brcmf_err("NCI: core %#x has %u interfaces\n", id, + nifaces); + return -EFAULT; + } + + pub = brcmf_chip_add_core(ci, id, 0, 0); + if (IS_ERR(pub)) + return PTR_ERR(pub); + ci->num_cores++; + pub->rev = FIELD_GET(NCI_CI_REV, coreinfo); + core = container_of(pub, struct brcmf_core_priv, pub); + if (!(desc1 & NCI_ID1_EROM1)) + core->dmpctrl = ptr + NCI_DMPCTRL; + core->nifaces = nifaces; + + wordoffset = 0; + for (i = 0; i < nifaces; i++) { + struct brcmf_nci_iface *ifc = &core->ifaces[i]; + u8 bpid; + + desc0 = ci->ops->read32(ci->ctx, addr); + desc1 = ci->ops->read32(ci->ctx, addr + 4); + addr += 8; + + bpid = FIELD_GET(NCI_ID1_BPID, desc1); + ifc->node = desc0 & NCI_ID0_NODEPTR; + ifc->booker = bpid == NCI_BPID_BOOKER; + ifc->pmni = !(desc1 & NCI_ID1_MASTER) && + bpid >= NCI_BPID_PMNI_FIRST && + bpid <= NCI_BPID_PMNI_LAST; + wordoffset = FIELD_GET(NCI_ID1_WORDOFFSET, desc1); + + if (desc1 & NCI_ID1_MASTER) + continue; + + naddr = FIELD_GET(NCI_ID1_NADDR, desc1) + 1; + base = brcmf_chip_nci_slave_addrs(ci, &addr, naddr); + /* Registers: the APB slave, or a bridge's own slave */ + if (!pub->base && (ifc->pmni || (coreinfo & NCI_CI_ISBP))) + pub->base = base; + } + + /* The first Booker interface is the core's wrapper */ + for (i = 0; i < nifaces; i++) + if (core->ifaces[i].booker) { + core->wrapbase = core->ifaces[i].node; + break; + } + + brcmf_dbg(INFO, "NCI: core %#x rev %u base %#x wrap %#x dmpctrl %#x, %u interfaces\n", + pub->id, pub->rev, pub->base, core->wrapbase, + core->dmpctrl, nifaces); + + if (!wordoffset) + break; + } + + brcmf_chip_nci_mark_shared(ci); + + return 0; +} + u32 brcmf_chip_enum_base(u16 devid) { return SI_ENUM_BASE_DEFAULT; @@ -1036,7 +1319,8 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci) brcmf_chip_name(ci->pub.chip, ci->pub.chiprev, ci->pub.name, sizeof(ci->pub.name)); brcmf_dbg(INFO, "found %s chip: %s\n", - socitype == SOCI_SB ? "SB" : "AXI", ci->pub.name); + socitype == SOCI_SB ? "SB" : socitype == SOCI_NCI ? "NCI" : "AXI", + ci->pub.name); if (socitype == SOCI_SB) { if (ci->pub.chip != BRCM_CC_4329_CHIP_ID) { @@ -1083,6 +1367,14 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci) ci->resetcore = brcmf_chip_ai_resetcore; brcmf_chip_dmp_erom_scan(ci); + } else if (socitype == SOCI_NCI) { + ci->iscoreup = brcmf_chip_nci_iscoreup; + ci->coredisable = brcmf_chip_nci_coredisable; + ci->resetcore = brcmf_chip_nci_resetcore; + + ret = brcmf_chip_nci_erom_scan(ci); + if (ret) + return ret; } else { brcmf_err("chip backplane type %u is not supported\n", socitype); @@ -1126,8 +1418,13 @@ static void brcmf_chip_disable_arm(struct brcmf_chip_priv *chip, u16 id) case BCMA_CORE_ARM_CA7: cpu = container_of(core, struct brcmf_core_priv, pub); - /* clear all IOCTL bits except HALT bit */ - val = chip->ops->read32(chip->ctx, cpu->wrapbase + BCMA_IOCTL); + /* clear all IOCTL bits except HALT bit (DMP control on NCI) */ + if (chip->resetcore == brcmf_chip_nci_resetcore) + val = cpu->dmpctrl ? + chip->ops->read32(chip->ctx, cpu->dmpctrl) : 0; + else + val = chip->ops->read32(chip->ctx, + cpu->wrapbase + BCMA_IOCTL); val &= ARMCR4_BCMA_IOCTL_CPUHALT; brcmf_chip_resetcore(core, val, ARMCR4_BCMA_IOCTL_CPUHALT, ARMCR4_BCMA_IOCTL_CPUHALT); @@ -1413,6 +1710,18 @@ static bool brcmf_chip_ca7_set_active(struct brcmf_chip_priv *chip, u32 rstvec) /* restore ARM */ core = brcmf_chip_get_core(&chip->pub, BCMA_CORE_ARM_CA7); + if (chip->resetcore == brcmf_chip_nci_resetcore) { + /* + * set_passive left the CA7 out of reset and halted; on NCI, + * as Broadcom's driver does, clearing the halt is enough + * (dhdpcie_bus_download_state()). Resetting it again keeps a + * second firmware download from starting. + */ + brcmf_chip_nci_cflags(container_of(core, struct brcmf_core_priv, + pub), + ARMCR4_BCMA_IOCTL_CPUHALT, 0); + return true; + } brcmf_chip_resetcore(core, ARMCR4_BCMA_IOCTL_CPUHALT, 0, 0); return true; From 9985ef1420057747f15c677eeb1625f237bfd1c0 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:09 -0400 Subject: [PATCH 12/32] wifi: brcmfmac: msgbuf: give control buffers the lowest packet IDs Broadcom's driver numbers the ioctl response and event buffers in a map of their own, of 1024 IDs (dhd_msgbuf.c pktid_ctrl_map), and the BCM4398's firmware checks them against that: with data, ioctl response and event buffers sharing one pool, the first event buffer posted after 1023 data buffers got ID 1025 and the firmware trapped ("pciedev_host_pktid_audit(pktid_type=0): Invalid pktid<1025>"). Reserve IDs 1 to 2 * (ioctl response + event buffers) for the control buffers (each is reposted before it is freed), and keep the data buffers above them. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/msgbuf.c | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c index cefa63de17..5a8988668f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c @@ -317,6 +317,8 @@ struct brcmf_msgbuf_pktid { struct brcmf_msgbuf_pktids { u32 array_size; u32 last_allocated_idx; + /* IDs 1 to nr_ctrl: the ioctl response and event buffers only */ + u32 nr_ctrl; enum dma_data_direction direction; struct brcmf_msgbuf_pktid *array; }; @@ -361,10 +363,10 @@ static int brcmf_msgbuf_alloc_pktid(struct device *dev, struct brcmf_msgbuf_pktids *pktids, struct sk_buff *skb, u16 data_offset, - dma_addr_t *physaddr, u32 *idx) + dma_addr_t *physaddr, u32 *idx, bool ctrl) { struct brcmf_msgbuf_pktid *array; - u32 count; + u32 first, end, count; array = pktids->array; @@ -376,21 +378,30 @@ brcmf_msgbuf_alloc_pktid(struct device *dev, return -ENOMEM; } - *idx = pktids->last_allocated_idx; + /* + * Packet ID 0 means "no packet" to the firmware: never hand it out. + * Control buffers get the lowest IDs: Broadcom's driver numbers them + * in a map of their own (1024 IDs), and a firmware that checks them + * against that traps on a larger one ("Invalid pktid"). + */ + first = ctrl ? 1 : pktids->nr_ctrl + 1; + end = ctrl ? pktids->nr_ctrl + 1 : pktids->array_size; + *idx = ctrl ? end - 1 : pktids->last_allocated_idx; + if (*idx < first || *idx >= end) + *idx = end - 1; - /* Packet ID 0 means "no packet" to the firmware: never hand it out. */ - count = 1; + count = 0; do { (*idx)++; - if (*idx == pktids->array_size) - *idx = 1; + if (*idx >= end) + *idx = first; if (array[*idx].allocated.counter == 0) if (atomic_cmpxchg(&array[*idx].allocated, 0, 1) == 0) break; count++; - } while (count < pktids->array_size); + } while (count < end - first); - if (count == pktids->array_size) { + if (count == end - first) { dma_unmap_single(dev, *physaddr, skb->len - data_offset, pktids->direction); return -ENOMEM; @@ -400,7 +411,8 @@ brcmf_msgbuf_alloc_pktid(struct device *dev, array[*idx].physaddr = *physaddr; array[*idx].skb = skb; - pktids->last_allocated_idx = *idx; + if (!ctrl) + pktids->last_allocated_idx = *idx; return 0; } @@ -856,7 +868,7 @@ static void brcmf_msgbuf_txflow(struct brcmf_msgbuf *msgbuf, u16 flowid) if (brcmf_msgbuf_alloc_pktid(msgbuf->drvr->bus_if->dev, msgbuf->tx_pktids, skb, sfh ? 0 : ETH_HLEN, - &physaddr, &pktid)) { + &physaddr, &pktid, false)) { if (sfh) brcmf_msgbuf_sfh_llc_remove(skb); brcmf_flowring_reinsert(flow, flowid, skb); @@ -1093,7 +1105,7 @@ static u32 brcmf_msgbuf_rxbuf_data_post(struct brcmf_msgbuf *msgbuf, u32 count) pktlen = skb->len; if (brcmf_msgbuf_alloc_pktid(msgbuf->drvr->bus_if->dev, msgbuf->rx_pktids, skb, 0, - &physaddr, &pktid)) { + &physaddr, &pktid, false)) { dev_kfree_skb_any(skb); bphy_err(drvr, "No PKTID available !!\n"); brcmf_commonring_write_cancel(commonring, alloced - i); @@ -1205,7 +1217,7 @@ brcmf_msgbuf_rxbuf_ctrl_post(struct brcmf_msgbuf *msgbuf, bool event_buf, pktlen = skb->len; if (brcmf_msgbuf_alloc_pktid(msgbuf->drvr->bus_if->dev, msgbuf->rx_pktids, skb, 0, - &physaddr, &pktid)) { + &physaddr, &pktid, true)) { dev_kfree_skb_any(skb); bphy_err(drvr, "No PKTID available !!\n"); brcmf_commonring_write_cancel(commonring, alloced - i); @@ -1822,8 +1834,8 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr) */ msgbuf->max_rxbufpost = min_t(u32, if_msgbuf->max_rxbufpost, NR_RX_PKTIDS - 1 - - msgbuf->max_ioctlrespbuf - - msgbuf->max_eventbuf); + 2 * (msgbuf->max_ioctlrespbuf + + msgbuf->max_eventbuf)); msgbuf->tx_pktids = brcmf_msgbuf_init_pktids(NR_TX_PKTIDS, DMA_TO_DEVICE); @@ -1833,6 +1845,9 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr) DMA_FROM_DEVICE); if (!msgbuf->rx_pktids) goto fail; + /* Twice the control buffers: each is reposted before it is freed */ + msgbuf->rx_pktids->nr_ctrl = 2 * (msgbuf->max_ioctlrespbuf + + msgbuf->max_eventbuf); msgbuf->flow = brcmf_flowring_attach(drvr->bus_if->dev, if_msgbuf->max_flowrings); From 962e3c0c86d07a3c0ff12ca8f4ef85e8ff3575f4 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:09 -0400 Subject: [PATCH 13/32] wifi: brcmfmac: msgbuf: wait for D2H items the firmware has finished With DMA'd ring indices the firmware can publish a completion's index before the item itself has reached host memory. Firmware that asks for D2H sync (PCIE_SHARED_D2H_SYNC_SEQNUM or _XORCSUM; the BCM4398's asks for XORCSUM) stamps each item with a sequence number in its epoch byte and, in XORCSUM mode, makes the XOR of the item's words zero. Wait for both before handling an item, as Broadcom's driver does (dhd_prot_d2h_sync_seqnum() and dhd_prot_d2h_sync_xorcsum()), with the same stepped retries, and skip an item that never completes, as there. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/bus.h | 1 + .../broadcom/brcm80211/brcmfmac/msgbuf.c | 78 ++++++++++++++++--- .../broadcom/brcm80211/brcmfmac/pcie.c | 5 ++ 3 files changed, 73 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h index f41d87dd55..0ced0b8c26 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h @@ -133,6 +133,7 @@ struct brcmf_bus_msgbuf { u16 max_flowrings; u16 max_submissionrings; u16 max_completionrings; + u32 d2h_sync; }; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c index 5a8988668f..93eebe6ceb 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c @@ -290,6 +290,9 @@ struct brcmf_msgbuf { u16 ioctl_seq_no; u32 reqid; u32 h2d_seqnum[BRCMF_NROF_H2D_COMMON_MSGRINGS]; + /* D2H sync (bcmdhd dhd_prot_d2h_sync_*()): mode, and next epochs */ + u32 d2h_sync; + u32 d2h_seqnum[BRCMF_NROF_COMMON_MSGRINGS]; wait_queue_head_t ioctl_resp_wait; bool ctl_completed; @@ -1521,9 +1524,55 @@ static void brcmf_msgbuf_process_msgtype(struct brcmf_msgbuf *msgbuf, void *buf) } -static void brcmf_msgbuf_process_rx(struct brcmf_msgbuf *msgbuf, - struct brcmf_commonring *commonring) +#define BRCMF_MSGBUF_D2H_EPOCH_MODULO 253 +#define BRCMF_MSGBUF_D2H_EPOCH_INIT 254 +#define BRCMF_MSGBUF_D2H_SYNC_SEQNUM 0x20000 +#define BRCMF_MSGBUF_D2H_SYNC_XORCSUM 0x40000 +#define BRCMF_MSGBUF_D2H_SYNC_TRIES 512 +#define BRCMF_MSGBUF_D2H_SYNC_STEPS 5 + +/* + * With DMA'd ring indices the firmware can publish a completion's index + * before the item itself has landed in host memory. Firmware that asks for + * D2H sync stamps each item with a sequence number (its epoch) and, in + * XORCSUM mode, a checksum making the XOR of the item's words zero; the + * host waits for both before reading the item, as Broadcom's driver does + * (dhd_prot_d2h_sync_seqnum() and dhd_prot_d2h_sync_xorcsum()). An item + * that never completes is skipped, as there. + */ +static bool brcmf_msgbuf_d2h_sync(struct brcmf_msgbuf *msgbuf, u32 ringid, + void *item, u16 len) +{ + u8 want = msgbuf->d2h_seqnum[ringid] % BRCMF_MSGBUF_D2H_EPOCH_MODULO; + struct msgbuf_common_hdr *hdr = item; + u32 step, tries, csum, i; + + for (step = 1; step <= BRCMF_MSGBUF_D2H_SYNC_STEPS; step++) { + for (tries = 0; tries < BRCMF_MSGBUF_D2H_SYNC_TRIES; tries++) { + if (READ_ONCE(hdr->rsvd0) == want) { + csum = 0; + if (msgbuf->d2h_sync & BRCMF_MSGBUF_D2H_SYNC_XORCSUM) + for (i = 0; i < len / 4; i++) + csum ^= READ_ONCE(((u32 *)item)[i]); + if (!csum) { + msgbuf->d2h_seqnum[ringid]++; + dma_rmb(); + return true; + } + } + udelay(step); + } + } + + brcmf_err("D2H ring %u: item never completed (epoch %u, want %u)\n", + ringid, READ_ONCE(hdr->rsvd0), want); + msgbuf->d2h_seqnum[ringid]++; + return false; +} + +static void brcmf_msgbuf_process_rx(struct brcmf_msgbuf *msgbuf, u32 ringid) { + struct brcmf_commonring *commonring = msgbuf->commonrings[ringid]; void *buf; u16 count; u16 processed; @@ -1535,8 +1584,11 @@ static void brcmf_msgbuf_process_rx(struct brcmf_msgbuf *msgbuf, processed = 0; while (count) { - brcmf_msgbuf_process_msgtype(msgbuf, - buf + msgbuf->rx_dataoffset); + if (!msgbuf->d2h_sync || + brcmf_msgbuf_d2h_sync(msgbuf, ringid, buf, + brcmf_commonring_len_item(commonring))) + brcmf_msgbuf_process_msgtype(msgbuf, + buf + msgbuf->rx_dataoffset); buf += brcmf_commonring_len_item(commonring); processed++; if (processed == BRCMF_MSGBUF_UPDATE_RX_PTR_THRS) { @@ -1592,7 +1644,6 @@ int brcmf_proto_msgbuf_rx_trigger(struct device *dev) struct brcmf_pub *drvr = bus_if->drvr; struct brcmf_msgbuf *msgbuf; struct brcmf_commonring *commonring; - void *buf; u32 flowid; int qlen; @@ -1600,12 +1651,9 @@ int brcmf_proto_msgbuf_rx_trigger(struct device *dev) return -ENODEV; msgbuf = (struct brcmf_msgbuf *)drvr->proto->pd; - buf = msgbuf->commonrings[BRCMF_D2H_MSGRING_RX_COMPLETE]; - brcmf_msgbuf_process_rx(msgbuf, buf); - buf = msgbuf->commonrings[BRCMF_D2H_MSGRING_TX_COMPLETE]; - brcmf_msgbuf_process_rx(msgbuf, buf); - buf = msgbuf->commonrings[BRCMF_D2H_MSGRING_CONTROL_COMPLETE]; - brcmf_msgbuf_process_rx(msgbuf, buf); + brcmf_msgbuf_process_rx(msgbuf, BRCMF_D2H_MSGRING_RX_COMPLETE); + brcmf_msgbuf_process_rx(msgbuf, BRCMF_D2H_MSGRING_TX_COMPLETE); + brcmf_msgbuf_process_rx(msgbuf, BRCMF_D2H_MSGRING_CONTROL_COMPLETE); for_each_set_bit(flowid, msgbuf->txstatus_done_map, msgbuf->max_flowrings) { @@ -1825,6 +1873,14 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr) goto fail; msgbuf->rx_dataoffset = if_msgbuf->rx_dataoffset; + msgbuf->d2h_sync = if_msgbuf->d2h_sync; + msgbuf->d2h_seqnum[BRCMF_D2H_MSGRING_CONTROL_COMPLETE] = + BRCMF_MSGBUF_D2H_EPOCH_INIT; + msgbuf->d2h_seqnum[BRCMF_D2H_MSGRING_TX_COMPLETE] = + BRCMF_MSGBUF_D2H_EPOCH_INIT; + msgbuf->d2h_seqnum[BRCMF_D2H_MSGRING_RX_COMPLETE] = + BRCMF_MSGBUF_D2H_EPOCH_INIT; + brcmf_dbg(MSGBUF, "D2H sync mode 0x%x\n", msgbuf->d2h_sync); msgbuf->max_ioctlrespbuf = BRCMF_MSGBUF_MAX_IOCTLRESPBUF_POST; msgbuf->max_eventbuf = BRCMF_MSGBUF_MAX_EVENTBUF_POST; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 4ca80e15e8..c11f6272fa 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -247,6 +247,8 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = { #define BRCMF_PCIE_MAX_SHARED_VERSION BRCMF_PCIE_SHARED_VERSION_9 #define BRCMF_PCIE_SHARED_VERSION_MASK 0x00FF #define BRCMF_PCIE_SHARED_DMA_INDEX 0x10000 +#define BRCMF_PCIE_SHARED_D2H_SYNC_SEQNUM 0x20000 +#define BRCMF_PCIE_SHARED_D2H_SYNC_XORCSUM 0x40000 #define BRCMF_PCIE_SHARED_DMA_2B_IDX 0x100000 #define BRCMF_PCIE_SHARED_USE_MAILBOX 0x2000000 #define BRCMF_PCIE_SHARED_HOSTRDY_DB1 0x10000000 @@ -2876,6 +2878,9 @@ static void brcmf_pcie_setup(struct device *dev, int ret, bus->msgbuf->rx_dataoffset = devinfo->shared.rx_dataoffset; bus->msgbuf->max_rxbufpost = devinfo->shared.max_rxbufpost; + bus->msgbuf->d2h_sync = devinfo->shared.flags & + (BRCMF_PCIE_SHARED_D2H_SYNC_SEQNUM | + BRCMF_PCIE_SHARED_D2H_SYNC_XORCSUM); bus->msgbuf->max_flowrings = devinfo->shared.max_flowrings; init_waitqueue_head(&devinfo->mbdata_resp_wait); From 70b77c34719f9f2f652e26e708394c9b8e5cd154 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:09 -0400 Subject: [PATCH 14/32] wifi: brcmfmac: fall back to event_msgs_ext The BCM4398's 24.100 firmware has dropped the "event_msgs" iovar (getting it fails, and brcmfmac stopped there: "Get event_msgs error (-52)"). Broadcom's driver uses "event_msgs_ext", whose mask is preceded by a small header, as brcmfmac's Cypress code already sends it. When the firmware rejects "event_msgs", read the mask with "event_msgs_ext" and keep using it to set the mask. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/common.c | 6 +- .../broadcom/brcm80211/brcmfmac/fweh.c | 78 ++++++++++++++++++- .../broadcom/brcm80211/brcmfmac/fweh.h | 4 + 3 files changed, 82 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c index b6027d83e6..f7165dfc36 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c @@ -412,8 +412,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) brcmf_c_set_joinpref_default(ifp); /* Setup event_msgs, enable E_IF */ - err = brcmf_fil_iovar_data_get(ifp, "event_msgs", fweh->event_mask, - fweh->event_mask_len); + err = brcmf_fweh_get_event_mask(ifp); if (err) { bphy_err(drvr, "Get event_msgs error (%d)\n", err); goto done; @@ -425,8 +424,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) * that all vendors have. */ setbit(fweh->event_mask, BRCMF_E_IF); - err = brcmf_fil_iovar_data_set(ifp, "event_msgs", fweh->event_mask, - fweh->event_mask_len); + err = brcmf_fweh_set_event_mask(ifp); if (err) { bphy_err(drvr, "Set event_msgs error (%d)\n", err); goto done; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c index 1cff4ba769..f6de0f0f36 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c @@ -430,6 +430,81 @@ void brcmf_fweh_unregister(struct brcmf_pub *drvr, drvr->fweh->evt_handler[evt_handler_idx] = NULL; } +/* + * Newer firmware (the BCM4398's 24.100) has dropped the "event_msgs" iovar + * for "event_msgs_ext", whose mask is preceded by a small header, as + * Broadcom's driver and the Cypress vendor code use it. + */ +struct brcmf_fweh_eventmsgs_ext { + u8 ver; + u8 command; + u8 len; + u8 maxgetsize; + u8 mask[]; +}; + +#define BRCMF_EVENTMSGS_EXT_VER 1 +#define BRCMF_EVENTMSGS_EXT_SET_MASK 3 + +int brcmf_fweh_get_event_mask(struct brcmf_if *ifp) +{ + struct brcmf_fweh_info *fweh = ifp->drvr->fweh; + struct brcmf_fweh_eventmsgs_ext *msg; + u32 msglen; + int err; + + err = brcmf_fil_iovar_data_get(ifp, "event_msgs", fweh->event_mask, + fweh->event_mask_len); + if (err != -EBADE) + return err; + + msglen = sizeof(*msg) + fweh->event_mask_len; + msg = kzalloc(msglen, GFP_KERNEL); + if (!msg) + return -ENOMEM; + msg->ver = BRCMF_EVENTMSGS_EXT_VER; + msg->len = fweh->event_mask_len; + msg->maxgetsize = fweh->event_mask_len; + + err = brcmf_fil_iovar_data_get(ifp, "event_msgs_ext", msg, msglen); + if (!err) { + memcpy(fweh->event_mask, msg->mask, + min_t(uint, msg->len, fweh->event_mask_len)); + fweh->event_msgs_ext = true; + brcmf_dbg(EVENT, "using event_msgs_ext (%u bytes)\n", msg->len); + } + kfree(msg); + + return err; +} + +int brcmf_fweh_set_event_mask(struct brcmf_if *ifp) +{ + struct brcmf_fweh_info *fweh = ifp->drvr->fweh; + struct brcmf_fweh_eventmsgs_ext *msg; + u32 msglen; + int err; + + if (!fweh->event_msgs_ext) + return brcmf_fil_iovar_data_set(ifp, "event_msgs", + fweh->event_mask, + fweh->event_mask_len); + + msglen = sizeof(*msg) + fweh->event_mask_len; + msg = kzalloc(msglen, GFP_KERNEL); + if (!msg) + return -ENOMEM; + msg->ver = BRCMF_EVENTMSGS_EXT_VER; + msg->command = BRCMF_EVENTMSGS_EXT_SET_MASK; + msg->len = fweh->event_mask_len; + memcpy(msg->mask, fweh->event_mask, fweh->event_mask_len); + + err = brcmf_fil_iovar_data_set(ifp, "event_msgs_ext", msg, msglen); + kfree(msg); + + return err; +} + /** * brcmf_fweh_activate_events() - enables firmware events registered. * @@ -459,8 +534,7 @@ int brcmf_fweh_activate_events(struct brcmf_if *ifp) if (!brcmf_fwvid_activate_events(ifp)) return 0; - err = brcmf_fil_iovar_data_set(ifp, "event_msgs", fweh->event_mask, - fweh->event_mask_len); + err = brcmf_fweh_set_event_mask(ifp); if (err) bphy_err(fweh->drvr, "Set event_msgs error (%d)\n", err); return err; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h index e327dd58d2..7dc26ab185 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h @@ -336,6 +336,8 @@ struct brcmf_fweh_event_map { struct brcmf_fweh_info { struct brcmf_pub *drvr; bool p2pdev_setup_ongoing; + /* the firmware takes "event_msgs_ext" rather than "event_msgs" */ + bool event_msgs_ext; struct work_struct event_work; spinlock_t evt_q_lock; struct list_head event_q; @@ -357,6 +359,8 @@ int brcmf_fweh_register(struct brcmf_pub *drvr, enum brcmf_fweh_event_code code, void brcmf_fweh_unregister(struct brcmf_pub *drvr, enum brcmf_fweh_event_code code); int brcmf_fweh_activate_events(struct brcmf_if *ifp); +int brcmf_fweh_get_event_mask(struct brcmf_if *ifp); +int brcmf_fweh_set_event_mask(struct brcmf_if *ifp); void brcmf_fweh_process_event(struct brcmf_pub *drvr, struct brcmf_event *event_packet, u32 packet_len, gfp_t gfp); From 809d88c784388741f351d34c4fea72af4172d0a7 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:09 -0400 Subject: [PATCH 15/32] wifi: brcmfmac: cfg80211: make room for a third band GET_BANDLIST returns the number of bands and then the bands. Firmware with a 6 GHz band, like the BCM4398's, reports three, and fails the call when the buffer only has room for two ("could not obtain band info: err=-52"). Only 2.4 and 5 GHz are set up from it, as before. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index 72ee403bab..4f7167a317 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -7748,7 +7748,7 @@ static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp) struct ieee80211_supported_band *band; u16 max_interfaces = 0; bool gscan; - __le32 bandlist[3]; + __le32 bandlist[4]; /* count, then up to 2.4, 5 and 6 GHz */ u32 n_bands; int err, i; From fa8930b793df1cef86d3cd68d4e35d7d67242258 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:10 -0400 Subject: [PATCH 16/32] wifi: brcmfmac: scan interface versions 3 and 4 "scan_ver" reports the scan interface's major version. Version 3 keeps the version 2 layout with its pad byte used as ssid_type; version 4 adds scan_type_ext after scan_type. The BCM4398's firmware reports 3 and rejects version 2 requests (brcmf_run_escan: error -52). Read the major version, and send version 3 or 4 escan parameters when the firmware asks for them, as Broadcom's driver does (wl_cfgscan.c, scan_params_ver). Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 31 ++++++++++++++++++- .../broadcom/brcm80211/brcmfmac/feature.c | 16 ++++++++++ .../broadcom/brcm80211/brcmfmac/feature.h | 6 +++- .../broadcom/brcm80211/brcmfmac/fwil_types.h | 6 ++++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index 4f7167a317..c4b7182249 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -1469,7 +1469,36 @@ brcmf_run_escan(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp, params->version = cpu_to_le32(BRCMF_ESCAN_REQ_VERSION_V2); - if (!brcmf_feat_is_enabled(ifp, BRCMF_FEAT_SCAN_V2)) { + if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_SCAN_V3)) { + /* The v2 layout; its pad byte is ssid_type, 0 for the default */ + params->version = cpu_to_le32(BRCMF_ESCAN_REQ_VERSION_V3); + params->params_v2_le.version = + cpu_to_le16(BRCMF_SCAN_PARAMS_VERSION_V3); + } else if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_SCAN_V4)) { + struct brcmf_escan_params_le *params_v4; + u8 *v2 = (u8 *)¶ms->params_v2_le; + u16 len = le16_to_cpu(params->params_v2_le.length); + u8 *v4; + + params_size += sizeof(__le32); + params_v4 = kzalloc(params_size, GFP_KERNEL); + if (!params_v4) { + err = -ENOMEM; + goto exit_params; + } + params_v4->version = cpu_to_le32(BRCMF_ESCAN_REQ_VERSION_V4); + v4 = (u8 *)¶ms_v4->params_v2_le; + memcpy(v4, v2, BRCMF_SCAN_PARAMS_V4_EXT_OFFSET); + memcpy(v4 + BRCMF_SCAN_PARAMS_V4_EXT_OFFSET + sizeof(__le32), + v2 + BRCMF_SCAN_PARAMS_V4_EXT_OFFSET, + len - BRCMF_SCAN_PARAMS_V4_EXT_OFFSET); + params_v4->params_v2_le.version = + cpu_to_le16(BRCMF_SCAN_PARAMS_VERSION_V4); + params_v4->params_v2_le.length = + cpu_to_le16(len + sizeof(__le32)); + kfree(params); + params = params_v4; + } else if (!brcmf_feat_is_enabled(ifp, BRCMF_FEAT_SCAN_V2)) { struct brcmf_escan_params_le *params_v1; params_size -= BRCMF_SCAN_PARAMS_V2_FIXED_SIZE; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c index 145b576395..afac815ca9 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c @@ -356,6 +356,22 @@ void brcmf_feat_attach(struct brcmf_pub *drvr) brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_FWSUP, "sup_wpa"); brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_SCAN_V2, "scan_ver"); + if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_SCAN_V2)) { + struct { + __le16 version; + __le16 length; + __le16 major; + } scan_ver = {}; + + err = brcmf_fil_iovar_data_get(ifp, "scan_ver", &scan_ver, + sizeof(scan_ver)); + brcmf_dbg(INFO, "scan interface version %u\n", + le16_to_cpu(scan_ver.major)); + if (!err && le16_to_cpu(scan_ver.major) == 3) + ifp->drvr->feat_flags |= BIT(BRCMF_FEAT_SCAN_V3); + else if (!err && le16_to_cpu(scan_ver.major) >= 4) + ifp->drvr->feat_flags |= BIT(BRCMF_FEAT_SCAN_V4); + } brcmf_feat_wlc_version_overrides(drvr); brcmf_feat_firmware_overrides(drvr); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h index 8ebd231169..be20a6336c 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h @@ -32,6 +32,8 @@ * DUMP_OBSS: Firmware has capable to dump obss info to support ACS * SCAN_V2: Version 2 scan params * SAE_EXT: SAE authentication handled by user-space supplicant + * SCAN_V3: Version 3 scan params (the v2 layout, with the pad as ssid_type) + * SCAN_V4: Version 4 scan params (scan_type_ext after scan_type) */ #define BRCMF_FEAT_LIST \ BRCMF_FEAT_DEF(MBSS) \ @@ -61,7 +63,9 @@ BRCMF_FEAT_DEF(PMKID_V3) \ BRCMF_FEAT_DEF(SAE_EXT) \ BRCMF_FEAT_DEF(JOIN_V1) \ - BRCMF_FEAT_DEF(HOST_SFHLLC) + BRCMF_FEAT_DEF(HOST_SFHLLC) \ + BRCMF_FEAT_DEF(SCAN_V3) \ + BRCMF_FEAT_DEF(SCAN_V4) /* * Quirks: diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h index f346f7c71a..a018dfa7a7 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h @@ -49,6 +49,10 @@ /* size of brcmf_scan_params not including variable length array */ #define BRCMF_SCAN_PARAMS_FIXED_SIZE 64 #define BRCMF_SCAN_PARAMS_V2_FIXED_SIZE 72 +#define BRCMF_SCAN_PARAMS_VERSION_V3 3 +#define BRCMF_SCAN_PARAMS_VERSION_V4 4 +/* v4: scan_type_ext follows scan_type, at the v2 offset of nprobes */ +#define BRCMF_SCAN_PARAMS_V4_EXT_OFFSET 52 /* version of brcmf_scan_params structure */ #define BRCMF_SCAN_PARAMS_VERSION_V2 2 @@ -72,6 +76,8 @@ #define DOT11_BSSTYPE_ANY 2 #define BRCMF_ESCAN_REQ_VERSION 1 #define BRCMF_ESCAN_REQ_VERSION_V2 2 +#define BRCMF_ESCAN_REQ_VERSION_V3 3 +#define BRCMF_ESCAN_REQ_VERSION_V4 4 #define BRCMF_MAXRATES_IN_SET 16 /* max # of rates in rateset */ From 082393519600b36cd2e04d92821e9ec0b229794c Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:10 -0400 Subject: [PATCH 17/32] wifi: brcmfmac: accept version 114 BSS info The BCM4398's firmware reports scan results as wl_bss_info version 114: version 109 with EHT fields appended, so every field brcmfmac reads is where it was, and the IEs are found from ie_offset as before. Accept it rather than dropping every result ("Version 114 != WL_BSS_INFO_VERSION"). Assisted-by: LLM Signed-off-by: Brett-Michael Green --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 ++- drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index c4b7182249..a667663b50 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -3545,7 +3545,8 @@ static s32 brcmf_inform_bss(struct brcmf_cfg80211_info *cfg) bss_list = (struct brcmf_scan_results *)cfg->escan_info.escan_buf; if (bss_list->count != 0 && - bss_list->version != BRCMF_BSS_INFO_VERSION) { + bss_list->version != BRCMF_BSS_INFO_VERSION && + bss_list->version != BRCMF_BSS_INFO_VERSION_114) { bphy_err(drvr, "Version %d != WL_BSS_INFO_VERSION\n", bss_list->version); return -EOPNOTSUPP; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h index a018dfa7a7..0fe42ec7a4 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h @@ -19,6 +19,8 @@ #define BRCMF_ARP_OL_PEER_AUTO_REPLY 0x00000008 #define BRCMF_BSS_INFO_VERSION 109 /* curr ver of brcmf_bss_info_le struct */ +/* v114 (the BCM4398's firmware): v109 with EHT fields appended */ +#define BRCMF_BSS_INFO_VERSION_114 114 #define BRCMF_BSS_RSSI_ON_CHANNEL 0x0004 #define BRCMF_STA_BRCM 0x00000001 /* Running a Broadcom driver */ From b2b432d6ed6680a67a70364934d05729fe1bbfc0 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:10 -0400 Subject: [PATCH 18/32] wifi: brcmfmac: add the BCM4398 chip id, RAM base and firmware name The Pixel 8 Pro's Wi-Fi chip is a BCM4398 (PCIe device 0x4444), rev 3 (d0). Bcmdhd puts its 4 MiB of RAM at 0x2a0000; it sizes its SYSMEM like the BCM4389's. Add the ids, the RAM base and the firmware name for d0 and later. The PCI id is added once the chip is supported. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 3 +++ drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 3 +++ drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c index c7278d2503..a97013c00b 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c @@ -824,6 +824,7 @@ static u32 brcmf_chip_sysmem_ramsize(struct brcmf_core_priv *sysmem) switch (sysmem->chip->pub.chip) { case BRCM_CC_4389_CHIP_ID: + case BRCM_CC_4398_CHIP_ID: /* Count the RAM banks only, and skip the ROM banks in * front of them. */ @@ -929,6 +930,8 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci) return 0x6e0000; case BRCM_CC_4387_CHIP_ID: return 0x740000; + case BRCM_CC_4398_CHIP_ID: + return 0x2a0000; default: brcmf_err("unknown chip: %s\n", ci->pub.name); break; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index c11f6272fa..6acd9c83b8 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -76,6 +76,8 @@ BRCMF_FW_CLM_DEF(4387C2, "brcmfmac4387c2-pcie"); BRCMF_FW_CLM_DEF(4389C1, "brcmfmac4389c1-pcie"); /* BCM4383 rev 2 (Pixel 9a): the owner's firmware set, with CLM and TXCAP blobs */ BRCMF_FW_CLM_DEF(4383, "brcmfmac4383-pcie"); +/* BCM4398 rev 3, d0 (Pixel 8 Pro): the owner's firmware set */ +BRCMF_FW_CLM_DEF(4398D0, "brcmfmac4398d0-pcie"); BRCMF_FW_CLM_DEF(54591, "brcmfmac54591-pcie"); /* firmware config files */ @@ -119,6 +121,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = { BRCMF_FW_ENTRY(BRCM_CC_4387_CHIP_ID, 0xFFFFFFFF, 4387C2), /* revision ID 7 */ BRCMF_FW_ENTRY(BRCM_CC_4389_CHIP_ID, 0xFFFFFFFF, 4389C1), BRCMF_FW_ENTRY(BRCM_CC_4383_CHIP_ID, 0xFFFFFFFF, 4383), + BRCMF_FW_ENTRY(BRCM_CC_4398_CHIP_ID, 0xFFFFFFF8, 4398D0), }; #define BRCMF_PCIE_FW_UP_TIMEOUT 5000 /* msec */ diff --git a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h index 7cbe571c39..c453d6d0f2 100644 --- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h +++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h @@ -57,6 +57,7 @@ #define BRCM_CC_4377_CHIP_ID 0x4377 #define BRCM_CC_4378_CHIP_ID 0x4378 #define BRCM_CC_4383_CHIP_ID 0x4383 +#define BRCM_CC_4398_CHIP_ID 0x4398 #define BRCM_CC_4387_CHIP_ID 0x4387 #define BRCM_CC_4389_CHIP_ID 0x4389 #define CY_CC_4373_CHIP_ID 0x4373 @@ -101,6 +102,7 @@ #define BRCM_PCIE_4377_DEVICE_ID 0x4488 #define BRCM_PCIE_4378_DEVICE_ID 0x4425 #define BRCM_PCIE_4383_DEVICE_ID 0x4449 +#define BRCM_PCIE_4398_DEVICE_ID 0x4444 #define BRCM_PCIE_4387_DEVICE_ID 0x4433 #define BRCM_PCIE_4389_DEVICE_ID 0x4441 #define CY_PCIE_54591_DEVICE_ID 0x4417 From 7a5ba0d0a9b6d275308e32dcda8bfa1365890a3e Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:10 -0400 Subject: [PATCH 19/32] wifi: brcmfmac: pcie: handle the BCM4398 like the BCM4389 The BCM4398 follows the BCM4389 in Broadcom's driver: it is reset with an FLR, told the host is ready with the same value, and serviced with the same INTx follow-ups and ring polling. It also splits its backplane into save/restore power domains, with two more than the BCM4389: the scan MAC and the SAQM (si_srpwr_domain_all_mask()). Key those paths on a helper covering both chips, and request the BCM4398's six domains. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/pcie.c | 49 ++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 6acd9c83b8..d56650a340 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -172,6 +172,8 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = { #define BRCMF_PCIE_SRPWR_DMN1_ARMBP BIT(1) #define BRCMF_PCIE_SRPWR_DMN2_MACAUX BIT(2) #define BRCMF_PCIE_SRPWR_DMN3_MACMAIN BIT(3) +#define BRCMF_PCIE_SRPWR_DMN4_MACSCAN BIT(4) +#define BRCMF_PCIE_SRPWR_DMN6_SAQM BIT(6) #define BRCMF_PCIE_SRPWR_DMN_ALL (BRCMF_PCIE_SRPWR_DMN0_PCIE | \ BRCMF_PCIE_SRPWR_DMN1_ARMBP | \ BRCMF_PCIE_SRPWR_DMN2_MACAUX | \ @@ -848,22 +850,48 @@ brcmf_pcie_select_core(struct brcmf_pciedev_info *devinfo, u16 coreid) /* - * Chips with several backplane power domains (the BCM4389 here) power the + * The BCM4389 and the BCM4398 after it are reset, told the host is ready and + * serviced the way Broadcom's driver does for its multi-backplane chips. + */ +static bool brcmf_pcie_is_4389_family(struct brcmf_pciedev_info *devinfo) +{ + return devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID || + devinfo->pdev->device == BRCM_PCIE_4398_DEVICE_ID; +} + +/* + * Chips with several backplane power domains (the BCM4389 and BCM4398) power the * ARM/backplane and MAC domains down unless the host asks for them, and * a chip reset drops the host's requests. Backplane accesses to a domain * that is off fault, and read back as 0xffffffff. */ +static u32 brcmf_pcie_srpwr_domains(struct brcmf_pciedev_info *devinfo) +{ + switch (devinfo->pdev->device) { + case BRCM_PCIE_4389_DEVICE_ID: + return BRCMF_PCIE_SRPWR_DMN_ALL; + case BRCM_PCIE_4398_DEVICE_ID: + /* and the scan MAC and SAQM domains (si_srpwr_domain_all_mask()) */ + return BRCMF_PCIE_SRPWR_DMN_ALL | BRCMF_PCIE_SRPWR_DMN4_MACSCAN | + BRCMF_PCIE_SRPWR_DMN6_SAQM; + default: + return 0; + } +} + static bool brcmf_pcie_has_srpwr(struct brcmf_pciedev_info *devinfo) { - return devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID; + return brcmf_pcie_srpwr_domains(devinfo); } static void brcmf_pcie_srpwr_request(struct brcmf_pciedev_info *devinfo) { u32 reg = BRCMF_PCIE_BARO_PCIE_ENUM_OFFSET + BRCMF_PCIE_PCIE2REG_POWERCTL; - u32 req = BRCMF_PCIE_SRPWR_DMN_ALL << BRCMF_PCIE_SRPWR_REQON_SHIFT; - u32 up = BRCMF_PCIE_SRPWR_DMN_ALL << BRCMF_PCIE_SRPWR_STATUS_SHIFT; + u32 req = brcmf_pcie_srpwr_domains(devinfo) << + BRCMF_PCIE_SRPWR_REQON_SHIFT; + u32 up = brcmf_pcie_srpwr_domains(devinfo) << + BRCMF_PCIE_SRPWR_STATUS_SHIFT; u32 dar = BRCMF_PCIE_BARO_PCIE_ENUM_OFFSET + BRCMF_PCIE_64_PCIE2REG_DAR_POWERCTL; u32 val; @@ -991,8 +1019,7 @@ static void brcmf_pcie_reset_device(struct brcmf_pciedev_info *devinfo) * second firmware download. */ brcmf_pcie_srpwr_request(devinfo); - if (devinfo->pdev->device != BRCM_PCIE_4389_DEVICE_ID || - brcmf_pcie_flr(devinfo)) { + if (!brcmf_pcie_is_4389_family(devinfo) || brcmf_pcie_flr(devinfo)) { brcmf_pcie_select_core(devinfo, BCMA_CORE_CHIPCOMMON); WRITECC32(devinfo, watchdog, 4); msleep(100); @@ -1285,7 +1312,7 @@ static void brcmf_pcie_intr_enable(struct brcmf_pciedev_info *devinfo) static bool brcmf_pcie_early_hostready(struct brcmf_pciedev_info *devinfo) { - return devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID || + return brcmf_pcie_is_4389_family(devinfo) || devinfo->shared.version == BRCMF_PCIE_SHARED_VERSION_9; } @@ -1297,8 +1324,7 @@ static void brcmf_pcie_hostready(struct brcmf_pciedev_info *devinfo) /* bcmdhd dhd_bus_hostready() writes this value */ brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->h2d_mailbox_1, - devinfo->pdev->device == - BRCM_PCIE_4389_DEVICE_ID ? + brcmf_pcie_is_4389_family(devinfo) ? 0x12345678 : 1); } } @@ -1404,7 +1430,7 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg) * (dhd_bus_handle_intx_ahead_dma_indices()). */ if (devinfo->dma_idx_sz && - devinfo->pdev->device == BRCM_PCIE_4389_DEVICE_ID && + brcmf_pcie_is_4389_family(devinfo) && devinfo->state == BRCMFMAC_PCIE_STATE_UP) { usleep_range(500, 1000); brcmf_pcie_rx_process(devinfo); @@ -2859,8 +2885,7 @@ static void brcmf_pcie_setup(struct device *dev, int ret, ret = brcmf_pcie_request_irq(devinfo); if (ret) goto fail; - devinfo->poll_enabled = devinfo->pdev->device == - BRCM_PCIE_4389_DEVICE_ID; + devinfo->poll_enabled = brcmf_pcie_is_4389_family(devinfo); /* Notify early firmware before its deferred TX-buffer allocation. */ if (brcmf_pcie_early_hostready(devinfo)) From c48582d760d82d63b2f99f5991c89707620e8b46 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:10 -0400 Subject: [PATCH 20/32] wifi: brcmfmac: pcie: wait for the BCM4398's boot interrupt The BCM4398's firmware writes an interim address to the last word of RAM before its shared area's, and signals the end of its boot with a mailbox interrupt, which Broadcom's driver waits for before it reads the address (dhdpcie_wait_readshared_area_addr(), "recd. boot intr"). brcmfmac took the interim address and failed the firmware's API checks. Interrupts are not set up yet at that point, so poll the PCIe core's mailbox status through BAR0's fixed window onto it, then read the address. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/pcie.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index d56650a340..e63d9a8f29 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -2423,6 +2423,37 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo, brcmf_dbg(PCIE, "Wait for FW init\n"); sharedram_addr = sharedram_addr_written; loop_counter = BRCMF_PCIE_FW_UP_TIMEOUT / 50; + /* + * The BCM4398's firmware writes an interim address to the last word + * of RAM before the real one, and signals the end of its boot with a + * mailbox interrupt, which Google's driver waits for (dhd_pcie.c + * dhdpcie_wait_readshared_area_addr(), "boot intr"). Interrupts are + * not set up yet, so poll for it. + */ + if (devinfo->pdev->device == BRCM_PCIE_4398_DEVICE_ID) { + u32 mbint = BRCMF_PCIE_BARO_PCIE_ENUM_OFFSET + + devinfo->reginfo->mailboxint; + u32 intstatus = 0; + + brcmf_pcie_select_core(devinfo, BCMA_CORE_PCIE2); + while (loop_counter) { + intstatus = brcmf_pcie_read_reg32(devinfo, mbint); + if (intstatus && intstatus != 0xffffffff) + break; + msleep(50); + loop_counter--; + } + brcmf_dbg(PCIE, "boot interrupt %#x after %u ms\n", intstatus, + (BRCMF_PCIE_FW_UP_TIMEOUT / 50 - loop_counter) * 50); + if (intstatus && intstatus != 0xffffffff) + brcmf_pcie_write_reg32(devinfo, + BRCMF_PCIE_BARO_PCIE_ENUM_OFFSET + + devinfo->reginfo->mailboxint, + intstatus); + sharedram_addr = brcmf_pcie_read_ram32(devinfo, + devinfo->ci->ramsize - + 4); + } while ((sharedram_addr == sharedram_addr_written) && (loop_counter)) { msleep(50); sharedram_addr = brcmf_pcie_read_ram32(devinfo, From b54caca427a858cb87e69156f1470689d613be5e Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:10 -0400 Subject: [PATCH 21/32] wifi: brcmfmac: pcie: make the BCM4398's firmware trap before release The BCM4398's always-on domain keeps its state across WL_REG_ON, an FLR and a PMU watchdog reset, and after a firmware has run, a second download never starts: reloading the driver needed a reboot. Broadcom's driver makes the firmware trap on purpose before it lets go of it, by writing a magic number to the PCIe core's H2D doorbell 1 of function 3 ("DB7"), and in its trap handler the firmware holds the power resources high so that the next one boots (dhdpcie_fw_trap(), DHD_DONGLE_TRAP_IN_DETACH). Do the same on remove when the firmware supports it (PCIE_SHARED2_TRAP_ON_HOST_DB7). With it, brcmfmac reloads, with or without the PCIe controller, load and run the firmware again. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/pcie.c | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index e63d9a8f29..3f5ea978cd 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -2352,6 +2352,43 @@ brcmf_pcie_provide_random_bytes(struct brcmf_pciedev_info *devinfo, u32 address) BRCMF_RANDOM_SEED_LENGTH); } +/* + * Before the host lets go of firmware that supports it, Broadcom's driver + * makes it trap on purpose by writing a magic number to the PCIe core's + * H2D doorbell 1 of function 3 ("DB7"): in its trap handler the firmware + * holds the chip's power resources high, which a new firmware needs to boot. + * Without it the always-on domain keeps the old firmware's PMU state across + * WL_REG_ON and an FLR, and a second download never starts + * (dhd_pcie.c dhdpcie_fw_trap(), DHD_DONGLE_TRAP_IN_DETACH). + */ +#define BRCMF_SHARED_FLAGS2_OFFSET 80 +#define BRCMF_PCIE_SHARED2_TRAP_ON_HOST_DB7 0x00040000 +#define BRCMF_PCIE_PCIE2REG_H2D3_DOORBELL1 0x174 +#define BRCMF_PCIE_DB7_MAGIC_DPC_TRAP 0xdead0002 +#define BRCMF_PCIE_DB7_TRAP_WAIT_MS 100 + +static void brcmf_pcie_db7_trap(struct brcmf_pciedev_info *devinfo) +{ + u32 flags2; + + if (devinfo->pdev->device != BRCM_PCIE_4398_DEVICE_ID || + !devinfo->shared.tcm_base_address) + return; + + flags2 = brcmf_pcie_read_tcm32(devinfo, + devinfo->shared.tcm_base_address + + BRCMF_SHARED_FLAGS2_OFFSET); + if (flags2 == 0xffffffff || + !(flags2 & BRCMF_PCIE_SHARED2_TRAP_ON_HOST_DB7)) + return; + + brcmf_dbg(PCIE, "DB7 trap before release\n"); + brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_BARO_PCIE_ENUM_OFFSET + + BRCMF_PCIE_PCIE2REG_H2D3_DOORBELL1, + BRCMF_PCIE_DB7_MAGIC_DPC_TRAP); + msleep(BRCMF_PCIE_DB7_TRAP_WAIT_MS); +} + static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo, const struct firmware *fw, void *nvram, u32 nvram_len) @@ -3366,6 +3403,7 @@ brcmf_pcie_remove(struct pci_dev *pdev) kfree(bus->msgbuf); kfree(bus); + brcmf_pcie_db7_trap(devinfo); brcmf_pcie_release_irq(devinfo); brcmf_pcie_release_scratchbuffers(devinfo); brcmf_pcie_release_ringbuffers(devinfo); From 450b334cfce5d3a2baa9b918c2cf37b5b59d83cf Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:10 -0400 Subject: [PATCH 22/32] wifi: brcmfmac: BCM4398 firmware quirks The BCM4398's 24.100 firmware (WLC version 18.2): - takes the versioned join parameters only, by the same WLC version test as the BCM4389 and BCM4383; - advertises the supplicant offload but refuses the key, as the BCM4383's does ("failed to change PSK in firmware"): leave the handshakes to the host; - advertises host_sfhllc and relies on it: given plain Ethernet frames it traps in its transmit path (a null write in txq_hw_fill() while encrypting the first aggregated frame). Build the 802.3/LLC header on the host, as for the BCM4389. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../broadcom/brcm80211/brcmfmac/feature.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c index afac815ca9..85c1ef8ff4 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c @@ -164,10 +164,12 @@ static void brcmf_feat_wlc_version_overrides(struct brcmf_pub *drv) * on 16, or 17 and later. The BCM4389 (its 20.101.90 firmware * reports 14.4 and rejects the unversioned layout) and the Pixel * 9a's BCM4383 (20.123.13: the unversioned "join" and SET_SSID - * both fail with -52). + * both fail with -52), and the Pixel 8 Pro's BCM4398 (24.100, + * WLC version 18.2). */ if ((drv->bus_if->chip == BRCM_CC_4389_CHIP_ID || - drv->bus_if->chip == BRCM_CC_4383_CHIP_ID) && + drv->bus_if->chip == BRCM_CC_4383_CHIP_ID || + drv->bus_if->chip == BRCM_CC_4398_CHIP_ID) && ((major == 14 && (minor == 2 || minor == 4)) || (major == 16 && minor >= 1) || major >= 17)) feat_flags |= BIT(BRCMF_FEAT_JOIN_V1); @@ -378,17 +380,20 @@ void brcmf_feat_attach(struct brcmf_pub *drvr) brcmf_fwvid_feat_attach(ifp); - /* Host-built 802.3 + LLC/SNAP TX headers: only the BCM4389 for now */ - if (drvr->bus_if->chip != BRCM_CC_4389_CHIP_ID) + /* Host-built 802.3 + LLC/SNAP TX headers: the BCM4389 and BCM4398 for now */ + if (drvr->bus_if->chip != BRCM_CC_4389_CHIP_ID && + drvr->bus_if->chip != BRCM_CC_4398_CHIP_ID) drvr->feat_flags &= ~BIT(BRCMF_FEAT_HOST_SFHLLC); /* - * The BCM4383's firmware (20.123.13 on the Pixel 9a) advertises the - * supplicant offload but refuses the key: brcmf_set_wsec() fails with - * "failed to change PSK in firmware" and the join never gets past + * The BCM4383's firmware (20.123.13 on the Pixel 9a) and the + * BCM4398's (24.100 on the Pixel 8 Pro) advertise the supplicant + * offload but refuse the key: brcmf_set_wsec() fails with "failed to + * change PSK in firmware" and the join never gets past * authentication. Leave the handshakes to the host. */ - if (drvr->bus_if->chip == BRCM_CC_4383_CHIP_ID) + if (drvr->bus_if->chip == BRCM_CC_4383_CHIP_ID || + drvr->bus_if->chip == BRCM_CC_4398_CHIP_ID) drvr->feat_flags &= ~(BIT(BRCMF_FEAT_FWSUP) | BIT(BRCMF_FEAT_SAE) | BIT(BRCMF_FEAT_FWAUTH)); From 7da01769c1a70db56fe1501161c2bcb098cba2b8 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 11:45:11 -0400 Subject: [PATCH 23/32] wifi: brcmfmac: add BCM4398 PCIe support Add the BCM4398's PCIe id. On the Pixel 8 Pro (firmware 24.100.671.86.2 from the device's factory image) it joins WPA2, passes 50 to 87 Mbit/s down and 47 to 70 Mbit/s up on 2.4 GHz, stays up across idle and deep sleep, and survives driver reloads. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 3f5ea978cd..969410ee3f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -3629,6 +3629,7 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = { BRCMF_PCIE_DEVICE(BRCM_PCIE_4387_DEVICE_ID, WCC_SEED), BRCMF_PCIE_DEVICE(BRCM_PCIE_4389_DEVICE_ID, WCC_SEED), BRCMF_PCIE_DEVICE(BRCM_PCIE_4383_DEVICE_ID, WCC_SEED), + BRCMF_PCIE_DEVICE(BRCM_PCIE_4398_DEVICE_ID, WCC_SEED), BRCMF_PCIE_DEVICE(BRCM_PCIE_43752_DEVICE_ID, WCC_SEED), BRCMF_PCIE_DEVICE(CY_PCIE_54591_DEVICE_ID, CYW), { /* end: all zeroes */ } From f805a1b1f2d6183bb036544fc97db8202c01dd53 Mon Sep 17 00:00:00 2001 From: Brett-Michael Green Date: Sat, 31 Oct 2026 08:15:31 -0400 Subject: [PATCH 24/32] arm64: dts: exynos: google: zuma-husky: enable the BCM4398 Wi-Fi The Pixel 8 Pro's BCM4398 sits on pcie_1. As stock's wlan node gives them: WL_REG_ON on gph3-4 (as the root port's supply, so the PCI pwrctrl core switches it around link training, with bcmdhd's 200 ms), device wake on gph3-5 and host wake on gpa5-1. Its DMA buffers come from a restricted pool below 4 GiB, as on the Pixel 7 Pro. Assisted-by: LLM Signed-off-by: Brett-Michael Green --- .../boot/dts/exynos/google/zuma-husky.dts | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/arch/arm64/boot/dts/exynos/google/zuma-husky.dts b/arch/arm64/boot/dts/exynos/google/zuma-husky.dts index f9d30456ae..ab0af9b6fe 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma-husky.dts +++ b/arch/arm64/boot/dts/exynos/google/zuma-husky.dts @@ -64,6 +64,24 @@ height-mm = <155>; }; + /* + * WL_REG_ON of the BCM4398 (gph3-4, stock's wl_reg_on). Modelled as + * the root port's supply so the PCI pwrctrl core switches it around + * link training; bcmdhd waits 200 ms after raising it. With pcie_1 + * disabled nothing enables it, so the chip stays off. + */ + wlan_pwr: regulator-wlan { + compatible = "regulator-fixed"; + regulator-name = "wlan-reg-on"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + gpio = <&gph3 4 GPIO_ACTIVE_HIGH>; + enable-active-high; + startup-delay-us = <200000>; + pinctrl-0 = <&wlan_reg_on>; + pinctrl-names = "default"; + }; + chosen { /* * ABL requires bootargs to exist; it appends its own after these. @@ -148,6 +166,19 @@ reg = <0x0 0xfac00000 (1344 * 2992 * 4)>; no-map; }; + + /* + * All of the Wi-Fi chip's DMA buffers come from this pool, below + * 4 GiB, as on the Pixel 7 Pro: it keeps driver bugs and stray + * pointers away from the rest of RAM. It does not confine the + * chip's own firmware. + */ + wifi_dma_pool: wifi-dma-pool { + compatible = "restricted-dma-pool"; + size = <0x1000000>; + alignment = <0x0 0x200000>; + alloc-ranges = <0x0 0x80000000 0x80000000>; + }; }; }; @@ -175,6 +206,69 @@ }; }; +/* + * Wi-Fi: the BCM4398 on pcie_1, one Gen3 lane as on stock. Its DMA + * buffers come from wifi_dma_pool. + */ +&pcie_1 { + pinctrl-0 = <&pcie1_clkreq>, <&pcie1_perst>, <&wlan_dev_wake>, + <&wlan_host_wake>; + status = "okay"; + + pcie@0,0 { + compatible = "pciclass,0604"; + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + bus-range = <0x01 0xff>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + vpcie3v3-supply = <&wlan_pwr>; + + wifi@0,0 { + compatible = "pci14e4,4444"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + brcm,board-type = "google,zuma-husky"; + memory-region = <&wifi_dma_pool>; + }; + }; +}; + +&pcie_1_phy { + status = "okay"; +}; + +&pinctrl_far_alive { + wlan_host_wake: wlan-host-wake-pins { + samsung,pins = "gpa5-1"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + samsung,pin-con-pdn = ; + samsung,pin-pud-pdn = ; + }; +}; + +&pinctrl_hsi2 { + wlan_reg_on: wlan-reg-on-pins { + samsung,pins = "gph3-4"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + samsung,pin-con-pdn = ; + samsung,pin-pud-pdn = ; + }; + + wlan_dev_wake: wlan-dev-wake-pins { + samsung,pins = "gph3-5"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + samsung,pin-con-pdn = ; + samsung,pin-pud-pdn = ; + }; +}; + &spi20 { status = "okay"; From 7ccfd02b4cc76bfadb57687e5088ca1fdd286edf Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 11:10:27 -0647 Subject: [PATCH 25/32] dt-bindings: PCI: google,gs201-pcie: Add zumapro as a fallback of zuma The Wi-Fi PCIe controller of zumapro (Tensor G4, Pixel 9a) is the one zuma has: the same DesignWare core and Samsung wrapper, at the same addresses (ELBI 0x13120000, DBI 0x13400000, config 0x60ffe000), with the same controller interrupt (SPI 439), and Google's pcie-exynos-rc.c drives both SoCs with the same code. The only place it tells them apart (IP version 0x986500 against 0x987500) is a register dump. Describe zumapro as "google,zumapro-pcie", "google,zuma-pcie", and make zuma's three-region constraint match on the fallback, so it covers zumapro too. Tested on a Pixel 9a with this pair of compatibles on PCIe channel 1, driven by pcie-gs201 with zuma's match data: the link trained at Gen2 x1 on the first try and the BCM4383 behind it came up in brcmfmac. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- .../bindings/pci/google,gs201-pcie.yaml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml b/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml index d967492b9f..19181b1434 100644 --- a/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml @@ -16,8 +16,10 @@ description: adds a sub-control block (ELBI) with link training control and interrupt status, and an I/A sequencer that re-locks the PHY clock-data recovery when the link leaves L1.2. zuma's Wi-Fi controller runs without the I/A, as on - stock. Legacy INTx interrupts are demultiplexed from the controller - interrupt by a child interrupt controller. + stock. zumapro's (Tensor G4) Wi-Fi controller is the same as zuma's, at + the same addresses and with the same register map, so it uses zuma's + compatible as a fallback. Legacy INTx interrupts are demultiplexed from + the controller interrupt by a child interrupt controller. allOf: - $ref: /schemas/pci/pci-host-bridge.yaml# @@ -25,7 +27,8 @@ allOf: - if: properties: compatible: - const: google,zuma-pcie + contains: + const: google,zuma-pcie then: properties: reg: @@ -35,9 +38,13 @@ allOf: properties: compatible: - enum: - - google,gs201-pcie - - google,zuma-pcie + oneOf: + - enum: + - google,gs201-pcie + - google,zuma-pcie + - items: + - const: google,zumapro-pcie + - const: google,zuma-pcie reg: minItems: 3 From 362fc4f4172fa29051b7e9d0a415f36420d43294 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 11:10:27 -0647 Subject: [PATCH 26/32] dt-bindings: phy: google,zuma-pcie-phy: Add zumapro as a fallback of zuma zumapro (Tensor G4, Pixel 9a) has zuma's one-lane Gen3 PHY on its Wi-Fi PCIe controller, at the same addresses (PMA 0x13160000, PCS 0x13140000, UDBG 0x13150000, SOC 0x13130000) and with the PMU's PHY control at the same offset (0x3ec8). Google builds one CAL file, pcie-exynos-zuma-rc-cal.c, for both SoCs, and its channel 1 sequence is the one this binding's driver programs, register for register. Describe zumapro as "google,zumapro-pcie-phy", "google,zuma-pcie-phy". Tested on a Pixel 9a with this pair of compatibles: phy-zuma-pcie reported the external PLL, PLL and CDR locked and offset calibration done, and the link trained at Gen2 x1. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- .../devicetree/bindings/phy/google,zuma-pcie-phy.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml b/Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml index 8003eb7b5e..544df73eba 100644 --- a/Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml +++ b/Documentation/devicetree/bindings/phy/google,zuma-pcie-phy.yaml @@ -14,11 +14,17 @@ description: PCIe controller, which connects the Wi-Fi chip on Pixel 8 phones. Its reference clock comes from an external PLL in the UDBG block, selected as the PHY's input clock in the controller's SOC block. The PMU isolates the - PHY until it is released. + PHY until it is released. zumapro (Tensor G4) has the same PHY for its + Wi-Fi controller, programmed with the same sequence, so it uses zuma's + compatible as a fallback. properties: compatible: - const: google,zuma-pcie-phy + oneOf: + - const: google,zuma-pcie-phy + - items: + - const: google,zumapro-pcie-phy + - const: google,zuma-pcie-phy reg: items: From ae07adf7913e5f72698fc9150570b24f2b04d4d9 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:37:56 -0647 Subject: [PATCH 27/32] dt-bindings: net: wireless: brcm,bcm4329-fmac: add BCM4383 PCI ID Add the PCI ID of the BCM4383, the Wi-Fi chip of Google's Pixel 9a. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- .../devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml index 8589631085..be1765aa4d 100644 --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml @@ -56,6 +56,7 @@ properties: - pci14e4,4433 # BCM4387 - pci14e4,4434 # BCM4388 - pci14e4,4441 # BCM4389 + - pci14e4,4449 # BCM4383 - pci14e4,449d # BCM43752 reg: From 01345de756405583a503692dab29d75873d5eb12 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 13:43:04 -0647 Subject: [PATCH 28/32] phy: samsung: zuma-pcie: Mark the PHY configured, park its clock when off Google's root-complex driver for the zuma family (pcie-exynos-rc.c, built with pcie-exynos-zuma-rc-cal.c for zuma and zumapro) does two things around the channel 1 PHY that this driver did not: - exynos_pcie_rc_establish_link() sets bit 10 of the PMU's PHY control register once the PHY has been configured, through its private PMU write, before it releases PERST#; - exynos_pcie_rc_poweroff() clears bits 1:0 of SOC 0x4000 before the PHY power-down, which switches the PHY's input clock back to the oscillator. Do the same on zumapro: set bit 10 at the end of power_on, after the UDBG 0xc800 write, and fail power_on if the PMU refuses it; return the input clock to the oscillator at the start of power_off. power_on already writes SOC 0x4000 first, so a power_off/power_on cycle (the host's training retry) selects the PHY clock again. Keep both to zumapro's own match entry, ahead of the zuma fallback its nodes carry. Google does them on zuma too, but they have only run on a zumapro board, so zuma's path stays as it was until a zuma board has run them. Nothing clears bit 10 again. Google never clears it in pcie-exynos-rc.c either: it is set by a read-modify-write and left set, and the isolation writes go through the PHY control mask, whose definition is not in the GPL sources, so that it leaves bit 10 alone is inferred, not read. Tested on a Pixel 9a (zumapro), PCIe channel 1, with pcie-gs201 as host: the link trained at Gen2 x1 on the first try and the BCM4383 joined a network with no ping loss. An unbind and rebind of the controller ran the oscillator step and the power-down; the PHY control read 0x4c1 before power_on set bit 10 again, and the rebind trained Gen2 x1 on the first try with it already set. That boot had both steps on zuma's match data; this version moves them to zumapro's entry, which the same node selects first. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/phy/samsung/phy-zuma-pcie.c | 54 ++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/phy/samsung/phy-zuma-pcie.c b/drivers/phy/samsung/phy-zuma-pcie.c index a00239085e..66a80c8399 100644 --- a/drivers/phy/samsung/phy-zuma-pcie.c +++ b/drivers/phy/samsung/phy-zuma-pcie.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -38,8 +39,12 @@ static unsigned int trace_delay_ms = 20; module_param(trace_delay_ms, uint, 0644); MODULE_PARM_DESC(trace_delay_ms, "Sleep after each trace line, in ms (default 20)"); -/* PMU PHY control: bit 0 clear isolates the PHY */ +/* + * PMU PHY control: bit 0 clear isolates the PHY; bit 10 tells the PMU the + * PHY has been configured + */ #define ZUMA_PMU_PHY_BYPASS BIT(0) +#define ZUMA_PMU_PHY_CONFIGURED BIT(10) /* PHY reset block, in the controller's sub-control (ELBI) space at +0x1400 */ #define ZUMA_PHY_RST_CMN 0x0 @@ -49,6 +54,7 @@ MODULE_PARM_DESC(trace_delay_ms, "Sleep after each trace line, in ms (default 20 /* SOC block: the PHY's input clock */ #define ZUMA_SOC_CLK_MODE 0x4000 #define ZUMA_SOC_CLK_MODE_VAL 0x15 +#define ZUMA_SOC_CLK_MODE_SEL GENMASK(1, 0) #define ZUMA_SOC_CLK_SEL 0x4004 #define ZUMA_SOC_CLK_SEL_TCXO BIT(2) #define ZUMA_SOC_CLK_SEL_EXT_PLL GENMASK(5, 4) @@ -149,6 +155,19 @@ struct zuma_pcie_phy { void __iomem *soc; struct regmap *pmu; u32 pmu_offset; + bool stock_link_steps; +}; + +/** + * struct zuma_pcie_phy_data - per-SoC steps + * @stock_link_steps: mark the PHY configured in the PMU at the end of + * power_on and return its input clock to the oscillator at power_off, + * as Google's exynos_pcie_rc_establish_link() and + * exynos_pcie_rc_poweroff() do. Only zumapro so far: zuma does them in + * Google's driver too, but they haven't run on a zuma board here. + */ +struct zuma_pcie_phy_data { + bool stock_link_steps; }; static __printf(2, 3) void zuma_phy_trace(struct zuma_pcie_phy *zp, @@ -324,6 +343,7 @@ static int zuma_pcie_phy_init(struct phy *phy) static int zuma_pcie_phy_power_on(struct phy *phy) { struct zuma_pcie_phy *zp = phy_get_drvdata(phy); + int ret; zuma_phy_trace(zp, "about to write SOC 0x4000 (first SOC access)"); writel(ZUMA_SOC_CLK_MODE_VAL, zp->soc + ZUMA_SOC_CLK_MODE); @@ -334,6 +354,20 @@ static int zuma_pcie_phy_power_on(struct phy *phy) /* exynos_pcie_rc_establish_link(), channel 1, before PERST# */ zuma_phy_trace(zp, "about to write UDBG 0xc800"); writel(ZUMA_UDBG_LINK_CTRL_VAL, zp->udbg + ZUMA_UDBG_LINK_CTRL); + + if (!zp->stock_link_steps) + return 0; + + /* exynos_pcie_rc_establish_link(): mark the PHY configured */ + zuma_phy_trace(zp, "about to set PMU %#x bit 10 (PHY configured, SMC)", + zp->pmu_offset); + ret = regmap_update_bits(zp->pmu, zp->pmu_offset, + ZUMA_PMU_PHY_CONFIGURED, + ZUMA_PMU_PHY_CONFIGURED); + if (ret) { + dev_err(zp->dev, "PMU write failed: %d\n", ret); + return ret; + } zuma_phy_trace(zp, "PHY configured"); return 0; @@ -343,6 +377,16 @@ static int zuma_pcie_phy_power_off(struct phy *phy) { struct zuma_pcie_phy *zp = phy_get_drvdata(phy); + /* + * exynos_pcie_rc_poweroff(): put the PHY's input clock back on the + * oscillator before the power-down + */ + if (zp->stock_link_steps) { + zuma_phy_trace(zp, "about to return the PHY clock to the oscillator (SOC 0x4000)"); + zuma_pcie_phy_rmw(zp->soc + ZUMA_SOC_CLK_MODE, + ZUMA_SOC_CLK_MODE_SEL, 0); + } + zuma_pcie_phy_pwrdn(zp); return 0; @@ -358,6 +402,7 @@ static const struct phy_ops zuma_pcie_phy_ops = { static int zuma_pcie_phy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct zuma_pcie_phy_data *data; struct phy_provider *provider; struct zuma_pcie_phy *zp; struct phy *phy; @@ -368,6 +413,8 @@ static int zuma_pcie_phy_probe(struct platform_device *pdev) return -ENOMEM; zp->dev = dev; + data = device_get_match_data(dev); + zp->stock_link_steps = data && data->stock_link_steps; /* Only mappings here: the PHY is not touched until phy_init() */ zp->pma = devm_platform_ioremap_resource_byname(pdev, "pma"); @@ -413,7 +460,12 @@ static int zuma_pcie_phy_probe(struct platform_device *pdev) return PTR_ERR_OR_ZERO(provider); } +static const struct zuma_pcie_phy_data zumapro_pcie_phy_data = { + .stock_link_steps = true, +}; + static const struct of_device_id zuma_pcie_phy_of_match[] = { + { .compatible = "google,zumapro-pcie-phy", .data = &zumapro_pcie_phy_data }, { .compatible = "google,zuma-pcie-phy" }, { } }; From 5745bd6a88050ae2d74b4d8567a35a95be683b61 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 13:43:19 -0647 Subject: [PATCH 29/32] PCI: dwc: gs201: Pulse the soft power reset before the zuma PHY powers down Google's exynos_pcie_rc_poweroff() for the zuma family (pcie-exynos-rc.c in the zuma and zumapro sources) turns the LTSSM off and pulses the controller's soft power reset (ELBI 0x3a4 bit 1 low for 20 us) while the PHY still runs, and only then powers the PHY down. This driver went straight to the PHY power-down. Do the same before the PHY power-down in the bring-down path, which runs at deinit and when host_init fails after the PHY came up. Keep it to a match entry of zumapro's own, ahead of the zuma fallback its node carries: Google does the same on zuma, but it has only run on a zumapro board, so zuma's path stays as it was until a zuma board has run it. The gs201 sequence follows Google's gs201 driver (dwc-whi), whose power-off I have not checked, and the gs201 power-down works as it is. Tested on a Pixel 9a (zumapro), with the pulse on zuma's match data, which the same node selected then: the link trained at Gen2 x1 and the BCM4383 joined a network with no ping loss. An unbind of the controller logged "LTSSM off, soft power reset pulse" before the PHY power-down, the rebind trained Gen2 x1 on the first try, the BCM4383 reconnected, and UFS logged no errors. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/pci/controller/dwc/pcie-gs201.c | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-gs201.c b/drivers/pci/controller/dwc/pcie-gs201.c index 98238660b2..b114c6be96 100644 --- a/drivers/pci/controller/dwc/pcie-gs201.c +++ b/drivers/pci/controller/dwc/pcie-gs201.c @@ -172,9 +172,14 @@ MODULE_PARM_DESC(cmu_acg_off, * set before the PHY configuration, and not again after it. zuma's * CAL does them in the middle of its PHY configuration; gs201's * establish_link() does them after. + * @pwr_reset_before_phy_off: the power-down turns the LTSSM off and pulses + * the soft power reset before the PHY powers down, as Google's + * exynos_pcie_rc_poweroff() does for the zuma family. Only zumapro so + * far: it hasn't run on a zuma board here. */ struct gs201_pcie_soc_data { bool ctrl_reset_before_phy; + bool pwr_reset_before_phy_off; }; struct gs201_pcie { @@ -730,9 +735,31 @@ static int gs201_pcie_bringup(struct gs201_pcie *gp, unsigned int last, return 0; } +/* + * zuma's exynos_pcie_rc_poweroff(): LTSSM off and a soft power reset pulse + * while the PHY still runs, before it is powered down + */ +static void gs201_pcie_pwr_reset_before_phy_off(struct gs201_pcie *gp) +{ + u32 val; + + if (!gp->data->pwr_reset_before_phy_off || !gp->phy_on) + return; + + gs201_trace(gp, "LTSSM off, soft power reset pulse (ELBI 0x054, 0x3a4 bit 1)"); + gs201_elbi_writel(gp, GS201_ELBI_LTSSM_EN, 0); + val = gs201_elbi_readl(gp, GS201_ELBI_SOFT_RESET); + gs201_elbi_writel(gp, GS201_ELBI_SOFT_RESET, + val & ~GS201_ELBI_SOFT_PWR_RESET); + usleep_range(20, 40); + gs201_elbi_writel(gp, GS201_ELBI_SOFT_RESET, + val | GS201_ELBI_SOFT_PWR_RESET); +} + /* Undo what the stages did, in reverse; the PHY stays out of isolation */ static void gs201_pcie_bringdown(struct gs201_pcie *gp) { + gs201_pcie_pwr_reset_before_phy_off(gp); gs201_pcie_phy_off(gp); if (gp->phy_inited) { gs201_trace(gp, "phy_exit"); @@ -1235,8 +1262,14 @@ static const struct gs201_pcie_soc_data zuma_pcie_data = { .ctrl_reset_before_phy = true, }; +static const struct gs201_pcie_soc_data zumapro_pcie_data = { + .ctrl_reset_before_phy = true, + .pwr_reset_before_phy_off = true, +}; + static const struct of_device_id gs201_pcie_of_match[] = { { .compatible = "google,gs201-pcie", .data = &gs201_pcie_data }, + { .compatible = "google,zumapro-pcie", .data = &zumapro_pcie_data }, { .compatible = "google,zuma-pcie", .data = &zuma_pcie_data }, { } }; From 6ad10ad08289b6f1db36ecabe3bef01f9066018d Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 11:12:03 -0647 Subject: [PATCH 30/32] arm64: dts: exynos: google: zumapro: Add PCIe channel 1 and its PHY Add zumapro's second PCIe controller (stock's pcie_1, ch-num 1, the Wi-Fi chip's link) and its Gen3 PHY, disabled. Both are zuma's: the same registers as stock's pcie@13120000 and zuma's nodes, the controller interrupt on SPI 439 with legacy INTx demultiplexed from it, PERST# on gph3-0 and CLKREQ# on gph3-1 with stock's pin settings, and the PHY's isolation at PMU offset 0x3ec8. So both nodes carry zuma's compatible as a fallback, and the gs201 host and zuma PHY drivers run them on zuma's data. As on stock and on zuma, the controller runs without the I/A and is not cache coherent. Unlike zuma, zumapro has a CMU_HSI2 driver, so the controller lists the PCIe1 gates it uses, up to the seven the DesignWare binding allows: its APB, DBI, slave and master clocks, and the PHY's UDBG, PAL and reference clocks. The PHY bridge and test APB, I/A, SSMT, System MMU and PMMU gates stay out; all of these gates are CLK_IGNORE_UNUSED, and stock lists no PCIe clocks at all (pcie-clk-num 0). Tested on a Pixel 9a with the same description applied as an overlay (that overlay listed all fourteen PCIe1 gates): the link trained at Gen2 x1, the limit of the BCM4383 behind it. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- .../arm64/boot/dts/exynos/google/zumapro.dtsi | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/arch/arm64/boot/dts/exynos/google/zumapro.dtsi b/arch/arm64/boot/dts/exynos/google/zumapro.dtsi index f8be1721dd..dd72aeec39 100644 --- a/arch/arm64/boot/dts/exynos/google/zumapro.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zumapro.dtsi @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -1180,6 +1181,24 @@ gpio-controller; #gpio-cells = <2>; }; + + /* Stock's pcie1 pins, the same as zuma's */ + pcie1_clkreq: pcie1-clkreq-pins { + samsung,pins = "gph3-1"; + samsung,pin-function = <2>; + samsung,pin-pud = <3>; + samsung,pin-drv = <3>; + samsung,pin-con-pdn = <3>; + samsung,pin-pud-pdn = <3>; + }; + + pcie1_perst: pcie1-perst-pins { + samsung,pins = "gph3-0"; + samsung,pin-function = <1>; + samsung,pin-pud = <0>; + samsung,pin-drv = <3>; + samsung,pin-con-pdn = <3>; + }; }; pinctrl_hsi2ufs: pinctrl@13060000 { @@ -1212,6 +1231,66 @@ }; }; + /* + * The Wi-Fi chip's controller (stock's pcie_1, ch-num 1), zuma's + * controller at zuma's addresses: one Gen3 lane, no I/A, not + * cache coherent. Its interrupts are its legacy INTx; stock's + * MSI lines are unused. + */ + pcie_1: pcie@13120000 { + compatible = "google,zumapro-pcie", "google,zuma-pcie"; + reg = <0x0 0x13120000 0x1400>, + <0x0 0x13400000 0x381000>, + <0x0 0x60ffe000 0x2000>; + reg-names = "elbi", "dbi", "config"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x82000000 0x0 0x60000000 0x0 0x60000000 0x0 0xff0000>; + bus-range = <0x00 0xff>; + interrupts = ; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &pcie_1_intc 1>, + <0 0 0 2 &pcie_1_intc 2>, + <0 0 0 3 &pcie_1_intc 3>, + <0 0 0 4 &pcie_1_intc 4>; + clocks = <&cmu_hsi2 CLK_GOUT_PCIE1_CTL_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_DBI_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SLV_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_MSTR_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_UDBG_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_PAL_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_REF>; + phys = <&pcie_1_phy>; + phy-names = "pcie"; + pinctrl-0 = <&pcie1_clkreq>, <&pcie1_perst>; + pinctrl-names = "default"; + reset-gpios = <&gph3 0 GPIO_ACTIVE_LOW>; + num-lanes = <1>; + max-link-speed = <3>; + status = "disabled"; + + pcie_1_intc: legacy-interrupt-controller { + #address-cells = <0>; + interrupt-controller; + #interrupt-cells = <1>; + }; + }; + + pcie_1_phy: phy@13160000 { + compatible = "google,zumapro-pcie-phy", "google,zuma-pcie-phy"; + reg = <0x0 0x13160000 0x3000>, + <0x0 0x13140000 0x5000>, + <0x0 0x13121400 0x10>, + <0x0 0x13150000 0xd000>, + <0x0 0x13130000 0x5000>; + reg-names = "pma", "pcs", "rst", "udbg", "soc"; + samsung,pmu-syscon = <&pmu_system_controller 0x3ec8>; + #phy-cells = <0>; + status = "disabled"; + }; + ufs: ufs@13200000 { compatible = "google,zumapro-ufs"; reg = <0x0 0x13200000 0x200>, From e85e8bc9ac0efbc875b546a9e025100cd705bd76 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 11:12:39 -0647 Subject: [PATCH 31/32] arm64: dts: exynos: google: zumapro-tegu: Add Wi-Fi The Pixel 9a's BCM4383 sits behind PCIe channel 1. Enable the channel and its PHY, give the root port WL_REG_ON (gph3-4) as a fixed regulator with the 150 ms the bring-up waited before configuring the PHY, and describe the chip with its board type, so brcmfmac picks the board's firmware files. The link runs at Gen2, the chip's own limit (its LnkCap reads 5 GT/s). ASPM L0s and L1 stay off on the root port: nothing re-locks the PHY's clock and data recovery after L1 on this path (no I/A sequencer), and with ASPM on, the link entered L1 and the chip's config space read as all ones. All of the chip's DMA goes through a 16 MiB restricted DMA pool below 4 GiB, as on the Pixel 7 Pro: the HSI2 System MMU and S2MPU see PCIe and UFS on the same VID, so they cannot confine the chip, and the pool at least keeps driver bugs away from the rest of RAM. Tested on the Pixel 9a with the same description applied as an overlay to 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, with pcie-gs201 and phy-zuma-pcie as modules: the link trained at Gen2 x1 on the first try, the chip used legacy INTx, brcmfmac assigned the pool to it and brought up wlan0, and wlan0 joined a network with no ping loss. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- .../boot/dts/exynos/google/zumapro-tegu.dts | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts b/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts index 76a95c1b05..9bde38dc25 100644 --- a/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts +++ b/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts @@ -147,6 +147,19 @@ regulator-boot-on; regulator-always-on; }; + + /* + * WL_REG_ON (gph3-4), the Wi-Fi chip's power enable (stock's + * pcie,wlan-gpio), raised 150 ms before the PCIe PHY is configured. + * It is the root port's supply, so the PCI pwrctrl core switches it. + */ + wlan_reg_on: regulator-wlan-reg-on { + compatible = "regulator-fixed"; + regulator-name = "wlan-reg-on"; + gpio = <&gph3 4 GPIO_ACTIVE_HIGH>; + enable-active-high; + startup-delay-us = <150000>; + }; }; &{/reserved-memory} { @@ -169,6 +182,19 @@ alignment = <0x0 0x00200000>; alloc-ranges = <0x0 0x98000000 0x06000000>; }; + + /* + * All of the Wi-Fi chip's DMA buffers come from this pool. It keeps + * driver bugs away from the rest of RAM; it does not confine the + * chip's own firmware, as the HSI2 System MMU and S2MPU see PCIe and + * UFS on the same VID and cannot enforce on it. + */ + wifi_dma_pool: wifi-dma-pool { + compatible = "restricted-dma-pool"; + size = <0x01000000>; + alignment = <0x0 0x00200000>; + alloc-ranges = <0x0 0x80000000 0x80000000>; + }; }; &acpm_ipc { @@ -466,6 +492,43 @@ }; }; +/* + * Wi-Fi: the BCM4383 on pcie_1, one lane at Gen2, the chip's own limit + * (its LnkCap reads 5 GT/s). Its DMA buffers come from wifi_dma_pool. + */ +&pcie_1 { + max-link-speed = <2>; + status = "okay"; + + pcie@0,0 { + compatible = "pciclass,0604"; + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + bus-range = <0x01 0xff>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + vpcie3v3-supply = <&wlan_reg_on>; + /* + * No I/A sequencer re-locks the PHY after L1: with ASPM on, the + * link entered L1 and config reads of the chip returned all ones. + */ + aspm-no-l0s; + aspm-no-l1; + + wifi@0,0 { + compatible = "pci14e4,4449"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + brcm,board-type = "google,zumapro-tegu"; + memory-region = <&wifi_dma_pool>; + }; + }; +}; + +&pcie_1_phy { + status = "okay"; +}; + &pinctrl_alive { status = "okay"; From 25b37329d143dfd3a3c79b5c41eb8fd8ef8e8bae Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sun, 1 Nov 2026 14:24:58 -0647 Subject: [PATCH 32/32] wifi: brcmfmac: pcie: reset the BCM4383 with an FLR too The BCM4383 (Pixel 9a) shares its chip with Bluetooth. With Bluetooth up, so with BT_REG_ON high, an unbind and rebind of the PCIe host (which drops and raises WL_REG_ON) left brcmfmac unable to start the chip again: it recognised the chip and downloaded the firmware, then failed with "FW failed to initialize". With hci_uart unloaded first, the same rebind brought wlan0 back. Broadcom's driver never resets this chip with the chipcommon watchdog. bcmdhd sets cc_wd_reset false, so dhdpcie_dongle_reset() resets the WLAN function with an FLR (dhd_bus_perform_flr()), with no check on Bluetooth: "For buscorerev = 66 and after, F0 FLR should be done independent from F1. So don't need BT quiesce" (dhd_pcie.c, google-modules/wlan/bcm4383). The chip advertises FLReset+. Reset it with the FLR the BCM4389 already uses, falling back to the watchdog if the FLR is refused or doesn't complete. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- .../broadcom/brcm80211/brcmfmac/pcie.c | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 969410ee3f..f53ded28ba 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -948,6 +948,19 @@ static void brcmf_pcie_set_bar_coherent(struct brcmf_pciedev_info *devinfo) */ #define BRCMF_PCIE_SSCTRL_SSRESET_STATUS BIT(13) +/* + * Chips Broadcom's driver resets with a function 0 FLR rather than the + * chipcommon watchdog (bcmdhd dhdpcie_dongle_reset(), cc_wd_reset false). + * The BCM4383 shares the chip with its Bluetooth: while BT_REG_ON holds the + * chip up, the watchdog reset leaves the WLAN cores in a state where the + * downloaded firmware never comes up, and an F0 FLR leaves Bluetooth alone. + */ +static bool brcmf_pcie_reset_by_flr(struct brcmf_pciedev_info *devinfo) +{ + return brcmf_pcie_is_4389_family(devinfo) || + devinfo->pdev->device == BRCM_PCIE_4383_DEVICE_ID; +} + static int brcmf_pcie_flr(struct brcmf_pciedev_info *devinfo) { struct pci_dev *pdev = devinfo->pdev; @@ -1014,12 +1027,13 @@ static void brcmf_pcie_reset_device(struct brcmf_pciedev_info *devinfo) val); /* Watchdog reset, with all power domains up as it starts. The - * BCM4389 is reset the way Broadcom's driver resets it, with an - * FLR: after a chipcommon watchdog reset its ARM does not boot a - * second firmware download. + * BCM4389 and BCM4383 are reset the way Broadcom's driver resets + * them, with an FLR: after a chipcommon watchdog reset the BCM4389's + * ARM does not boot a second firmware download, and the BCM4383's + * doesn't while its Bluetooth is on. */ brcmf_pcie_srpwr_request(devinfo); - if (!brcmf_pcie_is_4389_family(devinfo) || brcmf_pcie_flr(devinfo)) { + if (!brcmf_pcie_reset_by_flr(devinfo) || brcmf_pcie_flr(devinfo)) { brcmf_pcie_select_core(devinfo, BCMA_CORE_CHIPCOMMON); WRITECC32(devinfo, watchdog, 4); msleep(100);