arm64: dts: sun50i: Add support for Orange Pi 3
Subsystems (3)
v2 cover arm64: dts: sun50i: Add support for Orange Pi 3
Changes since v1:
* add CONFIG_FIXUP_BDADDR so fixing up a bdaddr is reusable
* try to use "bdaddr" first, then fall back to generating an address
Notes:
* the kernel patch for btbcm to accept the "local-bd-address" property just hit mainline.
Andre Heider (4):
sunxi: board: Use eth_env_set_enetaddr_by_index()
arm: sunxi: add a config option to fixup a Bluetooth address
arm64: dts: sync Allwinner H6 files
arm64: dts: sun50i: Add support for Orange Pi 3
arch/arm/dts/Makefile | 1 + arch/arm/dts/sun50i-h6-beelink-gs1.dts | 27 +++ arch/arm/dts/sun50i-h6-orangepi-3.dts | 287 +++++++++++++++++++++++++ arch/arm/dts/sun50i-h6-orangepi.dtsi | 4 + arch/arm/dts/sun50i-h6-pine-h64.dts | 4 + arch/arm/dts/sun50i-h6.dtsi | 137 ++++++++++-- arch/arm/mach-sunxi/Kconfig | 12 ++ board/sunxi/MAINTAINERS | 5 + board/sunxi/board.c | 40 +++- configs/orangepi_3_defconfig | 18 ++ 10 files changed, 509 insertions(+), 26 deletions(-) create mode 100644 arch/arm/dts/sun50i-h6-orangepi-3.dts create mode 100644 configs/orangepi_3_defconfig
Signature · 1 line
2.24.0
PATCH v2 1/4 sunxi: board: Use eth_env_set_enetaddr_by_index()
That helper takes care of assembling the correct name and doesn't allow overwriting existing env vars, so drop the checks here.
--- board/sunxi/board.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
board/sunxi/board.c +1 -9
@@ -807,14 +807,6 @@ static void setup_environment(const void *fdt)if (!fdt_get_alias (fdt, ethaddr))continue ; -if (i ==0 ) -strcpy (ethaddr,"ethaddr" ); -else -sprintf (ethaddr,"eth%daddr" , i); - -if (env_get (ethaddr)) -continue ; -/* Non OUI / registered MAC address */ mac_addr[0 ] = (i <<4 ) |0x02 ; mac_addr[1 ] = (sid[0 ] >>0 ) &0xff ;
@@ -823,7 +815,7 @@ static void setup_environment(const void *fdt) mac_addr[4 ] = (sid[3 ] >>8 ) &0xff ; mac_addr[5 ] = (sid[3 ] >>0 ) &0xff ; -eth_env_set_enetaddr (ethaddr, mac_addr); +eth_env_set_enetaddr_by_index ("eth" , i, mac_addr); }if (!env_get ("serial#" )) {
Signature · 1 line
2.24.0
PATCH v2 1/4 sunxi: board: Use eth_env_set_enetaddr_by_index()
Hello,
Quoted 28 lines · Andre Heider
That helper takes care of assembling the correct name and doesn't allow overwriting existing env vars, so drop the checks here.
Signed-off-by Andre Heider <[email protected]>--- board/sunxi/board.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)board/sunxi/board.c +0
-8@@ -807,14 +807,6 @@ static void setup_environment(const void *fdt)if (!fdt_get_alias (fdt, ethaddr))continue ; -if (i ==0 ) -strcpy (ethaddr,"ethaddr" ); -else -sprintf (ethaddr,"eth%daddr" , i); - -if (env_get (ethaddr)) -continue ; -/* Non OUI / registered MAC address */ mac_addr[0 ] = (i <<4 ) |0x02 ; mac_addr[1 ] = (sid[0 ] >>0 ) &0xff ;
board/sunxi/board.c static void setup_environment(const void *fdt) · line 818
Quoted 5 lines
board/sunxi/board.c +1
-1@@ -823,7 +815,7 @@ static void setup_environment(const void *fdt) mac_addr[4 ] = (sid[3 ] >>8 ) &0xff ; mac_addr[5 ] = (sid[3 ] >>0 ) &0xff ; -eth_env_set_enetaddr (ethaddr, mac_addr); +eth_env_set_enetaddr_by_index ("eth" , i, mac_addr);
This breaks the build with CONFIG_NET disabled in u-boot, since eth_env_set_enetaddr_by_index is only available in net/.
arm-linux-musleabihf-ld.bfd: board/sunxi/built-in.o: in function `setup_environment':board/sunxi/board.c:835: undefined reference to `eth_env_set_enetaddr_by_index'
See this thread for more info:
https://www.mail-archive.com/u-boot at lists.denx.de/msg340785.html
Use of eth_env_set_enetaddr is temporarily broken on master too, because this is still waiting to be merged:
https://www.mail-archive.com/u-boot at lists.denx.de/msg340882.html
regards,
o.
Quoted 6 lines
board/sunxi/board.c +0
-0}if (!env_get ("serial#" )) {Signature · 1 line
2.24.0
PATCH v2 1/4 sunxi: board: Use eth_env_set_enetaddr_by_index()
Quoted 43 lines · OndÅ™ej Jirman
Hello,
Quoted 28 lines · Andre Heider
That helper takes care of assembling the correct name and doesn't allow overwriting existing env vars, so drop the checks here.
Signed-off-by Andre Heider <[email protected]>--- board/sunxi/board.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)board/sunxi/board.c +0
-8@@ -807,14 +807,6 @@ static void setup_environment(const void *fdt)if (!fdt_get_alias (fdt, ethaddr))continue ; -if (i ==0 ) -strcpy (ethaddr,"ethaddr" ); -else -sprintf (ethaddr,"eth%daddr" , i); - -if (env_get (ethaddr)) -continue ; -/* Non OUI / registered MAC address */ mac_addr[0 ] = (i <<4 ) |0x02 ; mac_addr[1 ] = (sid[0 ] >>0 ) &0xff ;board/sunxi/board.c static void setup_environment(const void *fdt) · line 818
Quoted 5 lines
board/sunxi/board.c +1
-1@@ -823,7 +815,7 @@ static void setup_environment(const void *fdt) mac_addr[4 ] = (sid[3 ] >>8 ) &0xff ; mac_addr[5 ] = (sid[3 ] >>0 ) &0xff ; -eth_env_set_enetaddr (ethaddr, mac_addr); +eth_env_set_enetaddr_by_index ("eth" , i, mac_addr);This breaks the build with
CONFIG_NETdisabled in u-boot, sinceeth_env_set_enetaddr_by_indexis only available innet/.arm-linux-musleabihf-ld.bfd:
board/sunxi/built-in.o: in function `setup_environment':board/sunxi/board.c:835: undefined reference to `eth_env_set_enetaddr_by_index'
Quoted 7 lines
See this thread for more info:
https://www.mail-archive.com/u-boot at lists.denx.de/msg340785.htmlUse of
eth_env_set_enetaddris temporarily broken on master too, because this is still waiting to be merged:https://www.mail-archive.com/u-boot at lists.denx.de/msg340882.html
Ok, I'll drop the patch then, it was just a possible cleanup I stumbled upon anyway.
I applied the patch you linked to and it indeed fixes the build with CONFIG_NET=n.
Thanks,
Andre
PATCH v2 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
In reply to Andre HeiderSome 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.
--- arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++ board/sunxi/board.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)
arch/arm/mach-sunxi/Kconfig +12 -0
@@ -1009,4 +1009,16 @@ 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" + depends on MACH_SUN50I_H6 + 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
board/sunxi/board.c +30 -0
@@ -856,6 +856,34 @@ 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;
@@ -866,6 +894,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)
Signature · 1 line
2.24.0
PATCH v2 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
Hello Andre,
Quoted 4 lines · Andre Heider
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.
I tried it on TBS A711 tablet that also has bluetooth, but that doesn't have ethernet (ethernet alias is not set up) so no ethaddr gets generated and bdaddr setting fails due to dependency on ethernet alias being present.
So for this mechanism to be more universal, sid->mac_addr code probably needs to be moved to it's own function, and used both from setup_environment and fixup_bd_address, to avoid dependency on boards having ethernet.
Otherwise, on Orange Pi 3:
Also see the comment below:
Quoted 11 lines
Signed-off-by Andre Heider <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++ board/sunxi/board.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)arch/arm/mach-sunxi/Kconfig +0
-0
arch/arm/mach-sunxi/Kconfig config PINE64_DT_SELECTION · line 1014
Quoted 6 lines
arch/arm/mach-sunxi/Kconfig +3
-0@@ -1009,4 +1009,16 @@ 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" + depends on MACH_SUN50I_H6
^ This should be more sunxi generic or perhaps just removed, because the code is not specific to H6.
thank you and regards,
o.
Quoted 61 lines
arch/arm/mach-sunxi/Kconfig +9
-0+ 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. + endifboard/sunxi/board.c +30
-0@@ -856,6 +856,34 @@ 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;@@ -866,6 +894,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)Signature · 1 line
2.24.0
PATCH v2 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
Quoted 8 lines · megous hlavni
Hello Andre,
Quoted 4 lines · Andre Heider
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.
Quoted 7 lines
I tried it on TBS A711 tablet that also has bluetooth, but that doesn't have ethernet (ethernet alias is not set up) so no ethaddr gets generated and bdaddr setting fails due to dependency on ethernet alias being present.
So for this mechanism to be more universal,
sid->mac_addrcode probably needs to be moved to it's own function, and used both fromsetup_environmentandfixup_bd_address, to avoid dependency on boards having ethernet.
Or even simpler, just move the fixup_bd_address() code to setup_environment()
regards,
o.
Quoted 91 lines
Otherwise, on Orange Pi 3:
Tested-by Ondrej Jirman <[email protected]>Also see the comment below:
Quoted 11 lines
Signed-off-by Andre Heider <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++ board/sunxi/board.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)arch/arm/mach-sunxi/Kconfig +0
-0arch/arm/mach-sunxi/Kconfig config PINE64_DT_SELECTION · line 1014
Quoted 6 lines
arch/arm/mach-sunxi/Kconfig +3
-0@@ -1009,4 +1009,16 @@ 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" + depends on MACH_SUN50I_H6^ This should be more sunxi generic or perhaps just removed, because the code is not specific to H6.
thank you and regards,
o.Quoted 61 lines
arch/arm/mach-sunxi/Kconfig +9
-0+ 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. + endifboard/sunxi/board.c +30
-0@@ -856,6 +856,34 @@ 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;@@ -866,6 +894,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)Signature · 1 line
2.24.0
PATCH v2 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
In reply to Ondřej JirmanQuoted 8 lines · OndÅ™ej Jirman
Hello Andre,
Quoted 4 lines · Andre Heider
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.
Quoted 7 lines
I tried it on TBS A711 tablet that also has bluetooth, but that doesn't have ethernet (ethernet alias is not set up) so no ethaddr gets generated and bdaddr setting fails due to dependency on ethernet alias being present.
So for this mechanism to be more universal,
sid->mac_addrcode probably needs to be moved to it's own function, and used both fromsetup_environmentandfixup_bd_address, to avoid dependency on boards having ethernet.
Okay, I extracted a helper function locally, so it doesn't rely on "ethaddr". That should work on your tablet then I think. I'll wait a bit for further feedback before sending out v3.
Quoted 4 lines
Otherwise, on Orange Pi 3:
Tested-by Ondrej Jirman <[email protected]>
Nice, thanks!
Quoted 17 lines
Also see the comment below:
Quoted 14 lines
Signed-off-by Andre Heider <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++ board/sunxi/board.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)arch/arm/mach-sunxi/Kconfig +0
-0@@ -1009,4 +1009,16 @@ config PINE64_DT_SELECTION option, the device tree selection code specific to Pine64 which utilizes the DRAM size will be enabled.
Quoted 6 lines
arch/arm/mach-sunxi/Kconfig config PINE64_DT_SELECTION · line 1014
Quoted 3 lines
arch/arm/mach-sunxi/Kconfig +3
-0+config FIXUP_BDADDR + string "Fixup the Bluetooth controller address" + depends on MACH_SUN50I_H6^ This should be more sunxi generic or perhaps just removed, because the code is not specific to H6.
I didn't see a way to exclude fixup_bd_address() from compilation via #ifdefs when FIXUP_BDADDR is empty. And I didn't want to use 2 knobs (one to enable, one for the string).
Currently the function body has "if (strlen(CONFIG_FIXUP_BDADDR) < 1) return", and I *think* the compiler should be smart enough to just drop the whole thing if the string is empty. So the "depends on" is just a safety net to protect against code bloat for archs where it's currently unused anyway.
But I can drop it if there are no concerns.
Thanks,
Andre
Quoted 65 lines
thank you and regards,
o.Quoted 61 lines
arch/arm/mach-sunxi/Kconfig +9
-0+ 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. + endifboard/sunxi/board.c +30
-0@@ -856,6 +856,34 @@ 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;@@ -866,6 +894,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)Signature · 1 line
2.24.0
PATCH v2 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
Quoted 55 lines · Andre Heider
Quoted 8 lines · OndÅ™ej Jirman
Hello Andre,
Quoted 4 lines · Andre Heider
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.
Quoted 7 lines
I tried it on TBS A711 tablet that also has bluetooth, but that doesn't have ethernet (ethernet alias is not set up) so no ethaddr gets generated and bdaddr setting fails due to dependency on ethernet alias being present.
So for this mechanism to be more universal,
sid->mac_addrcode probably needs to be moved to it's own function, and used both fromsetup_environmentandfixup_bd_address, to avoid dependency on boards having ethernet.Okay, I extracted a helper function locally, so it doesn't rely on "ethaddr". That should work on your tablet then I think. I'll wait a bit for further feedback before sending out v3.
Quoted 4 lines
Otherwise, on Orange Pi 3:
Tested-by Ondrej Jirman <[email protected]>Nice, thanks!
Quoted 9 lines
Also see the comment below:
Quoted 6 lines
Signed-off-by Andre Heider <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++ board/sunxi/board.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)Quoted 13 lines
arch/arm/mach-sunxi/Kconfig config PINE64_DT_SELECTION · line 1013
Quoted 10 lines
arch/arm/mach-sunxi/Kconfig +3
-0@@ -1009,4 +1009,16 @@ 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" + depends on MACH_SUN50I_H6^ This should be more sunxi generic or perhaps just removed, because the code is not specific to H6.
I didn't see a way to exclude
fixup_bd_address()from compilation via #ifdefs whenFIXUP_BDADDRis empty. And I didn't want to use 2 knobs (one to enable, one for the string).
Quoted 6 lines
Currently the function body has "if (
strlen(CONFIG_FIXUP_BDADDR)< 1) return", and I *think* the compiler should be smart enough to just drop the whole thing if the string is empty. So the "depends on" is just a safety net to protect against code bloat for archs where it's currently unused anyway.But I can drop it if there are no concerns.
I understand, but this is useful for many more sunxi SoCs, so I think the small increase in main uboot size for sunxi boards is justified.
Anyway, I'd think using if (CONFIG_FIXUP_BDADDR[0]) would be a safer bet for compiler dropping the if body, rather than strlen.
regards,
o.
Quoted 67 lines
Thanks,
AndreQuoted 63 lines
thank you and regards,
o.Quoted 59 lines
arch/arm/mach-sunxi/Kconfig +9
-0+ 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. + endifboard/sunxi/board.c +30
-0@@ -856,6 +856,34 @@ 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;@@ -866,6 +894,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)Signature · 1 line
2.24.0
PATCH v2 2/4 arm: sunxi: add a config option to fixup a Bluetooth address
Quoted 61 lines · Ondřej Jirman
Quoted 60 lines · Andre Heider
Quoted 8 lines · Ondřej Jirman
Hello Andre,
Quoted 4 lines · Andre Heider
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.
Quoted 7 lines
I tried it on TBS A711 tablet that also has bluetooth, but that doesn't have ethernet (ethernet alias is not set up) so no ethaddr gets generated and bdaddr setting fails due to dependency on ethernet alias being present.
So for this mechanism to be more universal,
sid->mac_addrcode probably needs to be moved to it's own function, and used both fromsetup_environmentandfixup_bd_address, to avoid dependency on boards having ethernet.Okay, I extracted a helper function locally, so it doesn't rely on "ethaddr". That should work on your tablet then I think. I'll wait a bit for further feedback before sending out v3.
Quoted 4 lines
Otherwise, on Orange Pi 3:
Tested-by Ondrej Jirman <[email protected]>Nice, thanks!
Quoted 9 lines
Also see the comment below:
Quoted 6 lines
Signed-off-by Andre Heider <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++ board/sunxi/board.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)Quoted 13 lines
arch/arm/mach-sunxi/Kconfig config PINE64_DT_SELECTION · line 1013
Quoted 10 lines
arch/arm/mach-sunxi/Kconfig +3
-0@@ -1009,4 +1009,16 @@ 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" + depends on MACH_SUN50I_H6^ This should be more sunxi generic or perhaps just removed, because the code is not specific to H6.
I didn't see a way to exclude
fixup_bd_address()from compilation via #ifdefs whenFIXUP_BDADDRis empty. And I didn't want to use 2 knobs (one to enable, one for the string).Currently the function body has "if (
strlen(CONFIG_FIXUP_BDADDR)< 1) return", and I *think* the compiler should be smart enough to just drop the whole thing if the string is empty. So the "depends on" is just a safety net to protect against code bloat for archs where it's currently unused anyway.
Quoted 4 lines
Quoted 1 line
But I can drop it if there are no concerns.
I understand, but this is useful for many more sunxi SoCs, so I think the small increase in main uboot size for sunxi boards is justified.
Okay let me remove it then, but I'll go with what the maintainers deem acceptable.
Quoted 2 lines
Anyway, I'd think using
if (CONFIG_FIXUP_BDADDR[0])would be a safer bet for compiler dropping the if body, rather than strlen.
Yeah, that might just work, thanks!
Andre
PATCH v2 3/4 arm64: dts: sync Allwinner H6 files
In reply to Andre HeiderTaken from the kernel tag v5.4.
Drop the /omit-if-no-ref/ keyword as it's not supported by u-boot.
--- arch/arm/dts/sun50i-h6-beelink-gs1.dts | 27 +++++ arch/arm/dts/sun50i-h6-orangepi.dtsi | 4 + arch/arm/dts/sun50i-h6-pine-h64.dts | 4 + arch/arm/dts/sun50i-h6.dtsi | 137 ++++++++++++++++++++++--- 4 files changed, 155 insertions(+), 17 deletions(-)
arch/arm/dts/sun50i-h6-beelink-gs1.dts +27 -0
@@ -25,6 +25,7 @@ connector { compatible = "hdmi-connector"; type = "a"; + ddc-en-gpios = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */ port { hdmi_con_in: endpoint {
@@ -51,6 +52,24 @@ regulator-max-microvolt = <5000000>; regulator-always-on; }; + + sound-spdif { + compatible = "simple-audio-card"; + simple-audio-card,name = "sun50i-h6-spdif"; + + simple-audio-card,cpu { + sound-dai = <&spdif>; + }; + + simple-audio-card,codec { + sound-dai = <&spdif_out>; + }; + }; + + spdif_out: spdif-out { + #sound-dai-cells = <0>; + compatible = "linux,spdif-dit"; + }; }; &de {
@@ -232,6 +251,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &r_pio { /* * PL0 and PL1 are used for PMIC I2C
@@ -243,6 +266,10 @@ vcc-pm-supply = <®_aldo1>; }; +&spdif { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_ph_pins>;
arch/arm/dts/sun50i-h6-orangepi.dtsi +4 -0
@@ -189,6 +189,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_ph_pins>;
arch/arm/dts/sun50i-h6-pine-h64.dts +4 -0
@@ -255,6 +255,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &r_pio { vcc-pm-supply = <®_aldo1>; };
arch/arm/dts/sun50i-h6.dtsi +120 -17
248 lines not on this page · raw message
Signature · 1 line
2.24.0
PATCH v2 4/4 arm64: dts: sun50i: Add support for Orange Pi 3
In reply to Andre HeiderThe dts is taken from kernel tag v5.4.
The Bluetooth controller of this device ships with a default adress, use the new CONFIG_FIXUP_BDADDR option to fix it up.
--- arch/arm/dts/Makefile | 1 + arch/arm/dts/sun50i-h6-orangepi-3.dts | 287 ++++++++++++++++++++++++++ board/sunxi/MAINTAINERS | 5 + configs/orangepi_3_defconfig | 18 ++ 4 files changed, 311 insertions(+) create mode 100644 arch/arm/dts/sun50i-h6-orangepi-3.dts create mode 100644 configs/orangepi_3_defconfig
arch/arm/dts/Makefile +1 -0
@@ -540,6 +540,7 @@ dtb-$(CONFIG_MACH_SUN50I_H5) += \ sun50i-h5-orangepi-zero-plus2.dtb dtb-$(CONFIG_MACH_SUN50I_H6) += \ sun50i-h6-beelink-gs1.dtb \ + sun50i-h6-orangepi-3.dtb \ sun50i-h6-orangepi-lite2.dtb \ sun50i-h6-orangepi-one-plus.dtb \ sun50i-h6-pine-h64.dtb
arch/arm/dts/sun50i-h6-orangepi-3.dts new file +287 -0
287 lines not on this page · raw message
board/sunxi/MAINTAINERS +5 -0
@@ -375,6 +375,11 @@ M: Icenowy Zheng <[email protected]> S: Maintained F: configs/teres_i_defconfig +ORANGEPI 3 BOARD +M: Andre Heider <[email protected]> +S: Maintained +F: configs/orangepi_3_defconfig + ORANGEPI LITE2 BOARD M: Jagan Teki <[email protected]> S: Maintained
configs/orangepi_3_defconfig new file +18 -0
@@ -0,0 +1,18 @@ +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_SPL=y +CONFIG_MACH_SUN50I_H6=y +CONFIG_SUNXI_DRAM_H6_LPDDR3=y +CONFIG_MMC0_CD_PIN="PF6" +CONFIG_MMC_SUNXI_SLOT_EXTRA=2 +CONFIG_FIXUP_BDADDR="brcm,bcm4345c5" +# CONFIG_PSCI_RESET is not set +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_USE_PREBOOT=y +# CONFIG_CMD_FLASH is not set +# CONFIG_SPL_DOS_PARTITION is not set +# CONFIG_SPL_EFI_PARTITION is not set +CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-orangepi-3" +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_OHCI_HCD=y
Signature · 1 line
2.24.0