Skip to contentSkip to conversation

serial: 8250_tegra: Create Tegra specific 8250 driver

PATCH Superseded Jon Hunter 3 participants 7 messages Jan 20, 2020 – Jan 21, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jon Hunter

author maintainer
#0 lore raw

PATCH 1/1 serial: 8250_tegra: Create Tegra specific 8250 driver

From: Jeff Brasen <[email protected]>

To support booting NVIDIA Tegra platforms with either Device-Tree or ACPI, create a Tegra specific 8250 serial driver that supports both firmware types. Another benefit from doing this, is that the Tegra specific codec in the generic Open Firmware 8250 driver can now be removed.

---
 drivers/tty/serial/8250/8250_of.c    |  28 ----
 drivers/tty/serial/8250/8250_tegra.c | 197 +++++++++++++++++++++++++++
 drivers/tty/serial/8250/Kconfig      |   9 ++
 drivers/tty/serial/8250/Makefile     |   1 +
 4 files changed, 207 insertions(+), 28 deletions(-)
 create mode 100644 drivers/tty/serial/8250/8250_tegra.c
drivers/tty/serial/8250/8250_of.c +0 -28
index 531ad67395e0..5e45cf8dbc6e 100644
@@ -7,7 +7,6 @@
 #include <linux/console.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/delay.h>
 #include <linux/serial_core.h>
 #include <linux/serial_reg.h>
 #include <linux/of_address.h>
@@ -26,28 +25,6 @@ struct of_serial_info {
 	int line;
 };
 
-#ifdef CONFIG_ARCH_TEGRA
-static void tegra_serial_handle_break(struct uart_port *p)
-{
-	unsigned int status, tmout = 10000;
-
-	do {
-		status = p->serial_in(p, UART_LSR);
-		if (status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS))
-			status = p->serial_in(p, UART_RX);
-		else
-			break;
-		if (--tmout == 0)
-			break;
-		udelay(1);
-	} while (1);
-}
-#else
-static inline void tegra_serial_handle_break(struct uart_port *port)
-{
-}
-#endif
-
 static int of_8250_rs485_config(struct uart_port *port,
 				  struct serial_rs485 *rs485)
 {
@@ -211,10 +188,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
 	port->rs485_config = of_8250_rs485_config;
 
 	switch (type) {
-	case PORT_TEGRA:
-		port->handle_break = tegra_serial_handle_break;
-		break;
-
 	case PORT_RT2880:
 		port->iotype = UPIO_AU;
 		break;
@@ -359,7 +332,6 @@ static const struct of_device_id of_platform_serial_table[] = {
 	{ .compatible = "ns16550",  .data = (void *)PORT_16550, },
 	{ .compatible = "ns16750",  .data = (void *)PORT_16750, },
 	{ .compatible = "ns16850",  .data = (void *)PORT_16850, },
-	{ .compatible = "nvidia,tegra20-uart", .data = (void *)PORT_TEGRA, },
 	{ .compatible = "nxp,lpc3220-uart", .data = (void *)PORT_LPC3220, },
 	{ .compatible = "ralink,rt2880-uart", .data = (void *)PORT_RT2880, },
 	{ .compatible = "intel,xscale-uart", .data = (void *)PORT_XSCALE, },
drivers/tty/serial/8250/8250_tegra.c new file +197 -0

197 lines not on this page · raw message

drivers/tty/serial/8250/Kconfig +9 -0
index f16824bbb573..432b47647677 100644
@@ -500,6 +500,15 @@ config SERIAL_8250_PXA
 	  applicable to both devicetree and legacy boards, and early console is
 	  part of its support.
 
+config SERIAL_8250_TEGRA
+	tristate "8250 support for Tegra serial ports"
+	default SERIAL_8250
+	depends on SERIAL_8250
+	depends on ARCH_TEGRA
+	help
+	  Select this option if you have machine with an NVIDIA Tegra SoC and
+	  wish to enable 8250 serial driver for the Tegra serial interfaces.
+
 config SERIAL_OF_PLATFORM
 	tristate "Devicetree based probing for 8250 ports"
 	depends on SERIAL_8250 && OF
drivers/tty/serial/8250/Makefile +1 -0
index 51a6079d3f1f..a8bfb654d490 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_SERIAL_8250_INGENIC)	+= 8250_ingenic.o
 obj-$(CONFIG_SERIAL_8250_LPSS)		+= 8250_lpss.o
 obj-$(CONFIG_SERIAL_8250_MID)		+= 8250_mid.o
 obj-$(CONFIG_SERIAL_8250_PXA)		+= 8250_pxa.o
+obj-$(CONFIG_SERIAL_8250_TEGRA)		+= 8250_tegra.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM)	+= 8250_of.o
 
 CFLAGS_8250_ingenic.o += -I$(srctree)/scripts/dtc/libfdt
Signature · 1 line
2.17.1
#1 lore raw

drivers/tty/serial/8250/Kconfig config SERIAL_8250_PXA · line 507

Quoted 13 lines · Jon Hunter
drivers/tty/serial/8250/Kconfig +5 -0
index f16824bbb573..432b47647677 100644
@@ -500,6 +500,15 @@ config SERIAL_8250_PXA
 	  applicable to both devicetree and legacy boards, and early console is
 	  part of its support.
 
+config SERIAL_8250_TEGRA
+	tristate "8250 support for Tegra serial ports"
+	default SERIAL_8250
+	depends on SERIAL_8250
+	depends on ARCH_TEGRA

No COMPILE_TEST support so we can make sure we don't break the thing somehow?

thanks,

greg k-h

author maintainer
#2 lore raw
Quoted 9 lines · Greg Kroah-Hartman
Quoted 8 lines · Jon Hunter
drivers/tty/serial/8250/Kconfig +0 -0
index f16824bbb573..432b47647677 100644
@@ -500,6 +500,15 @@ config SERIAL_8250_PXA
 	  applicable to both devicetree and legacy boards, and early console is
 	  part of its support.
 
Quoted 8 lines

drivers/tty/serial/8250/Kconfig config SERIAL_8250_PXA · line 507

Quoted 5 lines
drivers/tty/serial/8250/Kconfig +5 -0
+config SERIAL_8250_TEGRA
+	tristate "8250 support for Tegra serial ports"
+	default SERIAL_8250
+	depends on SERIAL_8250
+	depends on ARCH_TEGRA

No COMPILE_TEST support so we can make sure we don't break the thing somehow?

Good point. Will add.

Thanks
Jon

Signature · 1 line
nvpublic
#3 lore raw
In reply to Jon Hunter

Hello Jon,

20.01.2020 19:01, Jon Hunter пишет:

[snip]

drivers/tty/serial/8250/8250_tegra.c line 81

Quoted 6 lines
drivers/tty/serial/8250/8250_tegra.c new file +6 -0
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	port->membase = devm_ioremap(&pdev->dev, res->start,
+				     resource_size(res));

devm_platform_ioremap_resource()

drivers/tty/serial/8250/8250_tegra.c line 88

Quoted 7 lines
drivers/tty/serial/8250/8250_tegra.c new file +7 -0
+	if (!port->membase)
+		return -ENOMEM;
+
+	port->mapbase = res->start;
+	port->mapsize = resource_size(res);
+
+	uart->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);

Why reset is shared? It shall not be shared at least on T20/30/124/210..

[snip]

#4 lore raw

21.01.2020 19:31, Dmitry Osipenko пишет:

Quoted 25 lines

Hello Jon,

20.01.2020 19:01, Jon Hunter пишет:

[snip]

drivers/tty/serial/8250/8250_tegra.c line 81

Quoted 6 lines
drivers/tty/serial/8250/8250_tegra.c new file +6 -0
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	port->membase = devm_ioremap(&pdev->dev, res->start,
+				     resource_size(res));

devm_platform_ioremap_resource()

drivers/tty/serial/8250/8250_tegra.c line 88

Quoted 7 lines
drivers/tty/serial/8250/8250_tegra.c new file +7 -0
+	if (!port->membase)
+		return -ENOMEM;
+
+	port->mapbase = res->start;
+	port->mapsize = resource_size(res);
+
+	uart->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);

Why reset is shared? It shall not be shared at least on T20/30/124/210..

Quoted 2 lines

[snip]

Actually, looks like use of a shared reset for a not-really-shared reset should be fine.

author maintainer
#5 lore raw
In reply to Dmitry Osipenko
Quoted 6 lines · Dmitry Osipenko

Hello Jon,

20.01.2020 19:01, Jon Hunter пишет:

[snip]

Quoted 8 lines

drivers/tty/serial/8250/8250_tegra.c line 81

Quoted 6 lines
drivers/tty/serial/8250/8250_tegra.c new file +6 -0
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	port->membase = devm_ioremap(&pdev->dev, res->start,
+				     resource_size(res));

devm_platform_ioremap_resource()

That would be ideal, but we cannot. The driver needs the res structure as well later on.

Jon

Signature · 1 line
nvpublic
#6 lore raw

21.01.2020 21:34, Jon Hunter пишет:

Quoted 17 lines · Dmitry Osipenko
Quoted 6 lines

Hello Jon,

20.01.2020 19:01, Jon Hunter пишет:

[snip]

Quoted 8 lines

drivers/tty/serial/8250/8250_tegra.c line 81

Quoted 6 lines
drivers/tty/serial/8250/8250_tegra.c new file +6 -0
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	port->membase = devm_ioremap(&pdev->dev, res->start,
+				     resource_size(res));

devm_platform_ioremap_resource()

Quoted 2 lines

That would be ideal, but we cannot. The driver needs the res structure as well later on.

Oh, indeed.