diff options
| author | Loic Poulain <loic.poulain@linaro.org> | 2017-09-11 15:07:19 +0200 |
|---|---|---|
| committer | Nicolas Dechesne <nicolas.dechesne@linaro.org> | 2017-09-12 08:10:23 +0000 |
| commit | 372982a4d4c4922e9214ff7d6aa5348aaba602a7 (patch) | |
| tree | 739610e4fb4695738769ea673df594d8fc861ee9 | |
| parent | 69abeab702a8c7ce8ed6b984cbd0307da21918ee (diff) | |
| download | lk-372982a4d4c4922e9214ff7d6aa5348aaba602a7.tar.gz | |
dev_tree: Add local-bd-address property to BT node
A local-bd-address is now expected by the Bluetooth driver
in order to set the bluetooth controller unique address.
Contrary to local-mac-address, the local-bd-address must
be formatted with least significant byte first (little-endian).
Keep the local-mac-address BT node property in order to guaranty
compatibility with existing user-space scripts and non-patched
kernel.
Change-Id: I91779009194977f619f0ad6c45117b8d3cd8288b
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
| -rwxr-xr-x | platform/msm_shared/dev_tree.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c index a5635e3..c7b7f66 100755 --- a/platform/msm_shared/dev_tree.c +++ b/platform/msm_shared/dev_tree.c @@ -1378,11 +1378,40 @@ int update_device_tree(void *fdt, const char *cmdline, } } - /* make sure local-mac-address is set for WCN BT device */ + /* make sure local-bd-address (and legacy 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-bd-address", NULL) == NULL) + { + unsigned char bdaddr[6]; + unsigned int i; + + /* local-bd-addr is expected with least significant bytes + * first (little endian format), reverse mac address. + */ + for (i = 0; i < sizeof(bdaddr); i++) + bdaddr[i] = mac[sizeof(bdaddr) - 1 - i]; + + /* The BD address is same as WLAN MAC address but with + * least significant bit flipped. + */ + bdaddr[0] ^= 0x01; + + dprintf(INFO, "Setting Bluetooth BD address in DT:" + " %02X:%02X:%02X:%02X:%02X:%02X\n", + bdaddr[5], bdaddr[4], bdaddr[3], + bdaddr[2], bdaddr[1], bdaddr[0]); + + ret = fdt_setprop(fdt, offset, "local-bd-address", bdaddr, 6); + if (ret) { + dprintf(CRITICAL, "ERROR: cannot set local-bd-address for \"qcom,wcnss-bt\"\n"); + return ret; + } + } + + /* Legacy (deprecated) local-mac-address */ 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 */ |
