Skip to contentSkip to conversation

arm64: dts: sun50i: Add support for Orange Pi 3

PATCH Superseded Andre Heider 2 participants 12 messages Nov 26, 2019

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index e3b2d13892..bb35d6b66e 100644
@@ -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
#2 lore raw

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.

---
 board/sunxi/board.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
board/sunxi/board.c +0 -8
index e3b2d13892..bb35d6b66e 100644
@@ -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
#3 lore raw

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.

---
  board/sunxi/board.c | 10 +---------
  1 file changed, 1 insertion(+), 9 deletions(-)
board/sunxi/board.c +0 -8
index e3b2d13892..bb35d6b66e 100644
@@ -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'

Quoted 7 lines

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

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

#4 lore raw

PATCH v2 2/4 arm: sunxi: add a config option to fixup a Bluetooth address

In reply to 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.

---
 arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++
 board/sunxi/board.c         | 30 ++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
arch/arm/mach-sunxi/Kconfig +12 -0
index 16d41b83af..b41c64870e 100644
@@ -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
index bb35d6b66e..89851102d1 100644
@@ -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
#5 lore raw

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
---
 arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++
 board/sunxi/board.c         | 30 ++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
arch/arm/mach-sunxi/Kconfig +0 -0
index 16d41b83af..b41c64870e 100644

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.
+
 endif
board/sunxi/board.c +30 -0
index bb35d6b66e..89851102d1 100644
@@ -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
#6 lore raw

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_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.

Or even simpler, just move the fixup_bd_address() code to setup_environment()

regards,

	o.
Quoted 91 lines

Otherwise, on Orange Pi 3:

Also see the comment below:

Quoted 11 lines
---
 arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++
 board/sunxi/board.c         | 30 ++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
arch/arm/mach-sunxi/Kconfig +0 -0
index 16d41b83af..b41c64870e 100644

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.
+
 endif
board/sunxi/board.c +30 -0
index bb35d6b66e..89851102d1 100644
@@ -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
#7 lore raw

PATCH v2 2/4 arm: sunxi: add a config option to fixup a Bluetooth address

In reply to Ondřej Jirman
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_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.

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:

Nice, thanks!

Quoted 17 lines

Also see the comment below:

Quoted 14 lines
---
  arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++
  board/sunxi/board.c         | 30 ++++++++++++++++++++++++++++++
  2 files changed, 42 insertions(+)
arch/arm/mach-sunxi/Kconfig +0 -0
index 16d41b83af..b41c64870e 100644
@@ -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.
+
  endif
board/sunxi/board.c +30 -0
index bb35d6b66e..89851102d1 100644
@@ -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
#8 lore raw

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_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.

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:

Nice, thanks!

Quoted 9 lines

Also see the comment below:

Quoted 6 lines
---
  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
index 16d41b83af..b41c64870e 100644
@@ -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 when FIXUP_BDADDR is 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,
Andre

Quoted 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.
+
  endif
board/sunxi/board.c +30 -0
index bb35d6b66e..89851102d1 100644
@@ -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
#9 lore raw

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_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.

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:

Nice, thanks!

Quoted 9 lines

Also see the comment below:

Quoted 6 lines
---
   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
index 16d41b83af..b41c64870e 100644
@@ -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 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.

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

#10 lore raw

PATCH v2 3/4 arm64: dts: sync Allwinner H6 files

In reply to Andre Heider

Taken 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
index 0dc33c90dd..1d05d57014 100644
@@ -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 = <&reg_aldo1>;
 };
 
+&spdif {
+	status = "okay";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_ph_pins>;
arch/arm/dts/sun50i-h6-orangepi.dtsi +4 -0
index 62e27948a3..ec9b6a578e 100644
@@ -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
index 1898345183..30102daf83 100644
@@ -255,6 +255,10 @@
 	};
 };
 
+&r_ir {
+	status = "okay";
+};
+
 &r_pio {
 	vcc-pm-supply = <&reg_aldo1>;
 };
arch/arm/dts/sun50i-h6.dtsi +120 -17

248 lines not on this page · raw message

Signature · 1 line
2.24.0
#11 lore raw

PATCH v2 4/4 arm64: dts: sun50i: Add support for Orange Pi 3

In reply to Andre Heider

The 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
index d8846df1bd..5040d4f50d 100644
@@ -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
index a2adf89b5d..3c0fd0cae8 100644
@@ -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
new file mode 100644
index 0000000000..c9db0abb77
@@ -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