Getting uart0 enabled

@frank-w can you help with getting uart0 (pins 11/13 11002000) enabled?

I have followed your instructions here: http://wiki.fw-web.de/doku.php?id=en/bpi-r2/gpio#port_preferences but cannot get it working. I am using your kernel source from https://github.com/frank-w/BPI-R2-4.14.git and my current build is is 4.9.119-bpi-r2-4.9-main I made the following change to change to mt7623n-bananapi-bpi-r2.dts

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_pins_a>;
	status = "okay";
};

dmesg only shows the debug uart.
[    0.267530] console [ttyS0] disabled
[    0.287725] 11004000.serial: ttyS0 at MMIO 0x11004000 (irq = 196, base_baud = 1625000) is a ST16650V2
[    0.999298] console [ttyS0] enabled

Thanks

Have you added uart0_pins_a block too? Node have to be inside &pio

This already exists inside &pio block.

uart0_pins_a: uart@0 {
	pins_dat {
		pinmux = <MT7623_PIN_79_URXD0_FUNC_URXD0>,
			 <MT7623_PIN_80_UTXD0_FUNC_UTXD0>;
	};
};

Is that what you meant?
Otherwise please paste your settings and I will copy them.

should be right…can you post your full dts as file.

We can look in sysfs but i have to look at home for right keys…

[12:46] frank@bpi-r2-e:~$ ls -l /sys/firmware/devicetree/base/serial\@11002000/
insgesamt 0
-r--r--r-- 1 root root  9 Aug 20 12:46 clock-names
-r--r--r-- 1 root root 16 Aug 20 12:46 clocks
-r--r--r-- 1 root root 42 Aug 20 12:46 compatible
-r--r--r-- 1 root root 12 Aug 20 12:46 interrupts
-r--r--r-- 1 root root  7 Aug 20 12:46 name
-r--r--r-- 1 root root  4 Aug 20 12:46 pinctrl-0
-r--r--r-- 1 root root  8 Aug 20 12:46 pinctrl-names
-r--r--r-- 1 root root 16 Aug 20 12:46 reg
-r--r--r-- 1 root root  5 Aug 20 12:46 status
[12:46] frank@bpi-r2-e:~$ cat /sys/firmware/devicetree/base/serial\@11002000/status
okay[12:46] frank@bpi-r2-e:~$

Ok here it is.

mt7623n-bananapi-bpi-r2.dts (19.1 KB)

I just retried this and cat /sys/firmware/devicetree/base/serial@11002000/status shows okay but still nothing in dmesg and stty -F /dev/ttyS1 gives Input/output error as it doesn’t exist.

Also setserial -g /dev/ttyS0 shows the expected /dev/ttyS0, UART: 16650V2, Port: 0x0000, IRQ: 196 but /dev/ttyS1 shows UART: unknown, Port: 0x0000, IRQ: 0 on ttyS1. Also ttyS2 as expected /dev/ttyS2, UART: unknown, Port: 0x0000, IRQ: 0.

I have no idea how to proceed.

Have you added uart0/uart1 to dtdi too?

I see youve included it twice…imho this should throw an error…but try to remove duplicate

Sorry now I have absolutely no idea what you mean. :slight_smile:

I can’t actually see anything included twice so perhaps you could point this out to me?
I haven’t actually “included” anything.
I actually just changed the file that was pulled from your git so if anything is included twice it was probably already there.

Please excuse my ignorance but this kernel building is fairly new to me.
Thanks

#include "mt7623.dtsi"
#include "mt6323.dtsi"

And uart0 have to exist in this file too

mt7623.dtsi has the actual definitions for uart0: serial@11002000 { , uart1, uart2, uart3 as in

uart0: serial@11002000 {
	compatible = "mediatek,mt7623-uart",
		     "mediatek,mt6577-uart";
	reg = <0 0x11002000 0 0x400>;
	interrupts = <GIC_SPI 51 IRQ_TYPE_LEVEL_LOW>;
	clocks = <&pericfg CLK_PERI_UART0_SEL>,
		 <&pericfg CLK_PERI_UART0>;
	clock-names = "baud", "bus";
	status = "okay";
};

mt6323.dtsi has nothing about uarts at all. Does this mean I have to copy the above defs to mt6323 as well or just

&uart0 { pinctrl-names = “default”; pinctrl-0 = <&uart0_pins_a>; status = “okay”; };

mt6323.dtsi (6.4 KB) mt7623.dtsi (26.1 KB)

Well after adding the following to both mt6323.dtsi and mt7623.dtsi unfortunately it still doesn’t work.

&uart0 { status = “okay”; };

&uart1 { status = “okay”; };

cat /sys/firmware/devicetree/base/serial@11002000/status shows okay but no ttyS* devices for ether uart0 or uart1.

Sorry,youre right these are 2 different files…too early in the morning :slight_smile:

Ok,please take a look at config…there is an option to limit the uart-ports…

Why do you use 4.9 and not 4.14 where these ports are enabled?

SERIAL_8250_NR_UARTS is already set to 4
SERIAL_8250_RUNTIME_UARTS is already set to 4
CONFIG_SERIAL_8250 is enabled
CONFIG_SERIAL_8250_CONSOLE is enabled
CONFIG_SERIAL_8250_MT6577 is enabled
CONFIG_SERIAL_8250_BTIF doesn’t exist.

I like 4.9.
I have been using this as a router since I got it and apart from these small things like 1-wire, pps and the uarts everything else appears to work perfectly.
Just need the uarts to work now so I can use my gps.
So back to the uarts.
Any other ideas?

I am also seeing this in the logs
[ 0.266820] mt6577-uart: probe of 11002000.serial failed with error -22
[ 0.266907] mt6577-uart: probe of 11003000.serial failed with error -22

Managed to get uart3 to work after adding the missing defs from 4.14 to 4.9
Still no uart0 or uart1.

udevadm info /sys/devices/platform/11002000.serial shows no driver
P: /devices/platform/11002000.serial
E: DEVPATH=/devices/platform/11002000.serial
E: MODALIAS=of:NserialTCmediatek,mt7623-uartCmediatek,mt6577-uart
E: OF_COMPATIBLE_0=mediatek,mt7623-uart
E: OF_COMPATIBLE_1=mediatek,mt6577-uart
E: OF_COMPATIBLE_N=2
E: OF_FULLNAME=/serial@11002000
E: OF_NAME=serial
E: SUBSYSTEM=platform

udevadm info /sys/devices/platform/11004000.serial shows a driver
P: /devices/platform/11004000.serial
E: DEVPATH=/devices/platform/11004000.serial
E: DRIVER=mt6577-uart
E: MODALIAS=of:NserialTCmediatek,mt7623-uartCmediatek,mt6577-uart
E: OF_ALIAS_0=serial2
E: OF_COMPATIBLE_0=mediatek,mt7623-uart
E: OF_COMPATIBLE_1=mediatek,mt6577-uart
E: OF_COMPATIBLE_N=2
E: OF_FULLNAME=/serial@11004000
E: OF_NAME=serial
E: SUBSYSTEM=platform

Uart3? This are the 2 dots near debuguart without pinheader…

i try to add uart0/1 if i have bit more time at home…can take some days

This is commit from 4.4 where i have added uart0/1 (pls ignore commit-msg):

Ok.
It’s weird that uart3 and uart2 have a driver associated with them.
Something weird here.

You can try to change compatible-string to that from uart2 (which is working)

Strings look the same
compatible = “mediatek,mt7623-uart”,“mediatek,mt6577-uart”;
Just tried, Didn’t seem to do anything.

Compatable is the same between uart0 and uart2 anyway.
E: OF_COMPATIBLE_0=mediatek,mt7623-uart
E: OF_COMPATIBLE_1=mediatek,mt6577-uart

Finally!
All uarts working under kernel 4.9.
uart3 is disabled and I will plug something into uart1 later today but uart0 is happily working away as I type.

[ 0.286814] 11004000.serial: ttyS0 at MMIO 0x11004000 (irq = 195, base_baud = 1625000) is a ST16650V2
[ 1.008495] 11002000.serial: ttyS1 at MMIO 0x11002000 (irq = 196, base_baud = 1625000) is a ST16650V2
[ 1.038531] 11003000.serial: ttyS2 at MMIO 0x11003000 (irq = 197, base_baud = 1625000) is a ST16650V2
See the dts* attachments for the changes.
mt7623.dtsi (2.5 KB) mt7623n-bananapi-bpi-r2.dts (908 Bytes)