* [RFC PATCH 00/10] drivers: PL011: add SBSA subset support
@ 2014-09-19 12:21 Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 01/10] drivers: PL011: avoid potential unregister_driver call Andre Przywara
` (11 more replies)
0 siblings, 12 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
(This version has still issues, but I'd like to have feedback on
the general feasibility of this approach before wasting even more
time on debugging).
The ARM Server Base System Architecture[1] document describes a
generic UART which is a subset of the PL011 UART.
It lacks DMA support, baud rate control and modem status line
control, among other things.
The idea is to move the UART initialization and setup into the
firmware (which does this job today already) and let the kernel just
use the UART for sending and receiving characters.
This patchset is an attempt to integrate support for this UART subset
into the existing PL011 driver - basically by refactoring some
functions and providing a new uart_ops structure for it. It also has
a separate probe function to be not dependent on AMBA/PrimeCell.
Beside the obvious effect of code sharing it has the advantage of not
introducing another serial device prefix, so it can go with ttyAMA,
which seems to be pretty common.
There is still one issue in bringing up the UART. On the PL011 we
send a dummy character via the loopback facility with the FIFOs
disabled to get things going, but both FIFO control and loopback are
outside of the SBSA spec. I consider this loopback approach a kludge
anyway, but am struggling to find a better way of fixing this due to
my lack of understanding of the TTY/serial layer.
If someone with more wisdom could enlighten me, I would be grateful.
Patch 1/10 contains a bug fix which applies to the PL011 part also,
it should be considered regardless of the rest of the series.
Patch 2-7 refactor some PL011 functions by splitting them up into
smaller pieces, so that most the code can be reused later by the SBSA
part.
Patch 8 and 9 introduce two new properties for the vendor structure,
this is for SBSA functionality which cannot be controlled by
separate uart_ops members only.
Patch 10 then finally drops in the SBSA specific code, by providing
a new uart_ops, vendor struct and probe function for it.
Please have a look and tell me whether this SBSA driver approach has
any future.
Regards,
Andre
Andre Przywara (10):
drivers: PL011: avoid potential unregister_driver call
drivers: PL011: refactor pl011_startup()
drivers: PL011: refactor pl011_shutdown()
drivers: PL011: refactor pl011_set_termios()
drivers: PL011: refactor pl011_probe()
drivers: PL011: replace UART_MIS reading with _RIS & _IMSC
drivers: PL011: move cts_event workaround into separate function
drivers: PL011: allow avoiding UART enabling/disabling
drivers: PL011: allow to supply fixed option string
drivers: PL011: add support for the ARM SBSA generic UART
.../devicetree/bindings/serial/arm_sbsa_uart.txt | 9 +
drivers/tty/serial/amba-pl011.c | 509 ++++++++++++++------
2 files changed, 380 insertions(+), 138 deletions(-)
create mode 100644 Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
--
1.7.9.5
^ permalink raw reply [flat|nested] 14+ messages in thread
* [RFC PATCH 01/10] drivers: PL011: avoid potential unregister_driver call
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 02/10] drivers: PL011: refactor pl011_startup() Andre Przywara
` (10 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
Although we care about not unregistering the driver if there are
still ports connected during the .remove callback, we do miss this
check in the pl011_probe function. So if the current port allocation
fails, but there are other ports already registered, we will kill
those.
So factor out the port removal into a separate function and use that
in the probe function, too.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 8572f2a..8fab985 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2118,6 +2118,24 @@ static int pl011_probe_dt_alias(int index, struct device *dev)
return ret;
}
+/* unregisters the driver also if no more ports are left */
+static void pl011_unregister_port(struct uart_amba_port *uap)
+{
+ int i;
+ bool busy = false;
+
+ for (i = 0; i < ARRAY_SIZE(amba_ports); i++) {
+ if (amba_ports[i] == uap)
+ amba_ports[i] = NULL;
+ else if (amba_ports[i])
+ busy = true;
+ }
+ pl011_dma_remove(uap);
+ if (!busy)
+ uart_unregister_driver(&amba_reg);
+}
+
+
static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
{
struct uart_amba_port *uap;
@@ -2183,11 +2201,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
}
ret = uart_add_one_port(&amba_reg, &uap->port);
- if (ret) {
- amba_ports[i] = NULL;
- uart_unregister_driver(&amba_reg);
- pl011_dma_remove(uap);
- }
+ if (ret)
+ pl011_unregister_port(uap);
return ret;
}
@@ -2195,20 +2210,9 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
static int pl011_remove(struct amba_device *dev)
{
struct uart_amba_port *uap = amba_get_drvdata(dev);
- bool busy = false;
- int i;
uart_remove_one_port(&amba_reg, &uap->port);
-
- for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
- if (amba_ports[i] == uap)
- amba_ports[i] = NULL;
- else if (amba_ports[i])
- busy = true;
-
- pl011_dma_remove(uap);
- if (!busy)
- uart_unregister_driver(&amba_reg);
+ pl011_unregister_port(uap);
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 02/10] drivers: PL011: refactor pl011_startup()
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 01/10] drivers: PL011: avoid potential unregister_driver call Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 03/10] drivers: PL011: refactor pl011_shutdown() Andre Przywara
` (9 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
Split the pl011_startup() function into smaller chunks to allow
easier reuse later when adding SBSA support.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 51 +++++++++++++++++++++++----------------
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 8fab985..22f113c 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1524,6 +1524,32 @@ static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
}
}
+static int pl011_allocate_irq(struct uart_amba_port *uap)
+{
+ writew(uap->im, uap->port.membase + UART011_IMSC);
+
+ return request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap);
+}
+
+/*
+ * Enable interrupts, only timeouts when using DMA
+ * if initial RX DMA job failed, start in interrupt mode
+ * as well.
+ */
+static void pl011_enable_interrupts(struct uart_amba_port *uap)
+{
+ spin_lock_irq(&uap->port.lock);
+
+ /* Clear out any spuriously appearing RX interrupts */
+ writew(UART011_RTIS | UART011_RXIS,
+ uap->port.membase + UART011_ICR);
+ uap->im = UART011_RTIM;
+ if (!pl011_dma_rx_running(uap))
+ uap->im |= UART011_RXIM;
+ writew(uap->im, uap->port.membase + UART011_IMSC);
+ spin_unlock_irq(&uap->port.lock);
+}
+
static int pl011_startup(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@ -1534,19 +1560,15 @@ static int pl011_startup(struct uart_port *port)
if (retval)
goto clk_dis;
- writew(uap->im, uap->port.membase + UART011_IMSC);
-
- /*
- * Allocate the IRQ
- */
- retval = request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap);
+ retval = pl011_allocate_irq(uap);
if (retval)
goto clk_dis;
writew(uap->vendor->ifls, uap->port.membase + UART011_IFLS);
/*
- * Provoke TX FIFO interrupt into asserting. Taking care to preserve
+ * Provoke TX FIFO interrupt into asserting by enabling loopback and
+ * sending a dummy character. Taking care to preserve
* baud rate and data format specified by FBRD, IBRD and LCRH as the
* UART may already be in use as a console.
*/
@@ -1584,20 +1606,7 @@ static int pl011_startup(struct uart_port *port)
/* Startup DMA */
pl011_dma_startup(uap);
- /*
- * Finally, enable interrupts, only timeouts when using DMA
- * if initial RX DMA job failed, start in interrupt mode
- * as well.
- */
- spin_lock_irq(&uap->port.lock);
- /* Clear out any spuriously appearing RX interrupts */
- writew(UART011_RTIS | UART011_RXIS,
- uap->port.membase + UART011_ICR);
- uap->im = UART011_RTIM;
- if (!pl011_dma_rx_running(uap))
- uap->im |= UART011_RXIM;
- writew(uap->im, uap->port.membase + UART011_IMSC);
- spin_unlock_irq(&uap->port.lock);
+ pl011_enable_interrupts(uap);
return 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 03/10] drivers: PL011: refactor pl011_shutdown()
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 01/10] drivers: PL011: avoid potential unregister_driver call Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 02/10] drivers: PL011: refactor pl011_startup() Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 04/10] drivers: PL011: refactor pl011_set_termios() Andre Przywara
` (8 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
Split the pl011_shutdown() function into smaller chunks to allow
easier reuse later when adding SBSA support.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 57 ++++++++++++++++++++++-----------------
1 file changed, 33 insertions(+), 24 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 22f113c..17ba997 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1625,33 +1625,15 @@ static void pl011_shutdown_channel(struct uart_amba_port *uap,
writew(val, uap->port.membase + lcrh);
}
-static void pl011_shutdown(struct uart_port *port)
+/*
+ * disable the port. It should not disable RTS and DTR.
+ * Also RTS and DTR state should be preserved to restore
+ * it during startup().
+ */
+static void pl011_disable_uart(struct uart_amba_port *uap)
{
- struct uart_amba_port *uap = (struct uart_amba_port *)port;
unsigned int cr;
- /*
- * disable all interrupts
- */
- spin_lock_irq(&uap->port.lock);
- uap->im = 0;
- writew(uap->im, uap->port.membase + UART011_IMSC);
- writew(0xffff, uap->port.membase + UART011_ICR);
- spin_unlock_irq(&uap->port.lock);
-
- pl011_dma_shutdown(uap);
-
- /*
- * Free the interrupt
- */
- free_irq(uap->port.irq, uap);
-
- /*
- * disable the port
- * disable the port. It should not disable RTS and DTR.
- * Also RTS and DTR state should be preserved to restore
- * it during startup().
- */
uap->autorts = false;
spin_lock_irq(&uap->port.lock);
cr = readw(uap->port.membase + UART011_CR);
@@ -1667,6 +1649,33 @@ static void pl011_shutdown(struct uart_port *port)
pl011_shutdown_channel(uap, uap->lcrh_rx);
if (uap->lcrh_rx != uap->lcrh_tx)
pl011_shutdown_channel(uap, uap->lcrh_tx);
+}
+
+static void pl011_disable_interrupts(struct uart_amba_port *uap)
+{
+ spin_lock_irq(&uap->port.lock);
+
+ /*
+ * mask all interrupts and clear all pending ones
+ */
+ uap->im = 0;
+ writew(uap->im, uap->port.membase + UART011_IMSC);
+ writew(0xffff, uap->port.membase + UART011_ICR);
+
+ spin_unlock_irq(&uap->port.lock);
+}
+
+static void pl011_shutdown(struct uart_port *port)
+{
+ struct uart_amba_port *uap = (struct uart_amba_port *)port;
+
+ pl011_disable_interrupts(uap);
+
+ pl011_dma_shutdown(uap);
+
+ free_irq(uap->port.irq, uap);
+
+ pl011_disable_uart(uap);
/*
* Shut down the clock producer
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 04/10] drivers: PL011: refactor pl011_set_termios()
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (2 preceding siblings ...)
2014-09-19 12:21 ` [RFC PATCH 03/10] drivers: PL011: refactor pl011_shutdown() Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 05/10] drivers: PL011: refactor pl011_probe() Andre Przywara
` (7 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
Split the pl011_set_termios() function into smaller chunks to allow
easier reuse later when adding SBSA support.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 60 +++++++++++++++++++++------------------
1 file changed, 33 insertions(+), 27 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 17ba997..9219127 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1695,6 +1695,38 @@ static void pl011_shutdown(struct uart_port *port)
}
static void
+pl011_setup_status_masks(struct uart_port *port, struct ktermios *termios)
+{
+ port->read_status_mask = UART011_DR_OE | 255;
+ if (termios->c_iflag & INPCK)
+ port->read_status_mask |= UART011_DR_FE | UART011_DR_PE;
+ if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
+ port->read_status_mask |= UART011_DR_BE;
+
+ /*
+ * Characters to ignore
+ */
+ port->ignore_status_mask = 0;
+ if (termios->c_iflag & IGNPAR)
+ port->ignore_status_mask |= UART011_DR_FE | UART011_DR_PE;
+ if (termios->c_iflag & IGNBRK) {
+ port->ignore_status_mask |= UART011_DR_BE;
+ /*
+ * If we're ignoring parity and break indicators,
+ * ignore overruns too (for real raw support).
+ */
+ if (termios->c_iflag & IGNPAR)
+ port->ignore_status_mask |= UART011_DR_OE;
+ }
+
+ /*
+ * Ignore all characters if CREAD is not set.
+ */
+ if ((termios->c_cflag & CREAD) == 0)
+ port->ignore_status_mask |= UART_DUMMY_DR_RX;
+}
+
+static void
pl011_set_termios(struct uart_port *port, struct ktermios *termios,
struct ktermios *old)
{
@@ -1757,33 +1789,7 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
*/
uart_update_timeout(port, termios->c_cflag, baud);
- port->read_status_mask = UART011_DR_OE | 255;
- if (termios->c_iflag & INPCK)
- port->read_status_mask |= UART011_DR_FE | UART011_DR_PE;
- if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
- port->read_status_mask |= UART011_DR_BE;
-
- /*
- * Characters to ignore
- */
- port->ignore_status_mask = 0;
- if (termios->c_iflag & IGNPAR)
- port->ignore_status_mask |= UART011_DR_FE | UART011_DR_PE;
- if (termios->c_iflag & IGNBRK) {
- port->ignore_status_mask |= UART011_DR_BE;
- /*
- * If we're ignoring parity and break indicators,
- * ignore overruns too (for real raw support).
- */
- if (termios->c_iflag & IGNPAR)
- port->ignore_status_mask |= UART011_DR_OE;
- }
-
- /*
- * Ignore all characters if CREAD is not set.
- */
- if ((termios->c_cflag & CREAD) == 0)
- port->ignore_status_mask |= UART_DUMMY_DR_RX;
+ pl011_setup_status_masks(port, termios);
if (UART_ENABLE_MS(port, termios->c_cflag))
pl011_enable_ms(port);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 05/10] drivers: PL011: refactor pl011_probe()
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (3 preceding siblings ...)
2014-09-19 12:21 ` [RFC PATCH 04/10] drivers: PL011: refactor pl011_set_termios() Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:40 ` Russell King - ARM Linux
2014-09-19 12:21 ` [RFC PATCH 06/10] drivers: PL011: replace UART_MIS reading with _RIS & _IMSC Andre Przywara
` (6 subsequent siblings)
11 siblings, 1 reply; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
Currently the pl011_probe() function is relying on some AMBA IDs
and a device tree node to initialize the driver and a port.
Both features are not necessarily required for the driver:
- we lack AMBA IDs in the ARM SBSA generic UART and
- we lack a DT node in ACPI systems.
So lets refactor the function to ease later reuse.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 90 ++++++++++++++++++++++++++-------------
1 file changed, 61 insertions(+), 29 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 9219127..457a8d90 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2159,13 +2159,10 @@ static void pl011_unregister_port(struct uart_amba_port *uap)
uart_unregister_driver(&amba_reg);
}
-
-static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
+static int pl011_allocate_port(struct device *dev, struct uart_amba_port **_uap)
{
struct uart_amba_port *uap;
- struct vendor_data *vendor = id->data;
- void __iomem *base;
- int i, ret;
+ int i;
for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
if (amba_ports[i] == NULL)
@@ -2174,47 +2171,50 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
if (i == ARRAY_SIZE(amba_ports))
return -EBUSY;
- uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
- GFP_KERNEL);
+ uap = devm_kzalloc(dev, sizeof(struct uart_amba_port), GFP_KERNEL);
if (uap == NULL)
return -ENOMEM;
- i = pl011_probe_dt_alias(i, &dev->dev);
+ if (_uap)
+ *_uap = uap;
+
+ return i;
+}
- base = devm_ioremap(&dev->dev, dev->res.start,
- resource_size(&dev->res));
+static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
+ struct resource *mmiobase, int index)
+{
+ void __iomem *base;
+
+ base = devm_ioremap_resource(dev, mmiobase);
if (!base)
return -ENOMEM;
- uap->clk = devm_clk_get(&dev->dev, NULL);
- if (IS_ERR(uap->clk))
- return PTR_ERR(uap->clk);
+ index = pl011_probe_dt_alias(index, dev);
- uap->vendor = vendor;
- uap->lcrh_rx = vendor->lcrh_rx;
- uap->lcrh_tx = vendor->lcrh_tx;
uap->old_cr = 0;
- uap->fifosize = vendor->get_fifosize(dev);
- uap->port.dev = &dev->dev;
- uap->port.mapbase = dev->res.start;
+ uap->port.dev = dev;
+ uap->port.mapbase = mmiobase->start;
uap->port.membase = base;
uap->port.iotype = UPIO_MEM;
- uap->port.irq = dev->irq[0];
uap->port.fifosize = uap->fifosize;
- uap->port.ops = &amba_pl011_pops;
uap->port.flags = UPF_BOOT_AUTOCONF;
- uap->port.line = i;
- pl011_dma_probe(&dev->dev, uap);
+ uap->port.line = index;
- /* Ensure interrupts from this UART are masked and cleared */
- writew(0, uap->port.membase + UART011_IMSC);
- writew(0xffff, uap->port.membase + UART011_ICR);
+ pl011_dma_probe(dev, uap);
- snprintf(uap->type, sizeof(uap->type), "PL011 rev%u", amba_rev(dev));
+ amba_ports[index] = uap;
- amba_ports[i] = uap;
+ return 0;
+}
- amba_set_drvdata(dev, uap);
+static int pl011_register_port(struct uart_amba_port *uap)
+{
+ int ret;
+
+ /* Ensure interrupts from this UART are masked and cleared */
+ writew(0, uap->port.membase + UART011_IMSC);
+ writew(0xffff, uap->port.membase + UART011_ICR);
if (!amba_reg.state) {
ret = uart_register_driver(&amba_reg);
@@ -2231,6 +2231,38 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
return ret;
}
+static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
+{
+ struct uart_amba_port *uap;
+ struct vendor_data *vendor = id->data;
+ int portnr, ret;
+
+ portnr = pl011_allocate_port(&dev->dev, &uap);
+ if (portnr < 0)
+ return portnr;
+
+ uap->clk = devm_clk_get(&dev->dev, NULL);
+ if (IS_ERR(uap->clk))
+ return PTR_ERR(uap->clk);
+
+ uap->vendor = vendor;
+ uap->lcrh_rx = vendor->lcrh_rx;
+ uap->lcrh_tx = vendor->lcrh_tx;
+ uap->fifosize = vendor->get_fifosize(dev);
+ uap->port.irq = dev->irq[0];
+ uap->port.ops = &amba_pl011_pops;
+
+ snprintf(uap->type, sizeof(uap->type), "PL011 rev%u", amba_rev(dev));
+
+ ret = pl011_setup_port(&dev->dev, uap, &dev->res, portnr);
+ if (ret)
+ return ret;
+
+ amba_set_drvdata(dev, uap);
+
+ return pl011_register_port(uap);
+}
+
static int pl011_remove(struct amba_device *dev)
{
struct uart_amba_port *uap = amba_get_drvdata(dev);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 06/10] drivers: PL011: replace UART_MIS reading with _RIS & _IMSC
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (4 preceding siblings ...)
2014-09-19 12:21 ` [RFC PATCH 05/10] drivers: PL011: refactor pl011_probe() Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 07/10] drivers: PL011: move cts_event workaround into separate function Andre Przywara
` (5 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
The PL011 register UART_MIS is actually a bitwise AND of the
UART_RIS and the UART_MISC register.
Since the SBSA UART does not include the _MIS register, use the
two separate registers to get the same behaviour. Since we are
inside the spinlock and we read the _IMSC register only once, there
should be no race issue.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 457a8d90..e7566ed 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1298,11 +1298,13 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
struct uart_amba_port *uap = dev_id;
unsigned long flags;
unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT;
+ u16 imsc;
int handled = 0;
unsigned int dummy_read;
spin_lock_irqsave(&uap->port.lock, flags);
- status = readw(uap->port.membase + UART011_MIS);
+ imsc = readw(uap->port.membase + UART011_IMSC);
+ status = readw(uap->port.membase + UART011_RIS) & imsc;
if (status) {
do {
if (uap->vendor->cts_event_workaround) {
@@ -1337,7 +1339,7 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
if (pass_counter-- == 0)
break;
- status = readw(uap->port.membase + UART011_MIS);
+ status = readw(uap->port.membase + UART011_RIS) & imsc;
} while (status != 0);
handled = 1;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 07/10] drivers: PL011: move cts_event workaround into separate function
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (5 preceding siblings ...)
2014-09-19 12:21 ` [RFC PATCH 06/10] drivers: PL011: replace UART_MIS reading with _RIS & _IMSC Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 08/10] drivers: PL011: allow avoiding UART enabling/disabling Andre Przywara
` (4 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
To avoid lines with more than 80 characters and to make the
pl011_int() function more readable, move the workaround out into a
separate function.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index e7566ed..65a0411 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1293,6 +1293,25 @@ static void pl011_modem_status(struct uart_amba_port *uap)
wake_up_interruptible(&uap->port.state->port.delta_msr_wait);
}
+static void check_apply_cts_event_workaround(struct uart_amba_port *uap)
+{
+ unsigned int dummy_read;
+
+ if (!uap->vendor->cts_event_workaround)
+ return;
+
+ /* workaround to make sure that all bits are unlocked.. */
+ writew(0x00, uap->port.membase + UART011_ICR);
+
+ /*
+ * WA: introduce 26ns(1 uart clk) delay before W1C;
+ * single apb access will incur 2 pclk(133.12Mhz) delay,
+ * so add 2 dummy reads
+ */
+ dummy_read = readw(uap->port.membase + UART011_ICR);
+ dummy_read = readw(uap->port.membase + UART011_ICR);
+}
+
static irqreturn_t pl011_int(int irq, void *dev_id)
{
struct uart_amba_port *uap = dev_id;
@@ -1300,25 +1319,13 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT;
u16 imsc;
int handled = 0;
- unsigned int dummy_read;
spin_lock_irqsave(&uap->port.lock, flags);
imsc = readw(uap->port.membase + UART011_IMSC);
status = readw(uap->port.membase + UART011_RIS) & imsc;
if (status) {
do {
- if (uap->vendor->cts_event_workaround) {
- /* workaround to make sure that all bits are unlocked.. */
- writew(0x00, uap->port.membase + UART011_ICR);
-
- /*
- * WA: introduce 26ns(1 uart clk) delay before W1C;
- * single apb access will incur 2 pclk(133.12Mhz) delay,
- * so add 2 dummy reads
- */
- dummy_read = readw(uap->port.membase + UART011_ICR);
- dummy_read = readw(uap->port.membase + UART011_ICR);
- }
+ check_apply_cts_event_workaround(uap);
writew(status & ~(UART011_TXIS|UART011_RTIS|
UART011_RXIS),
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 08/10] drivers: PL011: allow avoiding UART enabling/disabling
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (6 preceding siblings ...)
2014-09-19 12:21 ` [RFC PATCH 07/10] drivers: PL011: move cts_event workaround into separate function Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 09/10] drivers: PL011: allow to supply fixed option string Andre Przywara
` (3 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
The SBSA UART should not be enabled or disabled (it is always on),
and consequently the spec lacks the UART_CR register.
Add a vendor specific property to skip disabling or enabling of the
UART. This will be used later by the SBSA UART support.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 65a0411..70af210 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -78,6 +78,7 @@ struct vendor_data {
bool oversampling;
bool dma_threshold;
bool cts_event_workaround;
+ bool always_enabled;
unsigned int (*get_fifosize)(struct amba_device *dev);
};
@@ -94,6 +95,7 @@ static struct vendor_data vendor_arm = {
.oversampling = false,
.dma_threshold = false,
.cts_event_workaround = false,
+ .always_enabled = false,
.get_fifosize = get_fifosize_arm,
};
@@ -109,6 +111,7 @@ static struct vendor_data vendor_st = {
.oversampling = true,
.dma_threshold = true,
.cts_event_workaround = true,
+ .always_enabled = false,
.get_fifosize = get_fifosize_st,
};
@@ -1944,7 +1947,7 @@ static void
pl011_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_amba_port *uap = amba_ports[co->index];
- unsigned int status, old_cr, new_cr;
+ unsigned int status, old_cr = 0, new_cr;
unsigned long flags;
int locked = 1;
@@ -1961,10 +1964,12 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
/*
* First save the CR then disable the interrupts
*/
- old_cr = readw(uap->port.membase + UART011_CR);
- new_cr = old_cr & ~UART011_CR_CTSEN;
- new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
- writew(new_cr, uap->port.membase + UART011_CR);
+ if (!uap->vendor->always_enabled) {
+ old_cr = readw(uap->port.membase + UART011_CR);
+ new_cr = old_cr & ~UART011_CR_CTSEN;
+ new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
+ writew(new_cr, uap->port.membase + UART011_CR);
+ }
uart_console_write(&uap->port, s, count, pl011_console_putchar);
@@ -1975,7 +1980,8 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
do {
status = readw(uap->port.membase + UART01x_FR);
} while (status & UART01x_FR_BUSY);
- writew(old_cr, uap->port.membase + UART011_CR);
+ if (!uap->vendor->always_enabled)
+ writew(old_cr, uap->port.membase + UART011_CR);
if (locked)
spin_unlock(&uap->port.lock);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 09/10] drivers: PL011: allow to supply fixed option string
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (7 preceding siblings ...)
2014-09-19 12:21 ` [RFC PATCH 08/10] drivers: PL011: allow avoiding UART enabling/disabling Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 10/10] drivers: PL011: add support for the ARM SBSA generic UART Andre Przywara
` (2 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
The SBSA UART has a fixed baud rate and flow control setting, which
cannot be changed or queried by software.
Add a vendor specific property to always return fixed values when
trying to read the console options.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/tty/serial/amba-pl011.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 70af210..12f1a5f 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -79,6 +79,7 @@ struct vendor_data {
bool dma_threshold;
bool cts_event_workaround;
bool always_enabled;
+ char *fixed_options;
unsigned int (*get_fifosize)(struct amba_device *dev);
};
@@ -96,6 +97,7 @@ static struct vendor_data vendor_arm = {
.dma_threshold = false,
.cts_event_workaround = false,
.always_enabled = false,
+ .fixed_options = NULL,
.get_fifosize = get_fifosize_arm,
};
@@ -112,6 +114,7 @@ static struct vendor_data vendor_st = {
.dma_threshold = true,
.cts_event_workaround = true,
.always_enabled = false,
+ .fixed_options = NULL,
.get_fifosize = get_fifosize_st,
};
@@ -2062,6 +2065,9 @@ static int __init pl011_console_setup(struct console *co, char *options)
uap->port.uartclk = clk_get_rate(uap->clk);
+ if (!options && uap->vendor->fixed_options)
+ options = uap->vendor->fixed_options;
+
if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow);
else
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [RFC PATCH 10/10] drivers: PL011: add support for the ARM SBSA generic UART
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (8 preceding siblings ...)
2014-09-19 12:21 ` [RFC PATCH 09/10] drivers: PL011: allow to supply fixed option string Andre Przywara
@ 2014-09-19 12:21 ` Andre Przywara
2014-09-29 15:27 ` [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
2014-09-30 10:11 ` Graeme Gregory
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-19 12:21 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, linux-serial, linux-arm-kernel, Arnd Bergmann
The ARM Server Base System Architecture[1] document describes a
generic UART which is a subset of the PL011 UART.
It lacks DMA support, baud rate control and modem status line
control, among other things.
The idea is to move the UART initialization and setup into the
firmware (which does this job today already) and let the kernel just
use the UART for sending and receiving characters.
We use the recent refactoring the build a new struct uart_ops
variable which points to some new functions avoiding access to the
missing registers. We reuse as much existing PL011 code as possible.
In contrast to the PL011 the SBSA UART does not define any AMBA or
PrimeCell relations, so we go a pretty generic probe function
which only uses platform device functions.
A DT binding is provided, but other systems can easily attach to it,
too (hint, hint!).
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
.../devicetree/bindings/serial/arm_sbsa_uart.txt | 9 ++
drivers/tty/serial/amba-pl011.c | 152 ++++++++++++++++++++
2 files changed, 161 insertions(+)
create mode 100644 Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
diff --git a/Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt b/Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
new file mode 100644
index 0000000..21d211f
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
@@ -0,0 +1,9 @@
+* ARM SBSA defined generic UART
+This UART uses a subset of the PL011 registers and consequently lives
+in the PL011 driver. It's baudrate and other communication parameters
+cannot be adjusted at runtime, so it lacks a clock specifier here.
+
+Required properties:
+- compatible: must be "arm,sbsa-uart"
+- reg: exactly one register range
+- interrupts: exactly one interrupt specifier
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 12f1a5f..2065d07 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -101,6 +101,20 @@ static struct vendor_data vendor_arm = {
.get_fifosize = get_fifosize_arm,
};
+static unsigned int get_fifosize_sbsa(struct amba_device *dev)
+{
+ return 32;
+}
+
+static struct vendor_data vendor_sbsa = {
+ .oversampling = false,
+ .dma_threshold = false,
+ .cts_event_workaround = false,
+ .always_enabled = true,
+ .fixed_options = "115200n8",
+ .get_fifosize = get_fifosize_sbsa,
+};
+
static unsigned int get_fifosize_st(struct amba_device *dev)
{
return 64;
@@ -1630,6 +1644,29 @@ static int pl011_startup(struct uart_port *port)
return retval;
}
+static int sbsa_uart_startup(struct uart_port *port)
+{
+ struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ int retval;
+
+ retval = pl011_hwinit(port);
+ if (retval)
+ return retval;
+
+ retval = pl011_allocate_irq(uap);
+ if (retval)
+ return retval;
+
+ /*
+ * The SBSA UART does not support any modem status lines.
+ */
+ uap->old_status = 0;
+
+ pl011_enable_interrupts(uap);
+
+ return 0;
+}
+
static void pl011_shutdown_channel(struct uart_amba_port *uap,
unsigned int lcrh)
{
@@ -1706,7 +1743,15 @@ static void pl011_shutdown(struct uart_port *port)
if (plat->exit)
plat->exit();
}
+}
+
+static void sbsa_uart_shutdown(struct uart_port *port)
+{
+ struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ pl011_disable_interrupts(uap);
+
+ free_irq(uap->port.irq, uap);
}
static void
@@ -1859,6 +1904,26 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
spin_unlock_irqrestore(&port->lock, flags);
}
+static void
+sbsa_uart_set_termios(struct uart_port *port, struct ktermios *termios,
+ struct ktermios *old)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&port->lock, flags);
+
+ /*
+ * We don't know the clock or baud rate of the UART, so we do
+ * some kind of worst case assumption here. The code adds a
+ * 20ms buffer anyway, so going with 19200 should be fine.
+ */
+ uart_update_timeout(port, CS8, 19200);
+
+ pl011_setup_status_masks(port, termios);
+
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
static const char *pl011_type(struct uart_port *port)
{
struct uart_amba_port *uap = (struct uart_amba_port *)port;
@@ -1933,6 +1998,40 @@ static struct uart_ops amba_pl011_pops = {
#endif
};
+static void sbsa_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+}
+
+static unsigned int sbsa_uart_get_mctrl(struct uart_port *port)
+{
+ return 0;
+}
+
+static struct uart_ops sbsa_uart_pops = {
+ .tx_empty = pl011_tx_empty,
+ .set_mctrl = sbsa_uart_set_mctrl,
+ .get_mctrl = sbsa_uart_get_mctrl,
+ .stop_tx = pl011_stop_tx,
+ .start_tx = pl011_start_tx,
+ .stop_rx = pl011_stop_rx,
+ .enable_ms = NULL,
+ .break_ctl = NULL,
+ .startup = sbsa_uart_startup,
+ .shutdown = sbsa_uart_shutdown,
+ .flush_buffer = NULL,
+ .set_termios = sbsa_uart_set_termios,
+ .type = pl011_type,
+ .release_port = pl011_release_port,
+ .request_port = pl011_request_port,
+ .config_port = pl011_config_port,
+ .verify_port = pl011_verify_port,
+#ifdef CONFIG_CONSOLE_POLL
+ .poll_init = pl011_hwinit,
+ .poll_get_char = pl011_get_poll_char,
+ .poll_put_char = pl011_put_poll_char,
+#endif
+};
+
static struct uart_amba_port *amba_ports[UART_NR];
#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
@@ -2317,6 +2416,59 @@ static int pl011_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(pl011_dev_pm_ops, pl011_suspend, pl011_resume);
+static int sbsa_uart_probe(struct platform_device *pdev)
+{
+ struct uart_amba_port *uap;
+ struct resource *r;
+ int portnr, ret;
+
+ portnr = pl011_allocate_port(&pdev->dev, &uap);
+ if (portnr < 0)
+ return portnr;
+
+ uap->vendor = &vendor_sbsa;
+ uap->fifosize = 32;
+ uap->port.irq = platform_get_irq(pdev, 0);
+ uap->port.ops = &sbsa_uart_pops;
+
+ snprintf(uap->type, sizeof(uap->type), "SBSA");
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ ret = pl011_setup_port(&pdev->dev, uap, r, portnr);
+ if (ret)
+ return ret;
+
+ platform_set_drvdata(pdev, uap);
+
+ return pl011_register_port(uap);
+}
+
+static int sbsa_uart_remove(struct platform_device *pdev)
+{
+ struct uart_amba_port *uap = platform_get_drvdata(pdev);
+
+ uart_remove_one_port(&amba_reg, &uap->port);
+ pl011_unregister_port(uap);
+ return 0;
+}
+
+static const struct of_device_id sbsa_uart_match[] = {
+ { .compatible = "arm,sbsa-uart", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, sbsa_uart_match);
+
+static struct platform_driver arm_sbsa_uart_platform_driver = {
+ .probe = sbsa_uart_probe,
+ .remove = sbsa_uart_remove,
+ .driver = {
+ .name = "sbsa-uart",
+ .of_match_table = of_match_ptr(sbsa_uart_match),
+ },
+};
+
+module_platform_driver(arm_sbsa_uart_platform_driver);
+
static struct amba_id pl011_ids[] = {
{
.id = 0x00041011,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 05/10] drivers: PL011: refactor pl011_probe()
2014-09-19 12:21 ` [RFC PATCH 05/10] drivers: PL011: refactor pl011_probe() Andre Przywara
@ 2014-09-19 12:40 ` Russell King - ARM Linux
0 siblings, 0 replies; 14+ messages in thread
From: Russell King - ARM Linux @ 2014-09-19 12:40 UTC (permalink / raw)
To: Andre Przywara
Cc: Greg Kroah-Hartman, Jiri Slaby, rob.herring, linux-serial,
linux-arm-kernel, Arnd Bergmann
On Fri, Sep 19, 2014 at 01:21:18PM +0100, Andre Przywara wrote:
> Currently the pl011_probe() function is relying on some AMBA IDs
> and a device tree node to initialize the driver and a port.
> Both features are not necessarily required for the driver:
> - we lack AMBA IDs in the ARM SBSA generic UART and
> - we lack a DT node in ACPI systems.
> So lets refactor the function to ease later reuse.
Both features are not "necessary" for any driver, but that doesn't mean
we work around it by throwing a platform driver at it. We already have
this same problem with PL010 UARTs, and the DT support for AMBA has the
ability to specify the AMBA ID.
Moreover, there is nothing which prevents you from declaring an AMBA
device with an appropriate AMBA ID for the driver to bind to - which is
presumably something very similar to what you're already doing with a
platform device.
--
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 00/10] drivers: PL011: add SBSA subset support
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (9 preceding siblings ...)
2014-09-19 12:21 ` [RFC PATCH 10/10] drivers: PL011: add support for the ARM SBSA generic UART Andre Przywara
@ 2014-09-29 15:27 ` Andre Przywara
2014-09-30 10:11 ` Graeme Gregory
11 siblings, 0 replies; 14+ messages in thread
From: Andre Przywara @ 2014-09-29 15:27 UTC (permalink / raw)
To: Russell King, Greg Kroah-Hartman, Jiri Slaby
Cc: rob.herring, Arnd Bergmann, linux-arm-kernel, linux-serial,
Suravee Suthikulanit, Graeme Gregory
Hi,
(ping)
On 19/09/14 13:21, Andre Przywara wrote:
> (This version has still issues, but I'd like to have feedback on
> the general feasibility of this approach before wasting even more
> time on debugging).
>
> The ARM Server Base System Architecture[1] document describes a
> generic UART which is a subset of the PL011 UART.
> It lacks DMA support, baud rate control and modem status line
> control, among other things.
> The idea is to move the UART initialization and setup into the
> firmware (which does this job today already) and let the kernel just
> use the UART for sending and receiving characters.
>
> This patchset is an attempt to integrate support for this UART subset
> into the existing PL011 driver - basically by refactoring some
> functions and providing a new uart_ops structure for it. It also has
> a separate probe function to be not dependent on AMBA/PrimeCell.
> Beside the obvious effect of code sharing it has the advantage of not
> introducing another serial device prefix, so it can go with ttyAMA,
> which seems to be pretty common.
Is there any opinion on this patchset? Is this approach of integrating
the SBSA UART support in the PL011 driver a promising way?
Or do we look for a separate driver - which could not go with ttyAMA?
Grateful for any comments,
Andre
>
> There is still one issue in bringing up the UART. On the PL011 we
> send a dummy character via the loopback facility with the FIFOs
> disabled to get things going, but both FIFO control and loopback are
> outside of the SBSA spec. I consider this loopback approach a kludge
> anyway, but am struggling to find a better way of fixing this due to
> my lack of understanding of the TTY/serial layer.
> If someone with more wisdom could enlighten me, I would be grateful.
>
>
> Patch 1/10 contains a bug fix which applies to the PL011 part also,
> it should be considered regardless of the rest of the series.
> Patch 2-7 refactor some PL011 functions by splitting them up into
> smaller pieces, so that most the code can be reused later by the SBSA
> part.
> Patch 8 and 9 introduce two new properties for the vendor structure,
> this is for SBSA functionality which cannot be controlled by
> separate uart_ops members only.
> Patch 10 then finally drops in the SBSA specific code, by providing
> a new uart_ops, vendor struct and probe function for it.
>
> Please have a look and tell me whether this SBSA driver approach has
> any future.
>
> Regards,
> Andre
>
> Andre Przywara (10):
> drivers: PL011: avoid potential unregister_driver call
> drivers: PL011: refactor pl011_startup()
> drivers: PL011: refactor pl011_shutdown()
> drivers: PL011: refactor pl011_set_termios()
> drivers: PL011: refactor pl011_probe()
> drivers: PL011: replace UART_MIS reading with _RIS & _IMSC
> drivers: PL011: move cts_event workaround into separate function
> drivers: PL011: allow avoiding UART enabling/disabling
> drivers: PL011: allow to supply fixed option string
> drivers: PL011: add support for the ARM SBSA generic UART
>
> .../devicetree/bindings/serial/arm_sbsa_uart.txt | 9 +
> drivers/tty/serial/amba-pl011.c | 509 ++++++++++++++------
> 2 files changed, 380 insertions(+), 138 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 00/10] drivers: PL011: add SBSA subset support
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
` (10 preceding siblings ...)
2014-09-29 15:27 ` [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
@ 2014-09-30 10:11 ` Graeme Gregory
11 siblings, 0 replies; 14+ messages in thread
From: Graeme Gregory @ 2014-09-30 10:11 UTC (permalink / raw)
To: Andre Przywara
Cc: rob.herring, Russell King, Arnd Bergmann, Greg Kroah-Hartman,
linux-serial, Jiri Slaby, linux-arm-kernel
On Fri, Sep 19, 2014 at 01:21:13PM +0100, Andre Przywara wrote:
> (This version has still issues, but I'd like to have feedback on
> the general feasibility of this approach before wasting even more
> time on debugging).
>
> The ARM Server Base System Architecture[1] document describes a
> generic UART which is a subset of the PL011 UART.
> It lacks DMA support, baud rate control and modem status line
> control, among other things.
> The idea is to move the UART initialization and setup into the
> firmware (which does this job today already) and let the kernel just
> use the UART for sending and receiving characters.
>
> This patchset is an attempt to integrate support for this UART subset
> into the existing PL011 driver - basically by refactoring some
> functions and providing a new uart_ops structure for it. It also has
> a separate probe function to be not dependent on AMBA/PrimeCell.
> Beside the obvious effect of code sharing it has the advantage of not
> introducing another serial device prefix, so it can go with ttyAMA,
> which seems to be pretty common.
>
> There is still one issue in bringing up the UART. On the PL011 we
> send a dummy character via the loopback facility with the FIFOs
> disabled to get things going, but both FIFO control and loopback are
> outside of the SBSA spec. I consider this loopback approach a kludge
> anyway, but am struggling to find a better way of fixing this due to
> my lack of understanding of the TTY/serial layer.
> If someone with more wisdom could enlighten me, I would be grateful.
>
This is the killer issue at the moment it seems, once we get to usespace
the tty does not work.
>
> Patch 1/10 contains a bug fix which applies to the PL011 part also,
> it should be considered regardless of the rest of the series.
> Patch 2-7 refactor some PL011 functions by splitting them up into
> smaller pieces, so that most the code can be reused later by the SBSA
> part.
> Patch 8 and 9 introduce two new properties for the vendor structure,
> this is for SBSA functionality which cannot be controlled by
> separate uart_ops members only.
> Patch 10 then finally drops in the SBSA specific code, by providing
> a new uart_ops, vendor struct and probe function for it.
>
> Please have a look and tell me whether this SBSA driver approach has
> any future.
>
The patch series looks reasonable to me based on my very limited
knowledge of the tty layer and the pl011 UART.
Graeme
> Regards,
> Andre
>
> Andre Przywara (10):
> drivers: PL011: avoid potential unregister_driver call
> drivers: PL011: refactor pl011_startup()
> drivers: PL011: refactor pl011_shutdown()
> drivers: PL011: refactor pl011_set_termios()
> drivers: PL011: refactor pl011_probe()
> drivers: PL011: replace UART_MIS reading with _RIS & _IMSC
> drivers: PL011: move cts_event workaround into separate function
> drivers: PL011: allow avoiding UART enabling/disabling
> drivers: PL011: allow to supply fixed option string
> drivers: PL011: add support for the ARM SBSA generic UART
>
> .../devicetree/bindings/serial/arm_sbsa_uart.txt | 9 +
> drivers/tty/serial/amba-pl011.c | 509 ++++++++++++++------
> 2 files changed, 380 insertions(+), 138 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/serial/arm_sbsa_uart.txt
>
> --
> 1.7.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-09-30 10:11 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-19 12:21 [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 01/10] drivers: PL011: avoid potential unregister_driver call Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 02/10] drivers: PL011: refactor pl011_startup() Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 03/10] drivers: PL011: refactor pl011_shutdown() Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 04/10] drivers: PL011: refactor pl011_set_termios() Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 05/10] drivers: PL011: refactor pl011_probe() Andre Przywara
2014-09-19 12:40 ` Russell King - ARM Linux
2014-09-19 12:21 ` [RFC PATCH 06/10] drivers: PL011: replace UART_MIS reading with _RIS & _IMSC Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 07/10] drivers: PL011: move cts_event workaround into separate function Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 08/10] drivers: PL011: allow avoiding UART enabling/disabling Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 09/10] drivers: PL011: allow to supply fixed option string Andre Przywara
2014-09-19 12:21 ` [RFC PATCH 10/10] drivers: PL011: add support for the ARM SBSA generic UART Andre Przywara
2014-09-29 15:27 ` [RFC PATCH 00/10] drivers: PL011: add SBSA subset support Andre Przywara
2014-09-30 10:11 ` Graeme Gregory
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).