Skip to contentSkip to conversation

fix up pin definitions for BPI-R3 board

PATCH In review Leith Bade 6 participants 12 messages Jun 27, 2024 – Jul 30, 2024

Subsystems (2)
lore
Share & tools
lore

Leith Bade

author
#0 lore raw

cover fix up pin definitions for BPI-R3 board

This is my first patch submission to Linux so I apologise in advance for any mistakes.

These changes were motivated by a pin conflict with the PCIe M.2 connector and the push buttons. As a result I decided go work through all 100 GPIO pins using the public board schematics. As I need to acquire a M.2 SSD to test the PCIe pin change that patch is not included in this series yet.

Working though the pins I noticed a bug with with the MT7531 chip's reset line which was on the wrong GPIO. Since it was conflicting with the boot mode switch input GPIO pins I looked into ways to document the use of those pins with the switch. I ended up choosing a gpio-hog, but please let me know if there is a better alternative.

I also added some missing pin groups for some of the built-in SoC devices to clearly document the use of those GPIO pins.

I have actually written up a gpio-line-names list give all the pins names to match their usage on this board. If there is interest in this I can submit this as an additional patch. I see only some MT8xxx devices in the mediatek directory have a gpio-line-names so I wasn't sure if I should add it.

author
#1 lore raw

PATCH 1/4 arm64: dts: mediatek: mt7986: fix the switch reset line on BPI-R3

The current GPIO definition for the MT7531 switch reset line incorrectly specifies a pin GPIO_0 (GPIO5) that is connected to the boot mode selection DIP switch (SW1).

In the public schematic for the BPI-R3 (titled "BPI-R3-MT7986A", revision "V1.1", sheet 4), the SPI1_CS (GPIO32) pin of the MT7986 (U1E) is connected to the GbE_RESET net.

Frank Wunderlich has told me, via the Banana Pi forum, that this GbE_RESET net connects to the MT7531 reset line in the private part of the shematic he has a copy of.

---
 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts +1 -1
index ed79ad1ae871..951612ea1e66 100644
@@ -206,7 +206,7 @@ switch: switch@31 {
 		interrupt-controller;
 		#interrupt-cells = <1>;
 		interrupts-extended = <&pio 66 IRQ_TYPE_LEVEL_HIGH>;
-		reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&pio 32 GPIO_ACTIVE_HIGH>;
 	};
 };
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] arm64: dts: mediatek: mt7986: fix the switch reset line on BPI-R3

Il 27/06/24 09:58, Leith Bade ha scritto:

Quoted 4 lines

The current GPIO definition for the MT7531 switch reset line incorrectly specifies a pin GPIO_0 (GPIO5) that is connected to the boot mode selection DIP switch (SW1).

Quoted 8 lines

In the public schematic for the BPI-R3 (titled "BPI-R3-MT7986A", revision "V1.1", sheet 4), the SPI1_CS (GPIO32) pin of the MT7986 (U1E) is connected to the GbE_RESET net.

Frank Wunderlich has told me, via the Banana Pi forum, that this GbE_RESET net connects to the MT7531 reset line in the private part of the shematic he has a copy of.

This commit needs a Fixes tag. After which,

Quoted 18 lines
---
  arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts +1 -1
index ed79ad1ae871..951612ea1e66 100644
@@ -206,7 +206,7 @@ switch: switch@31 {
  		interrupt-controller;
  		#interrupt-cells = <1>;
  		interrupts-extended = <&pio 66 IRQ_TYPE_LEVEL_HIGH>;
-		reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&pio 32 GPIO_ACTIVE_HIGH>;
  	};
  };
 
author
#3 lore raw

PATCH 2/4 arm64: dts: mediatek: mt7986: add gpio-hog for boot mode switch on BPI-R3

In reply to Leith Bade

To avoid future pin conflicts with the boot mode dip switch (SW1), add a gpio-hog to document the two GPIOs it is connected to. If another device attempts to then claim the pins a log message will get printed.

The BPI-R3 has a four position DIP switch (labelled SW1), that is used to configure the boot mode. The first two positions (labelled A & B) configure two bootstrap pins on the MT7986 that select which flash chip the boot ROM will load the second stage bootloader from. The third position toggles chip select lines to select between the NOR or NAND chip on the SPI0 bus. The fourth position toggles chip select lines to select between the eMMC chip or SD card on the MMC0 bus.

Only the first two positions are connected to GPIO pins on the MT7986. In the public schematic for the BPI-R3 (titled "BPI-R3-MT7986A", revision "V1.1", sheet 4), these are the MT7986 (U1E) pins GPIO_0 (GPIO5) and GPIO_1 (GPIO6). This gpio-hog configures the two boot mode pins as inputs.

---
 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts +7 -0
index 951612ea1e66..2cccbec39d34 100644
@@ -235,6 +235,13 @@ &pcie_phy {
 };
 
 &pio {
+	boot_mode_hog: boot-mode-hog {
+		gpio-hog;
+		gpios = <5 GPIO_ACTIVE_HIGH>,
+			<6 GPIO_ACTIVE_HIGH>;
+		input;
+	};
+
 	i2c_pins: i2c-pins {
 		mux {
 			function = "i2c";
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH 2/4] arm64: dts: mediatek: mt7986: add gpio-hog for boot mode switch on BPI-R3

kernel test robot noticed the following build warnings:

Hi Leith,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.10-rc6 next-20240703] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Leith-Bade/arm64-dts-mediatek-mt7986-fix-the-switch-reset-line-on-BPI-R3/20240628-001353
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20240627075856.2314804-3-leith%40bade.nz
patch subject: [PATCH 2/4] arm64: dts: mediatek: mt7986: add gpio-hog for boot mode switch on BPI-R3
config: arm64-randconfig-051-20240703 (https://download.01.org/0day-ci/archive/20240703/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
dtschema version: 2024.6.dev3+g650bf2d
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240703/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

dtcheck warnings: (new ones prefixed by >>)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi:431.19-445.5: Warning (simple_bus_reg): /soc/t-phy: missing or empty reg/ranges property

>> arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: pinctrl@1001f000: 'boot-mode-hog' does not match any of the regexes: '-pins$', 'pinctrl-[0-9]+'

from schema $id: http://devicetree.org/schemas/pinctrl/mediatek,mt7986-pinctrl.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: crypto@10320000: interrupts: [[0, 116, 4], [0, 117, 4], [0, 118, 4], [0, 119, 4]] is too short
from schema $id: http://devicetree.org/schemas/crypto/inside-secure,safexcel.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: crypto@10320000: interrupt-names: ['ring0', 'ring1', 'ring2', 'ring3'] is too short
from schema $id: http://devicetree.org/schemas/crypto/inside-secure,safexcel.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: switch@31: 'interrupts' is a dependency of 'interrupt-controller'
from schema $id: http://devicetree.org/schemas/net/dsa/mediatek,mt7530.yaml#

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#5 lore raw

Re: [PATCH 2/4] arm64: dts: mediatek: mt7986: add gpio-hog for boot mode switch on BPI-R3

Quoted 9 lines · kernel test robot

Hi Leith,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.10-rc6 next-20240703]

dtcheck warnings: (new ones prefixed by >>)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi:431.19-445.5: Warning (simple_bus_reg): /soc/t-phy: missing or empty reg/ranges property

Quoted 8 lines
Quoted 1 line
Quoted 1 line

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: pinctrl@1001f000: 'boot-mode-hog' does not match any of the regexes: '-pins$', 'pinctrl-[0-9]+'

from schema $id: http://devicetree.org/schemas/pinctrl/mediatek,mt7986-pinctrl.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: crypto@10320000: interrupts: [[0, 116, 4], [0, 117, 4], [0, 118, 4], [0, 119, 4]] is too short
from schema $id: http://devicetree.org/schemas/crypto/inside-secure,safexcel.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: crypto@10320000: interrupt-names: ['ring0', 'ring1', 'ring2', 'ring3'] is too short
from schema $id: http://devicetree.org/schemas/crypto/inside-secure,safexcel.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: switch@31: 'interrupts' is a dependency of 'interrupt-controller'
from schema $id: http://devicetree.org/schemas/net/dsa/mediatek,mt7530.yaml#

Is this one more noise / false positive report?

Intel, please filter your emails only to relevant reports. I am really getting tired of them.

Best regards,
Krzysztof

#6 lore raw

Re: [PATCH 2/4] arm64: dts: mediatek: mt7986: add gpio-hog for boot mode switch on BPI-R3

Quoted 20 lines · Krzysztof Kozlowski
Quoted 9 lines · kernel test robot

Hi Leith,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.10-rc6 next-20240703]

dtcheck warnings: (new ones prefixed by >>)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi:431.19-445.5: Warning (simple_bus_reg): /soc/t-phy: missing or empty reg/ranges property

Quoted 8 lines
Quoted 1 line
Quoted 1 line

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: pinctrl@1001f000: 'boot-mode-hog' does not match any of the regexes: '-pins$', 'pinctrl-[0-9]+'

from schema $id: http://devicetree.org/schemas/pinctrl/mediatek,mt7986-pinctrl.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: crypto@10320000: interrupts: [[0, 116, 4], [0, 117, 4], [0, 118, 4], [0, 119, 4]] is too short
from schema $id: http://devicetree.org/schemas/crypto/inside-secure,safexcel.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: crypto@10320000: interrupt-names: ['ring0', 'ring1', 'ring2', 'ring3'] is too short
from schema $id: http://devicetree.org/schemas/crypto/inside-secure,safexcel.yaml#
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: switch@31: 'interrupts' is a dependency of 'interrupt-controller'
from schema $id: http://devicetree.org/schemas/net/dsa/mediatek,mt7530.yaml#

Quoted 4 lines

Is this one more noise / false positive report?

Intel, please filter your emails only to relevant reports. I am really getting tired of them.

Got it, sorry for the noise. We will configure the bot to avoid sending false reports in future.

Quoted 5 lines

Best regards,
Krzysztof

author
#7 lore raw

PATCH 3/4 arm64: dts: mediatek: mt7986: add missing pin groups to BPI-R3

In reply to Leith Bade

The uart0, mdio and switch nodes are not connected to pin groups unlike most of the other nodes.

---
 .../dts/mediatek/mt7986a-bananapi-bpi-r3.dts  | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts +27 -0
index 2cccbec39d34..54087001cc8c 100644
@@ -194,6 +194,8 @@ gmac1: mac@1 {
 	};
 
 	mdio: mdio-bus {
+		pinctrl-names = "default";
+		pinctrl-0 = <&mdio_pins>;
 		#address-cells = <1>;
 		#size-cells = <0>;
 	};
@@ -206,6 +208,8 @@ switch: switch@31 {
 		interrupt-controller;
 		#interrupt-cells = <1>;
 		interrupts-extended = <&pio 66 IRQ_TYPE_LEVEL_HIGH>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&switch_pins>;
 		reset-gpios = <&pio 32 GPIO_ACTIVE_HIGH>;
 	};
 };
@@ -335,6 +339,13 @@ mux {
 		};
 	};
 
+	uart0_pins: uart0-pins {
+		mux {
+			function = "uart";
+			groups = "uart0";
+		};
+	};
+
 	uart1_pins: uart1-pins {
 		mux {
 			function = "uart";
@@ -349,6 +360,20 @@ mux {
 		};
 	};
 
+	mdio_pins: mdio-pins {
+		mux {
+			function = "eth";
+			groups = "mdc_mdio";
+		};
+	};
+
+	switch_pins: switch-pins {
+		mux {
+			function = "eth";
+			groups = "switch_int";
+		};
+	};
+
 	wf_2g_5g_pins: wf-2g-5g-pins {
 		mux {
 			function = "wifi";
@@ -471,6 +496,8 @@ &trng {
 };
 
 &uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins>;
 	status = "okay";
 };
 
Signature · 1 line
2.25.1
author
#8 lore raw

PATCH 4/4 arm64: dts: mediatek: mt7986: add missing UART1 CTS/RTS pins in BPI-R3

In reply to Leith Bade

The current definition of the uart1_pins pin group does not include the CTS and RTS pins that are available on header CON1.

In the public schematic for the BPI-R3 (titled "BPI-R3-MT7986A", revision "V1.1", sheet 4), the UART1_RTS and UART1_CTS pins are connected via nets to the connector CON1 (sheet 14) UART0-RTS and UART0-CTS pins. The datasheet does not show these nets as connected to anything else.

These pins can be configured for either UART1 or as a GPIO, with no other alternate usage listed in the pinctrl driver. By changing the pin group definition from uart1_rx_tx to uart1 the additional RTS and CTS pins are included.

---
 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts +1 -1
index 54087001cc8c..48bd1e04963c 100644
@@ -349,7 +349,7 @@ mux {
 	uart1_pins: uart1-pins {
 		mux {
 			function = "uart";
-			groups = "uart1_rx_tx";
+			groups = "uart1";
 		};
 	};
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 4/4
#9 lore raw

Re: [PATCH 4/4] arm64: dts: mediatek: mt7986: add missing UART1 CTS/RTS pins in BPI-R3

Il 27/06/24 09:58, Leith Bade ha scritto:

Quoted 8 lines

The current definition of the uart1_pins pin group does not include the CTS and RTS pins that are available on header CON1.

In the public schematic for the BPI-R3 (titled "BPI-R3-MT7986A", revision "V1.1", sheet 4), the UART1_RTS and UART1_CTS pins are connected via nets to the connector CON1 (sheet 14) UART0-RTS and UART0-CTS pins. The datasheet does not show these nets as connected to anything else.

Quoted 6 lines

These pins can be configured for either UART1 or as a GPIO, with no other alternate usage listed in the pinctrl driver. By changing the pin group definition from uart1_rx_tx to uart1 the additional RTS and CTS pins are included.

Fixes tag please, after which:

Cheers,
Angelo

#10 lore raw
In reply to Leith Bade
Quoted 14 lines · Leith Bade

This is my first patch submission to Linux so I apologise in advance for any mistakes.

These changes were motivated by a pin conflict with the PCIe M.2 connector and the push buttons. As a result I decided go work through all 100 GPIO pins using the public board schematics. As I need to acquire a M.2 SSD to test the PCIe pin change that patch is not included in this series yet.

Working though the pins I noticed a bug with with the MT7531 chip's reset line which was on the wrong GPIO. Since it was conflicting with the boot mode switch input GPIO pins I looked into ways to document the use of those pins with the switch. I ended up choosing a gpio-hog, but please let me know if there is a better alternative.

Quoted 12 lines

I also added some missing pin groups for some of the built-in SoC devices to clearly document the use of those GPIO pins.

I have actually written up a gpio-line-names list give all the pins names to match their usage on this board. If there is interest in this I can submit this as an additional patch. I see only some MT8xxx devices in the mediatek directory have a gpio-line-names so I wasn't sure if I should add it.

My bot found new DTB warnings on the .dts files added or changed in this series.

Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings are fixed by another series. Ultimately, it is up to the platform maintainer whether these warnings are acceptable or not. No need to reply unless the platform maintainer has comments.

If you already ran DT checks and didn't see these error(s), then make sure dt-schema is up to date:

  pip3 install dtschema --upgrade

New warnings running 'make CHECK_DTBS=y mediatek/mt7986a-bananapi-bpi-r3.dtb' for [email protected]:

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: pinctrl@1001f000: 'boot-mode-hog' does not match any of the regexes: '-pins$', 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/pinctrl/mediatek,mt7986-pinctrl.yaml#

author
#11 lore raw
Quoted 4 lines · Rob Herring (Arm)

New warnings running 'make CHECK_DTBS=y mediatek/mt7986a-bananapi-bpi-r3.dtb' for [email protected]:

arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dtb: pinctrl@1001f000: 'boot-mode-hog' does not match any of the regexes: '-pins$', 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/pinctrl/mediatek,mt7986-pinctrl.yaml#

I saw this warning as well when I ran the DT schema check.

However I think this is a false warning as the gpio-hog schema requires "*-hog" in the name, but the MT7986 pinctrl schema doesn't allow for this.

Looking at other examples of gpio-hog I can see in arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi some hogs that are very similar to my new one with "*-hog" in the name under a node with "gpio-controller". Another example is arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts which has a hog ("asm_sel") under "pio" which is the same location as my new hog, but this one seems to violate the requirement for "hog" to be in the name.