i[amazon] use SYS_HAS_EARLY_PRINTK instead of prom_printf
[openwrt.git] / target / linux / amazon / files / drivers / serial / amazon_asc.c
1 /*
2 * Driver for AMAZONASC serial ports
3 *
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
5 * Based on drivers/serial/serial_s3c2400.c
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Copyright (C) 2004 Infineon IFAP DC COM CPE
22 * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
23 * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
24 */
25
26 #include <linux/module.h>
27 #include <linux/errno.h>
28 #include <linux/signal.h>
29 #include <linux/sched.h>
30 #include <linux/interrupt.h>
31 #include <linux/tty.h>
32 #include <linux/tty_flip.h>
33 #include <linux/major.h>
34 #include <linux/string.h>
35 #include <linux/fcntl.h>
36 #include <linux/ptrace.h>
37 #include <linux/ioport.h>
38 #include <linux/mm.h>
39 #include <linux/slab.h>
40 #include <linux/init.h>
41 #include <linux/circ_buf.h>
42 #include <linux/serial.h>
43 #include <linux/serial_core.h>
44 #include <linux/console.h>
45 #include <linux/sysrq.h>
46 #include <linux/irq.h>
47 #include <linux/platform_device.h>
48
49 #include <asm/system.h>
50 #include <asm/io.h>
51 #include <asm/uaccess.h>
52 #include <asm/bitops.h>
53 #include <asm/amazon/amazon.h>
54 #include <asm/amazon/irq.h>
55 #include <asm/amazon/serial.h>
56
57 #define PORT_AMAZONASC 111
58
59 #include <linux/serial_core.h>
60
61 #define UART_NR 1
62
63 #define UART_DUMMY_UER_RX 1
64
65 #define SERIAL_AMAZONASC_MAJOR TTY_MAJOR
66 #define CALLOUT_AMAZONASC_MAJOR TTYAUX_MAJOR
67 #define SERIAL_AMAZONASC_MINOR 64
68 #define SERIAL_AMAZONASC_NR UART_NR
69
70 static void amazonasc_tx_chars(struct uart_port *port);
71 static struct uart_port amazonasc_ports[UART_NR];
72 static struct uart_driver amazonasc_reg;
73 static unsigned int uartclk = 0;
74 extern unsigned int amazon_get_fpi_hz(void);
75
76 static void amazonasc_stop_tx(struct uart_port *port)
77 {
78 /* fifo underrun shuts up after firing once */
79 return;
80 }
81
82 static void amazonasc_start_tx(struct uart_port *port)
83 {
84 unsigned long flags;
85
86 local_irq_save(flags);
87 amazonasc_tx_chars(port);
88 local_irq_restore(flags);
89
90 return;
91 }
92
93 static void amazonasc_stop_rx(struct uart_port *port)
94 {
95 /* clear the RX enable bit */
96 amazon_writel(ASCWHBCON_CLRREN, AMAZON_ASC_WHBCON);
97 }
98
99 static void amazonasc_enable_ms(struct uart_port *port)
100 {
101 /* no modem signals */
102 return;
103 }
104
105 #include <linux/version.h>
106
107 static void
108 amazonasc_rx_chars(struct uart_port *port)
109 {
110 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 31))
111 struct tty_struct *tty = port->state->port.tty;
112 #else
113 struct tty_struct *tty = port->info->port.tty;
114 #endif
115 unsigned int ch = 0, rsr = 0, fifocnt;
116
117 fifocnt = amazon_readl(AMAZON_ASC_FSTAT) & ASCFSTAT_RXFFLMASK;
118 while (fifocnt--)
119 {
120 u8 flag = TTY_NORMAL;
121 ch = amazon_readl(AMAZON_ASC_RBUF);
122 rsr = (amazon_readl(AMAZON_ASC_CON) & ASCCON_ANY) | UART_DUMMY_UER_RX;
123 tty_flip_buffer_push(tty);
124 port->icount.rx++;
125
126 /*
127 * Note that the error handling code is
128 * out of the main execution path
129 */
130 if (rsr & ASCCON_ANY) {
131 if (rsr & ASCCON_PE) {
132 port->icount.parity++;
133 amazon_writel_masked(AMAZON_ASC_WHBCON, ASCWHBCON_CLRPE, ASCWHBCON_CLRPE);
134 } else if (rsr & ASCCON_FE) {
135 port->icount.frame++;
136 amazon_writel_masked(AMAZON_ASC_WHBCON, ASCWHBCON_CLRFE, ASCWHBCON_CLRFE);
137 }
138 if (rsr & ASCCON_OE) {
139 port->icount.overrun++;
140 amazon_writel_masked(AMAZON_ASC_WHBCON, ASCWHBCON_CLROE, ASCWHBCON_CLROE);
141 }
142
143 rsr &= port->read_status_mask;
144
145 if (rsr & ASCCON_PE)
146 flag = TTY_PARITY;
147 else if (rsr & ASCCON_FE)
148 flag = TTY_FRAME;
149 }
150
151 if ((rsr & port->ignore_status_mask) == 0)
152 tty_insert_flip_char(tty, ch, flag);
153
154 if (rsr & ASCCON_OE)
155 /*
156 * Overrun is special, since it's reported
157 * immediately, and doesn't affect the current
158 * character
159 */
160 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
161 }
162 if (ch != 0)
163 tty_flip_buffer_push(tty);
164
165 return;
166 }
167
168
169 static void amazonasc_tx_chars(struct uart_port *port)
170 {
171 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 31))
172 struct circ_buf *xmit = &port->state->xmit;
173 #else
174 struct circ_buf *xmit = &port->info->xmit;
175 #endif
176
177 if (uart_tx_stopped(port)) {
178 amazonasc_stop_tx(port);
179 return;
180 }
181
182 while (((amazon_readl(AMAZON_ASC_FSTAT) & ASCFSTAT_TXFFLMASK)
183 >> ASCFSTAT_TXFFLOFF) != AMAZONASC_TXFIFO_FULL)
184 {
185 if (port->x_char) {
186 amazon_writel(port->x_char, AMAZON_ASC_TBUF);
187 port->icount.tx++;
188 port->x_char = 0;
189 continue;
190 }
191
192 if (uart_circ_empty(xmit))
193 break;
194
195 amazon_writel(xmit->buf[xmit->tail], AMAZON_ASC_TBUF);
196 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
197 port->icount.tx++;
198 }
199
200 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
201 uart_write_wakeup(port);
202 }
203
204 static irqreturn_t amazonasc_tx_int(int irq, void *port)
205 {
206 amazon_writel(ASC_IRNCR_TIR, AMAZON_ASC_IRNCR1);
207 amazonasc_start_tx(port);
208
209 /* clear any pending interrupts */
210 amazon_writel_masked(AMAZON_ASC_WHBCON,
211 (ASCWHBCON_CLRPE | ASCWHBCON_CLRFE | ASCWHBCON_CLROE),
212 (ASCWHBCON_CLRPE | ASCWHBCON_CLRFE | ASCWHBCON_CLROE));
213
214 return IRQ_HANDLED;
215 }
216
217 static irqreturn_t amazonasc_er_int(int irq, void *port)
218 {
219 /* clear any pending interrupts */
220 amazon_writel_masked(AMAZON_ASC_WHBCON,
221 (ASCWHBCON_CLRPE | ASCWHBCON_CLRFE | ASCWHBCON_CLROE),
222 (ASCWHBCON_CLRPE | ASCWHBCON_CLRFE | ASCWHBCON_CLROE));
223
224 return IRQ_HANDLED;
225 }
226
227 static irqreturn_t amazonasc_rx_int(int irq, void *port)
228 {
229 amazon_writel(ASC_IRNCR_RIR, AMAZON_ASC_IRNCR1);
230 amazonasc_rx_chars((struct uart_port *) port);
231 return IRQ_HANDLED;
232 }
233
234 static u_int amazonasc_tx_empty(struct uart_port *port)
235 {
236 int status;
237
238 /*
239 * FSTAT tells exactly how many bytes are in the FIFO.
240 * The question is whether we really need to wait for all
241 * 16 bytes to be transmitted before reporting that the
242 * transmitter is empty.
243 */
244 status = amazon_readl(AMAZON_ASC_FSTAT) & ASCFSTAT_TXFFLMASK;
245 return status ? 0 : TIOCSER_TEMT;
246 }
247
248 static u_int amazonasc_get_mctrl(struct uart_port *port)
249 {
250 /* no modem control signals - the readme says to pretend all are set */
251 return TIOCM_CTS|TIOCM_CAR|TIOCM_DSR;
252 }
253
254 static void amazonasc_set_mctrl(struct uart_port *port, u_int mctrl)
255 {
256 /* no modem control - just return */
257 return;
258 }
259
260 static void amazonasc_break_ctl(struct uart_port *port, int break_state)
261 {
262 /* no way to send a break */
263 return;
264 }
265
266 static int amazonasc_startup(struct uart_port *port)
267 {
268 unsigned int con = 0;
269 unsigned long flags;
270 int retval;
271
272 /* this assumes: CON.BRS = CON.FDE = 0 */
273 if (uartclk == 0)
274 uartclk = amazon_get_fpi_hz();
275
276 amazonasc_ports[0].uartclk = uartclk;
277
278 local_irq_save(flags);
279
280 /* this setup was probably already done in u-boot */
281 /* ASC and GPIO Port 1 bits 3 and 4 share the same pins
282 * P1.3 (RX) in, Alternate 10
283 * P1.4 (TX) in, Alternate 10
284 */
285 amazon_writel_masked(AMAZON_GPIO_P1_DIR, 0x18, 0x10); //P1.4 output, P1.3 input
286 amazon_writel_masked(AMAZON_GPIO_P1_ALTSEL0, 0x18, 0x18); //ALTSETL0 11
287 amazon_writel_masked(AMAZON_GPIO_P1_ALTSEL1, 0x18, 0); //ALTSETL1 00
288 amazon_writel_masked(AMAZON_GPIO_P1_OD, 0x18, 0x10);
289
290 /* set up the CLC */
291 amazon_writel_masked(AMAZON_ASC_CLC, AMAZON_ASC_CLC_DISS, 0);
292 amazon_writel_masked(AMAZON_ASC_CLC, ASCCLC_RMCMASK, 1 << ASCCLC_RMCOFFSET);
293
294 /* asynchronous mode */
295 con = ASCCON_M_8ASYNC | ASCCON_FEN | ASCCON_OEN | ASCCON_PEN;
296
297 /* choose the line - there's only one */
298 amazon_writel(0, AMAZON_ASC_PISEL);
299 amazon_writel(((AMAZONASC_TXFIFO_FL << ASCTXFCON_TXFITLOFF) & ASCTXFCON_TXFITLMASK) | ASCTXFCON_TXFEN | ASCTXFCON_TXFFLU,
300 AMAZON_ASC_TXFCON);
301 amazon_writel(((AMAZONASC_RXFIFO_FL << ASCRXFCON_RXFITLOFF) & ASCRXFCON_RXFITLMASK) | ASCRXFCON_RXFEN | ASCRXFCON_RXFFLU,
302 AMAZON_ASC_RXFCON);
303 wmb();
304
305 amazon_writel_masked(AMAZON_ASC_CON, con, con);
306
307 retval = request_irq(AMAZONASC_RIR, amazonasc_rx_int, 0, "asc_rx", port);
308 if (retval){
309 printk("failed to request amazonasc_rx_int\n");
310 return retval;
311 }
312 retval = request_irq(AMAZONASC_TIR, amazonasc_tx_int, 0, "asc_tx", port);
313 if (retval){
314 printk("failed to request amazonasc_tx_int\n");
315 goto err1;
316 }
317
318 retval = request_irq(AMAZONASC_EIR, amazonasc_er_int, 0, "asc_er", port);
319 if (retval){
320 printk("failed to request amazonasc_er_int\n");
321 goto err2;
322 }
323
324 local_irq_restore(flags);
325 return 0;
326
327 err2:
328 free_irq(AMAZONASC_TIR, port);
329
330 err1:
331 free_irq(AMAZONASC_RIR, port);
332 local_irq_restore(flags);
333 return retval;
334 }
335
336 static void amazonasc_shutdown(struct uart_port *port)
337 {
338 free_irq(AMAZONASC_RIR, port);
339 free_irq(AMAZONASC_TIR, port);
340 free_irq(AMAZONASC_EIR, port);
341 /*
342 * disable the baudrate generator to disable the ASC
343 */
344 amazon_writel(0, AMAZON_ASC_CON);
345
346 /* flush and then disable the fifos */
347 amazon_writel_masked(AMAZON_ASC_RXFCON, ASCRXFCON_RXFFLU, ASCRXFCON_RXFFLU);
348 amazon_writel_masked(AMAZON_ASC_RXFCON, ASCRXFCON_RXFEN, 0);
349 amazon_writel_masked(AMAZON_ASC_TXFCON, ASCTXFCON_TXFFLU, ASCTXFCON_TXFFLU);
350 amazon_writel_masked(AMAZON_ASC_TXFCON, ASCTXFCON_TXFEN, 0);
351 }
352
353 static void amazonasc_set_termios(struct uart_port *port, struct ktermios *new, struct ktermios *old)
354 {
355 unsigned int cflag;
356 unsigned int iflag;
357 unsigned int baud, quot;
358 unsigned int con = 0;
359 unsigned long flags;
360
361 cflag = new->c_cflag;
362 iflag = new->c_iflag;
363
364 /* byte size and parity */
365 switch (cflag & CSIZE) {
366 /* 7 bits are always with parity */
367 case CS7: con = ASCCON_M_7ASYNCPAR; break;
368 /* the ASC only suports 7 and 8 bits */
369 case CS5:
370 case CS6:
371 default:
372 if (cflag & PARENB)
373 con = ASCCON_M_8ASYNCPAR;
374 else
375 con = ASCCON_M_8ASYNC;
376 break;
377 }
378 if (cflag & CSTOPB)
379 con |= ASCCON_STP;
380 if (cflag & PARENB) {
381 if (!(cflag & PARODD))
382 con &= ~ASCCON_ODD;
383 else
384 con |= ASCCON_ODD;
385 }
386
387 port->read_status_mask = ASCCON_OE;
388 if (iflag & INPCK)
389 port->read_status_mask |= ASCCON_FE | ASCCON_PE;
390
391 port->ignore_status_mask = 0;
392 if (iflag & IGNPAR)
393 port->ignore_status_mask |= ASCCON_FE | ASCCON_PE;
394
395 if (iflag & IGNBRK) {
396 /*
397 * If we're ignoring parity and break indicators,
398 * ignore overruns too (for real raw support).
399 */
400 if (iflag & IGNPAR)
401 port->ignore_status_mask |= ASCCON_OE;
402 }
403
404 /*
405 * Ignore all characters if CREAD is not set.
406 */
407 if ((cflag & CREAD) == 0)
408 port->ignore_status_mask |= UART_DUMMY_UER_RX;
409
410 /* set error signals - framing, parity and overrun */
411 con |= ASCCON_FEN;
412 con |= ASCCON_OEN;
413 con |= ASCCON_PEN;
414 /* enable the receiver */
415 con |= ASCCON_REN;
416
417 /* block the IRQs */
418 local_irq_save(flags);
419
420 /* set up CON */
421 amazon_writel(con, AMAZON_ASC_CON);
422
423 /* Set baud rate - take a divider of 2 into account */
424 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16);
425 quot = uart_get_divisor(port, baud);
426 quot = quot/2 - 1;
427
428 /* the next 3 probably already happened when we set CON above */
429 /* disable the baudrate generator */
430 amazon_writel_masked(AMAZON_ASC_CON, ASCCON_R, 0);
431 /* make sure the fractional divider is off */
432 amazon_writel_masked(AMAZON_ASC_CON, ASCCON_FDE, 0);
433 /* set up to use divisor of 2 */
434 amazon_writel_masked(AMAZON_ASC_CON, ASCCON_BRS, 0);
435 /* now we can write the new baudrate into the register */
436 amazon_writel(quot, AMAZON_ASC_BTR);
437 /* turn the baudrate generator back on */
438 amazon_writel_masked(AMAZON_ASC_CON, ASCCON_R, ASCCON_R);
439
440 local_irq_restore(flags);
441 }
442
443 static const char *amazonasc_type(struct uart_port *port)
444 {
445 return port->type == PORT_AMAZONASC ? "AMAZONASC" : NULL;
446 }
447
448 /*
449 * Release the memory region(s) being used by 'port'
450 */
451 static void amazonasc_release_port(struct uart_port *port)
452 {
453 return;
454 }
455
456 /*
457 * Request the memory region(s) being used by 'port'
458 */
459 static int amazonasc_request_port(struct uart_port *port)
460 {
461 return 0;
462 }
463
464 /*
465 * Configure/autoconfigure the port.
466 */
467 static void amazonasc_config_port(struct uart_port *port, int flags)
468 {
469 if (flags & UART_CONFIG_TYPE) {
470 port->type = PORT_AMAZONASC;
471 amazonasc_request_port(port);
472 }
473 }
474
475 /*
476 * verify the new serial_struct (for TIOCSSERIAL).
477 */
478 static int amazonasc_verify_port(struct uart_port *port, struct serial_struct *ser)
479 {
480 int ret = 0;
481 if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMAZONASC)
482 ret = -EINVAL;
483 if (ser->irq < 0 || ser->irq >= NR_IRQS)
484 ret = -EINVAL;
485 if (ser->baud_base < 9600)
486 ret = -EINVAL;
487 return ret;
488 }
489
490 static struct uart_ops amazonasc_pops = {
491 .tx_empty = amazonasc_tx_empty,
492 .set_mctrl = amazonasc_set_mctrl,
493 .get_mctrl = amazonasc_get_mctrl,
494 .stop_tx = amazonasc_stop_tx,
495 .start_tx = amazonasc_start_tx,
496 .stop_rx = amazonasc_stop_rx,
497 .enable_ms = amazonasc_enable_ms,
498 .break_ctl = amazonasc_break_ctl,
499 .startup = amazonasc_startup,
500 .shutdown = amazonasc_shutdown,
501 .set_termios = amazonasc_set_termios,
502 .type = amazonasc_type,
503 .release_port = amazonasc_release_port,
504 .request_port = amazonasc_request_port,
505 .config_port = amazonasc_config_port,
506 .verify_port = amazonasc_verify_port,
507 };
508
509 static struct uart_port amazonasc_ports[UART_NR] = {
510 {
511 membase: (void *)AMAZON_ASC,
512 mapbase: AMAZON_ASC,
513 iotype: SERIAL_IO_MEM,
514 irq: AMAZONASC_RIR, /* RIR */
515 uartclk: 0, /* filled in dynamically */
516 fifosize: 16,
517 unused: { AMAZONASC_TIR, AMAZONASC_EIR}, /* xmit/error/xmit-buffer-empty IRQ */
518 type: PORT_AMAZONASC,
519 ops: &amazonasc_pops,
520 flags: ASYNC_BOOT_AUTOCONF,
521 },
522 };
523
524 static void amazonasc_console_write(struct console *co, const char *s, u_int count)
525 {
526 int i, fifocnt;
527 unsigned long flags;
528 local_irq_save(flags);
529 for (i = 0; i < count;)
530 {
531 /* wait until the FIFO is not full */
532 do
533 {
534 fifocnt = (amazon_readl(AMAZON_ASC_FSTAT) & ASCFSTAT_TXFFLMASK)
535 >> ASCFSTAT_TXFFLOFF;
536 } while (fifocnt == AMAZONASC_TXFIFO_FULL);
537 if (s[i] == '\0')
538 {
539 break;
540 }
541 if (s[i] == '\n')
542 {
543 amazon_writel('\r', AMAZON_ASC_TBUF);
544 do
545 {
546 fifocnt = (amazon_readl(AMAZON_ASC_FSTAT) &
547 ASCFSTAT_TXFFLMASK) >> ASCFSTAT_TXFFLOFF;
548 } while (fifocnt == AMAZONASC_TXFIFO_FULL);
549 }
550 amazon_writel(s[i], AMAZON_ASC_TBUF);
551 i++;
552 }
553
554 local_irq_restore(flags);
555 }
556
557 static void __init
558 amazonasc_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
559 {
560 u_int lcr_h;
561
562 lcr_h = amazon_readl(AMAZON_ASC_CON);
563 /* do this only if the ASC is turned on */
564 if (lcr_h & ASCCON_R) {
565 u_int quot, div, fdiv, frac;
566
567 *parity = 'n';
568 if ((lcr_h & ASCCON_MODEMASK) == ASCCON_M_7ASYNCPAR ||
569 (lcr_h & ASCCON_MODEMASK) == ASCCON_M_8ASYNCPAR) {
570 if (lcr_h & ASCCON_ODD)
571 *parity = 'o';
572 else
573 *parity = 'e';
574 }
575
576 if ((lcr_h & ASCCON_MODEMASK) == ASCCON_M_7ASYNCPAR)
577 *bits = 7;
578 else
579 *bits = 8;
580
581 quot = amazon_readl(AMAZON_ASC_BTR) + 1;
582
583 /* this gets hairy if the fractional divider is used */
584 if (lcr_h & ASCCON_FDE)
585 {
586 div = 1;
587 fdiv = amazon_readl(AMAZON_ASC_FDV);
588 if (fdiv == 0)
589 fdiv = 512;
590 frac = 512;
591 }
592 else
593 {
594 div = lcr_h & ASCCON_BRS ? 3 : 2;
595 fdiv = frac = 1;
596 }
597 /*
598 * This doesn't work exactly because we use integer
599 * math to calculate baud which results in rounding
600 * errors when we try to go from quot -> baud !!
601 * Try to make this work for both the fractional divider
602 * and the simple divider. Also try to avoid rounding
603 * errors using integer math.
604 */
605
606 *baud = frac * (port->uartclk / (div * 512 * 16 * quot));
607 if (*baud > 1100 && *baud < 2400)
608 *baud = 1200;
609 if (*baud > 2300 && *baud < 4800)
610 *baud = 2400;
611 if (*baud > 4700 && *baud < 9600)
612 *baud = 4800;
613 if (*baud > 9500 && *baud < 19200)
614 *baud = 9600;
615 if (*baud > 19000 && *baud < 38400)
616 *baud = 19200;
617 if (*baud > 38400 && *baud < 57600)
618 *baud = 38400;
619 if (*baud > 57600 && *baud < 115200)
620 *baud = 57600;
621 if (*baud > 115200 && *baud < 230400)
622 *baud = 115200;
623 }
624 }
625
626 static int __init amazonasc_console_setup(struct console *co, char *options)
627 {
628 struct uart_port *port;
629 int baud = 115200;
630 int bits = 8;
631 int parity = 'n';
632 int flow = 'n';
633
634 /* this assumes: CON.BRS = CON.FDE = 0 */
635 if (uartclk == 0)
636 uartclk = amazon_get_fpi_hz();
637 co->index = 0;
638 port = &amazonasc_ports[0];
639 amazonasc_ports[0].uartclk = uartclk;
640 amazonasc_ports[0].type = PORT_AMAZONASC;
641
642 if (options){
643 uart_parse_options(options, &baud, &parity, &bits, &flow);
644 }
645
646 return uart_set_options(port, co, baud, parity, bits, flow);
647 }
648
649 static struct uart_driver amazonasc_reg;
650 static struct console amazonasc_console = {
651 name: "ttyS",
652 write: amazonasc_console_write,
653 device: uart_console_device,
654 setup: amazonasc_console_setup,
655 flags: CON_PRINTBUFFER,
656 index: -1,
657 data: &amazonasc_reg,
658 };
659
660 static struct uart_driver amazonasc_reg = {
661 .owner = THIS_MODULE,
662 .driver_name = "serial",
663 .dev_name = "ttyS",
664 .major = TTY_MAJOR,
665 .minor = 64,
666 .nr = UART_NR,
667 .cons = &amazonasc_console,
668 };
669
670 static int __init amazon_asc_probe(struct platform_device *dev)
671 {
672 unsigned char res;
673 uart_register_driver(&amazonasc_reg);
674 res = uart_add_one_port(&amazonasc_reg, &amazonasc_ports[0]);
675 return res;
676 }
677
678 static int amazon_asc_remove(struct platform_device *dev)
679 {
680 uart_unregister_driver(&amazonasc_reg);
681 return 0;
682 }
683
684 static struct platform_driver amazon_asc_driver = {
685 .probe = amazon_asc_probe,
686 .remove = amazon_asc_remove,
687 .driver = {
688 .name = "amazon_asc",
689 .owner = THIS_MODULE,
690 },
691 };
692
693 static int __init amazon_asc_init(void)
694 {
695 int ret = platform_driver_register(&amazon_asc_driver);
696 if (ret)
697 printk(KERN_WARNING "amazon_asc: error registering platfom driver!\n");
698 return ret;
699 }
700
701 static void __exit amazon_asc_cleanup(void)
702 {
703 platform_driver_unregister(&amazon_asc_driver);
704 }
705
706 module_init(amazon_asc_init);
707 module_exit(amazon_asc_cleanup);
708
709 MODULE_AUTHOR("Gary Jennejohn, Felix Fietkau, John Crispin");
710 MODULE_DESCRIPTION("MIPS AMAZONASC serial port driver");
711 MODULE_LICENSE("GPL");
712
This page took 0.085602 seconds and 5 git commands to generate.