* [PATCH 0/2] serial8250: support for DesignWare 8250
@ 2011-08-16 16:47 Jamie Iles
2011-08-16 16:47 ` [PATCH 1/2] tty: serial8250: add helpers for the " Jamie Iles
2011-08-16 16:47 ` [PATCH 2/2] tty: of_serial: add support " Jamie Iles
0 siblings, 2 replies; 4+ messages in thread
From: Jamie Iles @ 2011-08-16 16:47 UTC (permalink / raw)
To: linux-serial; +Cc: arnd, alan, Jamie Iles
This builds on my previous series that removes UPIO_DWAPB and
UPIO_DWAPB32 and allows the DesignWare 8250 extra features to be used.
I've set this up as a helper function that adds the accessors to a
uart_port as I thought this could be used by both of_serial and normal
platform devices. These helpers could be converted to a set of 8250 ops
once we have that in place.
Jamie
Jamie Iles (2):
tty: serial8250: add helpers for the DesignWare 8250
tty: of_serial: add support for the DesignWare 8250
.../devicetree/bindings/tty/serial/of-serial.txt | 1 +
drivers/tty/serial/8250_dw.c | 99 ++++++++++++++++++++
drivers/tty/serial/Kconfig | 7 ++
drivers/tty/serial/Makefile | 1 +
drivers/tty/serial/of_serial.c | 7 ++
include/linux/serial_8250.h | 8 ++
6 files changed, 123 insertions(+), 0 deletions(-)
create mode 100644 drivers/tty/serial/8250_dw.c
--
1.7.4.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] tty: serial8250: add helpers for the DesignWare 8250
2011-08-16 16:47 [PATCH 0/2] serial8250: support for DesignWare 8250 Jamie Iles
@ 2011-08-16 16:47 ` Jamie Iles
2011-08-16 16:57 ` Arnd Bergmann
2011-08-16 16:47 ` [PATCH 2/2] tty: of_serial: add support " Jamie Iles
1 sibling, 1 reply; 4+ messages in thread
From: Jamie Iles @ 2011-08-16 16:47 UTC (permalink / raw)
To: linux-serial; +Cc: arnd, alan, Jamie Iles, Alan Cox, Greg Kroah-Hartman
The Synopsys DesignWare 8250 is an 8250 that has an extra interrupt that
gets raised when writing to the LCR when busy. To handle this we need
special serial_out, serial_in and handle_irq methods. Add a new
function serial8250_use_designware_io() that configures a uart_port with
these accessors.
Cc: Alan Cox <alan@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
drivers/tty/serial/8250_dw.c | 99 ++++++++++++++++++++++++++++++++++++++++++
drivers/tty/serial/Kconfig | 7 +++
drivers/tty/serial/Makefile | 1 +
include/linux/serial_8250.h | 8 +++
4 files changed, 115 insertions(+), 0 deletions(-)
create mode 100644 drivers/tty/serial/8250_dw.c
diff --git a/drivers/tty/serial/8250_dw.c b/drivers/tty/serial/8250_dw.c
new file mode 100644
index 0000000..e25782a
--- /dev/null
+++ b/drivers/tty/serial/8250_dw.c
@@ -0,0 +1,99 @@
+/*
+ * Synopsys DesignWare specific 8250 operations.
+ *
+ * Copyright 2011 Picochip, Jamie Iles.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The Synopsys DesignWare 8250 has an extra feature whereby it detects if the
+ * LCR is written whilst busy. If it is, then a busy detect interrupt is
+ * raised, the LCR needs to be rewritten and the uart status register read.
+ */
+#include <linux/io.h>
+#include <linux/serial_8250.h>
+#include <linux/serial_core.h>
+#include <linux/serial_reg.h>
+#include <linux/slab.h>
+
+struct dw8250_data {
+ int last_lcr;
+};
+
+static void dw8250_serial_out(struct uart_port *p, int offset, int value)
+{
+ struct dw8250_data *d = p->private_data;
+
+ if (offset == UART_LCR)
+ d->last_lcr = value;
+
+ offset <<= p->regshift;
+ writeb(value, p->membase + offset);
+}
+
+static unsigned int dw8250_serial_in(struct uart_port *p, int offset)
+{
+ offset <<= p->regshift;
+
+ return readb(p->membase + offset);
+}
+
+static void dw8250_serial_out32(struct uart_port *p, int offset,
+ int value)
+{
+ struct dw8250_data *d = p->private_data;
+
+ if (offset == UART_LCR)
+ d->last_lcr = value;
+
+ offset <<= p->regshift;
+ writel(value, p->membase + offset);
+}
+
+static unsigned int dw8250_serial_in32(struct uart_port *p, int offset)
+{
+ offset <<= p->regshift;
+
+ return readl(p->membase + offset);
+}
+
+/* Offset for the DesignWare's UART Status Register. */
+#define UART_USR 0x1f
+
+static int dw8250_handle_irq(struct uart_port *p)
+{
+ struct dw8250_data *d = p->private_data;
+ unsigned int iir = p->serial_in(p, UART_IIR);
+
+ if (serial8250_handle_irq(p, iir)) {
+ return 1;
+ } else if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) {
+ /* Clear the USR and write the LCR again. */
+ (void)p->serial_in(p, UART_USR);
+ p->serial_out(p, d->last_lcr, UART_LCR);
+
+ return 1;
+ }
+
+ return 0;
+}
+
+int serial8250_use_designware_io(struct uart_port *up)
+{
+ up->private_data = kzalloc(sizeof(struct dw8250_data), GFP_KERNEL);
+ if (!up->private_data)
+ return -ENOMEM;
+
+ if (up->iotype == UPIO_MEM32) {
+ up->serial_out = dw8250_serial_out32;
+ up->serial_in = dw8250_serial_in32;
+ } else {
+ up->serial_out = dw8250_serial_out;
+ up->serial_in = dw8250_serial_in;
+ }
+ up->handle_irq = dw8250_handle_irq;
+
+ return 0;
+}
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 4dcb37bb..f314acc 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -267,6 +267,13 @@ config SERIAL_8250_RM9K
port hardware found on MIPS RM9122 and similar processors.
If unsure, say N.
+config SERIAL_8250_DW
+ bool "Support for Synopsys DesignWare 8250 quirks"
+ depends on SERIAL_8250
+ help
+ Selecting this option will enable handling of the extra features
+ present in the Synopsys DesignWare APB UART.
+
comment "Non-8250 serial port support"
config SERIAL_AMBA_PL010
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index 83b4da6..06c9808 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
+obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o
obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 1f05bbe..09e2dbc 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -86,5 +86,13 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
extern void serial8250_set_isa_configurator(void (*v)
(int port, struct uart_port *up,
unsigned short *capabilities));
+#ifndef SERIAL_8250_DW
+extern int serial8250_use_designware_io(struct uart_port *up);
+#else
+static inline int serial8250_use_designware_io(struct uart_port *up)
+{
+ return -EIO;
+}
+#endif
#endif
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] tty: of_serial: add support for the DesignWare 8250
2011-08-16 16:47 [PATCH 0/2] serial8250: support for DesignWare 8250 Jamie Iles
2011-08-16 16:47 ` [PATCH 1/2] tty: serial8250: add helpers for the " Jamie Iles
@ 2011-08-16 16:47 ` Jamie Iles
1 sibling, 0 replies; 4+ messages in thread
From: Jamie Iles @ 2011-08-16 16:47 UTC (permalink / raw)
To: linux-serial; +Cc: arnd, alan, Jamie Iles, Alan Cox, Greg Kroah-Hartman
Support the DesignWare 8250 by a new compatible string and registering
the DesignWare helpers. If the registration of the helpers fails, then
continue as a normal 8250 as we may still get some useful debug out.
Cc: Alan Cox <alan@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
.../devicetree/bindings/tty/serial/of-serial.txt | 1 +
drivers/tty/serial/of_serial.c | 7 +++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/tty/serial/of-serial.txt b/Documentation/devicetree/bindings/tty/serial/of-serial.txt
index b8b27b0..b7ceaaa 100644
--- a/Documentation/devicetree/bindings/tty/serial/of-serial.txt
+++ b/Documentation/devicetree/bindings/tty/serial/of-serial.txt
@@ -3,6 +3,7 @@
Required properties:
- compatible : one of:
- "ns8250"
+ - "ns8250dw"
- "ns16450"
- "ns16550a"
- "ns16550"
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index e58cece..024926c 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -78,6 +78,12 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
}
}
+ if (of_device_is_compatible(np, "ns8250dw")) {
+ ret = serial8250_use_designware_io(port);
+ if (ret)
+ dev_warn(&ofdev->dev, "unable to register DesignWare 8250 helpers, continuing as a normal 8250\n");
+ }
+
port->type = type;
port->uartclk = clk;
port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
@@ -176,6 +182,7 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
*/
static struct of_device_id __devinitdata of_platform_serial_table[] = {
{ .compatible = "ns8250", .data = (void *)PORT_8250, },
+ { .compatible = "ns8250dw", .data = (void *)PORT_8250, },
{ .compatible = "ns16450", .data = (void *)PORT_16450, },
{ .compatible = "ns16550a", .data = (void *)PORT_16550A, },
{ .compatible = "ns16550", .data = (void *)PORT_16550, },
--
1.7.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] tty: serial8250: add helpers for the DesignWare 8250
2011-08-16 16:47 ` [PATCH 1/2] tty: serial8250: add helpers for the " Jamie Iles
@ 2011-08-16 16:57 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2011-08-16 16:57 UTC (permalink / raw)
To: Jamie Iles; +Cc: linux-serial, alan, Alan Cox, Greg Kroah-Hartman
On Tuesday 16 August 2011, Jamie Iles wrote:
> The Synopsys DesignWare 8250 is an 8250 that has an extra interrupt that
> gets raised when writing to the LCR when busy. To handle this we need
> special serial_out, serial_in and handle_irq methods. Add a new
> function serial8250_use_designware_io() that configures a uart_port with
> these accessors.
>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Hmm, this looks about as good as the solution that I had in mind (doing
a new platform_driver). I can't any obvious advantages either way, so
I guess you get to have your version ;-)
Acked-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-16 16:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-16 16:47 [PATCH 0/2] serial8250: support for DesignWare 8250 Jamie Iles
2011-08-16 16:47 ` [PATCH 1/2] tty: serial8250: add helpers for the " Jamie Iles
2011-08-16 16:57 ` Arnd Bergmann
2011-08-16 16:47 ` [PATCH 2/2] tty: of_serial: add support " Jamie Iles
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox