Skip to content

Commit

Permalink
aboot: set wcnss-bt local-mac-address in DTS
Browse files Browse the repository at this point in the history
Set local-mac-address for the WCNSS BT node, if not set already.
To set it, we rely on the unique SN provided the target library
(typicall the eMMC CID).

The SN is formatted as an 8-char number with leading zero's if needed. The MAC
address is formed by adding '20:00' in front of the SN number to make sure that
we use a MAC address from the locally adminstrated pool.
The implementation is same as for wcnss-wlan MAC address,
but the last bit is flipped to differ between the two addresses.

Change-Id: I3e22ee96cf365aa8a3beee450987628aee835371
(cherry picked from commit f106f9387188ceb3694e654b503c00ed406bbafb)
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
  • Loading branch information
aff-tar authored and ndechesne committed Dec 8, 2016
1 parent 4336c26 commit d27b915
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions platform/msm_shared/dev_tree.c
Expand Up @@ -1367,12 +1367,33 @@ int update_device_tree(void *fdt, const char *cmdline,
{
if (fdt_getprop(fdt, offset, "local-mac-address", NULL) == NULL)
{
dprintf(INFO, "Setting mac address in DT: %x:%x:%x:%x:%x:%x\n",
dprintf(INFO, "Setting WLAN mac address in DT: %02X:%02X:%02X:%02X:%02X:%02X\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
ret = fdt_setprop(fdt, offset, "local-mac-address", mac, 6);
if (ret)
{
dprintf(CRITICAL, "ERROR: cannot set local-mac-address\n");
dprintf(CRITICAL, "ERROR: cannot set local-mac-address for \"qcom,wcnss-wlan\"\n");
return ret;
}
}
}

/* make sure local-mac-address is set for WCN BT device */
offset = fdt_node_offset_by_compatible(fdt, -1, "qcom,wcnss-bt");

if (offset != -FDT_ERR_NOTFOUND)
{
if (fdt_getprop(fdt, offset, "local-mac-address", NULL) == NULL)
{
/* The BT MAC address is same as WLAN MAC address but with last bit flipped */
mac[5] = (mac[5] & 0xFE) | ((mac[5] ^ 0x1) & 0x1);

dprintf(INFO, "Setting BT mac address in DT: %02X:%02X:%02X:%02X:%02X:%02X\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
ret = fdt_setprop(fdt, offset, "local-mac-address", mac, 6);
if (ret)
{
dprintf(CRITICAL, "ERROR: cannot set local-mac-address for \"qcom,wcnss-bt\"\n");
return ret;
}
}
Expand Down

0 comments on commit d27b915

Please sign in to comment.