2022-09-12 09:53:32

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 0/12] Add support for bcm4378 on Apple platforms

Hi,

This series adds support for bcm4378 found on Apple platforms, and has
been tested on the Apple Mac Mini. It is a re-posting of a subset of
Hector's previous 38 patch series, and it is believed that the comments
from that review were addressed.

(I'm just the middle man; please don't complain if something has been
missed.)

v2:
- sending for wireless-next
- fixed up %ld -> %zd for size_t
- added reviewed-bys

arch/arm64/boot/dts/apple/t8103-j274.dts | 4 +
arch/arm64/boot/dts/apple/t8103-j293.dts | 4 +
arch/arm64/boot/dts/apple/t8103-j313.dts | 4 +
arch/arm64/boot/dts/apple/t8103-j456.dts | 4 +
arch/arm64/boot/dts/apple/t8103-j457.dts | 4 +
arch/arm64/boot/dts/apple/t8103-jxxx.dtsi | 2 +
.../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 19 +-
.../wireless/broadcom/brcm80211/brcmfmac/chip.c | 2 +
.../wireless/broadcom/brcm80211/brcmfmac/common.c | 12 +-
.../wireless/broadcom/brcm80211/brcmfmac/common.h | 1 +
.../broadcom/brcm80211/brcmfmac/firmware.c | 115 ++++--
.../broadcom/brcm80211/brcmfmac/firmware.h | 4 +-
.../wireless/broadcom/brcm80211/brcmfmac/msgbuf.h | 4 +-
.../net/wireless/broadcom/brcm80211/brcmfmac/of.c | 12 +-
.../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 431 +++++++++++++++++++--
.../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 38 +-
.../wireless/broadcom/brcm80211/brcmfmac/sdio.h | 2 +
.../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 23 +-
.../broadcom/brcm80211/include/brcm_hw_ids.h | 2 +
include/linux/bcma/bcma_driver_chipcommon.h | 1 +
21 files changed, 610 insertions(+), 117 deletions(-)

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!


2022-09-12 09:53:50

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 02/12] brcmfmac: firmware: Handle per-board clm_blob files

From: Hector Martin <[email protected]>

Teach brcm_alt_fw_paths to correctly split off variable length
extensions, and enable alt firmware lookups for the CLM blob firmware
requests.

Apple platforms have per-board CLM blob files.

Acked-by: Linus Walleij <[email protected]>
Reviewed-by: Arend van Spriel <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/firmware.c | 33 +++++++++++--------
1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 15e99d8865bd..6c7c0c8f94ce 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -587,22 +587,29 @@ static int brcmf_fw_complete_request(const struct firmware *fw,

static char *brcm_alt_fw_path(const char *path, const char *board_type)
{
- char alt_path[BRCMF_FW_NAME_LEN];
- char suffix[5];
+ char base[BRCMF_FW_NAME_LEN];
+ const char *suffix;
+ char *ret;

- strscpy(alt_path, path, BRCMF_FW_NAME_LEN);
- /* At least one character + suffix */
- if (strlen(alt_path) < 5)
+ if (!board_type)
return NULL;

- /* strip .txt or .bin at the end */
- strscpy(suffix, alt_path + strlen(alt_path) - 4, 5);
- alt_path[strlen(alt_path) - 4] = 0;
- strlcat(alt_path, ".", BRCMF_FW_NAME_LEN);
- strlcat(alt_path, board_type, BRCMF_FW_NAME_LEN);
- strlcat(alt_path, suffix, BRCMF_FW_NAME_LEN);
+ suffix = strrchr(path, '.');
+ if (!suffix || suffix == path)
+ return NULL;
+
+ /* strip extension at the end */
+ strscpy(base, path, BRCMF_FW_NAME_LEN);
+ base[suffix - path] = 0;
+
+ ret = kasprintf(GFP_KERNEL, "%s.%s%s", base, board_type, suffix);
+ if (!ret)
+ brcmf_err("out of memory allocating firmware path for '%s'\n",
+ path);
+
+ brcmf_dbg(TRACE, "FW alt path: %s\n", ret);

- return kstrdup(alt_path, GFP_KERNEL);
+ return ret;
}

static int brcmf_fw_request_firmware(const struct firmware **fw,
@@ -612,7 +619,7 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,
int ret;

/* Files can be board-specific, first try a board-specific path */
- if (cur->type == BRCMF_FW_TYPE_NVRAM && fwctx->req->board_type) {
+ if (fwctx->req->board_type) {
char *alt_path;

alt_path = brcm_alt_fw_path(cur->path, fwctx->req->board_type);
--
2.30.2

2022-09-12 09:53:52

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 01/12] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips

From: Hector Martin <[email protected]>

This binding is currently used for SDIO devices, but these chips are
also used as PCIe devices on DT platforms and may be represented in the
DT. Re-use the existing binding and add chip compatibles used by Apple
T2 and M1 platforms (the T2 ones are not known to be used in DT
platforms, but we might as well document them).

Then, add properties required for firmware selection and calibration on
M1 machines.

Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Reviewed-by: Mark Kettenis <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
.../net/wireless/brcm,bcm4329-fmac.yaml | 39 +++++++++++++++++--
1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
index 53b4153d9bfc..fec1cc9b9a08 100644
--- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
+++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
@@ -4,7 +4,7 @@
$id: http://devicetree.org/schemas/net/wireless/brcm,bcm4329-fmac.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

-title: Broadcom BCM4329 family fullmac wireless SDIO devices
+title: Broadcom BCM4329 family fullmac wireless SDIO/PCIE devices

maintainers:
- Arend van Spriel <[email protected]>
@@ -41,11 +41,17 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
- cypress,cyw4373-fmac
- cypress,cyw43012-fmac
- const: brcm,bcm4329-fmac
- - const: brcm,bcm4329-fmac
+ - enum:
+ - brcm,bcm4329-fmac
+ - pci14e4,43dc # BCM4355
+ - pci14e4,4464 # BCM4364
+ - pci14e4,4488 # BCM4377
+ - pci14e4,4425 # BCM4378
+ - pci14e4,4433 # BCM4387

reg:
- description: SDIO function number for the device, for most cases
- this will be 1.
+ description: SDIO function number for the device (for most cases
+ this will be 1) or PCI device identifier.

interrupts:
maxItems: 1
@@ -85,6 +91,31 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
takes precedence.
type: boolean

+ brcm,cal-blob:
+ $ref: /schemas/types.yaml#/definitions/uint8-array
+ description: A per-device calibration blob for the Wi-Fi radio. This
+ should be filled in by the bootloader from platform configuration
+ data, if necessary, and will be uploaded to the device if present.
+
+ brcm,board-type:
+ $ref: /schemas/types.yaml#/definitions/string
+ description: Overrides the board type, which is normally the compatible of
+ the root node. This can be used to decouple the overall system board or
+ device name from the board type for WiFi purposes, which is used to
+ construct firmware and NVRAM configuration filenames, allowing for
+ multiple devices that share the same module or characteristics for the
+ WiFi subsystem to share the same firmware/NVRAM files. On Apple platforms,
+ this should be the Apple module-instance codename prefixed by "apple,",
+ e.g. "apple,honshu".
+
+ apple,antenna-sku:
+ $ref: /schemas/types.yaml#/definitions/string
+ description: Antenna SKU used to identify a specific antenna configuration
+ on Apple platforms. This is use to build firmware filenames, to allow
+ platforms with different antenna configs to have different firmware and/or
+ NVRAM. This would normally be filled in by the bootloader from platform
+ configuration data.
+
required:
- compatible
- reg
--
2.30.2

2022-09-12 09:53:52

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 03/12] brcmfmac: pcie/sdio/usb: Get CLM blob via standard firmware mechanism

From: Hector Martin <[email protected]>

Now that the firmware fetcher can handle per-board CLM files, load the
CLM blob alongside the other firmware files and change the bus API to
just return the existing blob, instead of fetching the filename.

This enables per-board CLM blobs, which are required on Apple platforms.

Acked-by: Linus Walleij <[email protected]>
Reviewed-by: Arend van Spriel <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/bus.h | 19 ++++++---
.../broadcom/brcm80211/brcmfmac/common.c | 12 +-----
.../broadcom/brcm80211/brcmfmac/pcie.c | 39 ++++++++++++-------
.../broadcom/brcm80211/brcmfmac/sdio.c | 36 ++++++++++-------
.../broadcom/brcm80211/brcmfmac/sdio.h | 2 +
.../broadcom/brcm80211/brcmfmac/usb.c | 23 +++--------
6 files changed, 69 insertions(+), 62 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
index ae5af76e2568..2208ab3aa795 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
@@ -6,6 +6,8 @@
#ifndef BRCMFMAC_BUS_H
#define BRCMFMAC_BUS_H

+#include <linux/kernel.h>
+#include <linux/firmware.h>
#include "debug.h"

/* IDs of the 6 default common rings of msgbuf protocol */
@@ -34,6 +36,11 @@ enum brcmf_bus_protocol_type {
BRCMF_PROTO_MSGBUF
};

+/* Firmware blobs that may be available */
+enum brcmf_blob_type {
+ BRCMF_BLOB_CLM,
+};
+
struct brcmf_mp_device;

struct brcmf_bus_dcmd {
@@ -60,7 +67,7 @@ struct brcmf_bus_dcmd {
* @wowl_config: specify if dongle is configured for wowl when going to suspend
* @get_ramsize: obtain size of device memory.
* @get_memdump: obtain device memory dump in provided buffer.
- * @get_fwname: obtain firmware name.
+ * @get_blob: obtain a firmware blob.
*
* This structure provides an abstract interface towards the
* bus specific driver. For control messages to common driver
@@ -77,8 +84,8 @@ struct brcmf_bus_ops {
void (*wowl_config)(struct device *dev, bool enabled);
size_t (*get_ramsize)(struct device *dev);
int (*get_memdump)(struct device *dev, void *data, size_t len);
- int (*get_fwname)(struct device *dev, const char *ext,
- unsigned char *fw_name);
+ int (*get_blob)(struct device *dev, const struct firmware **fw,
+ enum brcmf_blob_type type);
void (*debugfs_create)(struct device *dev);
int (*reset)(struct device *dev);
};
@@ -220,10 +227,10 @@ int brcmf_bus_get_memdump(struct brcmf_bus *bus, void *data, size_t len)
}

static inline
-int brcmf_bus_get_fwname(struct brcmf_bus *bus, const char *ext,
- unsigned char *fw_name)
+int brcmf_bus_get_blob(struct brcmf_bus *bus, const struct firmware **fw,
+ enum brcmf_blob_type type)
{
- return bus->ops->get_fwname(bus->dev, ext, fw_name);
+ return bus->ops->get_blob(bus->dev, fw, type);
}

static inline
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 372deeb69477..74020fa10065 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -123,7 +123,6 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
struct brcmf_bus *bus = drvr->bus_if;
struct brcmf_dload_data_le *chunk_buf;
const struct firmware *clm = NULL;
- u8 clm_name[BRCMF_FW_NAME_LEN];
u32 chunk_len;
u32 datalen;
u32 cumulative_len;
@@ -133,15 +132,8 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)

brcmf_dbg(TRACE, "Enter\n");

- memset(clm_name, 0, sizeof(clm_name));
- err = brcmf_bus_get_fwname(bus, ".clm_blob", clm_name);
- if (err) {
- bphy_err(drvr, "get CLM blob file name failed (%d)\n", err);
- return err;
- }
-
- err = firmware_request_nowarn(&clm, clm_name, bus->dev);
- if (err) {
+ err = brcmf_bus_get_blob(bus, &clm, BRCMF_BLOB_CLM);
+ if (err || !clm) {
brcmf_info("no clm_blob available (err=%d), device may have limited channels available\n",
err);
return 0;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 97f0f13dfe50..ec73d2620ec9 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -66,6 +66,7 @@ MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.txt");

/* per-board firmware binaries */
MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.bin");
+MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.clm_blob");

static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
BRCMF_FW_ENTRY(BRCM_CC_43602_CHIP_ID, 0xFFFFFFFF, 43602),
@@ -261,6 +262,8 @@ struct brcmf_pciedev_info {
struct pci_dev *pdev;
char fw_name[BRCMF_FW_NAME_LEN];
char nvram_name[BRCMF_FW_NAME_LEN];
+ char clm_name[BRCMF_FW_NAME_LEN];
+ const struct firmware *clm_fw;
void __iomem *regs;
void __iomem *tcm;
u32 ram_base;
@@ -1382,23 +1385,25 @@ static int brcmf_pcie_get_memdump(struct device *dev, void *data, size_t len)
return 0;
}

-static
-int brcmf_pcie_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
+static int brcmf_pcie_get_blob(struct device *dev, const struct firmware **fw,
+ enum brcmf_blob_type type)
{
struct brcmf_bus *bus_if = dev_get_drvdata(dev);
- struct brcmf_fw_request *fwreq;
- struct brcmf_fw_name fwnames[] = {
- { ext, fw_name },
- };
+ struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie;
+ struct brcmf_pciedev_info *devinfo = buspub->devinfo;

- fwreq = brcmf_fw_alloc_request(bus_if->chip, bus_if->chiprev,
- brcmf_pcie_fwnames,
- ARRAY_SIZE(brcmf_pcie_fwnames),
- fwnames, ARRAY_SIZE(fwnames));
- if (!fwreq)
- return -ENOMEM;
+ switch (type) {
+ case BRCMF_BLOB_CLM:
+ *fw = devinfo->clm_fw;
+ devinfo->clm_fw = NULL;
+ break;
+ default:
+ return -ENOENT;
+ }
+
+ if (!*fw)
+ return -ENOENT;

- kfree(fwreq);
return 0;
}

@@ -1445,7 +1450,7 @@ static const struct brcmf_bus_ops brcmf_pcie_bus_ops = {
.wowl_config = brcmf_pcie_wowl_config,
.get_ramsize = brcmf_pcie_get_ramsize,
.get_memdump = brcmf_pcie_get_memdump,
- .get_fwname = brcmf_pcie_get_fwname,
+ .get_blob = brcmf_pcie_get_blob,
.reset = brcmf_pcie_reset,
};

@@ -1731,6 +1736,7 @@ static const struct brcmf_buscore_ops brcmf_pcie_buscore_ops = {

#define BRCMF_PCIE_FW_CODE 0
#define BRCMF_PCIE_FW_NVRAM 1
+#define BRCMF_PCIE_FW_CLM 2

static void brcmf_pcie_setup(struct device *dev, int ret,
struct brcmf_fw_request *fwreq)
@@ -1755,6 +1761,7 @@ static void brcmf_pcie_setup(struct device *dev, int ret,
fw = fwreq->items[BRCMF_PCIE_FW_CODE].binary;
nvram = fwreq->items[BRCMF_PCIE_FW_NVRAM].nv_data.data;
nvram_len = fwreq->items[BRCMF_PCIE_FW_NVRAM].nv_data.len;
+ devinfo->clm_fw = fwreq->items[BRCMF_PCIE_FW_CLM].binary;
kfree(fwreq);

ret = brcmf_chip_get_raminfo(devinfo->ci);
@@ -1830,6 +1837,7 @@ brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
struct brcmf_fw_name fwnames[] = {
{ ".bin", devinfo->fw_name },
{ ".txt", devinfo->nvram_name },
+ { ".clm_blob", devinfo->clm_name },
};

fwreq = brcmf_fw_alloc_request(devinfo->ci->chip, devinfo->ci->chiprev,
@@ -1842,6 +1850,8 @@ brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
fwreq->items[BRCMF_PCIE_FW_CODE].type = BRCMF_FW_TYPE_BINARY;
fwreq->items[BRCMF_PCIE_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
fwreq->items[BRCMF_PCIE_FW_NVRAM].flags = BRCMF_FW_REQF_OPTIONAL;
+ fwreq->items[BRCMF_PCIE_FW_CLM].type = BRCMF_FW_TYPE_BINARY;
+ fwreq->items[BRCMF_PCIE_FW_CLM].flags = BRCMF_FW_REQF_OPTIONAL;
fwreq->board_type = devinfo->settings->board_type;
/* NVRAM reserves PCI domain 0 for Broadcom's SDK faked bus */
fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1;
@@ -1981,6 +1991,7 @@ brcmf_pcie_remove(struct pci_dev *pdev)
brcmf_pcie_release_ringbuffers(devinfo);
brcmf_pcie_reset_device(devinfo);
brcmf_pcie_release_resource(devinfo);
+ release_firmware(devinfo->clm_fw);

if (devinfo->ci)
brcmf_chip_detach(devinfo->ci);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index d7072009c47f..5eb9b3138f09 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4131,23 +4131,24 @@ brcmf_sdio_watchdog(struct timer_list *t)
}
}

-static
-int brcmf_sdio_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
+static int brcmf_sdio_get_blob(struct device *dev, const struct firmware **fw,
+ enum brcmf_blob_type type)
{
struct brcmf_bus *bus_if = dev_get_drvdata(dev);
- struct brcmf_fw_request *fwreq;
- struct brcmf_fw_name fwnames[] = {
- { ext, fw_name },
- };
+ struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;

- fwreq = brcmf_fw_alloc_request(bus_if->chip, bus_if->chiprev,
- brcmf_sdio_fwnames,
- ARRAY_SIZE(brcmf_sdio_fwnames),
- fwnames, ARRAY_SIZE(fwnames));
- if (!fwreq)
- return -ENOMEM;
+ switch (type) {
+ case BRCMF_BLOB_CLM:
+ *fw = sdiodev->clm_fw;
+ sdiodev->clm_fw = NULL;
+ break;
+ default:
+ return -ENOENT;
+ }
+
+ if (!*fw)
+ return -ENOENT;

- kfree(fwreq);
return 0;
}

@@ -4182,13 +4183,14 @@ static const struct brcmf_bus_ops brcmf_sdio_bus_ops = {
.wowl_config = brcmf_sdio_wowl_config,
.get_ramsize = brcmf_sdio_bus_get_ramsize,
.get_memdump = brcmf_sdio_bus_get_memdump,
- .get_fwname = brcmf_sdio_get_fwname,
+ .get_blob = brcmf_sdio_get_blob,
.debugfs_create = brcmf_sdio_debugfs_create,
.reset = brcmf_sdio_bus_reset
};

#define BRCMF_SDIO_FW_CODE 0
#define BRCMF_SDIO_FW_NVRAM 1
+#define BRCMF_SDIO_FW_CLM 2

static void brcmf_sdio_firmware_callback(struct device *dev, int err,
struct brcmf_fw_request *fwreq)
@@ -4211,6 +4213,7 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err,
code = fwreq->items[BRCMF_SDIO_FW_CODE].binary;
nvram = fwreq->items[BRCMF_SDIO_FW_NVRAM].nv_data.data;
nvram_len = fwreq->items[BRCMF_SDIO_FW_NVRAM].nv_data.len;
+ sdiod->clm_fw = fwreq->items[BRCMF_SDIO_FW_CLM].binary;
kfree(fwreq);

/* try to download image and nvram to the dongle */
@@ -4409,6 +4412,7 @@ brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus)
struct brcmf_fw_name fwnames[] = {
{ ".bin", bus->sdiodev->fw_name },
{ ".txt", bus->sdiodev->nvram_name },
+ { ".clm_blob", bus->sdiodev->clm_name },
};

fwreq = brcmf_fw_alloc_request(bus->ci->chip, bus->ci->chiprev,
@@ -4420,6 +4424,8 @@ brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus)

fwreq->items[BRCMF_SDIO_FW_CODE].type = BRCMF_FW_TYPE_BINARY;
fwreq->items[BRCMF_SDIO_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
+ fwreq->items[BRCMF_SDIO_FW_CLM].type = BRCMF_FW_TYPE_BINARY;
+ fwreq->items[BRCMF_SDIO_FW_CLM].flags = BRCMF_FW_REQF_OPTIONAL;
fwreq->board_type = bus->sdiodev->settings->board_type;

return fwreq;
@@ -4576,6 +4582,8 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
if (bus->sdiodev->settings)
brcmf_release_module_param(bus->sdiodev->settings);

+ release_firmware(bus->sdiodev->clm_fw);
+ bus->sdiodev->clm_fw = NULL;
kfree(bus->rxbuf);
kfree(bus->hdrbuf);
kfree(bus);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
index 47351ff458ca..b76d34d36bde 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
@@ -186,9 +186,11 @@ struct brcmf_sdio_dev {
struct sg_table sgtable;
char fw_name[BRCMF_FW_NAME_LEN];
char nvram_name[BRCMF_FW_NAME_LEN];
+ char clm_name[BRCMF_FW_NAME_LEN];
bool wowl_enabled;
enum brcmf_sdiod_state state;
struct brcmf_sdiod_freezer *freezer;
+ const struct firmware *clm_fw;
};

/* sdio core registers */
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index 9fb68c2dc7e3..85e18fb9c497 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1154,24 +1154,11 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo,
return NULL;
}

-static
-int brcmf_usb_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
+static int brcmf_usb_get_blob(struct device *dev, const struct firmware **fw,
+ enum brcmf_blob_type type)
{
- struct brcmf_bus *bus = dev_get_drvdata(dev);
- struct brcmf_fw_request *fwreq;
- struct brcmf_fw_name fwnames[] = {
- { ext, fw_name },
- };
-
- fwreq = brcmf_fw_alloc_request(bus->chip, bus->chiprev,
- brcmf_usb_fwnames,
- ARRAY_SIZE(brcmf_usb_fwnames),
- fwnames, ARRAY_SIZE(fwnames));
- if (!fwreq)
- return -ENOMEM;
-
- kfree(fwreq);
- return 0;
+ /* No blobs for USB devices... */
+ return -ENOENT;
}

static const struct brcmf_bus_ops brcmf_usb_bus_ops = {
@@ -1180,7 +1167,7 @@ static const struct brcmf_bus_ops brcmf_usb_bus_ops = {
.txdata = brcmf_usb_tx,
.txctl = brcmf_usb_tx_ctlpkt,
.rxctl = brcmf_usb_rx_ctlpkt,
- .get_fwname = brcmf_usb_get_fwname,
+ .get_blob = brcmf_usb_get_blob,
};

#define BRCMF_USB_FW_CODE 0
--
2.30.2

2022-09-12 09:53:58

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 04/12] brcmfmac: firmware: Support passing in multiple board_types

From: Hector Martin <[email protected]>

Apple platforms have firmware and config files identified with multiple
dimensions. We want to be able to find the most specific firmware
available for any given platform, progressively trying more general
firmwares.

To do this, first add support for passing in multiple board_types,
which will be tried in sequence.

Since this will cause more log spam due to missing firmwares, also
switch the secondary firmware fecthes to use the _nowarn variant, which
will not log if the firmware is not found.

Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/firmware.c | 53 +++++++++++++++----
.../broadcom/brcm80211/brcmfmac/firmware.h | 4 +-
.../broadcom/brcm80211/brcmfmac/pcie.c | 4 +-
.../broadcom/brcm80211/brcmfmac/sdio.c | 2 +-
4 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 6c7c0c8f94ce..371c086d1f48 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -430,6 +430,7 @@ struct brcmf_fw {
struct device *dev;
struct brcmf_fw_request *req;
u32 curpos;
+ unsigned int board_index;
void (*done)(struct device *dev, int err, struct brcmf_fw_request *req);
};

@@ -616,17 +617,21 @@ static int brcmf_fw_request_firmware(const struct firmware **fw,
struct brcmf_fw *fwctx)
{
struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos];
+ unsigned int i;
int ret;

- /* Files can be board-specific, first try a board-specific path */
- if (fwctx->req->board_type) {
+ /* Files can be board-specific, first try board-specific paths */
+ for (i = 0; i < ARRAY_SIZE(fwctx->req->board_types); i++) {
char *alt_path;

- alt_path = brcm_alt_fw_path(cur->path, fwctx->req->board_type);
+ if (!fwctx->req->board_types[i])
+ goto fallback;
+ alt_path = brcm_alt_fw_path(cur->path,
+ fwctx->req->board_types[i]);
if (!alt_path)
goto fallback;

- ret = request_firmware(fw, alt_path, fwctx->dev);
+ ret = firmware_request_nowarn(fw, alt_path, fwctx->dev);
kfree(alt_path);
if (ret == 0)
return ret;
@@ -660,15 +665,40 @@ static void brcmf_fw_request_done_alt_path(const struct firmware *fw, void *ctx)
{
struct brcmf_fw *fwctx = ctx;
struct brcmf_fw_item *first = &fwctx->req->items[0];
+ const char *board_type, *alt_path;
int ret = 0;

- /* Fall back to canonical path if board firmware not found */
- if (!fw)
- ret = request_firmware_nowait(THIS_MODULE, true, first->path,
+ if (fw) {
+ brcmf_fw_request_done(fw, ctx);
+ return;
+ }
+
+ /* Try next board firmware */
+ if (fwctx->board_index < ARRAY_SIZE(fwctx->req->board_types)) {
+ board_type = fwctx->req->board_types[fwctx->board_index++];
+ if (!board_type)
+ goto fallback;
+ alt_path = brcm_alt_fw_path(first->path, board_type);
+ if (!alt_path)
+ goto fallback;
+
+ ret = request_firmware_nowait(THIS_MODULE, true, alt_path,
fwctx->dev, GFP_KERNEL, fwctx,
- brcmf_fw_request_done);
+ brcmf_fw_request_done_alt_path);
+ kfree(alt_path);

- if (fw || ret < 0)
+ if (ret < 0)
+ brcmf_fw_request_done(fw, ctx);
+ return;
+ }
+
+fallback:
+ /* Fall back to canonical path if board firmware not found */
+ ret = request_firmware_nowait(THIS_MODULE, true, first->path,
+ fwctx->dev, GFP_KERNEL, fwctx,
+ brcmf_fw_request_done);
+
+ if (ret < 0)
brcmf_fw_request_done(fw, ctx);
}

@@ -712,10 +742,11 @@ int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
fwctx->done = fw_cb;

/* First try alternative board-specific path if any */
- if (fwctx->req->board_type)
+ if (fwctx->req->board_types[0])
alt_path = brcm_alt_fw_path(first->path,
- fwctx->req->board_type);
+ fwctx->req->board_types[0]);
if (alt_path) {
+ fwctx->board_index++;
ret = request_firmware_nowait(THIS_MODULE, true, alt_path,
fwctx->dev, GFP_KERNEL, fwctx,
brcmf_fw_request_done_alt_path);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
index e290dec9c53d..1266cbaee072 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
@@ -11,6 +11,8 @@

#define BRCMF_FW_DEFAULT_PATH "brcm/"

+#define BRCMF_FW_MAX_BOARD_TYPES 8
+
/**
* struct brcmf_firmware_mapping - Used to map chipid/revmask to firmware
* filename and nvram filename. Each bus type implementation should create
@@ -66,7 +68,7 @@ struct brcmf_fw_request {
u16 domain_nr;
u16 bus_nr;
u32 n_items;
- const char *board_type;
+ const char *board_types[BRCMF_FW_MAX_BOARD_TYPES];
struct brcmf_fw_item items[];
};

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index ec73d2620ec9..2a74c9d8d46a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1852,11 +1852,13 @@ brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
fwreq->items[BRCMF_PCIE_FW_NVRAM].flags = BRCMF_FW_REQF_OPTIONAL;
fwreq->items[BRCMF_PCIE_FW_CLM].type = BRCMF_FW_TYPE_BINARY;
fwreq->items[BRCMF_PCIE_FW_CLM].flags = BRCMF_FW_REQF_OPTIONAL;
- fwreq->board_type = devinfo->settings->board_type;
/* NVRAM reserves PCI domain 0 for Broadcom's SDK faked bus */
fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1;
fwreq->bus_nr = devinfo->pdev->bus->number;

+ brcmf_dbg(PCIE, "Board: %s\n", devinfo->settings->board_type);
+ fwreq->board_types[0] = devinfo->settings->board_type;
+
return fwreq;
}

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 5eb9b3138f09..465d95d83759 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4426,7 +4426,7 @@ brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus)
fwreq->items[BRCMF_SDIO_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM;
fwreq->items[BRCMF_SDIO_FW_CLM].type = BRCMF_FW_TYPE_BINARY;
fwreq->items[BRCMF_SDIO_FW_CLM].flags = BRCMF_FW_REQF_OPTIONAL;
- fwreq->board_type = bus->sdiodev->settings->board_type;
+ fwreq->board_types[0] = bus->sdiodev->settings->board_type;

return fwreq;
}
--
2.30.2

2022-09-12 09:54:11

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 06/12] brcmfmac: of: Fetch Apple properties

From: Hector Martin <[email protected]>

On Apple ARM64 platforms, firmware selection requires two properties
that come from system firmware: the module-instance (aka "island", a
codename representing a given hardware platform) and the antenna-sku.
We map Apple's module codenames to board_types in the form
"apple,<module-instance>".

The mapped board_type is added to the DTS file in that form, while the
antenna-sku is forwarded by our bootloader from the Apple Device Tree
into the FDT. Grab them from the DT so firmware selection can use
them.

Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
.../wireless/broadcom/brcm80211/brcmfmac/common.h | 1 +
.../net/wireless/broadcom/brcm80211/brcmfmac/of.c | 12 +++++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
index 6c5a22a32a96..aa25abffcc7d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
@@ -53,6 +53,7 @@ struct brcmf_mp_device {
struct brcmfmac_pd_cc *country_codes;
const char *board_type;
unsigned char mac[ETH_ALEN];
+ const char *antenna_sku;
union {
struct brcmfmac_sdio_pd sdio;
} bus;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
index 79388d49c256..a83699de01ec 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
@@ -70,14 +70,24 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
{
struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio;
struct device_node *root, *np = dev->of_node;
+ const char *prop;
int irq;
int err;
u32 irqf;
u32 val;

+ /* Apple ARM64 platforms have their own idea of board type, passed in
+ * via the device tree. They also have an antenna SKU parameter
+ */
+ if (!of_property_read_string(np, "brcm,board-type", &prop))
+ settings->board_type = prop;
+
+ if (!of_property_read_string(np, "apple,antenna-sku", &prop))
+ settings->antenna_sku = prop;
+
/* Set board-type to the first string of the machine compatible prop */
root = of_find_node_by_path("/");
- if (root) {
+ if (root && !settings->board_type) {
char *board_type;
const char *tmp;

--
2.30.2

2022-09-12 09:54:11

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 05/12] brcmfmac: pcie: Read Apple OTP information

From: Hector Martin <[email protected]>

On Apple platforms, the One Time Programmable ROM in the Broadcom chips
contains information about the specific board design (module, vendor,
version) that is required to select the correct NVRAM file. Parse this
OTP ROM and extract the required strings.

Note that the user OTP offset/size is per-chip. This patch does not add
any chips yet.

Reviewed-by: Arend van Spriel <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/pcie.c | 218 ++++++++++++++++++
include/linux/bcma/bcma_driver_chipcommon.h | 1 +
2 files changed, 219 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 2a74c9d8d46a..76ca835378bb 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -256,6 +256,15 @@ struct brcmf_pcie_core_info {
u32 wrapbase;
};

+#define BRCMF_OTP_MAX_PARAM_LEN 16
+
+struct brcmf_otp_params {
+ char module[BRCMF_OTP_MAX_PARAM_LEN];
+ char vendor[BRCMF_OTP_MAX_PARAM_LEN];
+ char version[BRCMF_OTP_MAX_PARAM_LEN];
+ bool valid;
+};
+
struct brcmf_pciedev_info {
enum brcmf_pcie_state state;
bool in_irq;
@@ -283,6 +292,7 @@ struct brcmf_pciedev_info {
void (*write_ptr)(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
u16 value);
struct brcmf_mp_device *settings;
+ struct brcmf_otp_params otp;
};

struct brcmf_pcie_ringbuf {
@@ -354,6 +364,14 @@ static void brcmf_pcie_setup(struct device *dev, int ret,
static struct brcmf_fw_request *
brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo);

+static u16
+brcmf_pcie_read_reg16(struct brcmf_pciedev_info *devinfo, u32 reg_offset)
+{
+ void __iomem *address = devinfo->regs + reg_offset;
+
+ return ioread16(address);
+}
+
static u32
brcmf_pcie_read_reg32(struct brcmf_pciedev_info *devinfo, u32 reg_offset)
{
@@ -499,6 +517,8 @@ brcmf_pcie_copy_dev_tomem(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
}


+#define READCC32(devinfo, reg) brcmf_pcie_read_reg32(devinfo, \
+ CHIPCREGOFFS(reg))
#define WRITECC32(devinfo, reg, value) brcmf_pcie_write_reg32(devinfo, \
CHIPCREGOFFS(reg), value)

@@ -1734,6 +1754,198 @@ static const struct brcmf_buscore_ops brcmf_pcie_buscore_ops = {
.write32 = brcmf_pcie_buscore_write32,
};

+#define BRCMF_OTP_SYS_VENDOR 0x15
+#define BRCMF_OTP_BRCM_CIS 0x80
+
+#define BRCMF_OTP_VENDOR_HDR 0x00000008
+
+static int
+brcmf_pcie_parse_otp_sys_vendor(struct brcmf_pciedev_info *devinfo,
+ u8 *data, size_t size)
+{
+ int idx = 4;
+ const char *chip_params;
+ const char *board_params;
+ const char *p;
+
+ /* 4-byte header and two empty strings */
+ if (size < 6)
+ return -EINVAL;
+
+ if (get_unaligned_le32(data) != BRCMF_OTP_VENDOR_HDR)
+ return -EINVAL;
+
+ chip_params = &data[idx];
+
+ /* Skip first string, including terminator */
+ idx += strnlen(chip_params, size - idx) + 1;
+ if (idx >= size)
+ return -EINVAL;
+
+ board_params = &data[idx];
+
+ /* Skip to terminator of second string */
+ idx += strnlen(board_params, size - idx);
+ if (idx >= size)
+ return -EINVAL;
+
+ /* At this point both strings are guaranteed NUL-terminated */
+ brcmf_dbg(PCIE, "OTP: chip_params='%s' board_params='%s'\n",
+ chip_params, board_params);
+
+ p = skip_spaces(board_params);
+ while (*p) {
+ char tag = *p++;
+ const char *end;
+ size_t len;
+
+ if (*p++ != '=') /* implicit NUL check */
+ return -EINVAL;
+
+ /* *p might be NUL here, if so end == p and len == 0 */
+ end = strchrnul(p, ' ');
+ len = end - p;
+
+ /* leave 1 byte for NUL in destination string */
+ if (len > (BRCMF_OTP_MAX_PARAM_LEN - 1))
+ return -EINVAL;
+
+ /* Copy len characters plus a NUL terminator */
+ switch (tag) {
+ case 'M':
+ strscpy(devinfo->otp.module, p, len + 1);
+ break;
+ case 'V':
+ strscpy(devinfo->otp.vendor, p, len + 1);
+ break;
+ case 'm':
+ strscpy(devinfo->otp.version, p, len + 1);
+ break;
+ }
+
+ /* Skip to next arg, if any */
+ p = skip_spaces(end);
+ }
+
+ brcmf_dbg(PCIE, "OTP: module=%s vendor=%s version=%s\n",
+ devinfo->otp.module, devinfo->otp.vendor,
+ devinfo->otp.version);
+
+ if (!devinfo->otp.module[0] ||
+ !devinfo->otp.vendor[0] ||
+ !devinfo->otp.version[0])
+ return -EINVAL;
+
+ devinfo->otp.valid = true;
+ return 0;
+}
+
+static int
+brcmf_pcie_parse_otp(struct brcmf_pciedev_info *devinfo, u8 *otp, size_t size)
+{
+ int p = 0;
+ int ret = -EINVAL;
+
+ brcmf_dbg(PCIE, "parse_otp size=%zd\n", size);
+
+ while (p < (size - 1)) {
+ u8 type = otp[p];
+ u8 length = otp[p + 1];
+
+ if (type == 0)
+ break;
+
+ if ((p + 2 + length) > size)
+ break;
+
+ switch (type) {
+ case BRCMF_OTP_SYS_VENDOR:
+ brcmf_dbg(PCIE, "OTP @ 0x%x (%d): SYS_VENDOR\n",
+ p, length);
+ ret = brcmf_pcie_parse_otp_sys_vendor(devinfo,
+ &otp[p + 2],
+ length);
+ break;
+ case BRCMF_OTP_BRCM_CIS:
+ brcmf_dbg(PCIE, "OTP @ 0x%x (%d): BRCM_CIS\n",
+ p, length);
+ break;
+ default:
+ brcmf_dbg(PCIE, "OTP @ 0x%x (%d): Unknown type 0x%x\n",
+ p, length, type);
+ break;
+ }
+
+ p += 2 + length;
+ }
+
+ return ret;
+}
+
+static int brcmf_pcie_read_otp(struct brcmf_pciedev_info *devinfo)
+{
+ const struct pci_dev *pdev = devinfo->pdev;
+ struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
+ u32 coreid, base, words, idx, sromctl;
+ u16 *otp;
+ struct brcmf_core *core;
+ int ret;
+
+ switch (devinfo->ci->chip) {
+ default:
+ /* OTP not supported on this chip */
+ return 0;
+ }
+
+ core = brcmf_chip_get_core(devinfo->ci, coreid);
+ if (!core) {
+ brcmf_err(bus, "No OTP core\n");
+ return -ENODEV;
+ }
+
+ if (coreid == BCMA_CORE_CHIPCOMMON) {
+ /* Chips with OTP accessed via ChipCommon need additional
+ * handling to access the OTP
+ */
+ brcmf_pcie_select_core(devinfo, coreid);
+ sromctl = READCC32(devinfo, sromcontrol);
+
+ if (!(sromctl & BCMA_CC_SROM_CONTROL_OTP_PRESENT)) {
+ /* Chip lacks OTP, try without it... */
+ brcmf_err(bus,
+ "OTP unavailable, using default firmware\n");
+ return 0;
+ }
+
+ /* Map OTP to shadow area */
+ WRITECC32(devinfo, sromcontrol,
+ sromctl | BCMA_CC_SROM_CONTROL_OTPSEL);
+ }
+
+ otp = kcalloc(words, sizeof(u16), GFP_KERNEL);
+ if (!otp)
+ return -ENOMEM;
+
+ /* Map bus window to SROM/OTP shadow area in core */
+ base = brcmf_pcie_buscore_prep_addr(devinfo->pdev, base + core->base);
+
+ brcmf_dbg(PCIE, "OTP data:\n");
+ for (idx = 0; idx < words; idx++) {
+ otp[idx] = brcmf_pcie_read_reg16(devinfo, base + 2 * idx);
+ brcmf_dbg(PCIE, "[%8x] 0x%04x\n", base + 2 * idx, otp[idx]);
+ }
+
+ if (coreid == BCMA_CORE_CHIPCOMMON) {
+ brcmf_pcie_select_core(devinfo, coreid);
+ WRITECC32(devinfo, sromcontrol, sromctl);
+ }
+
+ ret = brcmf_pcie_parse_otp(devinfo, (u8 *)otp, 2 * words);
+ kfree(otp);
+
+ return ret;
+}
+
#define BRCMF_PCIE_FW_CODE 0
#define BRCMF_PCIE_FW_NVRAM 1
#define BRCMF_PCIE_FW_CLM 2
@@ -1930,6 +2142,12 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (ret)
goto fail_bus;

+ ret = brcmf_pcie_read_otp(devinfo);
+ if (ret) {
+ brcmf_err(bus, "failed to parse OTP\n");
+ goto fail_brcmf;
+ }
+
fwreq = brcmf_pcie_prepare_fw_request(devinfo);
if (!fwreq) {
ret = -ENOMEM;
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index e3314f746bfa..2d94c30ed439 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -271,6 +271,7 @@
#define BCMA_CC_SROM_CONTROL_OP_WRDIS 0x40000000
#define BCMA_CC_SROM_CONTROL_OP_WREN 0x60000000
#define BCMA_CC_SROM_CONTROL_OTPSEL 0x00000010
+#define BCMA_CC_SROM_CONTROL_OTP_PRESENT 0x00000020
#define BCMA_CC_SROM_CONTROL_LOCK 0x00000008
#define BCMA_CC_SROM_CONTROL_SIZE_MASK 0x00000006
#define BCMA_CC_SROM_CONTROL_SIZE_1K 0x00000000
--
2.30.2

2022-09-12 09:54:24

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 07/12] brcmfmac: pcie: Perform firmware selection for Apple platforms

From: Hector Martin <[email protected]>

On Apple platforms, firmware selection uses the following elements:

Property Example Source
============== ======= ========================
* Chip name 4378 Device ID
* Chip revision B1 OTP
* Platform shikoku DT (ARM64) or ACPI (x86)
* Module type RASP OTP
* Module vendor m OTP
* Module version 6.11 OTP
* Antenna SKU X3 DT (ARM64) or ACPI (x86)

In macOS, these firmwares are stored using filenames in this format
under /usr/share/firmware/wifi:

C-4378__s-B1/P-shikoku-X3_M-RASP_V-m__m-6.11.txt

To prepare firmwares for Linux, we rename these to a scheme following
the existing brcmfmac convention:

brcmfmac<chip><lower(rev)>-pcie.apple,<platform>-<mod_type>-\
<mod_vendor>-<mod_version>-<antenna_sku>.txt

The NVRAM uses all the components, while the firmware and CLM blob only
use the chip/revision/platform/antenna_sku:

brcmfmac<chip><lower(rev)>-pcie.apple,<platform>-<antenna_sku>.bin

e.g.

brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11-X3.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-X3.bin

In addition, since there are over 1000 files in total, many of which are
symlinks or outright duplicates, we deduplicate and prune the firmware
tree to reduce firmware filenames to fewer dimensions. For example, the
shikoku platform (MacBook Air M1 2020) simplifies to just 4 files:

brcm/brcmfmac4378b1-pcie.apple,shikoku.clm_blob
brcm/brcmfmac4378b1-pcie.apple,shikoku.bin
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-u.txt

This reduces the total file count to around 170, of which 75 are
symlinks and 95 are regular files: 7 firmware blobs, 27 CLM blobs, and
61 NVRAM config files. We also slightly process NVRAM files to correct
some formatting issues.

To handle this, the driver must try the following path formats when
looking for firmware files:

brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11-X3.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-X3.txt *
brcm/brcmfmac4378b1-pcie.apple,shikoku.txt

* Not relevant for NVRAM, only for firmware/CLM.

The chip revision nominally comes from OTP on Apple platforms, but it
can be mapped to the PCI revision number, so we ignore the OTP revision
and continue to use the existing PCI revision mechanism to identify chip
revisions, as the driver already does for other chips. Unfortunately,
the mapping is not consistent between different chip types, so this has
to be determined experimentally.

Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/pcie.c | 41 ++++++++++++++++++-
1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 76ca835378bb..3fb590a6e03b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -2068,8 +2068,45 @@ brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1;
fwreq->bus_nr = devinfo->pdev->bus->number;

- brcmf_dbg(PCIE, "Board: %s\n", devinfo->settings->board_type);
- fwreq->board_types[0] = devinfo->settings->board_type;
+ /* Apple platforms with fancy firmware/NVRAM selection */
+ if (devinfo->settings->board_type &&
+ devinfo->settings->antenna_sku &&
+ devinfo->otp.valid) {
+ const struct brcmf_otp_params *otp = &devinfo->otp;
+ struct device *dev = &devinfo->pdev->dev;
+ const char **bt = fwreq->board_types;
+
+ brcmf_dbg(PCIE, "Apple board: %s\n",
+ devinfo->settings->board_type);
+
+ /* Example: apple,shikoku-RASP-m-6.11-X3 */
+ bt[0] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s-%s-%s-%s",
+ devinfo->settings->board_type,
+ otp->module, otp->vendor, otp->version,
+ devinfo->settings->antenna_sku);
+ bt[1] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s-%s-%s",
+ devinfo->settings->board_type,
+ otp->module, otp->vendor, otp->version);
+ bt[2] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s-%s",
+ devinfo->settings->board_type,
+ otp->module, otp->vendor);
+ bt[3] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s",
+ devinfo->settings->board_type,
+ otp->module);
+ bt[4] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s",
+ devinfo->settings->board_type,
+ devinfo->settings->antenna_sku);
+ bt[5] = devinfo->settings->board_type;
+
+ if (!bt[0] || !bt[1] || !bt[2] || !bt[3] || !bt[4]) {
+ kfree(fwreq);
+ return NULL;
+ }
+
+ } else {
+ brcmf_dbg(PCIE, "Board: %s\n", devinfo->settings->board_type);
+ fwreq->board_types[0] = devinfo->settings->board_type;
+ }

return fwreq;
}
--
2.30.2

2022-09-12 09:54:33

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 08/12] brcmfmac: firmware: Allow platform to override macaddr

From: Hector Martin <[email protected]>

On Device Tree platforms, it is customary to be able to set the MAC
address via the Device Tree, as it is often stored in system firmware.
This is particularly relevant for Apple ARM64 platforms, where this
information comes from system configuration and passed through by the
bootloader into the DT.

Implement support for this by fetching the platform MAC address and
adding or replacing the macaddr= property in nvram. This becomes the
dongle's default MAC address.

On platforms with an SROM MAC address, this overrides it. On platforms
without one, such as Apple ARM64 devices, this is required for the
firmware to boot (it will fail if it does not have a valid MAC at all).

Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/firmware.c | 31 +++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 371c086d1f48..c109e20fc5c6 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -21,6 +21,8 @@
#define BRCMF_FW_NVRAM_DEVPATH_LEN 19 /* devpath0=pcie/1/4/ */
#define BRCMF_FW_NVRAM_PCIEDEV_LEN 10 /* pcie/1/4/ + \0 */
#define BRCMF_FW_DEFAULT_BOARDREV "boardrev=0xff"
+#define BRCMF_FW_MACADDR_FMT "macaddr=%pM"
+#define BRCMF_FW_MACADDR_LEN (7 + ETH_ALEN * 3)

enum nvram_parser_state {
IDLE,
@@ -57,6 +59,7 @@ struct nvram_parser {
bool multi_dev_v1;
bool multi_dev_v2;
bool boardrev_found;
+ bool strip_mac;
};

/*
@@ -121,6 +124,10 @@ static enum nvram_parser_state brcmf_nvram_handle_key(struct nvram_parser *nvp)
nvp->multi_dev_v2 = true;
if (strncmp(&nvp->data[nvp->entry], "boardrev", 8) == 0)
nvp->boardrev_found = true;
+ /* strip macaddr if platform MAC overrides */
+ if (nvp->strip_mac &&
+ strncmp(&nvp->data[nvp->entry], "macaddr", 7) == 0)
+ st = COMMENT;
} else if (!is_nvram_char(c) || c == ' ') {
brcmf_dbg(INFO, "warning: ln=%d:col=%d: '=' expected, skip invalid key entry\n",
nvp->line, nvp->column);
@@ -209,6 +216,7 @@ static int brcmf_init_nvram_parser(struct nvram_parser *nvp,
size = data_len;
/* Add space for properties we may add */
size += strlen(BRCMF_FW_DEFAULT_BOARDREV) + 1;
+ size += BRCMF_FW_MACADDR_LEN + 1;
/* Alloc for extra 0 byte + roundup by 4 + length field */
size += 1 + 3 + sizeof(u32);
nvp->nvram = kzalloc(size, GFP_KERNEL);
@@ -368,22 +376,37 @@ static void brcmf_fw_add_defaults(struct nvram_parser *nvp)
nvp->nvram_len++;
}

+static void brcmf_fw_add_macaddr(struct nvram_parser *nvp, u8 *mac)
+{
+ int len;
+
+ len = scnprintf(&nvp->nvram[nvp->nvram_len], BRCMF_FW_MACADDR_LEN + 1,
+ BRCMF_FW_MACADDR_FMT, mac);
+ WARN_ON(len != BRCMF_FW_MACADDR_LEN);
+ nvp->nvram_len += len + 1;
+}
+
/* brcmf_nvram_strip :Takes a buffer of "<var>=<value>\n" lines read from a fil
* and ending in a NUL. Removes carriage returns, empty lines, comment lines,
* and converts newlines to NULs. Shortens buffer as needed and pads with NULs.
* End of buffer is completed with token identifying length of buffer.
*/
static void *brcmf_fw_nvram_strip(const u8 *data, size_t data_len,
- u32 *new_length, u16 domain_nr, u16 bus_nr)
+ u32 *new_length, u16 domain_nr, u16 bus_nr,
+ struct device *dev)
{
struct nvram_parser nvp;
u32 pad;
u32 token;
__le32 token_le;
+ u8 mac[ETH_ALEN];

if (brcmf_init_nvram_parser(&nvp, data, data_len) < 0)
return NULL;

+ if (eth_platform_get_mac_address(dev, mac) == 0)
+ nvp.strip_mac = true;
+
while (nvp.pos < data_len) {
nvp.state = nv_parser_states[nvp.state](&nvp);
if (nvp.state == END)
@@ -404,6 +427,9 @@ static void *brcmf_fw_nvram_strip(const u8 *data, size_t data_len,

brcmf_fw_add_defaults(&nvp);

+ if (nvp.strip_mac)
+ brcmf_fw_add_macaddr(&nvp, mac);
+
pad = nvp.nvram_len;
*new_length = roundup(nvp.nvram_len + 1, 4);
while (pad != *new_length) {
@@ -538,7 +564,8 @@ static int brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
if (data)
nvram = brcmf_fw_nvram_strip(data, data_len, &nvram_length,
fwctx->req->domain_nr,
- fwctx->req->bus_nr);
+ fwctx->req->bus_nr,
+ fwctx->dev);

if (free_bcm47xx_nvram)
bcm47xx_nvram_release_contents(data);
--
2.30.2

2022-09-12 09:54:37

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 09/12] brcmfmac: msgbuf: Increase RX ring sizes to 1024

From: Hector Martin <[email protected]>

Newer chips used on Apple platforms have a max_rxbufpost greater than
512, which causes warnings when brcmf_msgbuf_rxbuf_data_fill tries to
put more entries in the ring than will fit. Increase the ring sizes
to 1024.

Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.h
index 2e322edbb907..6a849f4a94dd 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.h
@@ -8,10 +8,10 @@
#ifdef CONFIG_BRCMFMAC_PROTO_MSGBUF

#define BRCMF_H2D_MSGRING_CONTROL_SUBMIT_MAX_ITEM 64
-#define BRCMF_H2D_MSGRING_RXPOST_SUBMIT_MAX_ITEM 512
+#define BRCMF_H2D_MSGRING_RXPOST_SUBMIT_MAX_ITEM 1024
#define BRCMF_D2H_MSGRING_CONTROL_COMPLETE_MAX_ITEM 64
#define BRCMF_D2H_MSGRING_TX_COMPLETE_MAX_ITEM 1024
-#define BRCMF_D2H_MSGRING_RX_COMPLETE_MAX_ITEM 512
+#define BRCMF_D2H_MSGRING_RX_COMPLETE_MAX_ITEM 1024
#define BRCMF_H2D_TXFLOWRING_MAX_ITEM 512

#define BRCMF_H2D_MSGRING_CONTROL_SUBMIT_ITEMSIZE 40
--
2.30.2

2022-09-12 09:55:05

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 10/12] brcmfmac: pcie: Support PCIe core revisions >= 64

From: Hector Martin <[email protected]>

These newer PCIe core revisions include new sets of registers that must
be used instead of the legacy ones. Introduce a brcmf_pcie_reginfo to
hold the specific register offsets and values to use for a given
platform, and change all the register accesses to indirect through it.

Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
---
.../broadcom/brcm80211/brcmfmac/pcie.c | 125 +++++++++++++++---
1 file changed, 105 insertions(+), 20 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 3fb590a6e03b..269a516ae654 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -119,6 +119,12 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
#define BRCMF_PCIE_PCIE2REG_H2D_MAILBOX_0 0x140
#define BRCMF_PCIE_PCIE2REG_H2D_MAILBOX_1 0x144

+#define BRCMF_PCIE_64_PCIE2REG_INTMASK 0xC14
+#define BRCMF_PCIE_64_PCIE2REG_MAILBOXINT 0xC30
+#define BRCMF_PCIE_64_PCIE2REG_MAILBOXMASK 0xC34
+#define BRCMF_PCIE_64_PCIE2REG_H2D_MAILBOX_0 0xA20
+#define BRCMF_PCIE_64_PCIE2REG_H2D_MAILBOX_1 0xA24
+
#define BRCMF_PCIE2_INTA 0x01
#define BRCMF_PCIE2_INTB 0x02

@@ -138,6 +144,8 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
#define BRCMF_PCIE_MB_INT_D2H3_DB0 0x400000
#define BRCMF_PCIE_MB_INT_D2H3_DB1 0x800000

+#define BRCMF_PCIE_MB_INT_FN0 (BRCMF_PCIE_MB_INT_FN0_0 | \
+ BRCMF_PCIE_MB_INT_FN0_1)
#define BRCMF_PCIE_MB_INT_D2H_DB (BRCMF_PCIE_MB_INT_D2H0_DB0 | \
BRCMF_PCIE_MB_INT_D2H0_DB1 | \
BRCMF_PCIE_MB_INT_D2H1_DB0 | \
@@ -147,6 +155,40 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
BRCMF_PCIE_MB_INT_D2H3_DB0 | \
BRCMF_PCIE_MB_INT_D2H3_DB1)

+#define BRCMF_PCIE_64_MB_INT_D2H0_DB0 0x1
+#define BRCMF_PCIE_64_MB_INT_D2H0_DB1 0x2
+#define BRCMF_PCIE_64_MB_INT_D2H1_DB0 0x4
+#define BRCMF_PCIE_64_MB_INT_D2H1_DB1 0x8
+#define BRCMF_PCIE_64_MB_INT_D2H2_DB0 0x10
+#define BRCMF_PCIE_64_MB_INT_D2H2_DB1 0x20
+#define BRCMF_PCIE_64_MB_INT_D2H3_DB0 0x40
+#define BRCMF_PCIE_64_MB_INT_D2H3_DB1 0x80
+#define BRCMF_PCIE_64_MB_INT_D2H4_DB0 0x100
+#define BRCMF_PCIE_64_MB_INT_D2H4_DB1 0x200
+#define BRCMF_PCIE_64_MB_INT_D2H5_DB0 0x400
+#define BRCMF_PCIE_64_MB_INT_D2H5_DB1 0x800
+#define BRCMF_PCIE_64_MB_INT_D2H6_DB0 0x1000
+#define BRCMF_PCIE_64_MB_INT_D2H6_DB1 0x2000
+#define BRCMF_PCIE_64_MB_INT_D2H7_DB0 0x4000
+#define BRCMF_PCIE_64_MB_INT_D2H7_DB1 0x8000
+
+#define BRCMF_PCIE_64_MB_INT_D2H_DB (BRCMF_PCIE_64_MB_INT_D2H0_DB0 | \
+ BRCMF_PCIE_64_MB_INT_D2H0_DB1 | \
+ BRCMF_PCIE_64_MB_INT_D2H1_DB0 | \
+ BRCMF_PCIE_64_MB_INT_D2H1_DB1 | \
+ BRCMF_PCIE_64_MB_INT_D2H2_DB0 | \
+ BRCMF_PCIE_64_MB_INT_D2H2_DB1 | \
+ BRCMF_PCIE_64_MB_INT_D2H3_DB0 | \
+ BRCMF_PCIE_64_MB_INT_D2H3_DB1 | \
+ BRCMF_PCIE_64_MB_INT_D2H4_DB0 | \
+ BRCMF_PCIE_64_MB_INT_D2H4_DB1 | \
+ BRCMF_PCIE_64_MB_INT_D2H5_DB0 | \
+ BRCMF_PCIE_64_MB_INT_D2H5_DB1 | \
+ BRCMF_PCIE_64_MB_INT_D2H6_DB0 | \
+ BRCMF_PCIE_64_MB_INT_D2H6_DB1 | \
+ BRCMF_PCIE_64_MB_INT_D2H7_DB0 | \
+ BRCMF_PCIE_64_MB_INT_D2H7_DB1)
+
#define BRCMF_PCIE_SHARED_VERSION_7 7
#define BRCMF_PCIE_MIN_SHARED_VERSION 5
#define BRCMF_PCIE_MAX_SHARED_VERSION BRCMF_PCIE_SHARED_VERSION_7
@@ -273,6 +315,7 @@ struct brcmf_pciedev_info {
char nvram_name[BRCMF_FW_NAME_LEN];
char clm_name[BRCMF_FW_NAME_LEN];
const struct firmware *clm_fw;
+ const struct brcmf_pcie_reginfo *reginfo;
void __iomem *regs;
void __iomem *tcm;
u32 ram_base;
@@ -359,6 +402,36 @@ static const u32 brcmf_ring_itemsize[BRCMF_NROF_COMMON_MSGRINGS] = {
BRCMF_D2H_MSGRING_RX_COMPLETE_ITEMSIZE
};

+struct brcmf_pcie_reginfo {
+ u32 intmask;
+ u32 mailboxint;
+ u32 mailboxmask;
+ u32 h2d_mailbox_0;
+ u32 h2d_mailbox_1;
+ u32 int_d2h_db;
+ u32 int_fn0;
+};
+
+static const struct brcmf_pcie_reginfo brcmf_reginfo_default = {
+ .intmask = BRCMF_PCIE_PCIE2REG_INTMASK,
+ .mailboxint = BRCMF_PCIE_PCIE2REG_MAILBOXINT,
+ .mailboxmask = BRCMF_PCIE_PCIE2REG_MAILBOXMASK,
+ .h2d_mailbox_0 = BRCMF_PCIE_PCIE2REG_H2D_MAILBOX_0,
+ .h2d_mailbox_1 = BRCMF_PCIE_PCIE2REG_H2D_MAILBOX_1,
+ .int_d2h_db = BRCMF_PCIE_MB_INT_D2H_DB,
+ .int_fn0 = BRCMF_PCIE_MB_INT_FN0,
+};
+
+static const struct brcmf_pcie_reginfo brcmf_reginfo_64 = {
+ .intmask = BRCMF_PCIE_64_PCIE2REG_INTMASK,
+ .mailboxint = BRCMF_PCIE_64_PCIE2REG_MAILBOXINT,
+ .mailboxmask = BRCMF_PCIE_64_PCIE2REG_MAILBOXMASK,
+ .h2d_mailbox_0 = BRCMF_PCIE_64_PCIE2REG_H2D_MAILBOX_0,
+ .h2d_mailbox_1 = BRCMF_PCIE_64_PCIE2REG_H2D_MAILBOX_1,
+ .int_d2h_db = BRCMF_PCIE_64_MB_INT_D2H_DB,
+ .int_fn0 = 0,
+};
+
static void brcmf_pcie_setup(struct device *dev, int ret,
struct brcmf_fw_request *fwreq);
static struct brcmf_fw_request *
@@ -802,30 +875,29 @@ static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo,

static void brcmf_pcie_intr_disable(struct brcmf_pciedev_info *devinfo)
{
- brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXMASK, 0);
+ brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->mailboxmask, 0);
}


static void brcmf_pcie_intr_enable(struct brcmf_pciedev_info *devinfo)
{
- brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXMASK,
- BRCMF_PCIE_MB_INT_D2H_DB |
- BRCMF_PCIE_MB_INT_FN0_0 |
- BRCMF_PCIE_MB_INT_FN0_1);
+ brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->mailboxmask,
+ devinfo->reginfo->int_d2h_db |
+ devinfo->reginfo->int_fn0);
}

static void brcmf_pcie_hostready(struct brcmf_pciedev_info *devinfo)
{
if (devinfo->shared.flags & BRCMF_PCIE_SHARED_HOSTRDY_DB1)
brcmf_pcie_write_reg32(devinfo,
- BRCMF_PCIE_PCIE2REG_H2D_MAILBOX_1, 1);
+ devinfo->reginfo->h2d_mailbox_1, 1);
}

static irqreturn_t brcmf_pcie_quick_check_isr(int irq, void *arg)
{
struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)arg;

- if (brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT)) {
+ if (brcmf_pcie_read_reg32(devinfo, devinfo->reginfo->mailboxint)) {
brcmf_pcie_intr_disable(devinfo);
brcmf_dbg(PCIE, "Enter\n");
return IRQ_WAKE_THREAD;
@@ -840,15 +912,14 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg)
u32 status;

devinfo->in_irq = true;
- status = brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT);
+ status = brcmf_pcie_read_reg32(devinfo, devinfo->reginfo->mailboxint);
brcmf_dbg(PCIE, "Enter %x\n", status);
if (status) {
- brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT,
+ brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->mailboxint,
status);
- if (status & (BRCMF_PCIE_MB_INT_FN0_0 |
- BRCMF_PCIE_MB_INT_FN0_1))
+ if (status & devinfo->reginfo->int_fn0)
brcmf_pcie_handle_mb_data(devinfo);
- if (status & BRCMF_PCIE_MB_INT_D2H_DB) {
+ if (status & devinfo->reginfo->int_d2h_db) {
if (devinfo->state == BRCMFMAC_PCIE_STATE_UP)
brcmf_proto_msgbuf_rx_trigger(
&devinfo->pdev->dev);
@@ -907,8 +978,8 @@ static void brcmf_pcie_release_irq(struct brcmf_pciedev_info *devinfo)
if (devinfo->in_irq)
brcmf_err(bus, "Still in IRQ (processing) !!!\n");

- status = brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT);
- brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT, status);
+ status = brcmf_pcie_read_reg32(devinfo, devinfo->reginfo->mailboxint);
+ brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->mailboxint, status);

devinfo->irq_allocated = false;
}
@@ -960,7 +1031,7 @@ static int brcmf_pcie_ring_mb_ring_bell(void *ctx)

brcmf_dbg(PCIE, "RING !\n");
/* Any arbitrary value will do, lets use 1 */
- brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_H2D_MAILBOX_0, 1);
+ brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->h2d_mailbox_0, 1);

return 0;
}
@@ -1723,15 +1794,22 @@ static int brcmf_pcie_buscoreprep(void *ctx)
static int brcmf_pcie_buscore_reset(void *ctx, struct brcmf_chip *chip)
{
struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)ctx;
- u32 val;
+ struct brcmf_core *core;
+ u32 val, reg;

devinfo->ci = chip;
brcmf_pcie_reset_device(devinfo);

- val = brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT);
+ /* reginfo is not ready yet */
+ core = brcmf_chip_get_core(chip, BCMA_CORE_PCIE2);
+ if (core->rev >= 64)
+ reg = BRCMF_PCIE_64_PCIE2REG_MAILBOXINT;
+ else
+ reg = BRCMF_PCIE_PCIE2REG_MAILBOXINT;
+
+ val = brcmf_pcie_read_reg32(devinfo, reg);
if (val != 0xffffffff)
- brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT,
- val);
+ brcmf_pcie_write_reg32(devinfo, reg, val);

return 0;
}
@@ -2118,6 +2196,7 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
struct brcmf_fw_request *fwreq;
struct brcmf_pciedev_info *devinfo;
struct brcmf_pciedev *pcie_bus_dev;
+ struct brcmf_core *core;
struct brcmf_bus *bus;

brcmf_dbg(PCIE, "Enter %x:%x\n", pdev->vendor, pdev->device);
@@ -2137,6 +2216,12 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto fail;
}

+ core = brcmf_chip_get_core(devinfo->ci, BCMA_CORE_PCIE2);
+ if (core->rev >= 64)
+ devinfo->reginfo = &brcmf_reginfo_64;
+ else
+ devinfo->reginfo = &brcmf_reginfo_default;
+
pcie_bus_dev = kzalloc(sizeof(*pcie_bus_dev), GFP_KERNEL);
if (pcie_bus_dev == NULL) {
ret = -ENOMEM;
@@ -2306,7 +2391,7 @@ static int brcmf_pcie_pm_leave_D3(struct device *dev)
brcmf_dbg(PCIE, "Enter, dev=%p, bus=%p\n", dev, bus);

/* Check if device is still up and running, if so we are ready */
- if (brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_INTMASK) != 0) {
+ if (brcmf_pcie_read_reg32(devinfo, devinfo->reginfo->intmask) != 0) {
brcmf_dbg(PCIE, "Try to wakeup device....\n");
if (brcmf_pcie_send_mb_data(devinfo, BRCMF_H2D_HOST_D0_INFORM))
goto cleanup;
--
2.30.2

2022-09-12 09:55:18

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 11/12] brcmfmac: pcie: Add IDs/properties for BCM4378

From: Hector Martin <[email protected]>

This chip is present on Apple M1 (t8103) platforms:

* atlantisb (apple,j274): Mac mini (M1, 2020)
* honshu (apple,j293): MacBook Pro (13-inch, M1, 2020)
* shikoku (apple,j313): MacBook Air (M1, 2020)
* capri (apple,j456): iMac (24-inch, 4x USB-C, M1, 2020)
* santorini (apple,j457): iMac (24-inch, 2x USB-C, M1, 2020)

Reviewed-by: Linus Walleij <[email protected]>
Signed-off-by: Hector Martin <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 2 ++
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++++
.../net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 2 ++
3 files changed, 12 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index 23295fceb062..3026166a56c1 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -733,6 +733,8 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
return 0x160000;
case CY_CC_43752_CHIP_ID:
return 0x170000;
+ case BRCM_CC_4378_CHIP_ID:
+ return 0x352000;
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 269a516ae654..0c627f33049e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -59,6 +59,7 @@ BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
+BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie");

/* firmware config files */
MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.txt");
@@ -88,6 +89,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
BRCMF_FW_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFFFFFF0, 4366C),
BRCMF_FW_ENTRY(BRCM_CC_43666_CHIP_ID, 0xFFFFFFF0, 4366C),
BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
+ BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFFF, 4378B1), /* 3 */
};

#define BRCMF_PCIE_FW_UP_TIMEOUT 5000 /* msec */
@@ -1970,6 +1972,11 @@ static int brcmf_pcie_read_otp(struct brcmf_pciedev_info *devinfo)
int ret;

switch (devinfo->ci->chip) {
+ case BRCM_CC_4378_CHIP_ID:
+ coreid = BCMA_CORE_GCI;
+ base = 0x1120;
+ words = 0x170;
+ break;
default:
/* OTP not supported on this chip */
return 0;
@@ -2458,6 +2465,7 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = {
BRCMF_PCIE_DEVICE(BRCM_PCIE_4366_2G_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_4366_5G_DEVICE_ID),
BRCMF_PCIE_DEVICE(BRCM_PCIE_4371_DEVICE_ID),
+ BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID),
{ /* 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 1f225cdac9bd..1003f123ec25 100644
--- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
+++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
@@ -51,6 +51,7 @@
#define BRCM_CC_43664_CHIP_ID 43664
#define BRCM_CC_43666_CHIP_ID 43666
#define BRCM_CC_4371_CHIP_ID 0x4371
+#define BRCM_CC_4378_CHIP_ID 0x4378
#define CY_CC_4373_CHIP_ID 0x4373
#define CY_CC_43012_CHIP_ID 43012
#define CY_CC_43439_CHIP_ID 43439
@@ -88,6 +89,7 @@
#define BRCM_PCIE_4366_2G_DEVICE_ID 0x43c4
#define BRCM_PCIE_4366_5G_DEVICE_ID 0x43c5
#define BRCM_PCIE_4371_DEVICE_ID 0x440d
+#define BRCM_PCIE_4378_DEVICE_ID 0x4425


/* brcmsmac IDs */
--
2.30.2

2022-09-12 09:55:31

by Russell King (Oracle)

[permalink] [raw]
Subject: [PATCH wireless-next v2 12/12] arm64: dts: apple: Add WiFi module and antenna properties

From: Hector Martin <[email protected]>

Add the new module-instance/antenna-sku properties required to select
WiFi firmwares properly to all board device trees.

Signed-off-by: Hector Martin <[email protected]>
Reviewed-by: Mark Kettenis <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
---
arch/arm64/boot/dts/apple/t8103-j274.dts | 4 ++++
arch/arm64/boot/dts/apple/t8103-j293.dts | 4 ++++
arch/arm64/boot/dts/apple/t8103-j313.dts | 4 ++++
arch/arm64/boot/dts/apple/t8103-j456.dts | 4 ++++
arch/arm64/boot/dts/apple/t8103-j457.dts | 4 ++++
arch/arm64/boot/dts/apple/t8103-jxxx.dtsi | 2 ++
6 files changed, 22 insertions(+)

diff --git a/arch/arm64/boot/dts/apple/t8103-j274.dts b/arch/arm64/boot/dts/apple/t8103-j274.dts
index 2cd429efba5b..c1f3ba9c39f6 100644
--- a/arch/arm64/boot/dts/apple/t8103-j274.dts
+++ b/arch/arm64/boot/dts/apple/t8103-j274.dts
@@ -21,6 +21,10 @@ aliases {
};
};

+&wifi0 {
+ brcm,board-type = "apple,atlantisb";
+};
+
/*
* Force the bus number assignments so that we can declare some of the
* on-board devices and properties that are populated by the bootloader
diff --git a/arch/arm64/boot/dts/apple/t8103-j293.dts b/arch/arm64/boot/dts/apple/t8103-j293.dts
index 49cdf4b560a3..ecb10d237a05 100644
--- a/arch/arm64/boot/dts/apple/t8103-j293.dts
+++ b/arch/arm64/boot/dts/apple/t8103-j293.dts
@@ -17,6 +17,10 @@ / {
model = "Apple MacBook Pro (13-inch, M1, 2020)";
};

+&wifi0 {
+ brcm,board-type = "apple,honshu";
+};
+
/*
* Remove unused PCIe ports and disable the associated DARTs.
*/
diff --git a/arch/arm64/boot/dts/apple/t8103-j313.dts b/arch/arm64/boot/dts/apple/t8103-j313.dts
index b0ebb45bdb6f..df741737b8e6 100644
--- a/arch/arm64/boot/dts/apple/t8103-j313.dts
+++ b/arch/arm64/boot/dts/apple/t8103-j313.dts
@@ -17,6 +17,10 @@ / {
model = "Apple MacBook Air (M1, 2020)";
};

+&wifi0 {
+ brcm,board-type = "apple,shikoku";
+};
+
/*
* Remove unused PCIe ports and disable the associated DARTs.
*/
diff --git a/arch/arm64/boot/dts/apple/t8103-j456.dts b/arch/arm64/boot/dts/apple/t8103-j456.dts
index 884fddf7d363..8c6bf9592510 100644
--- a/arch/arm64/boot/dts/apple/t8103-j456.dts
+++ b/arch/arm64/boot/dts/apple/t8103-j456.dts
@@ -21,6 +21,10 @@ aliases {
};
};

+&wifi0 {
+ brcm,board-type = "apple,capri";
+};
+
&i2c0 {
hpm2: usb-pd@3b {
compatible = "apple,cd321x";
diff --git a/arch/arm64/boot/dts/apple/t8103-j457.dts b/arch/arm64/boot/dts/apple/t8103-j457.dts
index d7c622931627..fe7c0aaf7d62 100644
--- a/arch/arm64/boot/dts/apple/t8103-j457.dts
+++ b/arch/arm64/boot/dts/apple/t8103-j457.dts
@@ -21,6 +21,10 @@ aliases {
};
};

+&wifi0 {
+ brcm,board-type = "apple,santorini";
+};
+
/*
* Force the bus number assignments so that we can declare some of the
* on-board devices and properties that are populated by the bootloader
diff --git a/arch/arm64/boot/dts/apple/t8103-jxxx.dtsi b/arch/arm64/boot/dts/apple/t8103-jxxx.dtsi
index fe2ae40fa9dd..3d15b8e2a6c1 100644
--- a/arch/arm64/boot/dts/apple/t8103-jxxx.dtsi
+++ b/arch/arm64/boot/dts/apple/t8103-jxxx.dtsi
@@ -71,8 +71,10 @@ hpm1: usb-pd@3f {
&port00 {
bus-range = <1 1>;
wifi0: network@0,0 {
+ compatible = "pci14e4,4425";
reg = <0x10000 0x0 0x0 0x0 0x0>;
/* To be filled by the loader */
local-mac-address = [00 00 00 00 00 00];
+ apple,antenna-sku = "XX";
};
};
--
2.30.2

2022-09-12 12:02:22

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 01/12] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips

On Mon, Sep 12, 2022 at 10:52:41AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> This binding is currently used for SDIO devices, but these chips are
> also used as PCIe devices on DT platforms and may be represented in the
> DT. Re-use the existing binding and add chip compatibles used by Apple
> T2 and M1 platforms (the T2 ones are not known to be used in DT
> platforms, but we might as well document them).
>
> Then, add properties required for firmware selection and calibration on
> M1 machines.
>
> Reviewed-by: Linus Walleij <[email protected]>
> Signed-off-by: Hector Martin <[email protected]>
> Reviewed-by: Mark Kettenis <[email protected]>
> Reviewed-by: Rob Herring <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---
> .../net/wireless/brcm,bcm4329-fmac.yaml | 39 +++++++++++++++++--
> 1 file changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> index 53b4153d9bfc..fec1cc9b9a08 100644
> --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> @@ -4,7 +4,7 @@
> $id: http://devicetree.org/schemas/net/wireless/brcm,bcm4329-fmac.yaml#
> $schema: http://devicetree.org/meta-schemas/core.yaml#
>
> -title: Broadcom BCM4329 family fullmac wireless SDIO devices
> +title: Broadcom BCM4329 family fullmac wireless SDIO/PCIE devices
>
> maintainers:
> - Arend van Spriel <[email protected]>
> @@ -41,11 +41,17 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> - cypress,cyw4373-fmac
> - cypress,cyw43012-fmac
> - const: brcm,bcm4329-fmac
> - - const: brcm,bcm4329-fmac
> + - enum:
> + - brcm,bcm4329-fmac
> + - pci14e4,43dc # BCM4355
> + - pci14e4,4464 # BCM4364
> + - pci14e4,4488 # BCM4377
> + - pci14e4,4425 # BCM4378
> + - pci14e4,4433 # BCM4387
>
> reg:
> - description: SDIO function number for the device, for most cases
> - this will be 1.
> + description: SDIO function number for the device (for most cases
> + this will be 1) or PCI device identifier.
>
> interrupts:
> maxItems: 1
> @@ -85,6 +91,31 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> takes precedence.
> type: boolean
>
> + brcm,cal-blob:
> + $ref: /schemas/types.yaml#/definitions/uint8-array
> + description: A per-device calibration blob for the Wi-Fi radio. This
> + should be filled in by the bootloader from platform configuration
> + data, if necessary, and will be uploaded to the device if present.

Is this a leftover from a previous revision of the patchset? Because as
far as I can tell, the CLM blob is (still) being loaded via firmware,
and no additional parsing has been added for this particular OF
property. Should it be dropped?

The rest looks quite OK.

Kind regards,
Alvin

> +
> + brcm,board-type:
> + $ref: /schemas/types.yaml#/definitions/string
> + description: Overrides the board type, which is normally the compatible of
> + the root node. This can be used to decouple the overall system board or
> + device name from the board type for WiFi purposes, which is used to
> + construct firmware and NVRAM configuration filenames, allowing for
> + multiple devices that share the same module or characteristics for the
> + WiFi subsystem to share the same firmware/NVRAM files. On Apple platforms,
> + this should be the Apple module-instance codename prefixed by "apple,",
> + e.g. "apple,honshu".

nit: s/WiFi/Wi-Fi/

> +
> + apple,antenna-sku:
> + $ref: /schemas/types.yaml#/definitions/string
> + description: Antenna SKU used to identify a specific antenna configuration
> + on Apple platforms. This is use to build firmware filenames, to allow
> + platforms with different antenna configs to have different firmware and/or
> + NVRAM. This would normally be filled in by the bootloader from platform
> + configuration data.
> +
> required:
> - compatible
> - reg
> --
> 2.30.2
>

2022-09-12 12:06:19

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 01/12] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips

On Mon, Sep 12, 2022 at 11:59:17AM +0000, Alvin Šipraga wrote:
> On Mon, Sep 12, 2022 at 10:52:41AM +0100, Russell King wrote:
> > From: Hector Martin <[email protected]>
> >
> > This binding is currently used for SDIO devices, but these chips are
> > also used as PCIe devices on DT platforms and may be represented in the
> > DT. Re-use the existing binding and add chip compatibles used by Apple
> > T2 and M1 platforms (the T2 ones are not known to be used in DT
> > platforms, but we might as well document them).
> >
> > Then, add properties required for firmware selection and calibration on
> > M1 machines.
> >
> > Reviewed-by: Linus Walleij <[email protected]>
> > Signed-off-by: Hector Martin <[email protected]>
> > Reviewed-by: Mark Kettenis <[email protected]>
> > Reviewed-by: Rob Herring <[email protected]>
> > Signed-off-by: Russell King (Oracle) <[email protected]>
> > ---
> > .../net/wireless/brcm,bcm4329-fmac.yaml | 39 +++++++++++++++++--
> > 1 file changed, 35 insertions(+), 4 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > index 53b4153d9bfc..fec1cc9b9a08 100644
> > --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > @@ -4,7 +4,7 @@
> > $id: http://devicetree.org/schemas/net/wireless/brcm,bcm4329-fmac.yaml#
> > $schema: http://devicetree.org/meta-schemas/core.yaml#
> >
> > -title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > +title: Broadcom BCM4329 family fullmac wireless SDIO/PCIE devices
> >
> > maintainers:
> > - Arend van Spriel <[email protected]>
> > @@ -41,11 +41,17 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > - cypress,cyw4373-fmac
> > - cypress,cyw43012-fmac
> > - const: brcm,bcm4329-fmac
> > - - const: brcm,bcm4329-fmac
> > + - enum:
> > + - brcm,bcm4329-fmac
> > + - pci14e4,43dc # BCM4355
> > + - pci14e4,4464 # BCM4364
> > + - pci14e4,4488 # BCM4377
> > + - pci14e4,4425 # BCM4378
> > + - pci14e4,4433 # BCM4387
> >
> > reg:
> > - description: SDIO function number for the device, for most cases
> > - this will be 1.
> > + description: SDIO function number for the device (for most cases
> > + this will be 1) or PCI device identifier.
> >
> > interrupts:
> > maxItems: 1
> > @@ -85,6 +91,31 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > takes precedence.
> > type: boolean
> >
> > + brcm,cal-blob:
> > + $ref: /schemas/types.yaml#/definitions/uint8-array
> > + description: A per-device calibration blob for the Wi-Fi radio. This
> > + should be filled in by the bootloader from platform configuration
> > + data, if necessary, and will be uploaded to the device if present.
>
> Is this a leftover from a previous revision of the patchset? Because as
> far as I can tell, the CLM blob is (still) being loaded via firmware,
> and no additional parsing has been added for this particular OF
> property. Should it be dropped?

It does appear to be unparsed, but I don't know whether it's needed for
the binding or not. I'll wait for the Asahi folk to review your comment
before possibly removing it.

Thanks!

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

2022-09-12 14:02:57

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 01/12] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips

On Mon, Sep 12, 2022 at 01:04:58PM +0100, Russell King (Oracle) wrote:
> On Mon, Sep 12, 2022 at 11:59:17AM +0000, Alvin Šipraga wrote:
> > On Mon, Sep 12, 2022 at 10:52:41AM +0100, Russell King wrote:
> > > From: Hector Martin <[email protected]>
> > >
> > > This binding is currently used for SDIO devices, but these chips are
> > > also used as PCIe devices on DT platforms and may be represented in the
> > > DT. Re-use the existing binding and add chip compatibles used by Apple
> > > T2 and M1 platforms (the T2 ones are not known to be used in DT
> > > platforms, but we might as well document them).
> > >
> > > Then, add properties required for firmware selection and calibration on
> > > M1 machines.
> > >
> > > Reviewed-by: Linus Walleij <[email protected]>
> > > Signed-off-by: Hector Martin <[email protected]>
> > > Reviewed-by: Mark Kettenis <[email protected]>
> > > Reviewed-by: Rob Herring <[email protected]>
> > > Signed-off-by: Russell King (Oracle) <[email protected]>
> > > ---
> > > .../net/wireless/brcm,bcm4329-fmac.yaml | 39 +++++++++++++++++--
> > > 1 file changed, 35 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > index 53b4153d9bfc..fec1cc9b9a08 100644
> > > --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > @@ -4,7 +4,7 @@
> > > $id: http://devicetree.org/schemas/net/wireless/brcm,bcm4329-fmac.yaml#
> > > $schema: http://devicetree.org/meta-schemas/core.yaml#
> > >
> > > -title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > +title: Broadcom BCM4329 family fullmac wireless SDIO/PCIE devices
> > >
> > > maintainers:
> > > - Arend van Spriel <[email protected]>
> > > @@ -41,11 +41,17 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > - cypress,cyw4373-fmac
> > > - cypress,cyw43012-fmac
> > > - const: brcm,bcm4329-fmac
> > > - - const: brcm,bcm4329-fmac
> > > + - enum:
> > > + - brcm,bcm4329-fmac
> > > + - pci14e4,43dc # BCM4355
> > > + - pci14e4,4464 # BCM4364
> > > + - pci14e4,4488 # BCM4377
> > > + - pci14e4,4425 # BCM4378
> > > + - pci14e4,4433 # BCM4387
> > >
> > > reg:
> > > - description: SDIO function number for the device, for most cases
> > > - this will be 1.
> > > + description: SDIO function number for the device (for most cases
> > > + this will be 1) or PCI device identifier.
> > >
> > > interrupts:
> > > maxItems: 1
> > > @@ -85,6 +91,31 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > takes precedence.
> > > type: boolean
> > >
> > > + brcm,cal-blob:
> > > + $ref: /schemas/types.yaml#/definitions/uint8-array
> > > + description: A per-device calibration blob for the Wi-Fi radio. This
> > > + should be filled in by the bootloader from platform configuration
> > > + data, if necessary, and will be uploaded to the device if present.
> >
> > Is this a leftover from a previous revision of the patchset? Because as
> > far as I can tell, the CLM blob is (still) being loaded via firmware,
> > and no additional parsing has been added for this particular OF
> > property. Should it be dropped?
>
> It does appear to be unparsed, but I don't know whether it's needed for
> the binding or not. I'll wait for the Asahi folk to review your comment
> before possibly removing it.

Okay, the answer is, it is still very much part of the binding, and
the m1n1 boot loader populates it.

This series is a subset of a larger series (remember the previous 34
or 35 patch series?), so there are things in the binding document
which are not included in this series.

I don't think it makes sense to break up the binding document given
that it has already been reviewed several times in its current state,
should we really remove this one property and throw away all that
review effort.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

2022-09-12 14:14:40

by Mark Kettenis

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 01/12] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips

> Date: Mon, 12 Sep 2022 15:01:06 +0100
> From: "Russell King (Oracle)" <[email protected]>
>
> On Mon, Sep 12, 2022 at 01:04:58PM +0100, Russell King (Oracle) wrote:
> > On Mon, Sep 12, 2022 at 11:59:17AM +0000, Alvin Šipraga wrote:
> > > On Mon, Sep 12, 2022 at 10:52:41AM +0100, Russell King wrote:
> > > > From: Hector Martin <[email protected]>
> > > >
> > > > This binding is currently used for SDIO devices, but these chips are
> > > > also used as PCIe devices on DT platforms and may be represented in the
> > > > DT. Re-use the existing binding and add chip compatibles used by Apple
> > > > T2 and M1 platforms (the T2 ones are not known to be used in DT
> > > > platforms, but we might as well document them).
> > > >
> > > > Then, add properties required for firmware selection and calibration on
> > > > M1 machines.
> > > >
> > > > Reviewed-by: Linus Walleij <[email protected]>
> > > > Signed-off-by: Hector Martin <[email protected]>
> > > > Reviewed-by: Mark Kettenis <[email protected]>
> > > > Reviewed-by: Rob Herring <[email protected]>
> > > > Signed-off-by: Russell King (Oracle) <[email protected]>
> > > > ---
> > > > .../net/wireless/brcm,bcm4329-fmac.yaml | 39 +++++++++++++++++--
> > > > 1 file changed, 35 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > index 53b4153d9bfc..fec1cc9b9a08 100644
> > > > --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > @@ -4,7 +4,7 @@
> > > > $id: http://devicetree.org/schemas/net/wireless/brcm,bcm4329-fmac.yaml#
> > > > $schema: http://devicetree.org/meta-schemas/core.yaml#
> > > >
> > > > -title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > +title: Broadcom BCM4329 family fullmac wireless SDIO/PCIE devices
> > > >
> > > > maintainers:
> > > > - Arend van Spriel <[email protected]>
> > > > @@ -41,11 +41,17 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > - cypress,cyw4373-fmac
> > > > - cypress,cyw43012-fmac
> > > > - const: brcm,bcm4329-fmac
> > > > - - const: brcm,bcm4329-fmac
> > > > + - enum:
> > > > + - brcm,bcm4329-fmac
> > > > + - pci14e4,43dc # BCM4355
> > > > + - pci14e4,4464 # BCM4364
> > > > + - pci14e4,4488 # BCM4377
> > > > + - pci14e4,4425 # BCM4378
> > > > + - pci14e4,4433 # BCM4387
> > > >
> > > > reg:
> > > > - description: SDIO function number for the device, for most cases
> > > > - this will be 1.
> > > > + description: SDIO function number for the device (for most cases
> > > > + this will be 1) or PCI device identifier.
> > > >
> > > > interrupts:
> > > > maxItems: 1
> > > > @@ -85,6 +91,31 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > takes precedence.
> > > > type: boolean
> > > >
> > > > + brcm,cal-blob:
> > > > + $ref: /schemas/types.yaml#/definitions/uint8-array
> > > > + description: A per-device calibration blob for the Wi-Fi radio. This
> > > > + should be filled in by the bootloader from platform configuration
> > > > + data, if necessary, and will be uploaded to the device if present.
> > >
> > > Is this a leftover from a previous revision of the patchset? Because as
> > > far as I can tell, the CLM blob is (still) being loaded via firmware,
> > > and no additional parsing has been added for this particular OF
> > > property. Should it be dropped?
> >
> > It does appear to be unparsed, but I don't know whether it's needed for
> > the binding or not. I'll wait for the Asahi folk to review your comment
> > before possibly removing it.
>
> Okay, the answer is, it is still very much part of the binding, and
> the m1n1 boot loader populates it.
>
> This series is a subset of a larger series (remember the previous 34
> or 35 patch series?), so there are things in the binding document
> which are not included in this series.
>
> I don't think it makes sense to break up the binding document given
> that it has already been reviewed several times in its current state,
> should we really remove this one property and throw away all that
> review effort.

The OpenBSD driver already uses these properties. So even if the
Linux driver doesn't use this yet, there is an existing implementation
that does. That should be good enough for it to be included in the
binding isn't it?

2022-09-12 14:38:43

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 01/12] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips

Hi both,

On Mon, Sep 12, 2022 at 04:13:08PM +0200, Mark Kettenis wrote:
> > Date: Mon, 12 Sep 2022 15:01:06 +0100
> > From: "Russell King (Oracle)" <[email protected]>
> >
> > On Mon, Sep 12, 2022 at 01:04:58PM +0100, Russell King (Oracle) wrote:
> > > On Mon, Sep 12, 2022 at 11:59:17AM +0000, Alvin Šipraga wrote:
> > > > On Mon, Sep 12, 2022 at 10:52:41AM +0100, Russell King wrote:
> > > > > From: Hector Martin <[email protected]>
> > > > >
> > > > > This binding is currently used for SDIO devices, but these chips are
> > > > > also used as PCIe devices on DT platforms and may be represented in the
> > > > > DT. Re-use the existing binding and add chip compatibles used by Apple
> > > > > T2 and M1 platforms (the T2 ones are not known to be used in DT
> > > > > platforms, but we might as well document them).
> > > > >
> > > > > Then, add properties required for firmware selection and calibration on
> > > > > M1 machines.
> > > > >
> > > > > Reviewed-by: Linus Walleij <[email protected]>
> > > > > Signed-off-by: Hector Martin <[email protected]>
> > > > > Reviewed-by: Mark Kettenis <[email protected]>
> > > > > Reviewed-by: Rob Herring <[email protected]>
> > > > > Signed-off-by: Russell King (Oracle) <[email protected]>
> > > > > ---
> > > > > .../net/wireless/brcm,bcm4329-fmac.yaml | 39 +++++++++++++++++--
> > > > > 1 file changed, 35 insertions(+), 4 deletions(-)
> > > > >
> > > > > diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > > index 53b4153d9bfc..fec1cc9b9a08 100644
> > > > > --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > > +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > > @@ -4,7 +4,7 @@
> > > > > $id: http://devicetree.org/schemas/net/wireless/brcm,bcm4329-fmac.yaml
> > > > > $schema: http://devicetree.org/meta-schemas/core.yaml
> > > > >
> > > > > -title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > > +title: Broadcom BCM4329 family fullmac wireless SDIO/PCIE devices
> > > > >
> > > > > maintainers:
> > > > > - Arend van Spriel <[email protected]>
> > > > > @@ -41,11 +41,17 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > > - cypress,cyw4373-fmac
> > > > > - cypress,cyw43012-fmac
> > > > > - const: brcm,bcm4329-fmac
> > > > > - - const: brcm,bcm4329-fmac
> > > > > + - enum:
> > > > > + - brcm,bcm4329-fmac
> > > > > + - pci14e4,43dc # BCM4355
> > > > > + - pci14e4,4464 # BCM4364
> > > > > + - pci14e4,4488 # BCM4377
> > > > > + - pci14e4,4425 # BCM4378
> > > > > + - pci14e4,4433 # BCM4387
> > > > >
> > > > > reg:
> > > > > - description: SDIO function number for the device, for most cases
> > > > > - this will be 1.
> > > > > + description: SDIO function number for the device (for most cases
> > > > > + this will be 1) or PCI device identifier.
> > > > >
> > > > > interrupts:
> > > > > maxItems: 1
> > > > > @@ -85,6 +91,31 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > > takes precedence.
> > > > > type: boolean
> > > > >
> > > > > + brcm,cal-blob:
> > > > > + $ref: /schemas/types.yaml#/definitions/uint8-array
> > > > > + description: A per-device calibration blob for the Wi-Fi radio. This
> > > > > + should be filled in by the bootloader from platform configuration
> > > > > + data, if necessary, and will be uploaded to the device if present.
> > > >
> > > > Is this a leftover from a previous revision of the patchset? Because as
> > > > far as I can tell, the CLM blob is (still) being loaded via firmware,
> > > > and no additional parsing has been added for this particular OF
> > > > property. Should it be dropped?
> > >
> > > It does appear to be unparsed, but I don't know whether it's needed for
> > > the binding or not. I'll wait for the Asahi folk to review your comment
> > > before possibly removing it.
> >
> > Okay, the answer is, it is still very much part of the binding, and
> > the m1n1 boot loader populates it.
> >
> > This series is a subset of a larger series (remember the previous 34
> > or 35 patch series?), so there are things in the binding document
> > which are not included in this series.
> >
> > I don't think it makes sense to break up the binding document given
> > that it has already been reviewed several times in its current state,
> > should we really remove this one property and throw away all that
> > review effort.
>
> The OpenBSD driver already uses these properties. So even if the
> Linux driver doesn't use this yet, there is an existing implementation
> that does. That should be good enough for it to be included in the
> binding isn't it?

Yes, I suspected that might be the case too. I think it's fine.

Thanks Russel for the clarification btw. Feel free to add my

Reviewed-by: Alvin Šipraga <[email protected]>

Kind regards,
Alvin

2022-09-12 14:43:07

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 01/12] dt-bindings: net: bcm4329-fmac: Add Apple properties & chips

On Mon, Sep 12, 2022 at 02:27:32PM +0000, Alvin Šipraga wrote:
> Hi both,
>
> On Mon, Sep 12, 2022 at 04:13:08PM +0200, Mark Kettenis wrote:
> > > Date: Mon, 12 Sep 2022 15:01:06 +0100
> > > From: "Russell King (Oracle)" <[email protected]>
> > >
> > > On Mon, Sep 12, 2022 at 01:04:58PM +0100, Russell King (Oracle) wrote:
> > > > On Mon, Sep 12, 2022 at 11:59:17AM +0000, Alvin Šipraga wrote:
> > > > > On Mon, Sep 12, 2022 at 10:52:41AM +0100, Russell King wrote:
> > > > > > From: Hector Martin <[email protected]>
> > > > > >
> > > > > > This binding is currently used for SDIO devices, but these chips are
> > > > > > also used as PCIe devices on DT platforms and may be represented in the
> > > > > > DT. Re-use the existing binding and add chip compatibles used by Apple
> > > > > > T2 and M1 platforms (the T2 ones are not known to be used in DT
> > > > > > platforms, but we might as well document them).
> > > > > >
> > > > > > Then, add properties required for firmware selection and calibration on
> > > > > > M1 machines.
> > > > > >
> > > > > > Reviewed-by: Linus Walleij <[email protected]>
> > > > > > Signed-off-by: Hector Martin <[email protected]>
> > > > > > Reviewed-by: Mark Kettenis <[email protected]>
> > > > > > Reviewed-by: Rob Herring <[email protected]>
> > > > > > Signed-off-by: Russell King (Oracle) <[email protected]>
> > > > > > ---
> > > > > > .../net/wireless/brcm,bcm4329-fmac.yaml | 39 +++++++++++++++++--
> > > > > > 1 file changed, 35 insertions(+), 4 deletions(-)
> > > > > >
> > > > > > diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > > > index 53b4153d9bfc..fec1cc9b9a08 100644
> > > > > > --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > > > +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml
> > > > > > @@ -4,7 +4,7 @@
> > > > > > $id: http://devicetree.org/schemas/net/wireless/brcm,bcm4329-fmac.yaml
> > > > > > $schema: http://devicetree.org/meta-schemas/core.yaml
> > > > > >
> > > > > > -title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > > > +title: Broadcom BCM4329 family fullmac wireless SDIO/PCIE devices
> > > > > >
> > > > > > maintainers:
> > > > > > - Arend van Spriel <[email protected]>
> > > > > > @@ -41,11 +41,17 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > > > - cypress,cyw4373-fmac
> > > > > > - cypress,cyw43012-fmac
> > > > > > - const: brcm,bcm4329-fmac
> > > > > > - - const: brcm,bcm4329-fmac
> > > > > > + - enum:
> > > > > > + - brcm,bcm4329-fmac
> > > > > > + - pci14e4,43dc # BCM4355
> > > > > > + - pci14e4,4464 # BCM4364
> > > > > > + - pci14e4,4488 # BCM4377
> > > > > > + - pci14e4,4425 # BCM4378
> > > > > > + - pci14e4,4433 # BCM4387
> > > > > >
> > > > > > reg:
> > > > > > - description: SDIO function number for the device, for most cases
> > > > > > - this will be 1.
> > > > > > + description: SDIO function number for the device (for most cases
> > > > > > + this will be 1) or PCI device identifier.
> > > > > >
> > > > > > interrupts:
> > > > > > maxItems: 1
> > > > > > @@ -85,6 +91,31 @@ title: Broadcom BCM4329 family fullmac wireless SDIO devices
> > > > > > takes precedence.
> > > > > > type: boolean
> > > > > >
> > > > > > + brcm,cal-blob:
> > > > > > + $ref: /schemas/types.yaml#/definitions/uint8-array
> > > > > > + description: A per-device calibration blob for the Wi-Fi radio. This
> > > > > > + should be filled in by the bootloader from platform configuration
> > > > > > + data, if necessary, and will be uploaded to the device if present.
> > > > >
> > > > > Is this a leftover from a previous revision of the patchset? Because as
> > > > > far as I can tell, the CLM blob is (still) being loaded via firmware,
> > > > > and no additional parsing has been added for this particular OF
> > > > > property. Should it be dropped?
> > > >
> > > > It does appear to be unparsed, but I don't know whether it's needed for
> > > > the binding or not. I'll wait for the Asahi folk to review your comment
> > > > before possibly removing it.
> > >
> > > Okay, the answer is, it is still very much part of the binding, and
> > > the m1n1 boot loader populates it.
> > >
> > > This series is a subset of a larger series (remember the previous 34
> > > or 35 patch series?), so there are things in the binding document
> > > which are not included in this series.
> > >
> > > I don't think it makes sense to break up the binding document given
> > > that it has already been reviewed several times in its current state,
> > > should we really remove this one property and throw away all that
> > > review effort.
> >
> > The OpenBSD driver already uses these properties. So even if the
> > Linux driver doesn't use this yet, there is an existing implementation
> > that does. That should be good enough for it to be included in the
> > binding isn't it?
>
> Yes, I suspected that might be the case too. I think it's fine.
>
> Thanks Russel for the clarification btw. Feel free to add my
>
> Reviewed-by: Alvin Šipraga <[email protected]>

Thanks!

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

2022-09-13 07:05:38

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 12/12] arm64: dts: apple: Add WiFi module and antenna properties

Russell King (Oracle) <[email protected]> writes:

> From: Hector Martin <[email protected]>
>
> Add the new module-instance/antenna-sku properties required to select
> WiFi firmwares properly to all board device trees.
>
> Signed-off-by: Hector Martin <[email protected]>
> Reviewed-by: Mark Kettenis <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---
> arch/arm64/boot/dts/apple/t8103-j274.dts | 4 ++++
> arch/arm64/boot/dts/apple/t8103-j293.dts | 4 ++++
> arch/arm64/boot/dts/apple/t8103-j313.dts | 4 ++++
> arch/arm64/boot/dts/apple/t8103-j456.dts | 4 ++++
> arch/arm64/boot/dts/apple/t8103-j457.dts | 4 ++++
> arch/arm64/boot/dts/apple/t8103-jxxx.dtsi | 2 ++
> 6 files changed, 22 insertions(+)

I didn't get any reply to my question in v1 so I assume this patch 12 is
ok to take to wireless-next. ARM folks, if this is not ok please let me
know.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-09-13 17:40:47

by Hector Martin

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 12/12] arm64: dts: apple: Add WiFi module and antenna properties

On 13/09/2022 15.52, Kalle Valo wrote:
> Russell King (Oracle) <[email protected]> writes:
>
>> From: Hector Martin <[email protected]>
>>
>> Add the new module-instance/antenna-sku properties required to select
>> WiFi firmwares properly to all board device trees.
>>
>> Signed-off-by: Hector Martin <[email protected]>
>> Reviewed-by: Mark Kettenis <[email protected]>
>> Signed-off-by: Russell King (Oracle) <[email protected]>
>> ---
>> arch/arm64/boot/dts/apple/t8103-j274.dts | 4 ++++
>> arch/arm64/boot/dts/apple/t8103-j293.dts | 4 ++++
>> arch/arm64/boot/dts/apple/t8103-j313.dts | 4 ++++
>> arch/arm64/boot/dts/apple/t8103-j456.dts | 4 ++++
>> arch/arm64/boot/dts/apple/t8103-j457.dts | 4 ++++
>> arch/arm64/boot/dts/apple/t8103-jxxx.dtsi | 2 ++
>> 6 files changed, 22 insertions(+)
>
> I didn't get any reply to my question in v1 so I assume this patch 12 is
> ok to take to wireless-next. ARM folks, if this is not ok please let me
> know.

Yup, this is OK to merge via wireless-next. In case you need it,

Acked-by: Hector Martin <[email protected]>

- Hector

2022-09-14 10:37:06

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 0/12] Add support for bcm4378 on Apple platforms

On 9/12/2022 11:52 AM, Russell King (Oracle) wrote:
> Hi,
>
> This series adds support for bcm4378 found on Apple platforms, and has
> been tested on the Apple Mac Mini. It is a re-posting of a subset of
> Hector's previous 38 patch series, and it is believed that the comments
> from that review were addressed.
>
> (I'm just the middle man; please don't complain if something has been
> missed.)

Hi Russell,

I reviewed this series (or actually the 30+ series) a couple of times
and actually thought it was already applied. Anyway, I will go over
these once more.

Regards,
Arend

2022-09-15 15:46:36

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 04/12] brcmfmac: firmware: Support passing in multiple board_types

On Mon, Sep 12, 2022 at 10:52:56AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> Apple platforms have firmware and config files identified with multiple
> dimensions. We want to be able to find the most specific firmware
> available for any given platform, progressively trying more general
> firmwares.
>
> To do this, first add support for passing in multiple board_types,
> which will be tried in sequence.
>
> Since this will cause more log spam due to missing firmwares, also
> switch the secondary firmware fecthes to use the _nowarn variant, which
> will not log if the firmware is not found.
>
> Signed-off-by: Hector Martin <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---

Reviewed-by: Alvin Šipraga <[email protected]>

2022-09-15 15:46:36

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 03/12] brcmfmac: pcie/sdio/usb: Get CLM blob via standard firmware mechanism

On Mon, Sep 12, 2022 at 10:52:51AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> Now that the firmware fetcher can handle per-board CLM files, load the
> CLM blob alongside the other firmware files and change the bus API to
> just return the existing blob, instead of fetching the filename.
>
> This enables per-board CLM blobs, which are required on Apple platforms.
>
> Acked-by: Linus Walleij <[email protected]>
> Reviewed-by: Arend van Spriel <[email protected]>
> Signed-off-by: Hector Martin <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---

Reviewed-by: Alvin Šipraga <[email protected]>

2022-09-15 15:46:40

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 06/12] brcmfmac: of: Fetch Apple properties

On Mon, Sep 12, 2022 at 10:53:07AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> On Apple ARM64 platforms, firmware selection requires two properties
> that come from system firmware: the module-instance (aka "island", a
> codename representing a given hardware platform) and the antenna-sku.
> We map Apple's module codenames to board_types in the form
> "apple,<module-instance>".
>
> The mapped board_type is added to the DTS file in that form, while the
> antenna-sku is forwarded by our bootloader from the Apple Device Tree
> into the FDT. Grab them from the DT so firmware selection can use
> them.
>
> Reviewed-by: Linus Walleij <[email protected]>
> Signed-off-by: Hector Martin <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---

Reviewed-by: Alvin Šipraga <[email protected]>

2022-09-15 15:47:07

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 08/12] brcmfmac: firmware: Allow platform to override macaddr

On Mon, Sep 12, 2022 at 10:53:17AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> On Device Tree platforms, it is customary to be able to set the MAC
> address via the Device Tree, as it is often stored in system firmware.
> This is particularly relevant for Apple ARM64 platforms, where this
> information comes from system configuration and passed through by the
> bootloader into the DT.
>
> Implement support for this by fetching the platform MAC address and
> adding or replacing the macaddr= property in nvram. This becomes the
> dongle's default MAC address.
>
> On platforms with an SROM MAC address, this overrides it. On platforms
> without one, such as Apple ARM64 devices, this is required for the
> firmware to boot (it will fail if it does not have a valid MAC at all).
>
> Reviewed-by: Linus Walleij <[email protected]>
> Signed-off-by: Hector Martin <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---
> .../broadcom/brcm80211/brcmfmac/firmware.c | 31 +++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> index 371c086d1f48..c109e20fc5c6 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
> @@ -21,6 +21,8 @@
> #define BRCMF_FW_NVRAM_DEVPATH_LEN 19 /* devpath0=pcie/1/4/ */
> #define BRCMF_FW_NVRAM_PCIEDEV_LEN 10 /* pcie/1/4/ + \0 */
> #define BRCMF_FW_DEFAULT_BOARDREV "boardrev=0xff"
> +#define BRCMF_FW_MACADDR_FMT "macaddr=%pM"
> +#define BRCMF_FW_MACADDR_LEN (7 + ETH_ALEN * 3)
>
> enum nvram_parser_state {
> IDLE,
> @@ -57,6 +59,7 @@ struct nvram_parser {
> bool multi_dev_v1;
> bool multi_dev_v2;
> bool boardrev_found;
> + bool strip_mac;

CC [M] drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.o
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:63: warning: Function parameter or member 'strip_mac' not described in 'nvram_parser'

Otherwise looks OK and you can add

Reviewed-by: Alvin Šipraga <[email protected]>


> };
>
> /*
> @@ -121,6 +124,10 @@ static enum nvram_parser_state brcmf_nvram_handle_key(struct nvram_parser *nvp)
> nvp->multi_dev_v2 = true;
> if (strncmp(&nvp->data[nvp->entry], "boardrev", 8) == 0)
> nvp->boardrev_found = true;
> + /* strip macaddr if platform MAC overrides */
> + if (nvp->strip_mac &&
> + strncmp(&nvp->data[nvp->entry], "macaddr", 7) == 0)
> + st = COMMENT;
> } else if (!is_nvram_char(c) || c == ' ') {
> brcmf_dbg(INFO, "warning: ln=%d:col=%d: '=' expected, skip invalid key entry\n",
> nvp->line, nvp->column);
> @@ -209,6 +216,7 @@ static int brcmf_init_nvram_parser(struct nvram_parser *nvp,
> size = data_len;
> /* Add space for properties we may add */
> size += strlen(BRCMF_FW_DEFAULT_BOARDREV) + 1;
> + size += BRCMF_FW_MACADDR_LEN + 1;
> /* Alloc for extra 0 byte + roundup by 4 + length field */
> size += 1 + 3 + sizeof(u32);
> nvp->nvram = kzalloc(size, GFP_KERNEL);
> @@ -368,22 +376,37 @@ static void brcmf_fw_add_defaults(struct nvram_parser *nvp)
> nvp->nvram_len++;
> }
>
> +static void brcmf_fw_add_macaddr(struct nvram_parser *nvp, u8 *mac)
> +{
> + int len;
> +
> + len = scnprintf(&nvp->nvram[nvp->nvram_len], BRCMF_FW_MACADDR_LEN + 1,
> + BRCMF_FW_MACADDR_FMT, mac);
> + WARN_ON(len != BRCMF_FW_MACADDR_LEN);
> + nvp->nvram_len += len + 1;
> +}
> +
> /* brcmf_nvram_strip :Takes a buffer of "<var>=<value>\n" lines read from a fil
> * and ending in a NUL. Removes carriage returns, empty lines, comment lines,
> * and converts newlines to NULs. Shortens buffer as needed and pads with NULs.
> * End of buffer is completed with token identifying length of buffer.
> */
> static void *brcmf_fw_nvram_strip(const u8 *data, size_t data_len,
> - u32 *new_length, u16 domain_nr, u16 bus_nr)
> + u32 *new_length, u16 domain_nr, u16 bus_nr,
> + struct device *dev)
> {
> struct nvram_parser nvp;
> u32 pad;
> u32 token;
> __le32 token_le;
> + u8 mac[ETH_ALEN];
>
> if (brcmf_init_nvram_parser(&nvp, data, data_len) < 0)
> return NULL;
>
> + if (eth_platform_get_mac_address(dev, mac) == 0)
> + nvp.strip_mac = true;
> +
> while (nvp.pos < data_len) {
> nvp.state = nv_parser_states[nvp.state](&nvp);
> if (nvp.state == END)
> @@ -404,6 +427,9 @@ static void *brcmf_fw_nvram_strip(const u8 *data, size_t data_len,
>
> brcmf_fw_add_defaults(&nvp);
>
> + if (nvp.strip_mac)
> + brcmf_fw_add_macaddr(&nvp, mac);
> +
> pad = nvp.nvram_len;
> *new_length = roundup(nvp.nvram_len + 1, 4);
> while (pad != *new_length) {
> @@ -538,7 +564,8 @@ static int brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
> if (data)
> nvram = brcmf_fw_nvram_strip(data, data_len, &nvram_length,
> fwctx->req->domain_nr,
> - fwctx->req->bus_nr);
> + fwctx->req->bus_nr,
> + fwctx->dev);
>
> if (free_bcm47xx_nvram)
> bcm47xx_nvram_release_contents(data);
> --
> 2.30.2
>

2022-09-15 15:47:09

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 09/12] brcmfmac: msgbuf: Increase RX ring sizes to 1024

On Mon, Sep 12, 2022 at 10:53:22AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> Newer chips used on Apple platforms have a max_rxbufpost greater than
> 512, which causes warnings when brcmf_msgbuf_rxbuf_data_fill tries to
> put more entries in the ring than will fit. Increase the ring sizes
> to 1024.
>
> Reviewed-by: Linus Walleij <[email protected]>
> Signed-off-by: Hector Martin <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---

Reviewed-by: Alvin Šipraga <[email protected]>

2022-09-15 15:47:11

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 11/12] brcmfmac: pcie: Add IDs/properties for BCM4378

On Mon, Sep 12, 2022 at 10:53:32AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> This chip is present on Apple M1 (t8103) platforms:
>
> * atlantisb (apple,j274): Mac mini (M1, 2020)
> * honshu (apple,j293): MacBook Pro (13-inch, M1, 2020)
> * shikoku (apple,j313): MacBook Air (M1, 2020)
> * capri (apple,j456): iMac (24-inch, 4x USB-C, M1, 2020)
> * santorini (apple,j457): iMac (24-inch, 2x USB-C, M1, 2020)
>
> Reviewed-by: Linus Walleij <[email protected]>
> Signed-off-by: Hector Martin <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---

Reviewed-by: Alvin Šipraga <[email protected]>

> drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 2 ++
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++++
> .../net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 2 ++
> 3 files changed, 12 insertions(+)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> index 23295fceb062..3026166a56c1 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> @@ -733,6 +733,8 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
> return 0x160000;
> case CY_CC_43752_CHIP_ID:
> return 0x170000;
> + case BRCM_CC_4378_CHIP_ID:
> + return 0x352000;
> 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 269a516ae654..0c627f33049e 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> @@ -59,6 +59,7 @@ BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
> BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
> BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
> BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
> +BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie");
>
> /* firmware config files */
> MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.txt");
> @@ -88,6 +89,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
> BRCMF_FW_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFFFFFF0, 4366C),
> BRCMF_FW_ENTRY(BRCM_CC_43666_CHIP_ID, 0xFFFFFFF0, 4366C),
> BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
> + BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFFF, 4378B1), /* 3 */

What is /* 3 */?

> };
>
> #define BRCMF_PCIE_FW_UP_TIMEOUT 5000 /* msec */
> @@ -1970,6 +1972,11 @@ static int brcmf_pcie_read_otp(struct brcmf_pciedev_info *devinfo)
> int ret;
>
> switch (devinfo->ci->chip) {
> + case BRCM_CC_4378_CHIP_ID:
> + coreid = BCMA_CORE_GCI;
> + base = 0x1120;
> + words = 0x170;
> + break;
> default:
> /* OTP not supported on this chip */
> return 0;
> @@ -2458,6 +2465,7 @@ static const struct pci_device_id brcmf_pcie_devid_table[] = {
> BRCMF_PCIE_DEVICE(BRCM_PCIE_4366_2G_DEVICE_ID),
> BRCMF_PCIE_DEVICE(BRCM_PCIE_4366_5G_DEVICE_ID),
> BRCMF_PCIE_DEVICE(BRCM_PCIE_4371_DEVICE_ID),
> + BRCMF_PCIE_DEVICE(BRCM_PCIE_4378_DEVICE_ID),
> { /* 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 1f225cdac9bd..1003f123ec25 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
> +++ b/drivers/net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h
> @@ -51,6 +51,7 @@
> #define BRCM_CC_43664_CHIP_ID 43664
> #define BRCM_CC_43666_CHIP_ID 43666
> #define BRCM_CC_4371_CHIP_ID 0x4371
> +#define BRCM_CC_4378_CHIP_ID 0x4378
> #define CY_CC_4373_CHIP_ID 0x4373
> #define CY_CC_43012_CHIP_ID 43012
> #define CY_CC_43439_CHIP_ID 43439
> @@ -88,6 +89,7 @@
> #define BRCM_PCIE_4366_2G_DEVICE_ID 0x43c4
> #define BRCM_PCIE_4366_5G_DEVICE_ID 0x43c5
> #define BRCM_PCIE_4371_DEVICE_ID 0x440d
> +#define BRCM_PCIE_4378_DEVICE_ID 0x4425
>
>
> /* brcmsmac IDs */
> --
> 2.30.2
>

2022-09-15 15:47:27

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 07/12] brcmfmac: pcie: Perform firmware selection for Apple platforms

On Mon, Sep 12, 2022 at 10:53:12AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> On Apple platforms, firmware selection uses the following elements:
>
> Property Example Source
> ============== ======= ========================
> * Chip name 4378 Device ID
> * Chip revision B1 OTP
> * Platform shikoku DT (ARM64) or ACPI (x86)
> * Module type RASP OTP
> * Module vendor m OTP
> * Module version 6.11 OTP
> * Antenna SKU X3 DT (ARM64) or ACPI (x86)
>
> In macOS, these firmwares are stored using filenames in this format
> under /usr/share/firmware/wifi:
>
> C-4378__s-B1/P-shikoku-X3_M-RASP_V-m__m-6.11.txt
>
> To prepare firmwares for Linux, we rename these to a scheme following
> the existing brcmfmac convention:
>
> brcmfmac<chip><lower(rev)>-pcie.apple,<platform>-<mod_type>-\
> <mod_vendor>-<mod_version>-<antenna_sku>.txt
>
> The NVRAM uses all the components, while the firmware and CLM blob only
> use the chip/revision/platform/antenna_sku:
>
> brcmfmac<chip><lower(rev)>-pcie.apple,<platform>-<antenna_sku>.bin
>
> e.g.
>
> brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11-X3.txt
> brcm/brcmfmac4378b1-pcie.apple,shikoku-X3.bin
>
> In addition, since there are over 1000 files in total, many of which are
> symlinks or outright duplicates, we deduplicate and prune the firmware
> tree to reduce firmware filenames to fewer dimensions. For example, the
> shikoku platform (MacBook Air M1 2020) simplifies to just 4 files:
>
> brcm/brcmfmac4378b1-pcie.apple,shikoku.clm_blob
> brcm/brcmfmac4378b1-pcie.apple,shikoku.bin
> brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m.txt
> brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-u.txt
>
> This reduces the total file count to around 170, of which 75 are
> symlinks and 95 are regular files: 7 firmware blobs, 27 CLM blobs, and
> 61 NVRAM config files. We also slightly process NVRAM files to correct
> some formatting issues.
>
> To handle this, the driver must try the following path formats when
> looking for firmware files:
>
> brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11-X3.txt
> brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11.txt
> brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m.txt
> brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP.txt
> brcm/brcmfmac4378b1-pcie.apple,shikoku-X3.txt *
> brcm/brcmfmac4378b1-pcie.apple,shikoku.txt
>
> * Not relevant for NVRAM, only for firmware/CLM.
>
> The chip revision nominally comes from OTP on Apple platforms, but it
> can be mapped to the PCI revision number, so we ignore the OTP revision
> and continue to use the existing PCI revision mechanism to identify chip
> revisions, as the driver already does for other chips. Unfortunately,
> the mapping is not consistent between different chip types, so this has
> to be determined experimentally.
>
> Reviewed-by: Linus Walleij <[email protected]>
> Signed-off-by: Hector Martin <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---

Reviewed-by: Alvin Šipraga <[email protected]>

> .../broadcom/brcm80211/brcmfmac/pcie.c | 41 ++++++++++++++++++-
> 1 file changed, 39 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> index 76ca835378bb..3fb590a6e03b 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> @@ -2068,8 +2068,45 @@ brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo)
> fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1;
> fwreq->bus_nr = devinfo->pdev->bus->number;
>
> - brcmf_dbg(PCIE, "Board: %s\n", devinfo->settings->board_type);
> - fwreq->board_types[0] = devinfo->settings->board_type;
> + /* Apple platforms with fancy firmware/NVRAM selection */
> + if (devinfo->settings->board_type &&
> + devinfo->settings->antenna_sku &&
> + devinfo->otp.valid) {
> + const struct brcmf_otp_params *otp = &devinfo->otp;
> + struct device *dev = &devinfo->pdev->dev;
> + const char **bt = fwreq->board_types;
> +
> + brcmf_dbg(PCIE, "Apple board: %s\n",
> + devinfo->settings->board_type);
> +
> + /* Example: apple,shikoku-RASP-m-6.11-X3 */
> + bt[0] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s-%s-%s-%s",
> + devinfo->settings->board_type,
> + otp->module, otp->vendor, otp->version,
> + devinfo->settings->antenna_sku);
> + bt[1] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s-%s-%s",
> + devinfo->settings->board_type,
> + otp->module, otp->vendor, otp->version);
> + bt[2] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s-%s",
> + devinfo->settings->board_type,
> + otp->module, otp->vendor);
> + bt[3] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s",
> + devinfo->settings->board_type,
> + otp->module);
> + bt[4] = devm_kasprintf(dev, GFP_KERNEL, "%s-%s",
> + devinfo->settings->board_type,
> + devinfo->settings->antenna_sku);
> + bt[5] = devinfo->settings->board_type;
> +
> + if (!bt[0] || !bt[1] || !bt[2] || !bt[3] || !bt[4]) {
> + kfree(fwreq);
> + return NULL;
> + }
> +

Spurious newline?

> + } else {
> + brcmf_dbg(PCIE, "Board: %s\n", devinfo->settings->board_type);
> + fwreq->board_types[0] = devinfo->settings->board_type;
> + }
>
> return fwreq;
> }
> --
> 2.30.2
>

2022-09-15 15:48:38

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 02/12] brcmfmac: firmware: Handle per-board clm_blob files

On Mon, Sep 12, 2022 at 10:52:46AM +0100, Russell King wrote:
> From: Hector Martin <[email protected]>
>
> Teach brcm_alt_fw_paths to correctly split off variable length
> extensions, and enable alt firmware lookups for the CLM blob firmware
> requests.
>
> Apple platforms have per-board CLM blob files.
>
> Acked-by: Linus Walleij <[email protected]>
> Reviewed-by: Arend van Spriel <[email protected]>
> Signed-off-by: Hector Martin <[email protected]>
> Signed-off-by: Russell King (Oracle) <[email protected]>
> ---

Reviewed-by: Alvin Šipraga <[email protected]>

2022-09-15 16:55:41

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 11/12] brcmfmac: pcie: Add IDs/properties for BCM4378

On Thu, Sep 15, 2022 at 03:34:59PM +0000, Alvin Šipraga wrote:
> On Mon, Sep 12, 2022 at 10:53:32AM +0100, Russell King wrote:
> > From: Hector Martin <[email protected]>
> >
> > This chip is present on Apple M1 (t8103) platforms:
> >
> > * atlantisb (apple,j274): Mac mini (M1, 2020)
> > * honshu (apple,j293): MacBook Pro (13-inch, M1, 2020)
> > * shikoku (apple,j313): MacBook Air (M1, 2020)
> > * capri (apple,j456): iMac (24-inch, 4x USB-C, M1, 2020)
> > * santorini (apple,j457): iMac (24-inch, 2x USB-C, M1, 2020)
> >
> > Reviewed-by: Linus Walleij <[email protected]>
> > Signed-off-by: Hector Martin <[email protected]>
> > Signed-off-by: Russell King (Oracle) <[email protected]>
> > ---
>
> Reviewed-by: Alvin Šipraga <[email protected]>
>
> > drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 2 ++
> > drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++++
> > .../net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 2 ++
> > 3 files changed, 12 insertions(+)
> >
> > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> > index 23295fceb062..3026166a56c1 100644
> > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> > @@ -733,6 +733,8 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
> > return 0x160000;
> > case CY_CC_43752_CHIP_ID:
> > return 0x170000;
> > + case BRCM_CC_4378_CHIP_ID:
> > + return 0x352000;
> > 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 269a516ae654..0c627f33049e 100644
> > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> > @@ -59,6 +59,7 @@ BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
> > BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
> > BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
> > BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
> > +BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie");
> >
> > /* firmware config files */
> > MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.txt");
> > @@ -88,6 +89,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
> > BRCMF_FW_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFFFFFF0, 4366C),
> > BRCMF_FW_ENTRY(BRCM_CC_43666_CHIP_ID, 0xFFFFFFF0, 4366C),
> > BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
> > + BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFFF, 4378B1), /* 3 */
>
> What is /* 3 */?

Hector says that it was mentioned in the prior review round as well.
It's the revision ID. The mask allows all IDs for chips where no
split has been seen, but if a new one comes up that comment is there
so we know where to split the mask.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

2022-09-15 17:38:41

by Alvin Šipraga

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 11/12] brcmfmac: pcie: Add IDs/properties for BCM4378

On Thu, Sep 15, 2022 at 05:54:11PM +0100, Russell King (Oracle) wrote:
> On Thu, Sep 15, 2022 at 03:34:59PM +0000, Alvin Šipraga wrote:
> > On Mon, Sep 12, 2022 at 10:53:32AM +0100, Russell King wrote:
> > > From: Hector Martin <[email protected]>
> > >
> > > This chip is present on Apple M1 (t8103) platforms:
> > >
> > > * atlantisb (apple,j274): Mac mini (M1, 2020)
> > > * honshu (apple,j293): MacBook Pro (13-inch, M1, 2020)
> > > * shikoku (apple,j313): MacBook Air (M1, 2020)
> > > * capri (apple,j456): iMac (24-inch, 4x USB-C, M1, 2020)
> > > * santorini (apple,j457): iMac (24-inch, 2x USB-C, M1, 2020)
> > >
> > > Reviewed-by: Linus Walleij <[email protected]>
> > > Signed-off-by: Hector Martin <[email protected]>
> > > Signed-off-by: Russell King (Oracle) <[email protected]>
> > > ---
> >
> > Reviewed-by: Alvin Šipraga <[email protected]>
> >
> > > drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 2 ++
> > > drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++++
> > > .../net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 2 ++
> > > 3 files changed, 12 insertions(+)
> > >
> > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> > > index 23295fceb062..3026166a56c1 100644
> > > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> > > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
> > > @@ -733,6 +733,8 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
> > > return 0x160000;
> > > case CY_CC_43752_CHIP_ID:
> > > return 0x170000;
> > > + case BRCM_CC_4378_CHIP_ID:
> > > + return 0x352000;
> > > 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 269a516ae654..0c627f33049e 100644
> > > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> > > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
> > > @@ -59,6 +59,7 @@ BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
> > > BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
> > > BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
> > > BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
> > > +BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie");
> > >
> > > /* firmware config files */
> > > MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.txt");
> > > @@ -88,6 +89,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
> > > BRCMF_FW_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFFFFFF0, 4366C),
> > > BRCMF_FW_ENTRY(BRCM_CC_43666_CHIP_ID, 0xFFFFFFF0, 4366C),
> > > BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
> > > + BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFFF, 4378B1), /* 3 */
> >
> > What is /* 3 */?
>
> Hector says that it was mentioned in the prior review round as well.
> It's the revision ID. The mask allows all IDs for chips where no
> split has been seen, but if a new one comes up that comment is there
> so we know where to split the mask.

Alright, makes sense. If you happen to re-spin the series then it would
be nice to include this info in the commit message.

Kind regards,
Alvin

2022-09-16 08:00:04

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 12/12] arm64: dts: apple: Add WiFi module and antenna properties

Hector Martin <[email protected]> writes:

> On 13/09/2022 15.52, Kalle Valo wrote:
>> Russell King (Oracle) <[email protected]> writes:
>>
>>> From: Hector Martin <[email protected]>
>>>
>>> Add the new module-instance/antenna-sku properties required to select
>>> WiFi firmwares properly to all board device trees.
>>>
>>> Signed-off-by: Hector Martin <[email protected]>
>>> Reviewed-by: Mark Kettenis <[email protected]>
>>> Signed-off-by: Russell King (Oracle) <[email protected]>
>>> ---
>>> arch/arm64/boot/dts/apple/t8103-j274.dts | 4 ++++
>>> arch/arm64/boot/dts/apple/t8103-j293.dts | 4 ++++
>>> arch/arm64/boot/dts/apple/t8103-j313.dts | 4 ++++
>>> arch/arm64/boot/dts/apple/t8103-j456.dts | 4 ++++
>>> arch/arm64/boot/dts/apple/t8103-j457.dts | 4 ++++
>>> arch/arm64/boot/dts/apple/t8103-jxxx.dtsi | 2 ++
>>> 6 files changed, 22 insertions(+)
>>
>> I didn't get any reply to my question in v1 so I assume this patch 12 is
>> ok to take to wireless-next. ARM folks, if this is not ok please let me
>> know.
>
> Yup, this is OK to merge via wireless-next. In case you need it,
>
> Acked-by: Hector Martin <[email protected]>

Perfect, thanks.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2022-09-16 08:02:06

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH wireless-next v2 11/12] brcmfmac: pcie: Add IDs/properties for BCM4378

Alvin Šipraga <[email protected]> writes:

> On Thu, Sep 15, 2022 at 05:54:11PM +0100, Russell King (Oracle) wrote:
>> On Thu, Sep 15, 2022 at 03:34:59PM +0000, Alvin Šipraga wrote:
>> > On Mon, Sep 12, 2022 at 10:53:32AM +0100, Russell King wrote:
>> > > From: Hector Martin <[email protected]>
>> > >
>> > > This chip is present on Apple M1 (t8103) platforms:
>> > >
>> > > * atlantisb (apple,j274): Mac mini (M1, 2020)
>> > > * honshu (apple,j293): MacBook Pro (13-inch, M1, 2020)
>> > > * shikoku (apple,j313): MacBook Air (M1, 2020)
>> > > * capri (apple,j456): iMac (24-inch, 4x USB-C, M1, 2020)
>> > > * santorini (apple,j457): iMac (24-inch, 2x USB-C, M1, 2020)
>> > >
>> > > Reviewed-by: Linus Walleij <[email protected]>
>> > > Signed-off-by: Hector Martin <[email protected]>
>> > > Signed-off-by: Russell King (Oracle) <[email protected]>
>> > > ---
>> >
>> > Reviewed-by: Alvin Šipraga <[email protected]>
>> >
>> > > drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 2 ++
>> > > drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++++
>> > > .../net/wireless/broadcom/brcm80211/include/brcm_hw_ids.h | 2 ++
>> > > 3 files changed, 12 insertions(+)
>> > >
>> > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
>> > > index 23295fceb062..3026166a56c1 100644
>> > > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
>> > > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
>> > > @@ -733,6 +733,8 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
>> > > return 0x160000;
>> > > case CY_CC_43752_CHIP_ID:
>> > > return 0x170000;
>> > > + case BRCM_CC_4378_CHIP_ID:
>> > > + return 0x352000;
>> > > 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 269a516ae654..0c627f33049e 100644
>> > > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> > > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
>> > > @@ -59,6 +59,7 @@ BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
>> > > BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
>> > > BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
>> > > BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
>> > > +BRCMF_FW_CLM_DEF(4378B1, "brcmfmac4378b1-pcie");
>> > >
>> > > /* firmware config files */
>> > > MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.txt");
>> > > @@ -88,6 +89,7 @@ static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
>> > > BRCMF_FW_ENTRY(BRCM_CC_43664_CHIP_ID, 0xFFFFFFF0, 4366C),
>> > > BRCMF_FW_ENTRY(BRCM_CC_43666_CHIP_ID, 0xFFFFFFF0, 4366C),
>> > > BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
>> > > + BRCMF_FW_ENTRY(BRCM_CC_4378_CHIP_ID, 0xFFFFFFFF, 4378B1), /* 3 */
>> >
>> > What is /* 3 */?
>>
>> Hector says that it was mentioned in the prior review round as well.
>> It's the revision ID. The mask allows all IDs for chips where no
>> split has been seen, but if a new one comes up that comment is there
>> so we know where to split the mask.
>
> Alright, makes sense. If you happen to re-spin the series then it would
> be nice to include this info in the commit message.

And maybe even change the comment to something like:

/* revision ID 3 */

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches