Commit 7b953c51654912b94a71854b9d2e6b48ee3b7908

Authored by Marek Vasut
Committed by Tom Rini
1 parent 41651cab97

serial: mips: Implement CONFIG_SERIAL_MULTI into au1x00 serial driver

Implement support for CONFIG_SERIAL_MULTI into au1x00 serial driver.
This driver was so far only usable directly, but this patch also adds
support for the multi method. This allows using more than one serial
driver alongside the au1x00 driver. Also, add a weak implementation
of default_serial_console() returning this driver.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Rini <trini@ti.com>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>

Showing 2 changed files with 67 additions and 10 deletions Side-by-side Diff

arch/mips/cpu/mips32/au1x00/au1x00_serial.c
... ... @@ -28,6 +28,8 @@
28 28 #include <config.h>
29 29 #include <common.h>
30 30 #include <asm/au1x00.h>
  31 +#include <serial.h>
  32 +#include <linux/compiler.h>
31 33  
32 34 /******************************************************************************
33 35 *
... ... @@ -40,7 +42,7 @@
40 42 * RETURNS: N/A
41 43 */
42 44  
43   -int serial_init (void)
  45 +static int au1x00_serial_init(void)
44 46 {
45 47 volatile u32 *uart_fifoctl = (volatile u32*)(UART0_ADDR+UART_FCR);
46 48 volatile u32 *uart_enable = (volatile u32*)(UART0_ADDR+UART_ENABLE);
... ... @@ -63,7 +65,7 @@
63 65 }
64 66  
65 67  
66   -void serial_setbrg (void)
  68 +static void au1x00_serial_setbrg(void)
67 69 {
68 70 volatile u32 *uart_clk = (volatile u32*)(UART0_ADDR+UART_CLK);
69 71 volatile u32 *uart_lcr = (volatile u32*)(UART0_ADDR+UART_LCR);
70 72  
... ... @@ -87,12 +89,13 @@
87 89 *uart_lcr = UART_LCR_WLEN8;
88 90 }
89 91  
90   -void serial_putc (const char c)
  92 +static void au1x00_serial_putc(const char c)
91 93 {
92 94 volatile u32 *uart_lsr = (volatile u32*)(UART0_ADDR+UART_LSR);
93 95 volatile u32 *uart_tx = (volatile u32*)(UART0_ADDR+UART_TX);
94 96  
95   - if (c == '\n') serial_putc ('\r');
  97 + if (c == '\n')
  98 + au1x00_serial_putc('\r');
96 99  
97 100 /* Wait for fifo to shift out some bytes */
98 101 while((*uart_lsr&UART_LSR_THRE)==0);
99 102  
100 103  
... ... @@ -100,15 +103,13 @@
100 103 *uart_tx = (u32)c;
101 104 }
102 105  
103   -void serial_puts (const char *s)
  106 +static void au1x00_serial_puts(const char *s)
104 107 {
105 108 while (*s)
106   - {
107   - serial_putc (*s++);
108   - }
  109 + serial_putc(*s++);
109 110 }
110 111  
111   -int serial_getc (void)
  112 +static int au1x00_serial_getc(void)
112 113 {
113 114 volatile u32 *uart_rx = (volatile u32*)(UART0_ADDR+UART_RX);
114 115 char c;
... ... @@ -119,7 +120,7 @@
119 120 return c;
120 121 }
121 122  
122   -int serial_tstc (void)
  123 +static int au1x00_serial_tstc(void)
123 124 {
124 125 volatile u32 *uart_lsr = (volatile u32*)(UART0_ADDR+UART_LSR);
125 126  
... ... @@ -129,4 +130,57 @@
129 130 }
130 131 return 0;
131 132 }
  133 +
  134 +#ifdef CONFIG_SERIAL_MULTI
  135 +static struct serial_device au1x00_serial_drv = {
  136 + .name = "au1x00_serial",
  137 + .start = au1x00_serial_init,
  138 + .stop = NULL,
  139 + .setbrg = au1x00_serial_setbrg,
  140 + .putc = au1x00_serial_putc,
  141 + .puts = au1x00_serial_puts,
  142 + .getc = au1x00_serial_getc,
  143 + .tstc = au1x00_serial_tstc,
  144 +};
  145 +
  146 +void au1x00_serial_initialize(void)
  147 +{
  148 + serial_register(&au1x00_serial_drv);
  149 +}
  150 +
  151 +__weak struct serial_device *default_serial_console(void)
  152 +{
  153 + return &au1x00_serial_drv;
  154 +}
  155 +#else
  156 +int serial_init(void)
  157 +{
  158 + return au1x00_serial_init();
  159 +}
  160 +
  161 +void serial_setbrg(void)
  162 +{
  163 + au1x00_serial_setbrg();
  164 +}
  165 +
  166 +void serial_putc(const char c)
  167 +{
  168 + au1x00_serial_putc(c);
  169 +}
  170 +
  171 +void serial_puts(const char *s)
  172 +{
  173 + au1x00_serial_puts(s);
  174 +}
  175 +
  176 +int serial_getc(void)
  177 +{
  178 + return au1x00_serial_getc();
  179 +}
  180 +
  181 +int serial_tstc(void)
  182 +{
  183 + return au1x00_serial_tstc();
  184 +}
  185 +#endif
... ... @@ -50,6 +50,7 @@
50 50 serial_initfunc(bfin_jtag_initialize);
51 51 serial_initfunc(mpc512x_serial_initialize);
52 52 serial_initfunc(uartlite_serial_initialize);
  53 +serial_initfunc(au1x00_serial_initialize);
53 54  
54 55 void serial_register(struct serial_device *dev)
55 56 {
... ... @@ -78,6 +79,8 @@
78 79 bfin_jtag_initialize();
79 80 uartlite_serial_initialize();
80 81 zynq_serial_initalize();
  82 + au1x00_serial_initialize();
  83 +
81 84 serial_assign(default_serial_console()->name);
82 85 }
83 86