Message ID | 20191203084539.1956677-3-a.heider@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Jagannadha Sutradharudu Teki |
Headers | show |
Series | arm64: sun50i: Add support for Orange Pi 3 | expand |
On Tue, Dec 3, 2019 at 2:15 PM Andre Heider <a.heider@gmail.com> wrote: > > Some Bluetooth controllers, like the BCM4345C5 of the Orange Pi 3, > ship with the controller default address. > > Add a config option to fix it up so it can function properly. You mean that the default factory address can't make functioning? also does it affect the boot process?
On Tue, Jan 21, 2020 at 01:12:47PM +0530, Jagan Teki wrote: > On Tue, Dec 3, 2019 at 2:15 PM Andre Heider <a.heider@gmail.com> wrote: > > > > Some Bluetooth controllers, like the BCM4345C5 of the Orange Pi 3, > > ship with the controller default address. > > > > Add a config option to fix it up so it can function properly. > > You mean that the default factory address can't make functioning? also > does it affect the boot process? Yes. With the default address, bluetooth functionality is disabled in the controller, unless some other address is set. o.
On Tue, Jan 21, 2020 at 4:35 PM Ondřej Jirman <megous@megous.com> wrote: > > On Tue, Jan 21, 2020 at 01:12:47PM +0530, Jagan Teki wrote: > > On Tue, Dec 3, 2019 at 2:15 PM Andre Heider <a.heider@gmail.com> wrote: > > > > > > Some Bluetooth controllers, like the BCM4345C5 of the Orange Pi 3, > > > ship with the controller default address. > > > > > > Add a config option to fix it up so it can function properly. > > > > You mean that the default factory address can't make functioning? also > > does it affect the boot process? > > Yes. With the default address, bluetooth functionality is disabled in the > controller, unless some other address is set. What about adding u-boot property instead of CONFIG macro. it would be easy to add it on board spec -u-boot.dtsi.
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 16d41b83af..4513c07ffb 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1009,4 +1009,15 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled. +config FIXUP_BDADDR + string "Fixup the Bluetooth controller address" + default "" + help + This option specifies the DT compatible name of the Bluetooth + controller for which to set the "local-bd-address" property. + Set this option if your device ships with the Bluetooth controller + default address. + The used address is "bdaddr" if set, and "ethaddr" with the LSB + flipped elsewise. + endif diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 42bec3a4d8..4311d4cba2 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -876,6 +876,38 @@ int misc_init_r(void) return 0; } +static void fixup_bd_address(void *blob) +{ + /* Some devices ship with a Bluetooth controller default address. + * Set a valid address through the device tree. + */ + uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN]; + unsigned int sid[4]; + int i; + + if (!CONFIG_FIXUP_BDADDR[0]) + return; + + if (eth_env_get_enetaddr("bdaddr", tmp)) { + /* Convert between the binary formats of the corresponding stacks */ + for (i = 0; i < ETH_ALEN; ++i) + bdaddr[i] = tmp[ETH_ALEN - i - 1]; + } else { + if (!get_unique_sid(sid)) + return; + + bdaddr[0] = ((sid[3] >> 0) & 0xff) ^ 1; + bdaddr[1] = (sid[3] >> 8) & 0xff; + bdaddr[2] = (sid[3] >> 16) & 0xff; + bdaddr[3] = (sid[3] >> 24) & 0xff; + bdaddr[4] = (sid[0] >> 0) & 0xff; + bdaddr[5] = 0x02; + } + + do_fixup_by_compat(blob, CONFIG_FIXUP_BDADDR, + "local-bd-address", bdaddr, ETH_ALEN, 1); +} + int ft_board_setup(void *blob, bd_t *bd) { int __maybe_unused r; @@ -886,6 +918,8 @@ 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)