Skip to content

Commit 85abc58

Browse files
committed
brcmfmac: common: Add support for external calibration blobs
The calibration blob for a chip is normally stored in SROM and loaded internally by the firmware. However, Apple ARM64 platforms instead store it as part of platform configuration data, and provide it via the Apple Device Tree. We forward this into the Linux DT in the bootloader. Add support for taking this blob from the DT and loading it into the dongle. The loading mechanism is the same as used for the CLM and TxCap blobs. Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Hector Martin <[email protected]>
1 parent 25db749 commit 85abc58

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,23 @@ static const u8 brcmf_default_mac_address[ETH_ALEN] = {
246246
0x00, 0x90, 0x4c, 0xc5, 0x12, 0x38
247247
};
248248

249+
static int brcmf_c_process_cal_blob(struct brcmf_if *ifp)
250+
{
251+
struct brcmf_pub *drvr = ifp->drvr;
252+
struct brcmf_mp_device *settings = drvr->settings;
253+
s32 err;
254+
255+
brcmf_dbg(TRACE, "Enter\n");
256+
257+
if (!settings->cal_blob || !settings->cal_size)
258+
return 0;
259+
260+
brcmf_info("Calibration blob provided by platform, loading\n");
261+
err = brcmf_c_download_blob(ifp, settings->cal_blob, settings->cal_size,
262+
"calload", "calload_status");
263+
return err;
264+
}
265+
249266
int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
250267
{
251268
struct brcmf_pub *drvr = ifp->drvr;
@@ -336,6 +353,13 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
336353
goto done;
337354
}
338355

356+
/* Download external calibration blob, if available */
357+
err = brcmf_c_process_cal_blob(ifp);
358+
if (err < 0) {
359+
bphy_err(drvr, "download calibration blob file failed, %d\n", err);
360+
goto done;
361+
}
362+
339363
/* query for 'ver' to get version info from firmware */
340364
memset(buf, 0, sizeof(buf));
341365
err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf));

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ struct brcmf_mp_device {
5454
const char *board_type;
5555
unsigned char mac[ETH_ALEN];
5656
const char *antenna_sku;
57+
const void *cal_blob;
58+
int cal_size;
5759
union {
5860
struct brcmfmac_sdio_pd sdio;
5961
} bus;

drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
8686
if (!of_property_read_string(np, "apple,antenna-sku", &prop))
8787
settings->antenna_sku = prop;
8888

89+
/* The WLAN calibration blob is normally stored in SROM, but Apple
90+
* ARM64 platforms pass it via the DT instead.
91+
*/
92+
prop = of_get_property(np, "brcm,cal-blob", &settings->cal_size);
93+
if (prop && settings->cal_size)
94+
settings->cal_blob = prop;
95+
8996
/* Set board-type to the first string of the machine compatible prop */
9097
root = of_find_node_by_path("/");
9198
if (root && err) {

0 commit comments

Comments
 (0)