xref: /linux/drivers/net/wireless/broadcom/brcm80211/brcmfmac/acpi.c (revision 0526b56cbc3c489642bd6a5fe4b718dea7ef0ee8)
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 		return;
31 	}
32 
33 	status = acpi_evaluate_object(adev->handle, "RWCV", NULL, &buf);
34 	o = buf.pointer;
35 	if (!ACPI_FAILURE(status) && o && o->type == ACPI_TYPE_BUFFER &&
36 	    o->buffer.length >= 2) {
37 		char *antenna_sku = devm_kzalloc(dev, 3, GFP_KERNEL);
38 
39 		if (antenna_sku) {
40 			memcpy(antenna_sku, o->buffer.pointer, 2);
41 			brcmf_dbg(INFO, "ACPI RWCV data=%*phN antenna-sku=%s\n",
42 				  (int)o->buffer.length, o->buffer.pointer,
43 				  antenna_sku);
44 			settings->antenna_sku = antenna_sku;
45 		}
46 
47 		kfree(buf.pointer);
48 	} else {
49 		brcmf_dbg(INFO, "No ACPI antenna-sku\n");
50 	}
51 }
52