From bb1f39e0c961de89a8d34ba1881931043a9d607a Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Tue, 26 Nov 2019 12:02:46 +0100 Subject: [PATCH] board: sunxi: Fix bdaddr generation for TBS A711 It doesn't have ethernet. Signed-off-by: Ondrej Jirman --- arch/arm/mach-sunxi/Kconfig | 1 - board/sunxi/board.c | 55 +++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 3cbabf390b2..0a5992aeee5 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1014,7 +1014,6 @@ config PINE64_DT_SELECTION config FIXUP_BDADDR string "Fixup the Bluetooth controller address" - depends on MACH_SUN50I_H6 default "" help This option specifies the DT compatible name of the Bluetooth diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 590a9533482..1d5b0559300 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -794,6 +794,7 @@ static void setup_environment(const void *fdt) unsigned int sid[4]; uint8_t mac_addr[6]; char ethaddr[16]; + uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN]; int i, ret; ret = sunxi_get_sid(sid); @@ -849,6 +850,30 @@ static void setup_environment(const void *fdt) env_set("serial#", serial_string); } + + /* Some devices ship with a Bluetooth controller default address. + * Set a valid address through the device tree. + */ +#ifdef CONFIG_FIXUP_BDADDR + if (CONFIG_FIXUP_BDADDR[0]) { + if (!eth_env_get_enetaddr("bdaddr", tmp)) { + tmp[0] = (5 << 4) | 0x02; + tmp[1] = (sid[0] >> 0) & 0xff; + tmp[2] = (sid[3] >> 24) & 0xff; + tmp[3] = (sid[3] >> 16) & 0xff; + tmp[4] = (sid[3] >> 8) & 0xff; + tmp[5] = (sid[3] >> 0) & 0xff; + } + + /* Addresses need to be in the binary format of the corresponding stack */ + for (i = 0; i < ETH_ALEN; ++i) + bdaddr[i] = tmp[ETH_ALEN - i - 1]; + + do_fixup_by_compat(fdt, CONFIG_FIXUP_BDADDR, + "local-bd-address", bdaddr, + ETH_ALEN, 1); + } +#endif } } @@ -881,34 +906,6 @@ int misc_init_r(void) return 0; } -static void fixup_bd_address(void *blob) -{ -#ifdef CONFIG_FIXUP_BDADDR - /* Some devices ship with a Bluetooth controller default address. - * Set a valid address through the device tree. - */ - uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN]; - int i; - - if (strlen(CONFIG_FIXUP_BDADDR) < 1) - return; - - if (!eth_env_get_enetaddr("bdaddr", tmp)) { - if (!eth_env_get_enetaddr("ethaddr", tmp)) - return; - - tmp[ETH_ALEN - 1] ^= 1; - } - - /* Addresses need to be in the binary format of the corresponding stack */ - for (i = 0; i < ETH_ALEN; ++i) - bdaddr[i] = tmp[ETH_ALEN - i - 1]; - - do_fixup_by_compat(blob, CONFIG_FIXUP_BDADDR, - "local-bd-address", bdaddr, ETH_ALEN, 1); -#endif -} - int ft_board_setup(void *blob, bd_t *bd) { int __maybe_unused r; @@ -919,8 +916,6 @@ int ft_board_setup(void *blob, bd_t *bd) */ setup_environment(blob); - fixup_bd_address(blob); - #ifdef CONFIG_VIDEO_DT_SIMPLEFB r = sunxi_simplefb_setup(blob); if (r)