From d27b915da64b5e3bc2f672cc8757ce523bf1b89c Mon Sep 17 00:00:00 2001 From: Ilia Lin Date: Sat, 2 Jul 2016 15:43:50 +0300 Subject: [PATCH] aboot: set wcnss-bt local-mac-address in DTS 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 --- platform/msm_shared/dev_tree.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c index 8a1dc95dc..a5635e31f 100755 --- a/platform/msm_shared/dev_tree.c +++ b/platform/msm_shared/dev_tree.c @@ -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; } }