ar71xx: add common m25p80 device
[openwrt.git] / target / linux / ifxmips / patches-2.6.30 / 120-serial.patch
1 Index: linux-2.6.30.8/drivers/serial/Kconfig
2 ===================================================================
3 --- linux-2.6.30.8.orig/drivers/serial/Kconfig 2009-09-24 17:28:02.000000000 +0200
4 +++ linux-2.6.30.8/drivers/serial/Kconfig 2009-10-19 21:31:32.000000000 +0200
5 @@ -1365,6 +1365,14 @@
6 help
7 Support for Console on the NWP serial ports.
8
9 +config SERIAL_IFXMIPS
10 + bool "IFXMips serial driver"
11 + depends on IFXMIPS
12 + select SERIAL_CORE
13 + select SERIAL_CORE_CONSOLE
14 + help
15 + Driver for the ifxmipss built in ASC hardware
16 +
17 config SERIAL_QE
18 tristate "Freescale QUICC Engine serial port support"
19 depends on QUICC_ENGINE
20 Index: linux-2.6.30.8/drivers/serial/Makefile
21 ===================================================================
22 --- linux-2.6.30.8.orig/drivers/serial/Makefile 2009-09-24 17:28:02.000000000 +0200
23 +++ linux-2.6.30.8/drivers/serial/Makefile 2009-10-19 21:31:32.000000000 +0200
24 @@ -77,3 +77,4 @@
25 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
26 obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
27 obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
28 +obj-$(CONFIG_SERIAL_IFXMIPS) += ifxmips_asc.o
29 Index: linux-2.6.30.8/drivers/serial/ifxmips_asc.c
30 ===================================================================
31 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
32 +++ linux-2.6.30.8/drivers/serial/ifxmips_asc.c 2009-10-19 21:41:27.000000000 +0200
33 @@ -0,0 +1,561 @@
34 +/*
35 + * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
36 + *
37 + * This program is free software; you can redistribute it and/or modify
38 + * it under the terms of the GNU General Public License as published by
39 + * the Free Software Foundation; either version 2 of the License, or
40 + * (at your option) any later version.
41 + *
42 + * This program is distributed in the hope that it will be useful,
43 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
44 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 + * GNU General Public License for more details.
46 + *
47 + * You should have received a copy of the GNU General Public License
48 + * along with this program; if not, write to the Free Software
49 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50 + *
51 + * Copyright (C) 2004 Infineon IFAP DC COM CPE
52 + * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
53 + * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
54 + */
55 +
56 +#include <linux/module.h>
57 +#include <linux/errno.h>
58 +#include <linux/signal.h>
59 +#include <linux/sched.h>
60 +#include <linux/interrupt.h>
61 +#include <linux/tty.h>
62 +#include <linux/tty_flip.h>
63 +#include <linux/major.h>
64 +#include <linux/string.h>
65 +#include <linux/fcntl.h>
66 +#include <linux/ptrace.h>
67 +#include <linux/ioport.h>
68 +#include <linux/mm.h>
69 +#include <linux/slab.h>
70 +#include <linux/init.h>
71 +#include <linux/circ_buf.h>
72 +#include <linux/serial.h>
73 +#include <linux/serial_core.h>
74 +#include <linux/console.h>
75 +#include <linux/sysrq.h>
76 +#include <linux/irq.h>
77 +#include <linux/platform_device.h>
78 +#include <linux/io.h>
79 +#include <linux/uaccess.h>
80 +#include <linux/bitops.h>
81 +
82 +#include <asm/system.h>
83 +
84 +#include <ifxmips.h>
85 +#include <ifxmips_irq.h>
86 +
87 +#define PORT_IFXMIPSASC 111
88 +
89 +#include <linux/serial_core.h>
90 +
91 +#define UART_DUMMY_UER_RX 1
92 +
93 +static void ifxmipsasc_tx_chars(struct uart_port *port);
94 +extern void prom_printf(const char *fmt, ...);
95 +static struct uart_port ifxmipsasc_port[2];
96 +static struct uart_driver ifxmipsasc_reg;
97 +extern unsigned int ifxmips_get_fpi_hz(void);
98 +
99 +static void ifxmipsasc_stop_tx(struct uart_port *port)
100 +{
101 + return;
102 +}
103 +
104 +static void ifxmipsasc_start_tx(struct uart_port *port)
105 +{
106 + unsigned long flags;
107 + local_irq_save(flags);
108 + ifxmipsasc_tx_chars(port);
109 + local_irq_restore(flags);
110 + return;
111 +}
112 +
113 +static void ifxmipsasc_stop_rx(struct uart_port *port)
114 +{
115 + ifxmips_w32(ASCWHBSTATE_CLRREN, port->membase + IFXMIPS_ASC_WHBSTATE);
116 +}
117 +
118 +static void ifxmipsasc_enable_ms(struct uart_port *port)
119 +{
120 +}
121 +
122 +#include <linux/version.h>
123 +
124 +static void ifxmipsasc_rx_chars(struct uart_port *port)
125 +{
126 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26))
127 + struct tty_struct *tty = port->info->port.tty;
128 +#else
129 + struct tty_struct *tty = port->info->tty;
130 +#endif
131 + unsigned int ch = 0, rsr = 0, fifocnt;
132 +
133 + fifocnt = ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_RXFFLMASK;
134 + while (fifocnt--) {
135 + u8 flag = TTY_NORMAL;
136 + ch = ifxmips_r32(port->membase + IFXMIPS_ASC_RBUF);
137 + rsr = (ifxmips_r32(port->membase + IFXMIPS_ASC_STATE) & ASCSTATE_ANY) | UART_DUMMY_UER_RX;
138 + tty_flip_buffer_push(tty);
139 + port->icount.rx++;
140 +
141 + /*
142 + * Note that the error handling code is
143 + * out of the main execution path
144 + */
145 + if (rsr & ASCSTATE_ANY) {
146 + if (rsr & ASCSTATE_PE) {
147 + port->icount.parity++;
148 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRPE, port->membase + IFXMIPS_ASC_WHBSTATE);
149 + } else if (rsr & ASCSTATE_FE) {
150 + port->icount.frame++;
151 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRFE, port->membase + IFXMIPS_ASC_WHBSTATE);
152 + }
153 + if (rsr & ASCSTATE_ROE) {
154 + port->icount.overrun++;
155 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRROE, port->membase + IFXMIPS_ASC_WHBSTATE);
156 + }
157 +
158 + rsr &= port->read_status_mask;
159 +
160 + if (rsr & ASCSTATE_PE)
161 + flag = TTY_PARITY;
162 + else if (rsr & ASCSTATE_FE)
163 + flag = TTY_FRAME;
164 + }
165 +
166 + if ((rsr & port->ignore_status_mask) == 0)
167 + tty_insert_flip_char(tty, ch, flag);
168 +
169 + if (rsr & ASCSTATE_ROE)
170 + /*
171 + * Overrun is special, since it's reported
172 + * immediately, and doesn't affect the current
173 + * character
174 + */
175 + tty_insert_flip_char(tty, 0, TTY_OVERRUN);
176 + }
177 + if (ch != 0)
178 + tty_flip_buffer_push(tty);
179 + return;
180 +}
181 +
182 +
183 +static void ifxmipsasc_tx_chars(struct uart_port *port)
184 +{
185 + struct circ_buf *xmit = &port->info->xmit;
186 + if (uart_tx_stopped(port)) {
187 + ifxmipsasc_stop_tx(port);
188 + return;
189 + }
190 +
191 + while (((ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK)
192 + >> ASCFSTAT_TXFFLOFF) != TXFIFO_FULL) {
193 + if (port->x_char) {
194 + ifxmips_w32(port->x_char, port->membase + IFXMIPS_ASC_TBUF);
195 + port->icount.tx++;
196 + port->x_char = 0;
197 + continue;
198 + }
199 +
200 + if (uart_circ_empty(xmit))
201 + break;
202 +
203 + ifxmips_w32(port->info->xmit.buf[port->info->xmit.tail], port->membase + IFXMIPS_ASC_TBUF);
204 + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
205 + port->icount.tx++;
206 + }
207 +
208 + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
209 + uart_write_wakeup(port);
210 +}
211 +
212 +static irqreturn_t ifxmipsasc_tx_int(int irq, void *_port)
213 +{
214 + struct uart_port *port = (struct uart_port *)_port;
215 + ifxmips_w32(ASC_IRNCR_TIR, port->membase + IFXMIPS_ASC_IRNCR);
216 + ifxmipsasc_start_tx(port);
217 + ifxmips_mask_and_ack_irq(irq);
218 + return IRQ_HANDLED;
219 +}
220 +
221 +static irqreturn_t ifxmipsasc_er_int(int irq, void *_port)
222 +{
223 + struct uart_port *port = (struct uart_port *)_port;
224 + /* clear any pending interrupts */
225 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRPE |
226 + ASCWHBSTATE_CLRFE | ASCWHBSTATE_CLRROE, port->membase + IFXMIPS_ASC_WHBSTATE);
227 + return IRQ_HANDLED;
228 +}
229 +
230 +static irqreturn_t ifxmipsasc_rx_int(int irq, void *_port)
231 +{
232 + struct uart_port *port = (struct uart_port *)_port;
233 + ifxmips_w32(ASC_IRNCR_RIR, port->membase + IFXMIPS_ASC_IRNCR);
234 + ifxmipsasc_rx_chars((struct uart_port *)port);
235 + ifxmips_mask_and_ack_irq(irq);
236 + return IRQ_HANDLED;
237 +}
238 +
239 +static unsigned int ifxmipsasc_tx_empty(struct uart_port *port)
240 +{
241 + int status;
242 + status = ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK;
243 + return status ? 0 : TIOCSER_TEMT;
244 +}
245 +
246 +static unsigned int ifxmipsasc_get_mctrl(struct uart_port *port)
247 +{
248 + return TIOCM_CTS | TIOCM_CAR | TIOCM_DSR;
249 +}
250 +
251 +static void ifxmipsasc_set_mctrl(struct uart_port *port, u_int mctrl)
252 +{
253 +}
254 +
255 +static void ifxmipsasc_break_ctl(struct uart_port *port, int break_state)
256 +{
257 +}
258 +
259 +static int ifxmipsasc_startup(struct uart_port *port)
260 +{
261 + unsigned long flags;
262 + int retval;
263 +
264 + port->uartclk = ifxmips_get_fpi_hz();
265 +
266 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CLC) & ~IFXMIPS_ASC_CLC_DISS, port->membase + IFXMIPS_ASC_CLC);
267 + ifxmips_w32(((ifxmips_r32(port->membase + IFXMIPS_ASC_CLC) & ~ASCCLC_RMCMASK)) | (1 << ASCCLC_RMCOFFSET), port->membase + IFXMIPS_ASC_CLC);
268 + ifxmips_w32(0, port->membase + IFXMIPS_ASC_PISEL);
269 + ifxmips_w32(((TXFIFO_FL << ASCTXFCON_TXFITLOFF) & ASCTXFCON_TXFITLMASK) | ASCTXFCON_TXFEN | ASCTXFCON_TXFFLU, port->membase + IFXMIPS_ASC_TXFCON);
270 + ifxmips_w32(((RXFIFO_FL << ASCRXFCON_RXFITLOFF) & ASCRXFCON_RXFITLMASK) | ASCRXFCON_RXFEN | ASCRXFCON_RXFFLU, port->membase + IFXMIPS_ASC_RXFCON);
271 + wmb();
272 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) | ASCCON_M_8ASYNC | ASCCON_FEN | ASCCON_TOEN | ASCCON_ROEN, port->membase + IFXMIPS_ASC_CON);
273 +
274 + local_irq_save(flags);
275 +
276 + retval = request_irq(port->irq, ifxmipsasc_tx_int, IRQF_DISABLED, "asc_tx", port);
277 + if (retval) {
278 + printk(KERN_ERR "failed to request ifxmipsasc_tx_int\n");
279 + return retval;
280 + }
281 +
282 + retval = request_irq(port->irq + 2, ifxmipsasc_rx_int, IRQF_DISABLED, "asc_rx", port);
283 + if (retval) {
284 + printk(KERN_ERR "failed to request ifxmipsasc_rx_int\n");
285 + goto err1;
286 + }
287 +
288 + retval = request_irq(port->irq + 3, ifxmipsasc_er_int, IRQF_DISABLED, "asc_er", port);
289 + if (retval) {
290 + printk(KERN_ERR "failed to request ifxmipsasc_er_int\n");
291 + goto err2;
292 + }
293 +
294 + ifxmips_w32(ASC_IRNREN_RX_BUF | ASC_IRNREN_TX_BUF | ASC_IRNREN_ERR | ASC_IRNREN_TX, port->membase + IFXMIPS_ASC_IRNREN);
295 +
296 + local_irq_restore(flags);
297 + return 0;
298 +
299 +err2:
300 + free_irq(port->irq + 2, port);
301 +err1:
302 + free_irq(port->irq, port);
303 + local_irq_restore(flags);
304 + return retval;
305 +}
306 +
307 +static void ifxmipsasc_shutdown(struct uart_port *port)
308 +{
309 + free_irq(port->irq, port);
310 + free_irq(port->irq + 2, port);
311 + free_irq(port->irq + 3, port);
312 +
313 + ifxmips_w32(0, port->membase + IFXMIPS_ASC_CON);
314 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_RXFCON) | ASCRXFCON_RXFFLU, port->membase + IFXMIPS_ASC_RXFCON);
315 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_RXFCON) & ~ASCRXFCON_RXFEN, port->membase + IFXMIPS_ASC_RXFCON);
316 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_TXFCON) | ASCTXFCON_TXFFLU, port->membase + IFXMIPS_ASC_TXFCON);
317 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_TXFCON) & ~ASCTXFCON_TXFEN, port->membase + IFXMIPS_ASC_TXFCON);
318 +}
319 +
320 +static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new, struct ktermios *old)
321 +{
322 + unsigned int cflag;
323 + unsigned int iflag;
324 + unsigned int quot;
325 + unsigned int baud;
326 + unsigned int con = 0;
327 + unsigned long flags;
328 +
329 + cflag = new->c_cflag;
330 + iflag = new->c_iflag;
331 +
332 + switch (cflag & CSIZE) {
333 + case CS7:
334 + con = ASCCON_M_7ASYNC;
335 + break;
336 +
337 + case CS5:
338 + case CS6:
339 + default:
340 + con = ASCCON_M_8ASYNC;
341 + break;
342 + }
343 +
344 + if (cflag & CSTOPB)
345 + con |= ASCCON_STP;
346 +
347 + if (cflag & PARENB) {
348 + if (!(cflag & PARODD))
349 + con &= ~ASCCON_ODD;
350 + else
351 + con |= ASCCON_ODD;
352 + }
353 +
354 + port->read_status_mask = ASCSTATE_ROE;
355 + if (iflag & INPCK)
356 + port->read_status_mask |= ASCSTATE_FE | ASCSTATE_PE;
357 +
358 + port->ignore_status_mask = 0;
359 + if (iflag & IGNPAR)
360 + port->ignore_status_mask |= ASCSTATE_FE | ASCSTATE_PE;
361 +
362 + if (iflag & IGNBRK) {
363 + /*
364 + * If we're ignoring parity and break indicators,
365 + * ignore overruns too (for real raw support).
366 + */
367 + if (iflag & IGNPAR)
368 + port->ignore_status_mask |= ASCSTATE_ROE;
369 + }
370 +
371 + if ((cflag & CREAD) == 0)
372 + port->ignore_status_mask |= UART_DUMMY_UER_RX;
373 +
374 + /* set error signals - framing, parity and overrun, enable receiver */
375 + con |= ASCCON_FEN | ASCCON_TOEN | ASCCON_ROEN;
376 +
377 + local_irq_save(flags);
378 +
379 + /* set up CON */
380 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) | con, port->membase + IFXMIPS_ASC_CON);
381 +
382 + /* Set baud rate - take a divider of 2 into account */
383 + baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16);
384 + quot = uart_get_divisor(port, baud);
385 + quot = quot / 2 - 1;
386 +
387 + /* disable the baudrate generator */
388 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) & ~ASCCON_R, port->membase + IFXMIPS_ASC_CON);
389 +
390 + /* make sure the fractional divider is off */
391 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) & ~ASCCON_FDE, port->membase + IFXMIPS_ASC_CON);
392 +
393 + /* set up to use divisor of 2 */
394 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) & ~ASCCON_BRS, port->membase + IFXMIPS_ASC_CON);
395 +
396 + /* now we can write the new baudrate into the register */
397 + ifxmips_w32(quot, port->membase + IFXMIPS_ASC_BG);
398 +
399 + /* turn the baudrate generator back on */
400 + ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) | ASCCON_R, port->membase + IFXMIPS_ASC_CON);
401 +
402 + /* enable rx */
403 + ifxmips_w32(ASCWHBSTATE_SETREN, port->membase + IFXMIPS_ASC_WHBSTATE);
404 +
405 + local_irq_restore(flags);
406 +}
407 +
408 +static const char *ifxmipsasc_type(struct uart_port *port)
409 +{
410 + if (port->type == PORT_IFXMIPSASC) {
411 + if (port->membase == (void *)IFXMIPS_ASC_BASE_ADDR)
412 + return "asc0";
413 + else
414 + return "asc1";
415 + } else {
416 + return NULL;
417 + }
418 +}
419 +
420 +static void ifxmipsasc_release_port(struct uart_port *port)
421 +{
422 +}
423 +
424 +static int ifxmipsasc_request_port(struct uart_port *port)
425 +{
426 + return 0;
427 +}
428 +
429 +static void ifxmipsasc_config_port(struct uart_port *port, int flags)
430 +{
431 + if (flags & UART_CONFIG_TYPE) {
432 + port->type = PORT_IFXMIPSASC;
433 + ifxmipsasc_request_port(port);
434 + }
435 +}
436 +
437 +static int ifxmipsasc_verify_port(struct uart_port *port, struct serial_struct *ser)
438 +{
439 + int ret = 0;
440 + if (ser->type != PORT_UNKNOWN && ser->type != PORT_IFXMIPSASC)
441 + ret = -EINVAL;
442 + if (ser->irq < 0 || ser->irq >= NR_IRQS)
443 + ret = -EINVAL;
444 + if (ser->baud_base < 9600)
445 + ret = -EINVAL;
446 + return ret;
447 +}
448 +
449 +static struct uart_ops ifxmipsasc_pops = {
450 + .tx_empty = ifxmipsasc_tx_empty,
451 + .set_mctrl = ifxmipsasc_set_mctrl,
452 + .get_mctrl = ifxmipsasc_get_mctrl,
453 + .stop_tx = ifxmipsasc_stop_tx,
454 + .start_tx = ifxmipsasc_start_tx,
455 + .stop_rx = ifxmipsasc_stop_rx,
456 + .enable_ms = ifxmipsasc_enable_ms,
457 + .break_ctl = ifxmipsasc_break_ctl,
458 + .startup = ifxmipsasc_startup,
459 + .shutdown = ifxmipsasc_shutdown,
460 + .set_termios = ifxmipsasc_set_termios,
461 + .type = ifxmipsasc_type,
462 + .release_port = ifxmipsasc_release_port,
463 + .request_port = ifxmipsasc_request_port,
464 + .config_port = ifxmipsasc_config_port,
465 + .verify_port = ifxmipsasc_verify_port,
466 +};
467 +
468 +static struct uart_port ifxmipsasc_port[2] = {
469 + {
470 + .membase = (void *)IFXMIPS_ASC_BASE_ADDR,
471 + .mapbase = IFXMIPS_ASC_BASE_ADDR,
472 + .iotype = SERIAL_IO_MEM,
473 + .irq = IFXMIPSASC_TIR(0),
474 + .uartclk = 0,
475 + .fifosize = 16,
476 + .type = PORT_IFXMIPSASC,
477 + .ops = &ifxmipsasc_pops,
478 + .flags = ASYNC_BOOT_AUTOCONF,
479 + .line = 0
480 + }, {
481 + .membase = (void *)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF),
482 + .mapbase = IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF,
483 + .iotype = SERIAL_IO_MEM,
484 + .irq = IFXMIPSASC_TIR(1),
485 + .uartclk = 0,
486 + .fifosize = 16,
487 + .type = PORT_IFXMIPSASC,
488 + .ops = &ifxmipsasc_pops,
489 + .flags = ASYNC_BOOT_AUTOCONF,
490 + .line = 1
491 + }
492 +};
493 +
494 +static void ifxmipsasc_console_write(struct console *co, const char *s, u_int count)
495 +{
496 + int port = co->index;
497 + int i, fifocnt;
498 + unsigned long flags;
499 + local_irq_save(flags);
500 + for (i = 0; i < count; i++) {
501 + do {
502 + fifocnt = (ifxmips_r32((u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK)
503 + >> ASCFSTAT_TXFFLOFF;
504 + } while (fifocnt == TXFIFO_FULL);
505 +
506 + if (s[i] == '\0')
507 + break;
508 +
509 + if (s[i] == '\n') {
510 + ifxmips_w32('\r', (u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF));
511 + do {
512 + fifocnt = (ifxmips_r32((u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK)
513 + >> ASCFSTAT_TXFFLOFF;
514 + } while (fifocnt == TXFIFO_FULL);
515 + }
516 + ifxmips_w32(s[i], (u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF));
517 + }
518 +
519 + local_irq_restore(flags);
520 +}
521 +
522 +static int __init ifxmipsasc_console_setup(struct console *co, char *options)
523 +{
524 + int port = co->index;
525 + int baud = 115200;
526 + int bits = 8;
527 + int parity = 'n';
528 + int flow = 'n';
529 + ifxmipsasc_port[port].uartclk = ifxmips_get_fpi_hz();
530 + ifxmipsasc_port[port].type = PORT_IFXMIPSASC;
531 + if (options)
532 + uart_parse_options(options, &baud, &parity, &bits, &flow);
533 + return uart_set_options(&ifxmipsasc_port[port], co, baud, parity, bits, flow);
534 +}
535 +
536 +static struct console ifxmipsasc_console[2] =
537 +{
538 + {
539 + .name = "ttyS",
540 + .write = ifxmipsasc_console_write,
541 + .device = uart_console_device,
542 + .setup = ifxmipsasc_console_setup,
543 + .flags = CON_PRINTBUFFER,
544 + .index = 0,
545 + .data = &ifxmipsasc_reg,
546 + }, {
547 + .name = "ttyS",
548 + .write = ifxmipsasc_console_write,
549 + .device = uart_console_device,
550 + .setup = ifxmipsasc_console_setup,
551 + .flags = CON_PRINTBUFFER,
552 + .index = 1,
553 + .data = &ifxmipsasc_reg,
554 + }
555 +};
556 +
557 +static int __init ifxmipsasc_console_init(void)
558 +{
559 + register_console(&ifxmipsasc_console[0]);
560 + register_console(&ifxmipsasc_console[1]);
561 + return 0;
562 +}
563 +console_initcall(ifxmipsasc_console_init);
564 +
565 +static struct uart_driver ifxmipsasc_reg = {
566 + .owner = THIS_MODULE,
567 + .driver_name = "serial",
568 + .dev_name = "ttyS",
569 + .major = TTY_MAJOR,
570 + .minor = 64,
571 + .nr = 2,
572 + .cons = &ifxmipsasc_console[1],
573 +};
574 +
575 +int __init ifxmipsasc_init(void)
576 +{
577 + int ret;
578 + uart_register_driver(&ifxmipsasc_reg);
579 + ret = uart_add_one_port(&ifxmipsasc_reg, &ifxmipsasc_port[0]);
580 + ret = uart_add_one_port(&ifxmipsasc_reg, &ifxmipsasc_port[1]);
581 + return 0;
582 +}
583 +
584 +void __exit ifxmipsasc_exit(void)
585 +{
586 + uart_unregister_driver(&ifxmipsasc_reg);
587 +}
588 +
589 +module_init(ifxmipsasc_init);
590 +module_exit(ifxmipsasc_exit);
591 +
592 +MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
593 +MODULE_DESCRIPTION("MIPS IFXMips serial port driver");
594 +MODULE_LICENSE("GPL");
This page took 0.05804 seconds and 5 git commands to generate.