From: Stephan Gerhold Date: Mon, 7 Apr 2025 16:59:24 +0000 (+0200) Subject: board: dragonboard410c: Fix BD address X-Git-Tag: v2025.07-rc1~78^2~10 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cc2dc23360144129ab2f5e39356fae93c479dcc;p=pandora-u-boot.git board: dragonboard410c: Fix BD address local-bd-address in the device tree needs to be formatted with the least significant byte first (i.e. little endian). We're not doing this when adding it to the DT, which means the MAC address ends up being reversed in Linux. Fix this by reversing the array before setting it in the DT. We're also flipping the wrong bit when generating the BD address. Before reversing the array, the least significant bit is in the last byte. Fixes: ff06dc240325 ("db410: alter WLAN/BT MAC address fixup") Signed-off-by: Stephan Gerhold Reviewed-by: Neil Armstrong Reviewed-by: Link: https://lore.kernel.org/r/20250407-db410c-fixes-v1-3-524aefbc8bb4@linaro.org Signed-off-by: Caleb Connolly --- diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c index d0d82489f53..744ac4fda8e 100644 --- a/board/qualcomm/dragonboard410c/dragonboard410c.c +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c @@ -97,9 +97,9 @@ int qcom_late_init(void) return 0; } -/* Fixup of DTB for Linux Kernel - * 1. Fixup installed DRAM. - * 2. Fixup WLAN/BT Mac address: +/* + * Fixup of DTB for Linux Kernel + * 1. Fixup WLAN/BT Mac address: * First, check if MAC addresses for WLAN/BT exists as environemnt * variables wlanaddr,btaddr. if not, generate a unique address. */ @@ -107,6 +107,7 @@ int qcom_late_init(void) int ft_board_setup(void *blob, struct bd_info *bd) { u8 mac[ARP_HLEN]; + int i; if (!eth_env_get_enetaddr("wlanaddr", mac)) { msm_generate_mac_addr(mac); @@ -118,12 +119,24 @@ int ft_board_setup(void *blob, struct bd_info *bd) if (!eth_env_get_enetaddr("btaddr", mac)) { msm_generate_mac_addr(mac); -/* The BD address is same as WLAN MAC address but with - * least significant bit flipped. - */ - mac[0] ^= 0x01; + /* + * The BD address is same as WLAN MAC address but with + * least significant bit flipped. + */ + mac[ARP_HLEN - 1] ^= 0x01; }; + /* + * Reverse array since local-bd-address is formatted with least + * significant byte first (little endian). + */ + for (i = 0; i < ARP_HLEN / 2; ++i) { + u8 tmp = mac[i]; + + mac[i] = mac[ARP_HLEN - 1 - i]; + mac[ARP_HLEN - 1 - i] = tmp; + } + do_fixup_by_compat(blob, "qcom,wcnss-bt", "local-bd-address", mac, ARP_HLEN, 1); return 0;