kboot: Provide antenna SKU in device tree

Read the antenna SKU from the ADT and store it in a
"apple,antenna-sku" property on the relevant node in the FDT.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
This commit is contained in:
Mark Kettenis 2021-12-20 22:45:06 +01:00 committed by Hector Martin
parent 054e437c31
commit 36954d51fd

View file

@ -293,6 +293,32 @@ static int dt_set_mac_addresses(void)
return 0;
}
static int dt_set_antenna(void)
{
int anode = adt_path_offset(adt, "/arm-io/wlan");
if (anode < 0)
bail("ADT: /arm-io/wlan not found\n");
uint8_t info[16];
if (ADT_GETPROP_ARRAY(adt, anode, "wifi-antenna-sku-info", info) < 0)
bail("ADT: Failed to get wifi-antenna-sku-info");
const char *path = fdt_get_alias(dt, "wifi0");
if (path == NULL)
return 0;
int node = fdt_path_offset(dt, path);
if (node < 0)
return 0;
char antenna[8];
memcpy(antenna, &info[8], sizeof(antenna));
fdt_setprop_string(dt, node, "apple,antenna-sku", antenna);
return 0;
}
static int dt_disable_missing_devs(const char *adt_prefix, const char *dt_prefix, int max_devs)
{
int ret = -1;
@ -451,6 +477,8 @@ int kboot_prepare_dt(void *fdt)
return -1;
if (dt_set_mac_addresses())
return -1;
if (dt_set_antenna())
return -1;
if (dt_disable_missing_devs("usb-drd", "usb@", 8))
return -1;
if (dt_disable_missing_devs("i2c", "i2c@", 8))