Skip to contentSkip to conversation

Port Aspeed VUART driver to 4.6/AST2500

PATCH New Xo Wang 1 participant 3 messages Aug 4, 2016

Subsystems (5)
lore
Share & tools
lore

Xo Wang

author
#0 lore raw

cover Port Aspeed VUART driver to 4.6/AST2500

Hi folks,

I've been experimenting with LPC by attaching a machine to the LPC header on the AST2500 EVB. I had VUART enabled and discarding bytes to test LPC functionality. But, I wanted to see the actual bytes on-screen so I ported these patches to the kernel we're using for the AST2500.

The patches are tested on the EVB (with uart6 enabled in the dts) to verify that bytes appeared on the TTY. obmc-console-server/-client also work after aliasing ttyS5 to uart6 as configured in the phosphor image.

cheers
xo

author
#1 lore raw

PATCH 1/2 drivers/serial: Add driver for Aspeed virtual UART

From: Jeremy Kerr <[email protected]>

This change adds a driver for the 16550-based Aspeed virtual UART device. We use a similar process to the of_serial driver for device probe, but expose some VUART-specific functions through sysfs too.

If host TX discard mode is enabled, we don't see the LSR[RBR} bit getting set on new characters written on the host side. This makes the VUART a little useless.

OpenPOWER firmware doesn't like it when the host-side of the VUART's FIFO is not drained. This change only disables host TX discard mode when the port is in use. We set the VUART enabled bit when we bind to the device, and clear it on unbind.

We don't want to do this on open/release, as the host may be using this bit to configure serial output modes, which is independent of whether the devices has been opened by BMC userspace.

---
 Documentation/devicetree/bindings/serial/8250.txt |   1 +
 drivers/tty/serial/Kconfig                        |  10 +
 drivers/tty/serial/Makefile                       |   1 +
 drivers/tty/serial/aspeed-vuart.c                 | 333 ++++++++++++++++++++++
 4 files changed, 345 insertions(+)
 create mode 100644 drivers/tty/serial/aspeed-vuart.c
Documentation/devicetree/bindings/serial/8250.txt +1 -0
index 936ab5b..ee6b3e8 100644
@@ -19,6 +19,7 @@ Required properties:
 	- "altr,16550-FIFO128"
 	- "fsl,16550-FIFO64"
 	- "fsl,ns16550"
+	- "aspeed,vuart"
 	- "serial" if the port type is unknown.
 - reg : offset and length of the register set for the device.
 - interrupts : should contain uart interrupt.
drivers/tty/serial/Kconfig +10 -0
index 13d4ed6..db6c677 100644
@@ -1093,6 +1093,16 @@ config SERIAL_NETX_CONSOLE
 	  If you have enabled the serial port on the Hilscher NetX SoC
 	  you can make it the console by answering Y to this option.
 
+config SERIAL_ASPEED_VUART
+	tristate "Aspeed Virtual UART"
+	depends on OF
+	depends on SERIAL_8250
+	help
+	  If you want to use the virtual UART (VUART) device on Aspeed
+	  BMC platforms, enable this option. This enables the 16550A-
+	  compatible device on the local LPC bus, giving a UART device
+	  with no physical RS232 connections.
+
 config SERIAL_OMAP
 	tristate "OMAP serial port support"
 	depends on ARCH_OMAP2PLUS
drivers/tty/serial/Makefile +1 -0
index 8c261ad..5c8f2c73 100644
@@ -62,6 +62,7 @@ obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o
 obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
 obj-$(CONFIG_SERIAL_MSM) += msm_serial.o
 obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
+obj-$(CONFIG_SERIAL_ASPEED_VUART) += aspeed-vuart.o
 obj-$(CONFIG_SERIAL_KGDB_NMI) += kgdb_nmi.o
 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
 obj-$(CONFIG_SERIAL_OMAP) += omap-serial.o
drivers/tty/serial/aspeed-vuart.c new file +333 -0

333 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3.226.g39d4020
author
#2 lore raw

PATCH 2/2 arm/aspeed: Enable VUART driver

In reply to Xo Wang

From: Jeremy Kerr <[email protected]>

This change makes use of the new VUART device driver. We need a separate compatible property for the VUART node, and a fix for the interrupt definitions. We also change the SCU setup to notify host firmware that the VUART is available.

---
 arch/arm/boot/dts/aspeed-g4.dtsi  | 6 +++---
 arch/arm/boot/dts/aspeed-g5.dtsi  | 6 +++---
 arch/arm/configs/aspeed_defconfig | 3 +++
 arch/arm/mach-aspeed/aspeed.c     | 2 +-
 4 files changed, 10 insertions(+), 7 deletions(-)
arch/arm/boot/dts/aspeed-g4.dtsi +3 -3
index ff1eb0b..41c59ab 100644
@@ -174,11 +174,11 @@
 				status = "disabled";
 			};
 
-			uart6: serial@1e787000 {
-				compatible = "ns16550a";
+			uart6: vuart@1e787000 {
+				compatible = "aspeed,vuart";
 				reg = <0x1e787000 0x1000>;
 				reg-shift = <2>;
-				interrupts = <10>;
+				interrupts = <8>;
 				clocks = <&clk_uart>;
 				no-loopback-test;
 				status = "disabled";
arch/arm/boot/dts/aspeed-g5.dtsi +3 -3
index afddbb8..6aaddfb 100644
@@ -191,11 +191,11 @@
 				status = "disabled";
 			};
 
-			uart6: serial@1e787000 {
-				compatible = "ns16550a";
+			uart6: vuart@1e787000 {
+				compatible = "aspeed,vuart";
 				reg = <0x1e787000 0x1000>;
 				reg-shift = <2>;
-				interrupts = <10>;
+				interrupts = <8>;
 				clocks = <&clk_uart>;
 				no-loopback-test;
 				status = "disabled";
arch/arm/configs/aspeed_defconfig +3 -0
index 4d850fc..003d39d 100644
@@ -94,6 +94,9 @@ CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=6
 CONFIG_SERIAL_8250_RUNTIME_UARTS=6
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_ASPEED_VUART=y
 CONFIG_SERIAL_OF_PLATFORM=y
 CONFIG_SERIAL_ASPEED_VUART=y
 CONFIG_HW_RANDOM=y
arch/arm/mach-aspeed/aspeed.c +1 -1
index dd9b3b8..9c9f6bc 100644
@@ -119,7 +119,7 @@ static void __init do_common_setup(void)
 
 	/* Setup scratch registers */
 	writel(0x00000042, AST_IO(AST_BASE_LPC | 0x170));
-	writel(0x00004000, AST_IO(AST_BASE_LPC | 0x174));
+	writel(0x00008000, AST_IO(AST_BASE_LPC | 0x174));
 }
 
 static void __init do_barreleye_setup(void)
Signature · 1 line
2.8.0.rc3.226.g39d4020