[OpenWrt-Devel] mt7620a serial port driver ordering of nodes uart/uartlite vs ttyS0/ttyS1 patch

Luis Soltero lsoltero at globalmarinenet.com
Fri Aug 29 17:56:13 EDT 2014

Hello All,

Most mt7620a routers defined in the target/linux/ramips/dts have exactly one serial port defined which is used for the
console.  The serial port driver links this to node /dev/ttyS0.

However.  one (and now 2) devices use the mt7620a serial port lines for use as a second real serial port (uart at 500 in
the dts).   Currently when when more than one serial port is defined  the boot sequence starts with the console attached
to uartlite but as soon as the serial port driver driver is loaded it deactivates the console and assigns it to
/dev/ttyS1 (which is the node created for uartlite).  So on these systems using the standard dts configuration the
mt7620a enhanced uart is bound to /dev/ttyS0 and uartlite is bound /dev/ttyS1.

This causes the console serial port to stop displaying output unless the following is added to the dts definition

        chosen {
                bootargs = "console=ttyS1,57600";

which redefines the console to /dev/ttyS1... this configuration works fine.   However some (including me) find this very
irritating.  These few routers defining a second serial port differ from all the others in their definition of
/dev/ttyS0 as the console.

So... for consistency it seems that it would be much better for ** ALL ** routers regardless of the number of serial
ports define /dev/ttyS0 as the console port.

The reason for the renumbering is due to the serial port driver to assign nodes on a first come first basis in the dts
definition.  Since in mt7620a.dtsi (included by most/all 7620a router board definitions) the definition for uart at 500 is
before that for uartlite at 00.  So  uart gets assigned /dev/ttyS0 while uartlite gets /dev/ttyS1.  You can't fault the
serial driver for doing it.  After all it really doesn't know for what purpose the serial port is to be used. 

A logical extension to the serial port dts properties would be to add a "node-name" or "node-order" or "node-number"
property that would allow the integrator to specify the node number or the node name for the serial port. However these
properties don't exist (or at least they were not obvious in either the source code or the documentation).  So... a
simple "fix" for the ordering is to reorder the definitions in mt7620a.dtsi.

This reordering affects exactly one mt7620a router in the dts definitions as of r42293 (NA930.dts).

Attached you will find a patch which modifies both mt7620a.dtsi and NA930.dts assigning the console to /dev/ttyS0 for
devices with more than one serial port.

Note that a similar issue applies to the RT5350.  Although we are currently not working with that architecture I am
happy to supply a patch if the community would like one.

here is a snippet from the boot log of our mt7620a board showing a console happily bound to /dev/ttyS0 and the second
serial port bound to /dev/ttyS1

[    0.350000] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.370000] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 20) is a 16550A
[    0.380000] console [ttyS0] enabled, bootconsole disabled
[    0.380000] console [ttyS0] enabled, bootconsole disabled
[    0.410000] 10000500.uart: ttyS1 at MMIO 0x10000500 (irq = 13) is a 16550A



Luis Soltero, Ph.D., MCS
Director of Software Development, CTO
Global Marine Networks, LLC
StarPilot, LLC
Tel: +1.865.379.8723
Fax: +1.865.681.5017
E-Mail: lsoltero at globalmarinenet.net
Web: http://www.globalmarinenet.net
Web: http://www.redportglobal.com
Web: http://www.starpilotllc.com

-------------- next part --------------
diff --git a/target/linux/ramips/dts/NA930.dts b/target/linux/ramips/dts/NA930.dts
index 6fe9964..ca25beb 100644
--- a/target/linux/ramips/dts/NA930.dts
+++ b/target/linux/ramips/dts/NA930.dts
@@ -7,7 +7,7 @@
 	model = "Sercomm NA930";
 	chosen {
-		bootargs = "console=ttyS1,57600";
+		bootargs = "console=ttyS0,57600";
 	pinctrl {
diff --git a/target/linux/ramips/dts/mt7620a.dtsi b/target/linux/ramips/dts/mt7620a.dtsi
index 9d077ee..669d69c 100644
--- a/target/linux/ramips/dts/mt7620a.dtsi
+++ b/target/linux/ramips/dts/mt7620a.dtsi
@@ -77,6 +77,22 @@
 			interrupts = <3>;
+		uartlite at c00 {
+			compatible = "ralink,mt7620a-uart", "ralink,rt2880-uart", "ns16550a";
+			reg = <0xc00 0x100>;
+			resets = <&rstctrl 19>;
+			reset-names = "uartl";
+			interrupt-parent = <&intc>;
+			interrupts = <12>;
+			reg-shift = <2>;
+			pinctrl-names = "default";
+			pinctrl-0 = <&uartlite_pins>;
+		};
 		uart at 500 {
 			compatible = "ralink,mt7620a-uart", "ralink,rt2880-uart", "ns16550a";
 			reg = <0x500 0x100>;
@@ -218,22 +234,6 @@
 			pinctrl-0 = <&spi_pins>;
-		uartlite at c00 {
-			compatible = "ralink,mt7620a-uart", "ralink,rt2880-uart", "ns16550a";
-			reg = <0xc00 0x100>;
-			resets = <&rstctrl 19>;
-			reset-names = "uartl";
-			interrupt-parent = <&intc>;
-			interrupts = <12>;
-			reg-shift = <2>;
-			pinctrl-names = "default";
-			pinctrl-0 = <&uartlite_pins>;
-		};
 		systick at d00 {
 			compatible = "ralink,mt7620a-systick", "ralink,cevt-systick";
 			reg = <0xd00 0x10>;
-------------- next part --------------
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list