aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/pmc-sierra/msp71xx/msp_serial.c165
-rw-r--r--drivers/serial/8250.c31
-rw-r--r--drivers/serial/serial_core.c2
-rw-r--r--include/linux/serial_core.h2
-rw-r--r--include/linux/serial_reg.h2
5 files changed, 202 insertions, 0 deletions
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_serial.c b/arch/mips/pmc-sierra/msp71xx/msp_serial.c
new file mode 100644
index 000000000000..c41b53faa8f6
--- /dev/null
+++ b/arch/mips/pmc-sierra/msp71xx/msp_serial.c
@@ -0,0 +1,165 @@
1/*
2 * The setup file for serial related hardware on PMC-Sierra MSP processors.
3 *
4 * Copyright 2005 PMC-Sierra, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
14 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27#include <linux/serial.h>
28#include <linux/serial_core.h>
29#include <linux/serial_reg.h>
30
31#include <asm/bootinfo.h>
32#include <asm/io.h>
33#include <asm/processor.h>
34#include <asm/serial.h>
35
36#include <msp_prom.h>
37#include <msp_int.h>
38#include <msp_regs.h>
39
40#ifdef CONFIG_KGDB
41/*
42 * kgdb uses serial port 1 so the console can remain on port 0.
43 * To use port 0 change the definition to read as follows:
44 * #define DEBUG_PORT_BASE KSEG1ADDR(MSP_UART0_BASE)
45 */
46#define DEBUG_PORT_BASE KSEG1ADDR(MSP_UART1_BASE)
47
48int putDebugChar(char c)
49{
50 volatile uint32_t *uart = (volatile uint32_t *)DEBUG_PORT_BASE;
51 uint32_t val = (uint32_t)c;
52
53 local_irq_disable();
54 while( !(uart[5] & 0x20) ); /* Wait for TXRDY */
55 uart[0] = val;
56 while( !(uart[5] & 0x20) ); /* Wait for TXRDY */
57 local_irq_enable();
58
59 return 1;
60}
61
62char getDebugChar(void)
63{
64 volatile uint32_t *uart = (volatile uint32_t *)DEBUG_PORT_BASE;
65 uint32_t val;
66
67 while( !(uart[5] & 0x01) ); /* Wait for RXRDY */
68 val = uart[0];
69
70 return (char)val;
71}
72
73void initDebugPort(unsigned int uartclk, unsigned int baudrate)
74{
75 unsigned int baud_divisor = (uartclk + 8 * baudrate)/(16 * baudrate);
76
77 /* Enable FIFOs */
78 writeb(UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
79 UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_4,
80 (char *)DEBUG_PORT_BASE + (UART_FCR * 4));
81
82 /* Select brtc divisor */
83 writeb(UART_LCR_DLAB, (char *)DEBUG_PORT_BASE + (UART_LCR * 4));
84
85 /* Store divisor lsb */
86 writeb(baud_divisor, (char *)DEBUG_PORT_BASE + (UART_TX * 4));
87
88 /* Store divisor msb */
89 writeb(baud_divisor >> 8, (char *)DEBUG_PORT_BASE + (UART_IER * 4));
90
91 /* Set 8N1 mode */
92 writeb(UART_LCR_WLEN8, (char *)DEBUG_PORT_BASE + (UART_LCR * 4));
93
94 /* Disable flow control */
95 writeb(0, (char *)DEBUG_PORT_BASE + (UART_MCR * 4));
96
97 /* Disable receive interrupt(!) */
98 writeb(0, (char *)DEBUG_PORT_BASE + (UART_IER * 4));
99}
100#endif
101
102void __init msp_serial_setup(void)
103{
104 char *s;
105 char *endp;
106 struct uart_port up;
107 unsigned int uartclk;
108
109 memset(&up, 0, sizeof(up));
110
111 /* Check if clock was specified in environment */
112 s = prom_getenv("uartfreqhz");
113 if(!(s && *s && (uartclk = simple_strtoul(s, &endp, 10)) && *endp == 0))
114 uartclk = MSP_BASE_BAUD;
115 ppfinit("UART clock set to %d\n", uartclk);
116
117 /* Initialize first serial port */
118 up.mapbase = MSP_UART0_BASE;
119 up.membase = ioremap_nocache(up.mapbase,MSP_UART_REG_LEN);
120 up.irq = MSP_INT_UART0;
121 up.uartclk = uartclk;
122 up.regshift = 2;
123 up.iotype = UPIO_DWAPB; /* UPIO_MEM like */
124 up.flags = STD_COM_FLAGS;
125 up.type = PORT_16550A;
126 up.line = 0;
127 up.private_data = (void*)UART0_STATUS_REG;
128 if (early_serial_setup(&up))
129 printk(KERN_ERR "Early serial init of port 0 failed\n");
130
131 /* Initialize the second serial port, if one exists */
132 switch (mips_machtype) {
133 case MACH_MSP4200_EVAL:
134 case MACH_MSP4200_GW:
135 case MACH_MSP4200_FPGA:
136 case MACH_MSP7120_EVAL:
137 case MACH_MSP7120_GW:
138 case MACH_MSP7120_FPGA:
139 /* Enable UART1 on MSP4200 and MSP7120 */
140 *GPIO_CFG2_REG = 0x00002299;
141
142#ifdef CONFIG_KGDB
143 /* Initialize UART1 for kgdb since PMON doesn't */
144 if( DEBUG_PORT_BASE == KSEG1ADDR(MSP_UART1_BASE) ) {
145 if( mips_machtype == MACH_MSP4200_FPGA
146 || mips_machtype == MACH_MSP7120_FPGA )
147 initDebugPort(uartclk,19200);
148 else
149 initDebugPort(uartclk,57600);
150 }
151#endif
152 break;
153
154 default:
155 return; /* No second serial port, good-bye. */
156 }
157
158 up.mapbase = MSP_UART1_BASE;
159 up.membase = ioremap_nocache(up.mapbase,MSP_UART_REG_LEN);
160 up.irq = MSP_INT_UART1;
161 up.line = 1;
162 up.private_data = (void*)UART1_STATUS_REG;
163 if (early_serial_setup(&up))
164 printk(KERN_ERR "Early serial init of port 1 failed\n");
165}
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 90621c3312bc..194362d9f5a3 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -308,6 +308,7 @@ static unsigned int serial_in(struct uart_8250_port *up, int offset)
308 return inb(up->port.iobase + 1); 308 return inb(up->port.iobase + 1);
309 309
310 case UPIO_MEM: 310 case UPIO_MEM:
311 case UPIO_DWAPB:
311 return readb(up->port.membase + offset); 312 return readb(up->port.membase + offset);
312 313
313 case UPIO_MEM32: 314 case UPIO_MEM32:
@@ -333,6 +334,8 @@ static unsigned int serial_in(struct uart_8250_port *up, int offset)
333static void 334static void
334serial_out(struct uart_8250_port *up, int offset, int value) 335serial_out(struct uart_8250_port *up, int offset, int value)
335{ 336{
337 /* Save the offset before it's remapped */
338 int save_offset = offset;
336 offset = map_8250_out_reg(up, offset) << up->port.regshift; 339 offset = map_8250_out_reg(up, offset) << up->port.regshift;
337 340
338 switch (up->port.iotype) { 341 switch (up->port.iotype) {
@@ -359,6 +362,18 @@ serial_out(struct uart_8250_port *up, int offset, int value)
359 writeb(value, up->port.membase + offset); 362 writeb(value, up->port.membase + offset);
360 break; 363 break;
361 364
365 case UPIO_DWAPB:
366 /* Save the LCR value so it can be re-written when a
367 * Busy Detect interrupt occurs. */
368 if (save_offset == UART_LCR)
369 up->lcr = value;
370 writeb(value, up->port.membase + offset);
371 /* Read the IER to ensure any interrupt is cleared before
372 * returning from ISR. */
373 if (save_offset == UART_TX || save_offset == UART_IER)
374 value = serial_in(up, UART_IER);
375 break;
376
362 default: 377 default:
363 outb(value, up->port.iobase + offset); 378 outb(value, up->port.iobase + offset);
364 } 379 }
@@ -373,6 +388,7 @@ serial_out_sync(struct uart_8250_port *up, int offset, int value)
373#ifdef CONFIG_SERIAL_8250_AU1X00 388#ifdef CONFIG_SERIAL_8250_AU1X00
374 case UPIO_AU: 389 case UPIO_AU:
375#endif 390#endif
391 case UPIO_DWAPB:
376 serial_out(up, offset, value); 392 serial_out(up, offset, value);
377 serial_in(up, UART_LCR); /* safe, no side-effects */ 393 serial_in(up, UART_LCR); /* safe, no side-effects */
378 break; 394 break;
@@ -1389,6 +1405,19 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id)
1389 handled = 1; 1405 handled = 1;
1390 1406
1391 end = NULL; 1407 end = NULL;
1408 } else if (up->port.iotype == UPIO_DWAPB &&
1409 (iir & UART_IIR_BUSY) == UART_IIR_BUSY) {
1410 /* The DesignWare APB UART has an Busy Detect (0x07)
1411 * interrupt meaning an LCR write attempt occured while the
1412 * UART was busy. The interrupt must be cleared by reading
1413 * the UART status register (USR) and the LCR re-written. */
1414 unsigned int status;
1415 status = *(volatile u32 *)up->port.private_data;
1416 serial_out(up, UART_LCR, up->lcr);
1417
1418 handled = 1;
1419
1420 end = NULL;
1392 } else if (end == NULL) 1421 } else if (end == NULL)
1393 end = l; 1422 end = l;
1394 1423
@@ -2090,6 +2119,7 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
2090 case UPIO_TSI: 2119 case UPIO_TSI:
2091 case UPIO_MEM32: 2120 case UPIO_MEM32:
2092 case UPIO_MEM: 2121 case UPIO_MEM:
2122 case UPIO_DWAPB:
2093 if (!up->port.mapbase) 2123 if (!up->port.mapbase)
2094 break; 2124 break;
2095 2125
@@ -2127,6 +2157,7 @@ static void serial8250_release_std_resource(struct uart_8250_port *up)
2127 case UPIO_TSI: 2157 case UPIO_TSI:
2128 case UPIO_MEM32: 2158 case UPIO_MEM32:
2129 case UPIO_MEM: 2159 case UPIO_MEM:
2160 case UPIO_DWAPB:
2130 if (!up->port.mapbase) 2161 if (!up->port.mapbase)
2131 break; 2162 break;
2132 2163
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 0422c0f1f852..a677133ab2d4 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -2064,6 +2064,7 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port)
2064 case UPIO_MEM32: 2064 case UPIO_MEM32:
2065 case UPIO_AU: 2065 case UPIO_AU:
2066 case UPIO_TSI: 2066 case UPIO_TSI:
2067 case UPIO_DWAPB:
2067 snprintf(address, sizeof(address), 2068 snprintf(address, sizeof(address),
2068 "MMIO 0x%lx", port->mapbase); 2069 "MMIO 0x%lx", port->mapbase);
2069 break; 2070 break;
@@ -2409,6 +2410,7 @@ int uart_match_port(struct uart_port *port1, struct uart_port *port2)
2409 case UPIO_MEM32: 2410 case UPIO_MEM32:
2410 case UPIO_AU: 2411 case UPIO_AU:
2411 case UPIO_TSI: 2412 case UPIO_TSI:
2413 case UPIO_DWAPB:
2412 return (port1->mapbase == port2->mapbase); 2414 return (port1->mapbase == port2->mapbase);
2413 } 2415 }
2414 return 0; 2416 return 0;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 586aaba91720..8b5592e6aca4 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -230,6 +230,7 @@ struct uart_port {
230#define UPIO_MEM32 (3) 230#define UPIO_MEM32 (3)
231#define UPIO_AU (4) /* Au1x00 type IO */ 231#define UPIO_AU (4) /* Au1x00 type IO */
232#define UPIO_TSI (5) /* Tsi108/109 type IO */ 232#define UPIO_TSI (5) /* Tsi108/109 type IO */
233#define UPIO_DWAPB (6) /* DesignWare APB UART */
233 234
234 unsigned int read_status_mask; /* driver specific */ 235 unsigned int read_status_mask; /* driver specific */
235 unsigned int ignore_status_mask; /* driver specific */ 236 unsigned int ignore_status_mask; /* driver specific */
@@ -276,6 +277,7 @@ struct uart_port {
276 struct device *dev; /* parent device */ 277 struct device *dev; /* parent device */
277 unsigned char hub6; /* this should be in the 8250 driver */ 278 unsigned char hub6; /* this should be in the 8250 driver */
278 unsigned char unused[3]; 279 unsigned char unused[3];
280 void *private_data; /* generic platform data pointer */
279}; 281};
280 282
281/* 283/*
diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h
index 3c8a6aa77415..1c5ed7d92b0f 100644
--- a/include/linux/serial_reg.h
+++ b/include/linux/serial_reg.h
@@ -38,6 +38,8 @@
38#define UART_IIR_RDI 0x04 /* Receiver data interrupt */ 38#define UART_IIR_RDI 0x04 /* Receiver data interrupt */
39#define UART_IIR_RLSI 0x06 /* Receiver line status interrupt */ 39#define UART_IIR_RLSI 0x06 /* Receiver line status interrupt */
40 40
41#define UART_IIR_BUSY 0x07 /* DesignWare APB Busy Detect */
42
41#define UART_FCR 2 /* Out: FIFO Control Register */ 43#define UART_FCR 2 /* Out: FIFO Control Register */
42#define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */ 44#define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */
43#define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */ 45#define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */