serial: Drivers for Altera UARTs
Tobias Klauser
maintainerPATCH v2 1/2 serial: Add driver for the Altera JTAG UART
In reply to Tobias KlauserAdd an UART driver for the JTAG UART component available as a SOPC (System on Programmable Chip) component for Altera FPGAs.
--- drivers/serial/Kconfig | 21 ++ drivers/serial/Makefile | 1 + drivers/serial/altera_jtaguart.c | 504 ++++++++++++++++++++++++++++++++++++++ include/linux/altera_jtaguart.h | 16 ++ include/linux/serial_core.h | 3 + 5 files changed, 545 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/altera_jtaguart.c create mode 100644 include/linux/altera_jtaguart.h
drivers/serial/Kconfig +21 -0
@@ -1490,4 +1490,25 @@ config SERIAL_GRLIB_GAISLER_APBUART_CONSOLE help Support for running a console on the GRLIB APBUART +config SERIAL_ALTERA_JTAGUART + bool "Altera JTAG UART support" + select SERIAL_CORE + help + This driver supports the Altera JTAG UART port. + +config SERIAL_ALTERA_JTAGUART_CONSOLE + bool "Altera JTAG UART console support" + depends on SERIAL_ALTERA_JTAGUART + select SERIAL_CORE_CONSOLE + help + Enable a Altera JTAG UART port to be the system console. + +config SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS + bool "Bypass output when no connection" + depends on SERIAL_ALTERA_JTAGUART_CONSOLE + select SERIAL_CORE_CONSOLE + help + Bypass console output and keep going even if there is no + JTAG terminal connection with the host. + endmenu
drivers/serial/Makefile +1 -0
@@ -82,3 +82,4 @@ obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o obj-$(CONFIG_SERIAL_QE) += ucc_uart.o obj-$(CONFIG_SERIAL_TIMBERDALE) += timbuart.o obj-$(CONFIG_SERIAL_GRLIB_GAISLER_APBUART) += apbuart.o +obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o
drivers/serial/altera_jtaguart.c new file +504 -0
504 lines not on this page · raw message
include/linux/altera_jtaguart.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* altera_jtaguart.h -- Altera JTAG UART driver defines. +*/ + +#ifndef __ALTJUART_H +#define __ALTJUART_H + +#define ALTERA_JTAGUART_MAJOR 204 +#define ALTERA_JTAGUART_MINOR 186 + +struct altera_jtaguart_platform_uart { +unsigned long mapbase;/* Physical address base */ +unsigned int irq;/* Interrupt vector */ +}; + +#endif /* __ALTJUART_H */
include/linux/serial_core.h +3 -0
@@ -182,6 +182,9 @@/* Aeroflex Gaisler GRLIB APBUART */ #define PORT_APBUART 90 +/* Altera UARTs */ +#define PORT_ALTERA_JTAGUART 91 +#ifdef __KERNEL__#include <linux/compiler.h>
Signature · 1 line
1.6.3.3
Tobias Klauser
maintainerPATCH v2 2/2 serial: Add driver for the Altera UART
Add an UART driver for the UART component available as a SOPC (System on Programmable Chip) component for Altera FPGAs.
--- drivers/serial/Kconfig | 31 +++ drivers/serial/Makefile | 1 + drivers/serial/altera_uart.c | 584 ++++++++++++++++++++++++++++++++++++++++++ include/linux/altera_uart.h | 14 + include/linux/serial_core.h | 1 + 5 files changed, 631 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/altera_uart.c create mode 100644 include/linux/altera_uart.h
drivers/serial/Kconfig +31 -0
@@ -1511,4 +1511,35 @@ config SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS Bypass console output and keep going even if there is no JTAG terminal connection with the host. +config SERIAL_ALTERA_UART + bool "Altera UART support" + select SERIAL_CORE + help + This driver supports the Altera softcore UART port. + +config SERIAL_ALTERA_UART_MAXPORTS + int "Maximum number of Altera UART ports" + depends on SERIAL_ALTERA_UART + default 4 + help + This setting lets you define the maximum number of the Altera + UART ports. The usual default varies from board to board, and + this setting is a way of catering for that. + +config SERIAL_ALTERA_UART_BAUDRATE + int "Default baudrate for Altera UART ports" + depends on SERIAL_ALTERA_UART + default 115200 + help + This setting lets you define what the default baudrate is for the + Altera UART ports. The usual default varies from board to board, + and this setting is a way of catering for that. + +config SERIAL_ALTERA_UART_CONSOLE + bool "Altera UART console support" + depends on SERIAL_ALTERA_UART + select SERIAL_CORE_CONSOLE + help + Enable a Altera UART port to be the system console. + endmenu
drivers/serial/Makefile +1 -0
@@ -83,3 +83,4 @@ obj-$(CONFIG_SERIAL_QE) += ucc_uart.o obj-$(CONFIG_SERIAL_TIMBERDALE) += timbuart.o obj-$(CONFIG_SERIAL_GRLIB_GAISLER_APBUART) += apbuart.o obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o +obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
drivers/serial/altera_uart.c new file +584 -0
584 lines not on this page · raw message
include/linux/altera_uart.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* altera_uart.h -- Altera UART driver defines. +*/ + +#ifndef __ALTUART_H +#define __ALTUART_H + +struct altera_uart_platform_uart { +unsigned long mapbase;/* Physical address base */ +unsigned int irq;/* Interrupt vector */ +unsigned int uartclk;/* UART clock rate */ +}; + +#endif /* __ALTUART_H */
include/linux/serial_core.h +1 -0
@@ -184,6 +184,7 @@/* Altera UARTs */ #define PORT_ALTERA_JTAGUART 91 +#define PORT_ALTERA_UART 92#ifdef __KERNEL__
Signature · 1 line
1.6.3.3
Tobias Klauser
maintainerv2 cover serial: Drivers for Altera UARTs
This is the second version of the patchset to add the serial drivers for the Altera UARTs. The following changes were made on top of the first version submitted on 25 Feb 2010:
- altera_jtaguart: Implement altera_jtaguart_set_termios
- altera_jtaguart: Protect port.tty in altera_jtaguart_rx_chars
- altera_uart, altera_jtaguart: Don't depend on EMBEDDED
- altera_jtaguart: Correct check for co->index
- altera_uart: Correct check for co->index
Thanks,
Tobias
Re: [PATCHv2 2/2] serial: Add driver for the Altera UART
In reply to Tobias Klauserdrivers/serial/altera_uart.c line 87
Quoted 13 lines
+ * Some boards implement the DTR/DCD lines using GPIO lines, most don't. Dummy
+ * out the access macros for those that don't. Those that do should define these
+ * macros somewhere in their board specific inlude files.
+ */drivers/serial/altera_uart.c new file +9
-0+#if !defined(altera_uart_getppdcd) +# define altera_uart_getppdcd (p) (1) +#endif +#if !defined(altera_uart_getppdtr) +# define altera_uart_getppdtr (p) (1) +#endif +#if !defined(altera_uart_setppdtr) +# define altera_uart_setppdtr (p, v) do { } while (0) +#endif
Those ought to be in the board stuff only - the problem you have otherwise is that someone not noticing won't get an error.
drivers/serial/altera_uart.c line 201
Quoted 13 lines
drivers/serial/altera_uart.c new file +13
-0+static void altera_uart_set_termios (struct uart_port *port, +struct ktermios *termios, +struct ktermios *old) +{ +unsigned long flags; +unsigned int baud, baudclk; + + baud =uart_get_baud_rate (port, termios, old,0 ,4000000 ); + baudclk = port->uartclk / baud; + +spin_lock_irqsave (&port->lock, flags); +writel (baudclk, port->membase +ALTERA_UART_DIVISOR_REG ); +spin_unlock_irqrestore (&port->lock, flags);
If you only support board setting then copy the old termios back as in the other driver and the use tty_termios_encode_baud_rate() to report set the baud rate accordingly.
As the oddments that want adjusting can be done post merge and I'd rather see this in now than later as there are some serial_core changes cooking that will need to touch all drivers.
Tobias Klauser
maintainerRe: [PATCHv2 2/2] serial: Add driver for the Altera UART
Quoted 6 lines · Alan Cox
Acked-by Alan Cox <[email protected]>As the oddments that want adjusting can be done post merge and I'd rather see this in now than later as there are some
serial_corechanges cooking that will need to touch all drivers.
It doesn't seem that the drivers got merged yet, so I posted an updated patchset adressing these oddments.
Thanks a lot,
Tobias