Skip to contentSkip to conversation

arm64: dts: sync Allwinner H6 files

PATCH New Andre Heider 3 participants 9 messages Nov 22, 2019 – Nov 23, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 arm64: dts: sync Allwinner H6 files

Taken from the kernel tag v5.4-rc8.
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
#1 lore raw

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

The dts is taken from kernel tag v5.4-rc8.

---
 arch/arm/dts/Makefile                 |   1 +
 arch/arm/dts/sun50i-h6-orangepi-3.dts | 287 ++++++++++++++++++++++++++
 board/sunxi/MAINTAINERS               |   5 +
 configs/orangepi_3_defconfig          |  17 ++
 4 files changed, 310 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 +17 -0
new file mode 100644
index 0000000000..b2084013cf
@@ -0,0 +1,17 @@
+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_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
#2 lore raw

PATCH 3/4 sunxi: board: Use eth_env_set_enetaddr_by_index()

In reply to 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 +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
#3 lore raw

PATCH 4/4 sunxi: board: fixup the BT address for Orange Pi 3

In reply to Andre Heider

The BCM4345C5 of the Orange Pi 3 ships with the controller default address. Fix it up so it can function properly.

The used address is "ethaddr" with the LSB flipped.

---

NOTE:
"local-bd-address" is a universal property, the kernel patch for btbcm to use that is in bluetooth-next.

 board/sunxi/board.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
board/sunxi/board.c +28 -0
index bb35d6b66e..2897bf45e1 100644
@@ -856,6 +856,32 @@ int misc_init_r(void)
 	return 0;
 }
 
+static void fixup_bd_address(void *blob)
+{
+#if defined(CONFIG_MACH_SUN50I_H6)
+	/* Some devices ship with the controller default address.
+	 * Set a valid address through the device tree.
+	 */
+	uchar mac[ETH_ALEN], bdaddr[ETH_ALEN];
+	int i;
+
+	if (!of_machine_is_compatible("xunlong,orangepi-3"))
+		return;
+
+	if (!eth_env_get_enetaddr("ethaddr", mac))
+		return;
+
+	/* Addresses need to be in the binary format of the corresponding stack */
+	for (i = 0; i < ETH_ALEN; ++i)
+		bdaddr[i] = mac[ETH_ALEN - i - 1];
+
+	bdaddr[0] ^= 1;
+
+	do_fixup_by_compat(blob, "brcm,bcm4345c5",
+			   "local-bd-address", bdaddr, ETH_ALEN, 1);
+#endif
+}
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
 	int __maybe_unused r;
@@ -866,6 +892,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
#4 lore raw

PATCH 4/4 sunxi: board: fixup the BT address for Orange Pi 3

Hello,

Quoted 2 lines · Andre Heider

The BCM4345C5 of the Orange Pi 3 ships with the controller default address. Fix it up so it can function properly.

This is very nice!

Quoted 17 lines

The used address is "ethaddr" with the LSB flipped.

---

NOTE:
"local-bd-address" is a universal property, the kernel patch for btbcm to use that is in bluetooth-next.

 board/sunxi/board.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
board/sunxi/board.c +0 -0
index bb35d6b66e..2897bf45e1 100644

board/sunxi/board.c int misc_init_r(void) · line 861

Quoted 6 lines
board/sunxi/board.c +3 -0
@@ -856,6 +856,32 @@ int misc_init_r(void)
 	return 0;
 }
 
+static void fixup_bd_address(void *blob)
+{
+#if defined(CONFIG_MACH_SUN50I_H6)

This sounds useful for other sunxi boards too (many ship with broadcom BT chips with unassigned addresses), can we have a generic config for the fixup?

Something like CONFIG_SUNXI_BTADDR_FIXUP that can be enabled in defconfig files, or pre-selected/implied by CONFIG_MACH_SUN* that may want it on by default?

board/sunxi/board.c int misc_init_r(void) · line 869

Quoted 8 lines
board/sunxi/board.c +8 -0
+	/* Some devices ship with the controller default address.
+	 * Set a valid address through the device tree.
+	 */
+	uchar mac[ETH_ALEN], bdaddr[ETH_ALEN];
+	int i;
+
+	if (!of_machine_is_compatible("xunlong,orangepi-3"))
+		return;

You don't need to limit this to opi3 only.

thank you and regards,

	o.
Quoted 30 lines
board/sunxi/board.c +17 -0
+
+	if (!eth_env_get_enetaddr("ethaddr", mac))
+		return;
+
+	/* Addresses need to be in the binary format of the corresponding stack */
+	for (i = 0; i < ETH_ALEN; ++i)
+		bdaddr[i] = mac[ETH_ALEN - i - 1];
+
+	bdaddr[0] ^= 1;
+
+	do_fixup_by_compat(blob, "brcm,bcm4345c5",
+			   "local-bd-address", bdaddr, ETH_ALEN, 1);
+#endif
+}
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
 	int __maybe_unused r;
@@ -866,6 +892,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 4/4 sunxi: board: fixup the BT address for Orange Pi 3

Hey Ondřej,

Quoted 36 lines · Ondřej Jirman

Hello,

Quoted 2 lines · Andre Heider

The BCM4345C5 of the Orange Pi 3 ships with the controller default address. Fix it up so it can function properly.

This is very nice!

Quoted 17 lines

The used address is "ethaddr" with the LSB flipped.

---

NOTE:
"local-bd-address" is a universal property, the kernel patch for btbcm to use that is in bluetooth-next.

  board/sunxi/board.c | 28 ++++++++++++++++++++++++++++
  1 file changed, 28 insertions(+)
board/sunxi/board.c +0 -0
index bb35d6b66e..2897bf45e1 100644

board/sunxi/board.c int misc_init_r(void) · line 861

Quoted 6 lines
board/sunxi/board.c +3 -0
@@ -856,6 +856,32 @@ int misc_init_r(void)
  	return 0;
  }
 
+static void fixup_bd_address(void *blob)
+{
+#if defined(CONFIG_MACH_SUN50I_H6)

This sounds useful for other sunxi boards too (many ship with broadcom BT chips with unassigned addresses), can we have a generic config for the fixup?

Quoted 3 lines

Something like CONFIG_SUNXI_BTADDR_FIXUP that can be enabled in defconfig files, or pre-selected/implied by CONFIG_MACH_SUN* that may want it on by default?

sure, we can do that, but note there's "brcm,bcm4345c5" used below, hence me limiting it to opi3 for now.

So we either need to have something like
CONFIG_SUNXI_BTADDR_FIXUP="brcm,bcm4345c5"
or a dts "bluetooth" alias we can refer to.

I'd go for the former, would that be an acceptable solution?

Thanks,
Andre

Quoted 45 lines

board/sunxi/board.c int misc_init_r(void) · line 869

Quoted 9 lines
board/sunxi/board.c +8 -0
+	/* Some devices ship with the controller default address.
+	 * Set a valid address through the device tree.
+	 */
+	uchar mac[ETH_ALEN], bdaddr[ETH_ALEN];
+	int i;
+
+	if (!of_machine_is_compatible("xunlong,orangepi-3"))
+		return;

You don't need to limit this to opi3 only.

thank you and regards,

	o.
Quoted 30 lines
board/sunxi/board.c +17 -0
+
+	if (!eth_env_get_enetaddr("ethaddr", mac))
+		return;
+
+	/* Addresses need to be in the binary format of the corresponding stack */
+	for (i = 0; i < ETH_ALEN; ++i)
+		bdaddr[i] = mac[ETH_ALEN - i - 1];
+
+	bdaddr[0] ^= 1;
+
+	do_fixup_by_compat(blob, "brcm,bcm4345c5",
+			   "local-bd-address", bdaddr, ETH_ALEN, 1);
+#endif
+}
+
  int ft_board_setup(void *blob, bd_t *bd)
  {
  	int __maybe_unused r;
@@ -866,6 +892,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 4/4 sunxi: board: fixup the BT address for Orange Pi 3

Hi,

Quoted 42 lines · Andre Heider

Hey Ondřej,

Quoted 35 lines · Ondřej Jirman

Hello,

Quoted 2 lines · Andre Heider

The BCM4345C5 of the Orange Pi 3 ships with the controller default address. Fix it up so it can function properly.

This is very nice!

Quoted 17 lines

The used address is "ethaddr" with the LSB flipped.

---

NOTE:
"local-bd-address" is a universal property, the kernel patch for btbcm to use that is in bluetooth-next.

  board/sunxi/board.c | 28 ++++++++++++++++++++++++++++
  1 file changed, 28 insertions(+)
board/sunxi/board.c +0 -0
index bb35d6b66e..2897bf45e1 100644

board/sunxi/board.c int misc_init_r(void) · line 860

Quoted 5 lines
board/sunxi/board.c +3 -0
@@ -856,6 +856,32 @@ int misc_init_r(void)
  	return 0;
  }
+static void fixup_bd_address(void *blob)
+{
+#if defined(CONFIG_MACH_SUN50I_H6)

This sounds useful for other sunxi boards too (many ship with broadcom BT chips with unassigned addresses), can we have a generic config for the fixup?

Quoted 3 lines

Something like CONFIG_SUNXI_BTADDR_FIXUP that can be enabled in defconfig files, or pre-selected/implied by CONFIG_MACH_SUN* that may want it on by default?

Quoted 8 lines

sure, we can do that, but note there's "brcm,bcm4345c5" used below, hence me limiting it to opi3 for now.

So we either need to have something like
CONFIG_SUNXI_BTADDR_FIXUP="brcm,bcm4345c5"
or a dts "bluetooth" alias we can refer to.

I'd go for the former, would that be an acceptable solution?

I'm not the maintainer, so I don't know what will be acceptable. Alias solution is used for ethernet, so I think that may be more acceptable, as it's already used in u-boot. It can also be more precise, as you can point to a specific node with the alias.

OTOH, I'm not aware of any sunxi board with multiple BT chips and alias solution will also need modification of DTS files for all boards that will want to opt in into this, instead of just having to switch on a config in u-boot.

regards,

	o.
Quoted 52 lines

Thanks,
Andre

Quoted 36 lines

board/sunxi/board.c int misc_init_r(void) · line 869

Quoted 9 lines
board/sunxi/board.c +8 -0
+	/* Some devices ship with the controller default address.
+	 * Set a valid address through the device tree.
+	 */
+	uchar mac[ETH_ALEN], bdaddr[ETH_ALEN];
+	int i;
+
+	if (!of_machine_is_compatible("xunlong,orangepi-3"))
+		return;

You don't need to limit this to opi3 only.

thank you and regards,

	o.
Quoted 21 lines
board/sunxi/board.c +15 -0
+
+	if (!eth_env_get_enetaddr("ethaddr", mac))
+		return;
+
+	/* Addresses need to be in the binary format of the corresponding stack */
+	for (i = 0; i < ETH_ALEN; ++i)
+		bdaddr[i] = mac[ETH_ALEN - i - 1];
+
+	bdaddr[0] ^= 1;
+
+	do_fixup_by_compat(blob, "brcm,bcm4345c5",
+			   "local-bd-address", bdaddr, ETH_ALEN, 1);
+#endif
+}
+
  int ft_board_setup(void *blob, bd_t *bd)
  {
  	int __maybe_unused r;
@@ -866,6 +892,8 @@ int ft_board_setup(void *blob, bd_t *bd)
  	 */
  	setup_environment(blob);
Quoted 8 lines
Quoted 8 lines
board/sunxi/board.c +2 -0
+	fixup_bd_address(blob);
+
  #ifdef CONFIG_VIDEO_DT_SIMPLEFB
  	r = sunxi_simplefb_setup(blob);
  	if (r)
Signature · 1 line
2.24.0

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

maintainer
#7 lore raw

PATCH 4/4 sunxi: board: fixup the BT address for Orange Pi 3

In reply to Andre Heider
Quoted 34 lines · Andre Heider

The BCM4345C5 of the Orange Pi 3 ships with the controller default address. Fix it up so it can function properly.

The used address is "ethaddr" with the LSB flipped.

---

NOTE:
"local-bd-address" is a universal property, the kernel patch for btbcm to use that is in bluetooth-next.

 board/sunxi/board.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
board/sunxi/board.c +10 -0
index bb35d6b66e..2897bf45e1 100644
@@ -856,6 +856,32 @@ int misc_init_r(void)
        return 0;
 }
 
+static void fixup_bd_address(void *blob)
+{
+#if defined(CONFIG_MACH_SUN50I_H6)
+       /* Some devices ship with the controller default address.
+        * Set a valid address through the device tree.
+        */
+       uchar mac[ETH_ALEN], bdaddr[ETH_ALEN];
+       int i;
+
+       if (!of_machine_is_compatible("xunlong,orangepi-3"))

board/sunxi/board.c int misc_init_r(void) · line 878

Quoted 10 lines
board/sunxi/board.c +10 -0
+               return;
+
+       if (!eth_env_get_enetaddr("ethaddr", mac))
+               return;
+
+       /* Addresses need to be in the binary format of the corresponding stack */
+       for (i = 0; i < ETH_ALEN; ++i)
+               bdaddr[i] = mac[ETH_ALEN - i - 1];
+
+       bdaddr[0] ^= 1;

IIRC someone mentioned before that unlike Ethernet and WiFi, Bluetooth does not have a "locally administered" address space, so any address used could possibly collide with other devices.

ChenYu

Quoted 25 lines
board/sunxi/board.c +8 -1
+
+       do_fixup_by_compat(blob, "brcm,bcm4345c5",
+                          "local-bd-address", bdaddr, ETH_ALEN, 1);
+#endif
+}
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
        int __maybe_unused r;
@@ -866,6 +892,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)
--

2.24.0

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#8 lore raw

PATCH 4/4 sunxi: board: fixup the BT address for Orange Pi 3

Quoted 41 lines · Chen-Yu Tsai
Quoted 40 lines · Andre Heider

The BCM4345C5 of the Orange Pi 3 ships with the controller default address. Fix it up so it can function properly.

The used address is "ethaddr" with the LSB flipped.

---

NOTE:
"local-bd-address" is a universal property, the kernel patch for btbcm to use that is in bluetooth-next.

  board/sunxi/board.c | 28 ++++++++++++++++++++++++++++
  1 file changed, 28 insertions(+)
board/sunxi/board.c +16 -0
index bb35d6b66e..2897bf45e1 100644
@@ -856,6 +856,32 @@ int misc_init_r(void)
         return 0;
  }
 
+static void fixup_bd_address(void *blob)
+{
+#if defined(CONFIG_MACH_SUN50I_H6)
+       /* Some devices ship with the controller default address.
+        * Set a valid address through the device tree.
+        */
+       uchar mac[ETH_ALEN], bdaddr[ETH_ALEN];
+       int i;
+
+       if (!of_machine_is_compatible("xunlong,orangepi-3"))
+               return;
+
+       if (!eth_env_get_enetaddr("ethaddr", mac))
+               return;
+
+       /* Addresses need to be in the binary format of the corresponding stack */
Quoted 8 lines

board/sunxi/board.c int misc_init_r(void) · line 878

Quoted 4 lines
board/sunxi/board.c +4 -0
+       for (i = 0; i < ETH_ALEN; ++i)
+               bdaddr[i] = mac[ETH_ALEN - i - 1];
+
+       bdaddr[0] ^= 1;

IIRC someone mentioned before that unlike Ethernet and WiFi, Bluetooth does not have a "locally administered" address space, so any address used could possibly collide with other devices.

The kernel even refuses to use the controller default address, likely because of collisions. While this patch obviously doesn't guarantee a unique address, I guess it's in the same ballpark as "ethaddr" for sunxi. This at least gets BT working out of the box.

But I guess we should give the user an option to set a bdaddr of her/his choosing. I'll add support for reading the env var "bdaddr" and fall back to this address generation if that wasn't successful.

Or do you think we can do better?

Regards,
Andre