Skip to content

Commit 27ea7b8

Browse files
committed
brcmfmac: acpi: Add support for fetching Apple ACPI properties
On DT platforms, the module-instance and antenna-sku-info properties are passed in the DT. On ACPI platforms, module-instance is passed via the analogous Apple device property mechanism, while the antenna SKU info is instead obtained via an ACPI method that grabs it from non-volatile storage. Add support for this, to allow proper firmware selection on Apple platforms. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 128223b commit 27ea7b8

4 files changed

Lines changed: 64 additions & 0 deletions

File tree

drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ brcmfmac-$(CONFIG_OF) += \
4848
of.o
4949
brcmfmac-$(CONFIG_DMI) += \
5050
dmi.o
51+
brcmfmac-$(CONFIG_ACPI) += \
52+
acpi.o
5153

5254
ifeq ($(CONFIG_BRCMFMAC),m)
5355
obj-m += wcc/
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-License-Identifier: ISC
2+
/*
3+
* Copyright The Asahi Linux Contributors
4+
*/
5+
6+
#include <linux/acpi.h>
7+
#include "debug.h"
8+
#include "core.h"
9+
#include "common.h"
10+
11+
void brcmf_acpi_probe(struct device *dev, enum brcmf_bus_type bus_type,
12+
struct brcmf_mp_device *settings)
13+
{
14+
acpi_status status;
15+
const union acpi_object *o;
16+
struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
17+
struct acpi_device *adev = ACPI_COMPANION(dev);
18+
19+
if (!adev)
20+
return;
21+
22+
if (!ACPI_FAILURE(acpi_dev_get_property(adev, "module-instance",
23+
ACPI_TYPE_STRING, &o))) {
24+
brcmf_dbg(INFO, "ACPI module-instance=%s\n", o->string.pointer);
25+
settings->board_type = devm_kasprintf(dev, GFP_KERNEL,
26+
"apple,%s",
27+
o->string.pointer);
28+
} else {
29+
brcmf_dbg(INFO, "No ACPI module-instance\n");
30+
}
31+
32+
status = acpi_evaluate_object(adev->handle, "RWCV", NULL, &buf);
33+
o = buf.pointer;
34+
if (!ACPI_FAILURE(status) && o && o->type == ACPI_TYPE_BUFFER &&
35+
o->buffer.length >= 2) {
36+
char *antenna_sku = devm_kzalloc(dev, 3, GFP_KERNEL);
37+
38+
if (!antenna_sku) {
39+
brcmf_err("Failed to allocate antenna-sku");
40+
} else {
41+
memcpy(antenna_sku, o->buffer.pointer, 2);
42+
brcmf_dbg(INFO, "ACPI RWCV data=%*phN antenna-sku=%s\n",
43+
(int)o->buffer.length, o->buffer.pointer,
44+
antenna_sku);
45+
settings->antenna_sku = antenna_sku;
46+
}
47+
48+
kfree(buf.pointer);
49+
} else {
50+
brcmf_dbg(INFO, "No ACPI antenna-sku\n");
51+
}
52+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
487487
/* No platform data for this device, try OF and DMI data */
488488
brcmf_dmi_probe(settings, chip, chiprev);
489489
brcmf_of_probe(dev, bus_type, settings);
490+
brcmf_acpi_probe(dev, bus_type, settings);
490491
}
491492
return settings;
492493
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ static inline void
7777
brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev) {}
7878
#endif
7979

80+
#ifdef CONFIG_ACPI
81+
void brcmf_acpi_probe(struct device *dev, enum brcmf_bus_type bus_type,
82+
struct brcmf_mp_device *settings);
83+
#else
84+
static inline void brcmf_acpi_probe(struct device *dev,
85+
enum brcmf_bus_type bus_type,
86+
struct brcmf_mp_device *settings) {}
87+
#endif
88+
8089
u8 brcmf_map_prio_to_prec(void *cfg, u8 prio);
8190

8291
u8 brcmf_map_prio_to_aci(void *cfg, u8 prio);

0 commit comments

Comments
 (0)