1 --- a/drivers/serial/amba-pl010.c
2 +++ b/drivers/serial/amba-pl010.c
9 #define SERIAL_AMBA_MAJOR 204
10 #define SERIAL_AMBA_MINOR 16
11 -#define SERIAL_AMBA_NR UART_NR
12 +#define SERIAL_AMBA_NR CONFIG_SERIAL_AMBA_PL010_NUMPORTS
13 +#define SERIAL_AMBA_NAME CONFIG_SERIAL_AMBA_PL010_PORTNAME
15 #define AMBA_ISR_PASS_LIMIT 256
18 struct uart_amba_port *uap = (struct uart_amba_port *)port;
21 - cr = readb(uap->port.membase + UART010_CR);
22 + cr = __raw_readl(uap->port.membase + UART010_CR);
23 cr &= ~UART010_CR_TIE;
24 - writel(cr, uap->port.membase + UART010_CR);
25 + __raw_writel(cr, uap->port.membase + UART010_CR);
28 static void pl010_start_tx(struct uart_port *port)
30 struct uart_amba_port *uap = (struct uart_amba_port *)port;
33 - cr = readb(uap->port.membase + UART010_CR);
34 + cr = __raw_readl(uap->port.membase + UART010_CR);
36 - writel(cr, uap->port.membase + UART010_CR);
37 + __raw_writel(cr, uap->port.membase + UART010_CR);
40 static void pl010_stop_rx(struct uart_port *port)
42 struct uart_amba_port *uap = (struct uart_amba_port *)port;
45 - cr = readb(uap->port.membase + UART010_CR);
46 + cr = __raw_readl(uap->port.membase + UART010_CR);
47 cr &= ~(UART010_CR_RIE | UART010_CR_RTIE);
48 - writel(cr, uap->port.membase + UART010_CR);
49 + __raw_writel(cr, uap->port.membase + UART010_CR);
52 static void pl010_enable_ms(struct uart_port *port)
54 struct uart_amba_port *uap = (struct uart_amba_port *)port;
57 - cr = readb(uap->port.membase + UART010_CR);
58 + cr = __raw_readl(uap->port.membase + UART010_CR);
59 cr |= UART010_CR_MSIE;
60 - writel(cr, uap->port.membase + UART010_CR);
61 + __raw_writel(cr, uap->port.membase + UART010_CR);
64 static void pl010_rx_chars(struct uart_amba_port *uap)
66 struct tty_struct *tty = uap->port.info->tty;
67 unsigned int status, ch, flag, rsr, max_count = 256;
69 - status = readb(uap->port.membase + UART01x_FR);
70 + status = __raw_readl(uap->port.membase + UART01x_FR);
71 while (UART_RX_DATA(status) && max_count--) {
72 - ch = readb(uap->port.membase + UART01x_DR);
73 + ch = __raw_readl(uap->port.membase + UART01x_DR);
76 uap->port.icount.rx++;
78 * Note that the error handling code is
79 * out of the main execution path
81 - rsr = readb(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
82 + rsr = __raw_readl(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
83 if (unlikely(rsr & UART01x_RSR_ANY)) {
84 - writel(0, uap->port.membase + UART01x_ECR);
85 + __raw_writel(0, uap->port.membase + UART01x_ECR);
87 if (rsr & UART01x_RSR_BE) {
88 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
90 uart_insert_char(&uap->port, rsr, UART01x_RSR_OE, ch, flag);
93 - status = readb(uap->port.membase + UART01x_FR);
94 + status = __raw_readl(uap->port.membase + UART01x_FR);
96 spin_unlock(&uap->port.lock);
97 tty_flip_buffer_push(tty);
101 if (uap->port.x_char) {
102 - writel(uap->port.x_char, uap->port.membase + UART01x_DR);
103 + __raw_writel(uap->port.x_char, uap->port.membase + UART01x_DR);
104 uap->port.icount.tx++;
105 uap->port.x_char = 0;
109 count = uap->port.fifosize >> 1;
111 - writel(xmit->buf[xmit->tail], uap->port.membase + UART01x_DR);
112 + __raw_writel(xmit->buf[xmit->tail], uap->port.membase + UART01x_DR);
113 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
114 uap->port.icount.tx++;
115 if (uart_circ_empty(xmit))
118 unsigned int status, delta;
120 - writel(0, uap->port.membase + UART010_ICR);
121 + __raw_writel(0, uap->port.membase + UART010_ICR);
123 - status = readb(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
124 + status = __raw_readl(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
126 delta = status ^ uap->old_status;
127 uap->old_status = status;
130 spin_lock(&uap->port.lock);
132 - status = readb(uap->port.membase + UART010_IIR);
133 + status = __raw_readl(uap->port.membase + UART010_IIR);
136 if (status & (UART010_IIR_RTIS | UART010_IIR_RIS))
138 if (pass_counter-- == 0)
141 - status = readb(uap->port.membase + UART010_IIR);
142 + status = __raw_readl(uap->port.membase + UART010_IIR);
143 } while (status & (UART010_IIR_RTIS | UART010_IIR_RIS |
147 static unsigned int pl010_tx_empty(struct uart_port *port)
149 struct uart_amba_port *uap = (struct uart_amba_port *)port;
150 - unsigned int status = readb(uap->port.membase + UART01x_FR);
151 + unsigned int status = __raw_readl(uap->port.membase + UART01x_FR);
152 return status & UART01x_FR_BUSY ? 0 : TIOCSER_TEMT;
156 unsigned int result = 0;
159 - status = readb(uap->port.membase + UART01x_FR);
160 + status = __raw_readl(uap->port.membase + UART01x_FR);
161 if (status & UART01x_FR_DCD)
163 if (status & UART01x_FR_DSR)
164 @@ -301,12 +300,12 @@
167 spin_lock_irqsave(&uap->port.lock, flags);
168 - lcr_h = readb(uap->port.membase + UART010_LCRH);
169 + lcr_h = __raw_readl(uap->port.membase + UART010_LCRH);
170 if (break_state == -1)
171 lcr_h |= UART01x_LCRH_BRK;
173 lcr_h &= ~UART01x_LCRH_BRK;
174 - writel(lcr_h, uap->port.membase + UART010_LCRH);
175 + __raw_writel(lcr_h, uap->port.membase + UART010_LCRH);
176 spin_unlock_irqrestore(&uap->port.lock, flags);
179 @@ -334,12 +333,12 @@
181 * initialise the old status of the modem signals
183 - uap->old_status = readb(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
184 + uap->old_status = __raw_readl(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
187 * Finally, enable interrupts
189 - writel(UART01x_CR_UARTEN | UART010_CR_RIE | UART010_CR_RTIE,
190 + __raw_writel(UART01x_CR_UARTEN | UART010_CR_RIE | UART010_CR_RTIE,
191 uap->port.membase + UART010_CR);
194 @@ -362,10 +361,10 @@
196 * disable all interrupts, disable the port
198 - writel(0, uap->port.membase + UART010_CR);
199 + __raw_writel(0, uap->port.membase + UART010_CR);
201 /* disable break condition and fifos */
202 - writel(readb(uap->port.membase + UART010_LCRH) &
203 + __raw_writel(__raw_readl(uap->port.membase + UART010_LCRH) &
204 ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN),
205 uap->port.membase + UART010_LCRH);
209 * Ask the core to calculate the divisor for us.
211 - baud = uart_get_baud_rate(port, termios, old, 0, uap->port.uartclk/16);
212 + baud = uart_get_baud_rate(port, termios, old, 0, uap->port.uartclk/16);
213 quot = uart_get_divisor(port, baud);
215 switch (termios->c_cflag & CSIZE) {
216 @@ -450,25 +449,25 @@
217 uap->port.ignore_status_mask |= UART_DUMMY_RSR_RX;
219 /* first, disable everything */
220 - old_cr = readb(uap->port.membase + UART010_CR) & ~UART010_CR_MSIE;
221 + old_cr = __raw_readl(uap->port.membase + UART010_CR) & ~UART010_CR_MSIE;
223 if (UART_ENABLE_MS(port, termios->c_cflag))
224 old_cr |= UART010_CR_MSIE;
226 - writel(0, uap->port.membase + UART010_CR);
227 + __raw_writel(0, uap->port.membase + UART010_CR);
231 - writel((quot & 0xf00) >> 8, uap->port.membase + UART010_LCRM);
232 - writel(quot & 0xff, uap->port.membase + UART010_LCRL);
233 + __raw_writel((quot & 0xf00) >> 8, uap->port.membase + UART010_LCRM);
234 + __raw_writel(quot & 0xff, uap->port.membase + UART010_LCRL);
237 * ----------v----------v----------v----------v-----
238 * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
239 * ----------^----------^----------^----------^-----
241 - writel(lcr_h, uap->port.membase + UART010_LCRH);
242 - writel(old_cr, uap->port.membase + UART010_CR);
243 + __raw_writel(lcr_h, uap->port.membase + UART010_LCRH);
244 + __raw_writel(old_cr, uap->port.membase + UART010_CR);
246 spin_unlock_irqrestore(&uap->port.lock, flags);
249 .verify_port = pl010_verify_port,
252 -static struct uart_amba_port *amba_ports[UART_NR];
253 +static struct uart_amba_port *amba_ports[SERIAL_AMBA_NR];
255 #ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE
257 @@ -550,10 +549,10 @@
261 - status = readb(uap->port.membase + UART01x_FR);
262 + status = __raw_readl(uap->port.membase + UART01x_FR);
264 } while (!UART_TX_READY(status));
265 - writel(ch, uap->port.membase + UART01x_DR);
266 + __raw_writel(ch, uap->port.membase + UART01x_DR);
272 * First save the CR then disable the interrupts
274 - old_cr = readb(uap->port.membase + UART010_CR);
275 - writel(UART01x_CR_UARTEN, uap->port.membase + UART010_CR);
276 + old_cr = __raw_readl(uap->port.membase + UART010_CR);
277 + __raw_writel(UART01x_CR_UARTEN, uap->port.membase + UART010_CR);
279 uart_console_write(&uap->port, s, count, pl010_console_putchar);
281 @@ -577,10 +576,10 @@
282 * and restore the TCR
285 - status = readb(uap->port.membase + UART01x_FR);
286 + status = __raw_readl(uap->port.membase + UART01x_FR);
288 } while (status & UART01x_FR_BUSY);
289 - writel(old_cr, uap->port.membase + UART010_CR);
290 + __raw_writel(old_cr, uap->port.membase + UART010_CR);
292 clk_disable(uap->clk);
295 pl010_console_get_options(struct uart_amba_port *uap, int *baud,
296 int *parity, int *bits)
298 - if (readb(uap->port.membase + UART010_CR) & UART01x_CR_UARTEN) {
299 + if (__raw_readl(uap->port.membase + UART010_CR) & UART01x_CR_UARTEN) {
300 unsigned int lcr_h, quot;
301 - lcr_h = readb(uap->port.membase + UART010_LCRH);
302 + lcr_h = __raw_readl(uap->port.membase + UART010_LCRH);
305 if (lcr_h & UART01x_LCRH_PEN) {
310 - quot = readb(uap->port.membase + UART010_LCRL) |
311 - readb(uap->port.membase + UART010_LCRM) << 8;
312 + quot = __raw_readl(uap->port.membase + UART010_LCRL) |
313 + __raw_readl(uap->port.membase + UART010_LCRM) << 8;
314 *baud = uap->port.uartclk / (16 * (quot + 1));
318 * if so, search for the first available port that does have
321 - if (co->index >= UART_NR)
322 + if (co->index >= SERIAL_AMBA_NR)
324 uap = amba_ports[co->index];
328 static struct uart_driver amba_reg;
329 static struct console amba_console = {
331 + .name = SERIAL_AMBA_NAME,
332 .write = pl010_console_write,
333 .device = uart_console_device,
334 .setup = pl010_console_setup,
335 @@ -659,11 +658,11 @@
337 static struct uart_driver amba_reg = {
338 .owner = THIS_MODULE,
339 - .driver_name = "ttyAM",
340 - .dev_name = "ttyAM",
341 + .driver_name = SERIAL_AMBA_NAME,
342 + .dev_name = SERIAL_AMBA_NAME,
343 .major = SERIAL_AMBA_MAJOR,
344 .minor = SERIAL_AMBA_MINOR,
346 + .nr = SERIAL_AMBA_NR,
347 .cons = AMBA_CONSOLE,
350 --- a/drivers/serial/Kconfig
351 +++ b/drivers/serial/Kconfig
352 @@ -287,10 +287,25 @@
354 This selects the ARM(R) AMBA(R) PrimeCell PL010 UART. If you have
355 an Integrator/AP or Integrator/PP2 platform, or if you have a
356 - Cirrus Logic EP93xx CPU, say Y or M here.
357 + Cirrus Logic EP93xx CPU or an Infineon ADM5120 SOC, say Y or M here.
361 +config SERIAL_AMBA_PL010_NUMPORTS
362 + int "Maximum number of AMBA PL010 serial ports"
363 + depends on SERIAL_AMBA_PL010
366 + Set this to the number of serial ports you want the AMBA PL010 driver
369 +config SERIAL_AMBA_PL010_PORTNAME
370 + string "Name of the AMBA PL010 serial ports"
371 + depends on SERIAL_AMBA_PL010
374 + ::: To be written :::
376 config SERIAL_AMBA_PL010_CONSOLE
377 bool "Support for console on AMBA serial port"
378 depends on SERIAL_AMBA_PL010=y