Skip to contentSkip to conversation

Add BananaPi R3

RFC Superseded Frank Wunderlich 4 participants 15 messages Oct 26, 2022 – Nov 1, 2022

Subsystems (2)

v2 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add BananaPi R3

From: Frank Wunderlich <[email protected]>

This Series adds some Nodes to mt7986 devicetree and the BananaPi R3

i included sams series for mt7986 DTS with small changes
https://patchwork.kernel.org/project/linux-mediatek/cover/[email protected]/

this series need these Patches:

i2c-support:
https://patchwork.kernel.org/project/linux-mediatek/cover/[email protected]/

mmc bindings:
https://patchwork.kernel.org/project/linux-mediatek/list/?series=688675

update pinctrl-bindings:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

hwrng and pinctrl (uart splitting) are already applied to next

v2 do not include PCIe as there is still a discussion on bindings.

i had run full dtbs-check but i end up with some strange warnings in ethernet-node that should not come up as phy-handle and sfp/managed properties are already defined.

phy-handle made optional
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/net/mediatek,net.yaml#n265

property sfp/managed (which is included for mac subnode in yaml above):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/net/ethernet-controller.yaml#n137

Frank Wunderlich (2):
arm64: dts: mt7986: add i2c node
arm64: dts: mt7986: add Bananapi R3

Sam Shih (5):
arm64: dts: mt7986: harmonize device node order
arm64: dts: mt7986: add spi related device nodes
arm64: dts: mt7986: add usb related device nodes
arm64: dts: mt7986: add crypto related device nodes
arm64: dts: mt7986: add mmc related device nodes

 arch/arm64/boot/dts/mediatek/Makefile         |   2 +
 .../mediatek/mt7986a-bananapi-bpi-r3-emmc.dts |  34 +
 .../mediatek/mt7986a-bananapi-bpi-r3-sd.dts   |  29 +
 .../dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi | 593 ++++++++++++++++++
 arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts  | 246 ++++++--
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi     | 127 ++++
 arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts  |  83 ++-
 7 files changed, 1059 insertions(+), 55 deletions(-)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts
 create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts
 create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi
Signature · 1 line
2.34.1
#1 lore raw

RFC v2 1/7 arm64: dts: mt7986: harmonize device node order

From: Sam Shih <[email protected]>

This arrange device tree nodes in alphabetical order.

---
i modified sams patch

https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

by moving pio-node up instead of moving uarts down to ensure alphabetical order for switch-/wifi-node.

And moved uart0 and wifi in mt7986b-rfb too.

---
 arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 94 ++++++++++----------
 arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 22 ++---
 2 files changed, 58 insertions(+), 58 deletions(-)
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts +47 -47
index afe37b702eef..6189436fe31d 100644
@@ -54,6 +54,53 @@ switch: switch@0 {
 	};
 };
 
+&pio {
+	uart1_pins: uart1-pins {
+		mux {
+			function = "uart";
+			groups = "uart1";
+		};
+	};
+
+	uart2_pins: uart2-pins {
+		mux {
+			function = "uart";
+			groups = "uart2";
+		};
+	};
+
+	wf_2g_5g_pins: wf-2g-5g-pins {
+		mux {
+			function = "wifi";
+			groups = "wf_2g", "wf_5g";
+		};
+		conf {
+			pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
+			       "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
+			       "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
+			       "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
+			       "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
+			       "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
+			       "WF1_TOP_CLK", "WF1_TOP_DATA";
+			drive-strength = <4>;
+		};
+	};
+
+	wf_dbdc_pins: wf-dbdc-pins {
+		mux {
+			function = "wifi";
+			groups = "wf_dbdc";
+		};
+		conf {
+			pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
+			       "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
+			       "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
+			       "WF0_TOP_CLK", "WF0_TOP_DATA";
+			drive-strength = <4>;
+		};
+	};
+};
+
 &switch {
 	ports {
 		#address-cells = <1>;
@@ -121,50 +168,3 @@ &wifi {
 	pinctrl-0 = <&wf_2g_5g_pins>;
 	pinctrl-1 = <&wf_dbdc_pins>;
 };
-
-&pio {
-	uart1_pins: uart1-pins {
-		mux {
-			function = "uart";
-			groups = "uart1";
-		};
-	};
-
-	uart2_pins: uart2-pins {
-		mux {
-			function = "uart";
-			groups = "uart2";
-		};
-	};
-
-	wf_2g_5g_pins: wf-2g-5g-pins {
-		mux {
-			function = "wifi";
-			groups = "wf_2g", "wf_5g";
-		};
-		conf {
-			pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
-			       "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
-			       "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
-			       "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
-			       "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
-			       "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
-			       "WF1_TOP_CLK", "WF1_TOP_DATA";
-			drive-strength = <4>;
-		};
-	};
-
-	wf_dbdc_pins: wf-dbdc-pins {
-		mux {
-			function = "wifi";
-			groups = "wf_dbdc";
-		};
-		conf {
-			pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
-			       "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
-			       "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
-			       "WF0_TOP_CLK", "WF0_TOP_DATA";
-			drive-strength = <4>;
-		};
-	};
-};
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts +11 -11
index 3443013b5971..7459ddb6b6f0 100644
@@ -25,10 +25,6 @@ memory@40000000 {
 	};
 };
 
-&uart0 {
-	status = "okay";
-};
-
 &eth {
 	status = "okay";
 
@@ -99,13 +95,6 @@ fixed-link {
 	};
 };
 
-&wifi {
-	status = "okay";
-	pinctrl-names = "default", "dbdc";
-	pinctrl-0 = <&wf_2g_5g_pins>;
-	pinctrl-1 = <&wf_dbdc_pins>;
-};
-
 &pio {
 	wf_2g_5g_pins: wf-2g-5g-pins {
 		mux {
@@ -138,3 +127,14 @@ conf {
 		};
 	};
 };
+
+&uart0 {
+	status = "okay";
+};
+
+&wifi {
+	status = "okay";
+	pinctrl-names = "default", "dbdc";
+	pinctrl-0 = <&wf_2g_5g_pins>;
+	pinctrl-1 = <&wf_dbdc_pins>;
+};
Signature · 1 line
2.34.1
#3 lore raw

RFC v2 2/7 arm64: dts: mt7986: add spi related device nodes

In reply to Frank Wunderlich

From: Sam Shih <[email protected]>

This patch adds spi support for MT7986.

---
 arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 35 ++++++++++++++++++++
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi    | 28 ++++++++++++++++
 arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 35 ++++++++++++++++++++
 3 files changed, 98 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts +35 -0
index 6189436fe31d..58f7e6b169bf 100644
@@ -55,6 +55,20 @@ switch: switch@0 {
 };
 
 &pio {
+	spi_flash_pins: spi-flash-pins {
+		mux {
+			function = "spi";
+			groups = "spi0", "spi0_wp_hold";
+		};
+	};
+
+	spic_pins: spic-pins {
+		mux {
+			function = "spi";
+			groups = "spi1_2";
+		};
+	};
+
 	uart1_pins: uart1-pins {
 		mux {
 			function = "uart";
@@ -101,6 +115,27 @@ conf {
 	};
 };
 
+&spi0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi_flash_pins>;
+	cs-gpios = <0>, <0>;
+	status = "okay";
+	spi_nand: spi_nand@0 {
+		compatible = "spi-nand";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+		spi-tx-buswidth = <4>;
+		spi-rx-buswidth = <4>;
+	};
+};
+
+&spi1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spic_pins>;
+	cs-gpios = <0>, <0>;
+	status = "okay";
+};
+
 &switch {
 	ports {
 		#address-cells = <1>;
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +28 -0
index 226648f48df2..6d881095d933 100644
@@ -112,6 +112,34 @@ infracfg: infracfg@10001000 {
 			#clock-cells = <1>;
 		};
 
+		spi0: spi@1100a000 {
+			compatible = "mediatek,mt7986-spi-ipm", "mediatek,spi-ipm";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0 0x1100a000 0 0x100>;
+			interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&topckgen CLK_TOP_MPLL_D2>,
+				 <&topckgen CLK_TOP_SPI_SEL>,
+				 <&infracfg CLK_INFRA_SPI0_CK>,
+				 <&infracfg CLK_INFRA_SPI0_HCK_CK>;
+			clock-names = "parent-clk", "sel-clk", "spi-clk", "hclk";
+			status = "disabled";
+		};
+
+		spi1: spi@1100b000 {
+			compatible = "mediatek,mt7986-spi-ipm", "mediatek,spi-ipm";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0 0x1100b000 0 0x100>;
+			interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&topckgen CLK_TOP_MPLL_D2>,
+				 <&topckgen CLK_TOP_SPIM_MST_SEL>,
+				 <&infracfg CLK_INFRA_SPI1_CK>,
+				 <&infracfg CLK_INFRA_SPI1_HCK_CK>;
+			clock-names = "parent-clk", "sel-clk", "spi-clk", "hclk";
+			status = "disabled";
+		};
+
 		topckgen: topckgen@1001b000 {
 			compatible = "mediatek,mt7986-topckgen", "syscon";
 			reg = <0 0x1001B000 0 0x1000>;
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts +35 -0
index 7459ddb6b6f0..7673aa3fa6ae 100644
@@ -96,6 +96,20 @@ fixed-link {
 };
 
 &pio {
+	spi_flash_pins: spi-flash-pins {
+		mux {
+			function = "spi";
+			groups = "spi0", "spi0_wp_hold";
+		};
+	};
+
+	spic_pins: spic-pins {
+		mux {
+			function = "spi";
+			groups = "spi1_2";
+		};
+	};
+
 	wf_2g_5g_pins: wf-2g-5g-pins {
 		mux {
 			function = "wifi";
@@ -128,6 +142,27 @@ conf {
 	};
 };
 
+&spi0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi_flash_pins>;
+	cs-gpios = <0>, <0>;
+	status = "okay";
+	spi_nand: spi_nand@0 {
+		compatible = "spi-nand";
+		reg = <0>;
+		spi-max-frequency = <10000000>;
+		spi-tx-buswidth = <4>;
+		spi-rx-buswidth = <4>;
+	};
+};
+
+&spi1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spic_pins>;
+	cs-gpios = <0>, <0>;
+	status = "okay";
+};
+
 &uart0 {
 	status = "okay";
 };
Signature · 1 line
2.34.1
#4 lore raw

RFC v2 3/7 arm64: dts: mt7986: add usb related device nodes

In reply to Frank Wunderlich

From: Sam Shih <[email protected]>

This patch adds USB support for MT7986.

---
changes compared to sams original version:
- reorder xhci-clocks based on yaml binding

---
 arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 28 ++++++++++
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi    | 55 ++++++++++++++++++++
 arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 28 ++++++++++
 3 files changed, 111 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts +28 -0
index 58f7e6b169bf..de5d771e5251 100644
@@ -23,6 +23,24 @@ memory@40000000 {
 		device_type = "memory";
 		reg = <0 0x40000000 0 0x40000000>;
 	};
+
+	reg_3p3v: regulator-3p3v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
 };
 
 &eth {
@@ -136,6 +154,12 @@ &spi1 {
 	status = "okay";
 };
 
+&ssusb {
+	vusb33-supply = <&reg_3p3v>;
+	vbus-supply = <&reg_5v>;
+	status = "okay";
+};
+
 &switch {
 	ports {
 		#address-cells = <1>;
@@ -197,6 +221,10 @@ &uart2 {
 	status = "okay";
 };
 
+&usb_phy {
+	status = "okay";
+};
+
 &wifi {
 	status = "okay";
 	pinctrl-names = "default", "dbdc";
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +55 -0

61 lines not on this page · raw message

arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts +28 -0
index 7673aa3fa6ae..cd1763fa7f19 100644
@@ -23,6 +23,24 @@ memory@40000000 {
 		device_type = "memory";
 		reg = <0 0x40000000 0 0x40000000>;
 	};
+
+	reg_3p3v: regulator-3p3v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
 };
 
 &eth {
@@ -163,10 +181,20 @@ &spi1 {
 	status = "okay";
 };
 
+&ssusb {
+	vusb33-supply = <&reg_3p3v>;
+	vbus-supply = <&reg_5v>;
+	status = "okay";
+};
+
 &uart0 {
 	status = "okay";
 };
 
+&usb_phy {
+	status = "okay";
+};
+
 &wifi {
 	status = "okay";
 	pinctrl-names = "default", "dbdc";
Signature · 1 line
2.34.1
#5 lore raw

RFC v2 4/7 arm64: dts: mt7986: add crypto related device nodes

In reply to Frank Wunderlich

From: Sam Shih <[email protected]>

This patch adds crypto engine support for MT7986.

---
 arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts |  4 ++++
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi    | 15 +++++++++++++++
 arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts |  4 ++++
 3 files changed, 23 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts +4 -0
index de5d771e5251..2b5d7ea31b4d 100644
@@ -43,6 +43,10 @@ reg_5v: regulator-5v {
 	};
 };
 
+&crypto {
+	status = "okay";
+};
+
 &eth {
 	status = "okay";
 
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +15 -0
index 58bbecfbab98..1c7a973c28ca 100644
@@ -205,6 +205,21 @@ trng: rng@1020f000 {
 			status = "disabled";
 		};
 
+		crypto: crypto@10320000 {
+			compatible = "inside-secure,safexcel-eip97";
+			reg = <0 0x10320000 0 0x40000>;
+			interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "ring0", "ring1", "ring2", "ring3";
+			clocks = <&infracfg CLK_INFRA_EIP97_CK>;
+			clock-names = "infra_eip97_ck";
+			assigned-clocks = <&topckgen CLK_TOP_EIP_B_SEL>;
+			assigned-clock-parents = <&apmixedsys CLK_APMIXED_NET2PLL>;
+			status = "disabled";
+		};
+
 		uart0: serial@11002000 {
 			compatible = "mediatek,mt7986-uart",
 				     "mediatek,mt6577-uart";
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts +4 -0
index cd1763fa7f19..a98025112b5a 100644
@@ -43,6 +43,10 @@ reg_5v: regulator-5v {
 	};
 };
 
+&crypto {
+	status = "okay";
+};
+
 &eth {
 	status = "okay";
 
Signature · 1 line
2.34.1
#6 lore raw

RFC v2 5/7 arm64: dts: mt7986: add mmc related device nodes

In reply to Frank Wunderlich

From: Sam Shih <[email protected]>

This patch adds mmc support for MT7986.

v2:
- update mmc-node because clocks changed

---
 arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 85 ++++++++++++++++++++
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi    | 15 ++++
 2 files changed, 100 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts +85 -0
index 2b5d7ea31b4d..c5cc7bd19dbf 100644
@@ -24,6 +24,15 @@ memory@40000000 {
 		reg = <0 0x40000000 0 0x40000000>;
 	};
 
+	reg_1p8v: regulator-1p8v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+
 	reg_3p3v: regulator-3p3v {
 		compatible = "regulator-fixed";
 		regulator-name = "fixed-3.3V";
@@ -76,7 +85,83 @@ switch: switch@0 {
 	};
 };
 
+&mmc0 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+	bus-width = <8>;
+	max-frequency = <200000000>;
+	cap-mmc-highspeed;
+	mmc-hs200-1_8v;
+	mmc-hs400-1_8v;
+	hs400-ds-delay = <0x14014>;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	non-removable;
+	no-sd;
+	no-sdio;
+	status = "okay";
+};
+
 &pio {
+	mmc0_pins_default: mmc0-pins {
+		mux {
+			function = "emmc";
+			groups = "emmc_51";
+		};
+		conf-cmd-dat {
+			pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
+			       "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
+			       "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
+			input-enable;
+			drive-strength = <4>;
+			mediatek,pull-up-adv = <1>;	/* pull-up 10K */
+		};
+		conf-clk {
+			pins = "EMMC_CK";
+			drive-strength = <6>;
+			mediatek,pull-down-adv = <2>;	/* pull-down 50K */
+		};
+		conf-ds {
+			pins = "EMMC_DSL";
+			mediatek,pull-down-adv = <2>;	/* pull-down 50K */
+		};
+		conf-rst {
+			pins = "EMMC_RSTB";
+			drive-strength = <4>;
+			mediatek,pull-up-adv = <1>;	/* pull-up 10K */
+		};
+	};
+
+	mmc0_pins_uhs: mmc0-uhs-pins {
+		mux {
+			function = "emmc";
+			groups = "emmc_51";
+		};
+		conf-cmd-dat {
+			pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
+			       "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
+			       "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
+			input-enable;
+			drive-strength = <4>;
+			mediatek,pull-up-adv = <1>;	/* pull-up 10K */
+		};
+		conf-clk {
+			pins = "EMMC_CK";
+			drive-strength = <6>;
+			mediatek,pull-down-adv = <2>;	/* pull-down 50K */
+		};
+		conf-ds {
+			pins = "EMMC_DSL";
+			mediatek,pull-down-adv = <2>;	/* pull-down 50K */
+		};
+		conf-rst {
+			pins = "EMMC_RSTB";
+			drive-strength = <4>;
+			mediatek,pull-up-adv = <1>;	/* pull-up 10K */
+		};
+	};
+
 	spi_flash_pins: spi-flash-pins {
 		mux {
 			function = "spi";
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +15 -0
index 1c7a973c28ca..32c26b239ae6 100644
@@ -284,6 +284,21 @@ ssusb: usb@11200000 {
 			status = "disabled";
 		};
 
+		mmc0: mmc@11230000 {
+			compatible = "mediatek,mt7986-mmc";
+			reg = <0 0x11230000 0 0x1000>,
+			      <0 0x11c20000 0 0x1000>;
+			interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&topckgen CLK_TOP_EMMC_416M_SEL>,
+				 <&infracfg CLK_INFRA_MSDC_HCK_CK>,
+				 <&infracfg CLK_INFRA_MSDC_CK>,
+				 <&infracfg CLK_INFRA_MSDC_133M_CK>,
+				 <&infracfg CLK_INFRA_MSDC_66M_CK>;
+			clock-names = "source", "hclk", "source_cg", "bus_clk",
+				      "sys_cg";
+			status = "disabled";
+		};
+
 		usb_phy: t-phy@11e10000 {
 			compatible = "mediatek,mt7986-tphy",
 				     "mediatek,generic-tphy-v2";
Signature · 1 line
2.34.1
#7 lore raw

RFC v2 6/7 arm64: dts: mt7986: add i2c node

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Add i2c Node to mt7986 devicetree.

---
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +14 -0
index 32c26b239ae6..a1a788db113a 100644
@@ -261,6 +261,20 @@ uart2: serial@11004000 {
 			status = "disabled";
 		};
 
+		i2c0: i2c@11008000 {
+			compatible = "mediatek,mt7986-i2c";
+			reg = <0 0x11008000 0 0x90>,
+			      <0 0x10217080 0 0x80>;
+			interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
+			clock-div = <5>;
+			clocks = <&infracfg CLK_INFRA_I2C0_CK>,
+				 <&infracfg CLK_INFRA_AP_DMA_CK>;
+			clock-names = "main", "dma";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
 		ssusb: usb@11200000 {
 			compatible = "mediatek,mt7986-xhci",
 				     "mediatek,mtk-xhci";
Signature · 1 line
2.34.1
#8 lore raw

RFC v2 7/7 arm64: dts: mt7986: add Bananapi R3

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Add support for Bananapi R3 SBC.

- SD/eMMC support (switching first 4 bits of data-bus with sw6/D)
- all rj45 ports and both SFP working (eth1/lan4)
- all USB-Ports + SIM-Slot tested
- i2c and all uarts tested
- wifi tested

---
SPI-NAND/NOR switched (CS by sw5/C) not yet included
this is done with DT-Overlays in my tree, but i have no idea yet, how to upstream

break some lines in wifi-eeprom-data because of checkpatch warnings. originally there were 8 x int32 per line

changes:

v2:
- remove pcie to be added later (discussion about clocks)
- some fixes based on suggestions on ML
- add key suffix like it's done in mt7622-bpi-r64 devicetree
- add dash in sfp node names
- use reg as unit for switch-node
- drop "-3-4" suffix from i2c-pins node name
- fix order in Makefile

---
 arch/arm64/boot/dts/mediatek/Makefile         |   2 +
 .../mediatek/mt7986a-bananapi-bpi-r3-emmc.dts |  34 +
 .../mediatek/mt7986a-bananapi-bpi-r3-sd.dts   |  29 +
 .../dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi | 593 ++++++++++++++++++
 4 files changed, 658 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts
 create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts
 create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi
arch/arm64/boot/dts/mediatek/Makefile +2 -0
index 0ec90cb3ef28..e8902f2cc58f 100644
@@ -7,6 +7,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-evb.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-x20-dev.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-rfb1.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-bananapi-bpi-r64.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-emmc.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-sd.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-rfb.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986b-rfb.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt8167-pumpkin.dtb
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +34 -0
new file mode 100644
index 000000000000..859b4180ca11
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Author: Sam.Shih <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7986a-bananapi-bpi-r3.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3 (emmc)";
+};
+
+&mmc0 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+	bus-width = <8>;
+	max-frequency = <200000000>;
+	cap-mmc-highspeed;
+	mmc-hs200-1_8v;
+	mmc-hs400-1_8v;
+	hs400-ds-delay = <0x14014>;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	non-removable;
+	no-sd;
+	no-sdio;
+	status = "okay";
+};
+
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +29 -0
new file mode 100644
index 000000000000..57200407ab86
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Author: Sam.Shih <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7986a-bananapi-bpi-r3.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3 (sdmmc)";
+};
+
+&mmc0 {
+	//sdcard
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+	bus-width = <4>;
+	max-frequency = <52000000>;
+	cap-sd-highspeed;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	status = "okay";
+};
+
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +593 -0

593 lines not on this page · raw message

Signature · 1 line
2.34.1
#9 lore raw

Re: [RFC v2 7/7] arm64: dts: mt7986: add Bananapi R3

Il 26/10/22 11:36, Frank Wunderlich ha scritto:

Quoted 68 lines

From: Frank Wunderlich <[email protected]>

Add support for Bananapi R3 SBC.

- SD/eMMC support (switching first 4 bits of data-bus with sw6/D)
- all rj45 ports and both SFP working (eth1/lan4)
- all USB-Ports + SIM-Slot tested
- i2c and all uarts tested
- wifi tested

---
SPI-NAND/NOR switched (CS by sw5/C) not yet included
this is done with DT-Overlays in my tree, but i have no idea yet, how to upstream

break some lines in wifi-eeprom-data because of checkpatch warnings. originally there were 8 x int32 per line

changes:

v2:
- remove pcie to be added later (discussion about clocks)
- some fixes based on suggestions on ML
- add key suffix like it's done in mt7622-bpi-r64 devicetree
- add dash in sfp node names
- use reg as unit for switch-node
- drop "-3-4" suffix from i2c-pins node name
- fix order in Makefile

---
  arch/arm64/boot/dts/mediatek/Makefile         |   2 +
  .../mediatek/mt7986a-bananapi-bpi-r3-emmc.dts |  34 +
  .../mediatek/mt7986a-bananapi-bpi-r3-sd.dts   |  29 +
  .../dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi | 593 ++++++++++++++++++
  4 files changed, 658 insertions(+)

create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi

arch/arm64/boot/dts/mediatek/Makefile +2 -0
index 0ec90cb3ef28..e8902f2cc58f 100644
@@ -7,6 +7,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-evb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-x20-dev.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-rfb1.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-bananapi-bpi-r64.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-emmc.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-sd.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-rfb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986b-rfb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt8167-pumpkin.dtb
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +10 -0
new file mode 100644
index 000000000000..859b4180ca11
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Author: Sam.Shih <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts line 20

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +10 -0
+#include "mt7986a-bananapi-bpi-r3.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3 (emmc)";
+};
+
+&mmc0 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;

pinctrl properties and power supply properties can go to the shared mt7986a-bananapi-bpi-r3.dtsi file.

Also, I have a question here... so your hardware can take either eMMC or MicroSD... and... is there really no way to build in both devicetrees and having the bootloader to select the right one based on hardware version or on machine compatible?

I can see, on the wiki, that both bootloader and ATF can be customized (so, can be compiled and flashed just fine), so I would say that even if the "original" U-Boot doesn't distinguish devicetrees, you can definitely easily implement that.

If you have no idea how to recognize the boards, from a fast look at the board schematics, I can see that there's a bootstrap setting based on the state of GPIO0 and GPIO1... you can perhaps use that somehow? Otherwise, remember that, most of the times, there are other ways to determine the board version, like Board ID resistors...

Also, still on the wiki, I can't see any no-eMMC version of this board: is the sd-only a pre-production version or..?

Quoted 28 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +14 -0
+	bus-width = <8>;
+	max-frequency = <200000000>;
+	cap-mmc-highspeed;
+	mmc-hs200-1_8v;
+	mmc-hs400-1_8v;
+	hs400-ds-delay = <0x14014>;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	non-removable;
+	no-sd;
+	no-sdio;
+	status = "okay";
+};
+
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +8 -0
new file mode 100644
index 000000000000..57200407ab86
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Author: Sam.Shih <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts line 18

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +10 -0
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7986a-bananapi-bpi-r3.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3 (sdmmc)";
+};
+
+&mmc0 {
+	//sdcard

C-style comments please

Quoted 40 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +11 -0
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+	bus-width = <4>;
+	max-frequency = <52000000>;
+	cap-sd-highspeed;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	status = "okay";
+};
+
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +23 -0
new file mode 100644
index 000000000000..fc100c3a6415
@@ -0,0 +1,593 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Authors: Sam.Shih <[email protected]>
+ *          Frank Wunderlich <[email protected]>
+ *          Daniel Golle <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+
+#include "mt7986a.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3";
+	compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
+
+	aliases {
+		serial0 = &uart0;
+		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 33

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +10 -0
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		factory-key {

I'd say that this is not "factory-key" but "reset-key"?

Quoted 12 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +12 -0
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+		};
+
+		wps-key {
+			label = "wps";
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
+		};
+	};
+

..snip..

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 86

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+
+	memory@40000000 {
+		device_type = "memory";
+		reg = <0 0x40000000 0 0x40000000>;

Doesn't your bootloader fill-in the memory size automatically?

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 91

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_1p8v: regulator-1p8v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";

This is "avdd18", isn't it?

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 95

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		regulator-always-on;

All these regulators have a vin-supply: please fill it in. Moreover, in the schematics, I can also see other LDOs: 0.9VD (input +12VD), AVDD12 (input 1.8VD), DDRV_VPP (input 3.3VD)...

Of course, this means that you have one more 1.8V regulator, called 1.8vd.

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 100

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_3p3v: regulator-3p3v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";

regulator-name = "3.3vd";

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 104

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;

vin-supply = <&dcin>; (dcin: regulator-12vd { ... })

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 109

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";

regulator-name = "fixed-5p1";

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 111

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;

Schematics say "+5V: 5.1V/3A", so this is not 5000000.

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		regulator-boot-on;
+		regulator-always-on;

vin-supply = <&dcin>;

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+	};
+

..snip..

Quoted 11 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +11 -0
+
+&pio {
+	i2c_pins: i2c-pins {
+		mux {
+			function = "i2c";
+			groups = "i2c";
+		};
+	};
+
+	mmc0_pins_default: mmc0-pins {
+		mux {

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 203

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +10 -0
+			function = "emmc";
+			groups = "emmc_51";
+		};
+		conf-cmd-dat {
+			pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
+			       "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
+			       "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
+			input-enable;
+			drive-strength = <4>;
+			mediatek,pull-up-adv = <1>;	/* pull-up 10K */

Can we please stop using these custom pull-{up,down}-adv properties? Check what was done on pinctrl-mt8192.c (and dt schema) for more information and examples.

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		};
+		conf-clk {

..snip..

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 427

Quoted 8 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +8 -0
+
+&wifi {
+	status = "okay";
+	pinctrl-names = "default", "dbdc";
+	pinctrl-0 = <&wf_2g_5g_pins>, <&wf_led_pins>;
+	pinctrl-1 = <&wf_dbdc_pins>, <&wf_led_pins>;
+
+	mediatek,eeprom-data = <0x86790900 0xc4326 0x60000000 0x00 0x00 0x00 0x00 0x00

Ouch! This looks like firmware unrolled in a devicetree property - that can't be right.

Please dump that in a binary file and load it as firmware from userspace.

Regards,
Angelo

#10 lore raw

Re: [RFC v2 7/7] arm64: dts: mt7986: add Bananapi R3

Am 2022-10-28 11:19, schrieb AngeloGioacchino Del Regno:

Quoted 78 lines

Il 26/10/22 11:36, Frank Wunderlich ha scritto:

Quoted 77 lines

From: Frank Wunderlich <[email protected]>

Add support for Bananapi R3 SBC.

- SD/eMMC support (switching first 4 bits of data-bus with sw6/D)
- all rj45 ports and both SFP working (eth1/lan4)
- all USB-Ports + SIM-Slot tested
- i2c and all uarts tested
- wifi tested

---
SPI-NAND/NOR switched (CS by sw5/C) not yet included
this is done with DT-Overlays in my tree, but i have no idea yet, how to upstream

break some lines in wifi-eeprom-data because of checkpatch warnings. originally there were 8 x int32 per line

changes:

v2:
- remove pcie to be added later (discussion about clocks)
- some fixes based on suggestions on ML
- add key suffix like it's done in mt7622-bpi-r64 devicetree
- add dash in sfp node names
- use reg as unit for switch-node
- drop "-3-4" suffix from i2c-pins node name
- fix order in Makefile

---
  arch/arm64/boot/dts/mediatek/Makefile         |   2 +
  .../mediatek/mt7986a-bananapi-bpi-r3-emmc.dts |  34 +
  .../mediatek/mt7986a-bananapi-bpi-r3-sd.dts   |  29 +
  .../dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi | 593 
++++++++++++++++++
  4 files changed, 658 insertions(+)

create mode 100644
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts
create mode 100644
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts
create mode 100644
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi

arch/arm64/boot/dts/mediatek/Makefile +2 -0
index 0ec90cb3ef28..e8902f2cc58f 100644
@@ -7,6 +7,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-evb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-x20-dev.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-rfb1.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-bananapi-bpi-r64.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-emmc.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-sd.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-rfb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986b-rfb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt8167-pumpkin.dtb
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +15 -0
new file mode 100644
index 000000000000..859b4180ca11
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Author: Sam.Shih <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7986a-bananapi-bpi-r3.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3 (emmc)";
+};
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts line 20

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +5 -0
+
+&mmc0 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;

pinctrl properties and power supply properties can go to the shared mt7986a-bananapi-bpi-r3.dtsi file.

OK

Quoted 4 lines

Also, I have a question here... so your hardware can take either eMMC or MicroSD... and... is there really no way to build in both devicetrees and having the bootloader to select the right one based on hardware version or on machine compatible?

as i wrote in description the board has both, an emmc-chip and microsd-slot, but they cannot be used simultanously as mt7986 has only 1 mmc-controller. BPI-R3 has a switch that changes the first 4 data-lines either to emmc or microsd-slot. You have only 1 mmc-node that has to be configured to which mmc-device you have connected, so i have to use 2 different devicetrees here.

Quoted 4 lines

I can see, on the wiki, that both bootloader and ATF can be customized (so, can be compiled and flashed just fine), so I would say that even if the "original" U-Boot doesn't distinguish devicetrees, you can definitely easily implement that.

i already boot a fit-image with 2 dts (and 2 overlays for spi-nand/nor) and my uboot can check with "mmc partconf" if emmc is available and if not choose the sd-dts.

Quoted 5 lines

If you have no idea how to recognize the boards, from a fast look at the board schematics, I can see that there's a bootstrap setting based on the state of GPIO0 and GPIO1... you can perhaps use that somehow? Otherwise, remember that, most of the times, there are other ways to determine the board version, like Board ID resistors...

but how should this effect the dts files here? originally i had the sd-card dts as base and the emmc had overridden/deleted some properties there (so only 2 dts-files). Had talked to Matthias and he suggested having a base dtsi and 2 dts for the 2 mmc-configs.

Quoted 2 lines

Also, still on the wiki, I can't see any no-eMMC version of this board: is the sd-only a pre-production version or..?

no sd/emmc-only version...1 board with 1 mmc-controller, but 2 "storages" connected (only 1 functional based on hw switch setting)

Quoted 32 lines
Quoted 32 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +14 -0
+	bus-width = <8>;
+	max-frequency = <200000000>;
+	cap-mmc-highspeed;
+	mmc-hs200-1_8v;
+	mmc-hs400-1_8v;
+	hs400-ds-delay = <0x14014>;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	non-removable;
+	no-sd;
+	no-sdio;
+	status = "okay";
+};
+
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +12 -0
new file mode 100644
index 000000000000..57200407ab86
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Author: Sam.Shih <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7986a-bananapi-bpi-r3.dtsi"
+
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts line 18

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +6 -0
+/ {
+	model = "Bananapi BPI-R3 (sdmmc)";
+};
+
+&mmc0 {
+	//sdcard

C-style comments please

ok

Quoted 44 lines
Quoted 44 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +11 -0
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+	bus-width = <4>;
+	max-frequency = <52000000>;
+	cap-sd-highspeed;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	status = "okay";
+};
+
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +27 -0
new file mode 100644
index 000000000000..fc100c3a6415
@@ -0,0 +1,593 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Authors: Sam.Shih <[email protected]>
+ *          Frank Wunderlich <[email protected]>
+ *          Daniel Golle <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+
+#include "mt7986a.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3";
+	compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
+
+	aliases {
+		serial0 = &uart0;
+		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 33

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +6 -0
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		factory-key {

I'd say that this is not "factory-key" but "reset-key"?

okay i rename it.

Quoted 15 lines
Quoted 12 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +12 -0
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+		};
+
+		wps-key {
+			label = "wps";
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
+		};
+	};
+

..snip..

Quoted 6 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 86

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+
+	memory@40000000 {
+		device_type = "memory";
+		reg = <0 0x40000000 0 0x40000000>;

Doesn't your bootloader fill-in the memory size automatically?

have not tried yet.

Quoted 7 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 91

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_1p8v: regulator-1p8v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";

This is "avdd18", isn't it?

need to check

Quoted 9 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 95

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		regulator-always-on;

All these regulators have a vin-supply: please fill it in. Moreover, in the schematics, I can also see other LDOs: 0.9VD (input +12VD),
AVDD12 (input 1.8VD), DDRV_VPP (input 3.3VD)...

ok

Quoted 58 lines

Of course, this means that you have one more 1.8V regulator, called 1.8vd.

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 100

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_3p3v: regulator-3p3v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";

regulator-name = "3.3vd";

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 104

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;

vin-supply = <&dcin>; (dcin: regulator-12vd { ... })

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 109

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";

regulator-name = "fixed-5p1";

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 111

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;

Schematics say "+5V: 5.1V/3A", so this is not 5000000.

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		regulator-boot-on;
+		regulator-always-on;

vin-supply = <&dcin>;

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+	};
+

..snip..

Quoted 17 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +17 -0
+
+&pio {
+	i2c_pins: i2c-pins {
+		mux {
+			function = "i2c";
+			groups = "i2c";
+		};
+	};
+
+	mmc0_pins_default: mmc0-pins {
+		mux {
+			function = "emmc";
+			groups = "emmc_51";
+		};
+		conf-cmd-dat {
+			pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
+			       "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 203

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+			       "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
+			input-enable;
+			drive-strength = <4>;
+			mediatek,pull-up-adv = <1>;	/* pull-up 10K */

Can we please stop using these custom pull-{up,down}-adv properties? Check what was done on pinctrl-mt8192.c (and dt schema) for more information and examples.

need to check these with MTK.

Quoted 18 lines
Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		};
+		conf-clk {

..snip..

Quoted 9 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +8 -0
+
+&wifi {
+	status = "okay";
+	pinctrl-names = "default", "dbdc";
+	pinctrl-0 = <&wf_2g_5g_pins>, <&wf_led_pins>;
+	pinctrl-1 = <&wf_dbdc_pins>, <&wf_led_pins>;
+
+	mediatek,eeprom-data = <0x86790900 0xc4326 0x60000000 0x00 0x00 0x00 

0x00 0x00

Ouch! This looks like firmware unrolled in a devicetree property - that can't be right.

Quoted 1 line

Please dump that in a binary file and load it as firmware from userspace.

it uses the mt76 driver and here eeprom can only be loaded from mtd-partition or from device tree. Previous attempts loading eeprom data from userspace file (like it's done for "normal" firmware) were rejected.

regards Frank

#11 lore raw

Re: [RFC v2 7/7] arm64: dts: mt7986: add Bananapi R3

Quoted 99 lines · Frank Wunderlich (linux)

Am 2022-10-28 11:19, schrieb AngeloGioacchino Del Regno:

Quoted 81 lines

Il 26/10/22 11:36, Frank Wunderlich ha scritto:

Quoted 80 lines

From: Frank Wunderlich <[email protected]>

Add support for Bananapi R3 SBC.

- SD/eMMC support (switching first 4 bits of data-bus with sw6/D)
- all rj45 ports and both SFP working (eth1/lan4)
- all USB-Ports + SIM-Slot tested
- i2c and all uarts tested
- wifi tested

---
SPI-NAND/NOR switched (CS by sw5/C) not yet included
this is done with DT-Overlays in my tree, but i have no idea yet, how to upstream

break some lines in wifi-eeprom-data because of checkpatch warnings. originally there were 8 x int32 per line

changes:

v2:
- remove pcie to be added later (discussion about clocks)
- some fixes based on suggestions on ML
- add key suffix like it's done in mt7622-bpi-r64 devicetree
- add dash in sfp node names
- use reg as unit for switch-node
- drop "-3-4" suffix from i2c-pins node name
- fix order in Makefile

---
  arch/arm64/boot/dts/mediatek/Makefile         |   2 +
  .../mediatek/mt7986a-bananapi-bpi-r3-emmc.dts |  34 +
  .../mediatek/mt7986a-bananapi-bpi-r3-sd.dts   |  29 +
  .../dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi | 593
++++++++++++++++++
  4 files changed, 658 insertions(+)

create mode 100644
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts
create mode 100644
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts
create mode 100644
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi

arch/arm64/boot/dts/mediatek/Makefile +2 -0
index 0ec90cb3ef28..e8902f2cc58f 100644
@@ -7,6 +7,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-evb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-x20-dev.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-rfb1.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-bananapi-bpi-r64.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-emmc.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-sd.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-rfb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986b-rfb.dtb
  dtb-$(CONFIG_ARCH_MEDIATEK) += mt8167-pumpkin.dtb

diff --git a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file mode 100644
index 000000000000..859b4180ca11

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +15 -0
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Author: Sam.Shih <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7986a-bananapi-bpi-r3.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3 (emmc)";
+};
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts line 20

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +5 -0
+
+&mmc0 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;

pinctrl properties and power supply properties can go to the shared mt7986a-bananapi-bpi-r3.dtsi file.

OK

Quoted 5 lines

Also, I have a question here... so your hardware can take either eMMC or MicroSD... and... is there really no way to build in both devicetrees and having the bootloader to select the right one based on hardware version
or on machine compatible?

Quoted 6 lines

as i wrote in description the board has both, an emmc-chip and microsd-slot, but they cannot be used simultanously as mt7986 has only 1 mmc-controller. BPI-R3 has a switch that changes the first 4 data-lines either to emmc or microsd-slot. You have only 1 mmc-node that has to be configured to which mmc-device you have connected, so i have to use 2 different devicetrees here.

You could also use device tree overlays to select SDMMC or eMMC just like for the NOR vs. NAND choice on this board.

Quoted 11 lines
Quoted 7 lines

I can see, on the wiki, that both bootloader and ATF can be customized (so,
can be compiled and flashed just fine), so I would say that even if the "original" U-Boot doesn't distinguish devicetrees, you can definitely easily
implement that.

i already boot a fit-image with 2 dts (and 2 overlays for spi-nand/nor) and my uboot can check with "mmc partconf" if emmc is available and if not choose the sd-dts.

Exactly. This is how it's done in OpenWrt as well.

Quoted 121 lines
Quoted 8 lines

If you have no idea how to recognize the boards, from a fast look at the board schematics, I can see that there's a bootstrap setting based on the
state of GPIO0 and GPIO1... you can perhaps use that somehow? Otherwise, remember that, most of the times, there are other ways to determine
the board version, like Board ID resistors...

but how should this effect the dts files here? originally i had the sd-card dts as base and the emmc had overridden/deleted some properties there (so only 2 dts-files). Had talked to Matthias and he suggested having a base dtsi and 2 dts for the 2 mmc-configs.

Quoted 3 lines

Also, still on the wiki, I can't see any no-eMMC version of this board:
is
the sd-only a pre-production version or..?

no sd/emmc-only version...1 board with 1 mmc-controller, but 2 "storages" connected (only 1 functional based on hw switch setting)

Quoted 34 lines
Quoted 34 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dts new file +14 -0
+	bus-width = <8>;
+	max-frequency = <200000000>;
+	cap-mmc-highspeed;
+	mmc-hs200-1_8v;
+	mmc-hs400-1_8v;
+	hs400-ds-delay = <0x14014>;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	non-removable;
+	no-sd;
+	no-sdio;
+	status = "okay";
+};
+

diff --git a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file mode 100644
index 000000000000..57200407ab86

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +12 -0
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Author: Sam.Shih <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7986a-bananapi-bpi-r3.dtsi"
+
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts line 18

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +6 -0
+/ {
+	model = "Bananapi BPI-R3 (sdmmc)";
+};
+
+&mmc0 {
+	//sdcard

C-style comments please

ok

Quoted 46 lines
Quoted 46 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +11 -0
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+	bus-width = <4>;
+	max-frequency = <52000000>;
+	cap-sd-highspeed;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_1p8v>;
+	status = "okay";
+};
+

diff --git a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file mode 100644
index 000000000000..fc100c3a6415

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +27 -0
@@ -0,0 +1,593 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2021 MediaTek Inc.
+ * Authors: Sam.Shih <[email protected]>
+ *          Frank Wunderlich <[email protected]>
+ *          Daniel Golle <[email protected]>
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+
+#include "mt7986a.dtsi"
+
+/ {
+	model = "Bananapi BPI-R3";
+	compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
+
+	aliases {
+		serial0 = &uart0;
+		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 33

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +6 -0
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		factory-key {

I'd say that this is not "factory-key" but "reset-key"?

Quoted 5 lines

okay i rename it.

Quoted 3 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 36

Quoted 3 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +3 -0
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;

At least on my V1.0 board and reportedly also on V1.1 boards the RST button doesn't work. As soon as a NVME/M.2 module is inserted this also connects the GPIO just like if the button was pressed all the time. This issue has also been discussed in BananaPi forums.

Quoted 133 lines
Quoted 12 lines
Quoted 9 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +9 -0
+		};
+
+		wps-key {
+			label = "wps";
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
+		};
+	};
+

..snip..

Quoted 6 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 86

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+
+	memory@40000000 {
+		device_type = "memory";
+		reg = <0 0x40000000 0 0x40000000>;

Doesn't your bootloader fill-in the memory size automatically?

have not tried yet.

Quoted 7 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 91

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_1p8v: regulator-1p8v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";

This is "avdd18", isn't it?

need to check

Quoted 9 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 95

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		regulator-always-on;

All these regulators have a vin-supply: please fill it in. Moreover, in the schematics, I can also see other LDOs: 0.9VD (input +12VD),
AVDD12 (input 1.8VD), DDRV_VPP (input 3.3VD)...

ok

Quoted 60 lines

Of course, this means that you have one more 1.8V regulator, called 1.8vd.

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 100

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_3p3v: regulator-3p3v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";

regulator-name = "3.3vd";

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 104

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;

vin-supply = <&dcin>; (dcin: regulator-12vd { ... })

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 109

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";

regulator-name = "fixed-5p1";

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 111

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;

Schematics say "+5V: 5.1V/3A", so this is not 5000000.

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		regulator-boot-on;
+		regulator-always-on;

vin-supply = <&dcin>;

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+	};
+

..snip..

Quoted 18 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +18 -0
+
+&pio {
+	i2c_pins: i2c-pins {
+		mux {
+			function = "i2c";
+			groups = "i2c";
+		};
+	};
+
+	mmc0_pins_default: mmc0-pins {
+		mux {
+			function = "emmc";
+			groups = "emmc_51";
+		};
+		conf-cmd-dat {
+			pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
+			       "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
+			       "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 203

Quoted 3 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +3 -0
+			input-enable;
+			drive-strength = <4>;
+			mediatek,pull-up-adv = <1>;	/* pull-up 10K */

Can we please stop using these custom pull-{up,down}-adv properties? Check what was done on pinctrl-mt8192.c (and dt schema) for more information
and examples.

need to check these with MTK.

Quoted 19 lines
Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		};
+		conf-clk {

..snip..

Quoted 9 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +8 -0
+
+&wifi {
+	status = "okay";
+	pinctrl-names = "default", "dbdc";
+	pinctrl-0 = <&wf_2g_5g_pins>, <&wf_led_pins>;
+	pinctrl-1 = <&wf_dbdc_pins>, <&wf_led_pins>;
+
+	mediatek,eeprom-data = <0x86790900 0xc4326 0x60000000 0x00 0x00

0x00 0x00 0x00

Ouch! This looks like firmware unrolled in a devicetree property - that can't
be right.

Quoted 6 lines
Quoted 2 lines

Please dump that in a binary file and load it as firmware from userspace.

it uses the mt76 driver and here eeprom can only be loaded from mtd-partition or from device tree. Previous attempts loading eeprom data from userspace file (like it's done for "normal" firmware) were rejected.

Note that strictly speaking this is not firmware but rather calibration data (ie. board-specific configuration, not code).

In case you don't like the large amount of data in the DTS file, you can use the /incbin/ statement to include it from a file instead.

As there is no physical EEPROM nor calibration data stored anywhere in he flash there is no easy way the driver could request a board-specific filename, unlike e.g. ath10k requesting BDF from userspace. In the past (e.g. out-of-tree patches for rt2x00 driver allowing it's use on Rt305x WiSoC) this lack of a board-specific filename has lead to people treating the file just like a generic firmware file: ignoring the board-specific nature of calibration data and just copying it from another board... As a work-around to prevent that, we could at least embed the filename in the dts or hack the driver to request a filename based on the top level 'compatible' string of the board's device tree.

I've added Felix to Cc: as he suggested that solution back then.

Cheers

Daniel

#12 lore raw

Aw: Re: [RFC v2 7/7] arm64: dts: mt7986: add Bananapi R3

Hi

Quoted 10 lines

Gesendet: Freitag, 28. Oktober 2022 um 15:49 Uhr
Von: "Daniel Golle" <[email protected]>

Quoted 3 lines · Frank Wunderlich (linux)

Am 2022-10-28 11:19, schrieb AngeloGioacchino Del Regno:

Quoted 2 lines

Il 26/10/22 11:36, Frank Wunderlich ha scritto:

Quoted 1 line

From: Frank Wunderlich <[email protected]>

You could also use device tree overlays to select SDMMC or eMMC just like for the NOR vs. NAND choice on this board.

i recently found a way to compile dtbo via kernel compile-tools

https://github.com/frank-w/BPI-R2-4.14/commit/8a0d96d0932e71dd226b4cca641dcc097b23247c

is this the right way?

imho adding the mmc-node in base dts is better than getting device to boot only with at least one overlay.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 33

Quoted 1 line
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +1 -0
+		factory-key {

I'd say that this is not "factory-key" but "reset-key"?

okay i rename it.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 36

Quoted 3 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +3 -0
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;

At least on my V1.0 board and reportedly also on V1.1 boards the RST button doesn't work. As soon as a NVME/M.2 module is inserted this also connects the GPIO just like if the button was pressed all the time. This issue has also been discussed in BananaPi forums.

maybe drop it for now till we can test it?

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +9 -0
+	mmc0_pins_default: mmc0-pins {
+		mux {
+			function = "emmc";
+			groups = "emmc_51";
+		};
+		conf-cmd-dat {
+			pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
+			       "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
+			       "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 203

Quoted 3 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +3 -0
+			input-enable;
+			drive-strength = <4>;
+			mediatek,pull-up-adv = <1>;	/* pull-up 10K */

Can we please stop using these custom pull-{up,down}-adv properties? Check what was done on pinctrl-mt8192.c (and dt schema) for more information
and examples.

as far as i see it defines array mt8192_pull_type with multiple MTK_PULL_PU_PD_TYPE / MTK_PULL_PUPD_R1R0_TYPE / MTK_PULL_PU_PD_RSEL_TYPE, but have not yet found out how it is working (array only put into mt8192_data.pull_type, no usage of this memeber, see no reference in mt8192.dtsi).

maybe with the

bias-pull-up = <MTK_PULL_SET_RSEL_011>;

in arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi is pointing to this array?

Quoted 25 lines
Quoted 18 lines

need to check these with MTK.

Quoted 16 lines
Quoted 11 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +9 -0
+		};
+		conf-clk {
 
+&wifi {
+	status = "okay";
+	pinctrl-names = "default", "dbdc";
+	pinctrl-0 = <&wf_2g_5g_pins>, <&wf_led_pins>;
+	pinctrl-1 = <&wf_dbdc_pins>, <&wf_led_pins>;
+
+	mediatek,eeprom-data = <0x86790900 0xc4326 0x60000000 0x00 0x00

0x00 0x00 0x00

Ouch! This looks like firmware unrolled in a devicetree property - that can't
be right.

Quoted 6 lines
Quoted 2 lines

Please dump that in a binary file and load it as firmware from userspace.

it uses the mt76 driver and here eeprom can only be loaded from mtd-partition or from device tree. Previous attempts loading eeprom data from userspace file (like it's done for "normal" firmware) were rejected.

Quoted 5 lines

Note that strictly speaking this is not firmware but rather calibration data (ie. board-specific configuration, not code).

In case you don't like the large amount of data in the DTS file, you can use the /incbin/ statement to include it from a file instead.

but this file needs to be inside the kernels tree to get the dts compiled. As this is basicly a blob (and firmware is stored outside) this is tricky.

Quoted 11 lines

As there is no physical EEPROM nor calibration data stored anywhere in he flash there is no easy way the driver could request a board-specific filename, unlike e.g. ath10k requesting BDF from userspace. In the past (e.g. out-of-tree patches for rt2x00 driver allowing it's use on Rt305x WiSoC) this lack of a board-specific filename has lead to people treating the file just like a generic firmware file: ignoring the board-specific nature of calibration data and just copying it from another board... As a work-around to prevent that, we could at least embed the filename in the dts or hack the driver to request a filename based on the top level 'compatible' string of the board's device tree.

Quoted 1 line

I've added Felix to Cc: as he suggested that solution back then.

maybe i should drop it for now to get basic support of the board without wifi till this is solved?

or adding wifi without the eeprom-data property and add firmware (file or directly like now) in my own repo, but this needs to be done in every sourcebase as mainline is then non-functional.

regards Frank

#13 lore raw

Re: [RFC v2 7/7] arm64: dts: mt7986: add Bananapi R3

In reply to AngeloGioacchino Del Regno

Hi

looked now on the keys and regulators comments...

Am 2022-10-28 11:19, schrieb AngeloGioacchino Del Regno:

Quoted 6 lines

Il 26/10/22 11:36, Frank Wunderlich ha scritto:

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts line 18

Quoted 3 lines

From: Frank Wunderlich <[email protected]>
+&mmc0 {

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dts new file +1 -0
+	//sdcard

C-style comments please

i drop it completely if still using the way of an separate sd dts.

Quoted 11 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 33

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		factory-key {

I'd say that this is not "factory-key" but "reset-key"?

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 37

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+		};

i kept definition similar to mt7622-bpi-r64,in shematic it is defined as "reset/factory default" and openwrt wants to use it for "factory" function (afair booting some kind of rescue-system for reflashing nand/nor). basicly it is a gpio connected to different reset-lines (including m.2 slot where it has some side-effects in my board-version).

Quoted 7 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 91

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_1p8v: regulator-1p8v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-1.8V";

This is "avdd18", isn't it?

no it is the 1.8VD used for emmc.

Quoted 9 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 95

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+		regulator-boot-on;
+		regulator-always-on;

All these regulators have a vin-supply: please fill it in. Moreover, in the schematics, I can also see other LDOs: 0.9VD (input +12VD),
AVDD12 (input 1.8VD), DDRV_VPP (input 3.3VD)...

i have not looked for which the others are defined in shematic only added the ones i need to get the board running.

Quoted 1 line

Of course, this means that you have one more 1.8V regulator, called 1.8vd.

this is the right one

Quoted 15 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 100

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_3p3v: regulator-3p3v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-3.3V";

regulator-name = "3.3vd";

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 104

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +4 -0
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;

vin-supply = <&dcin>; (dcin: regulator-12vd { ... })

Quoted 7 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 109

Quoted 5 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +5 -0
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";

regulator-name = "fixed-5p1";

why this regulator name and not regulator-name = "5.1vd"; here (or 5vd)?

Quoted 10 lines

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi line 111

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtsi new file +2 -0
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;

Schematics say "+5V: 5.1V/3A", so this is not 5000000.

Review

Quoted 2 lines
(quoted diff) +2 -0
+		regulator-boot-on;
+		regulator-always-on;

vin-supply = <&dcin>;

basicly i will change the regulator to this:
/* dcin above gpio-keys to preserve alphabetic order - or should i name it reg_dcin to have all regulators together? but dcin should be always above the others which breaks ordering */

	dcin: regulator-12vd {
		compatible = "regulator-fixed";
		regulator-name = "12vd";
		regulator-min-microvolt = <12000000>;
		regulator-max-microvolt = <12000000>;
		regulator-boot-on;
		regulator-always-on;
	};

/* as far as i see in my shematic all regulators here are powered from +12v */

	reg_1p8v: regulator-1p8v {
		compatible = "regulator-fixed";
		regulator-name = "1.8vd";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-boot-on;
		regulator-always-on;
		vin-supply = <&dcin>;
	};

	reg_3p3v: regulator-3p3v {
		compatible = "regulator-fixed";
		regulator-name = "3.3vd";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		regulator-always-on;
		vin-supply = <&dcin>;
	};

	reg_5v: regulator-5v {
		compatible = "regulator-fixed";
		regulator-name  = "fixed-5p1";
		regulator-min-microvolt = <5100000>;
		regulator-max-microvolt = <5100000>;
		regulator-boot-on;
		regulator-always-on;
		vin-supply = <&dcin>;
	};

using a different naming sheme for reg_5v (regulator-name) does not makes sense to me.

regards Frank

#14 lore raw
In reply to Frank Wunderlich

Hi,

any comments on Parts 2,3,4 and 6?

Quoted 4 lines

arm64: dts: mt7986: add i2c node
arm64: dts: mt7986: add spi related device nodes
arm64: dts: mt7986: add usb related device nodes
arm64: dts: mt7986: add crypto related device nodes

maybe they are ready to merge? mtk is working on mmc-pinctrl and i work on the other comments for r3 dts.

regards Frank