[amazon] Some general changes for amazon drivers.
[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
48 #include <asm/system.h>
49 #include <asm/io.h>
50 #include <asm/uaccess.h>
51 #include <asm/bitops.h>
52 #include <asm/amazon/amazon.h>
53 #include <asm/amazon/irq.h>
54 #include <asm/amazon/serial.h>
55
56 #define PORT_AMAZONASC 111
57
58 #include <linux/serial_core.h>
59
60 #define UART_NR 1
61
62 #define UART_DUMMY_UER_RX 1
63
64 #define SERIAL_AMAZONASC_MAJOR TTY_MAJOR
65 #define CALLOUT_AMAZONASC_MAJOR TTYAUX_MAJOR
66 #define SERIAL_AMAZONASC_MINOR 64
67 #define SERIAL_AMAZONASC_NR UART_NR
68
69 static void amazonasc_tx_chars(struct uart_port *port);
70 extern void prom_printf(const char * fmt, ...);
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, 26))
111 struct tty_struct *tty = port->info->port.tty;
112 #else
113 struct tty_struct *tty = port->info->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 struct circ_buf *xmit = &port->info->xmit;
172
173 if (uart_tx_stopped(port)) {
174 amazonasc_stop_tx(port);
175 return;
176 }
177
178 while (((amazon_readl(AMAZON_ASC_FSTAT) & ASCFSTAT_TXFFLMASK)
179 >> ASCFSTAT_TXFFLOFF) != AMAZONASC_TXFIFO_FULL)
180 {
181 if (port->x_char) {
182 amazon_writel(port->x_char, AMAZON_ASC_TBUF);
183 port->icount.tx++;
184 port->x_char = 0;
185 continue;
186 }
187
188 if (uart_circ_empty(xmit))
189 break;
190
191 amazon_writel(xmit->buf[xmit->tail], AMAZON_ASC_TBUF);
192 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
193 port->icount.tx++;
194 }
195
196 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
197 uart_write_wakeup(port);
198 }
199
200 static irqreturn_t amazonasc_tx_int(int irq, void *port)
201 {
202 amazon_writel(ASC_IRNCR_TIR, AMAZON_ASC_IRNCR1);
203 amazonasc_start_tx(port);
204
205 /* clear any pending interrupts */
206 amazon_writel_masked(AMAZON_ASC_WHBCON,
207 (ASCWHBCON_CLRPE | ASCWHBCON_CLRFE | ASCWHBCON_CLROE),
208 (ASCWHBCON_CLRPE | ASCWHBCON_CLRFE | ASCWHBCON_CLROE));
209
210 return IRQ_HANDLED;
211 }
212
213 static irqreturn_t amazonasc_er_int(int irq, void *port)
214 {
215 /* clear any pending interrupts */
216 amazon_writel_masked(AMAZON_ASC_WHBCON,
217 (ASCWHBCON_CLRPE | ASCWHBCON_CLRFE | ASCWHBCON_CLROE),
218 (ASCWHBCON_CLRPE | ASCWHBCON_CLRFE | ASCWHBCON_CLROE));
219
220 return IRQ_HANDLED;
221 }
222
223 static irqreturn_t amazonasc_rx_int(int irq, void *port)
224 {
225 amazon_writel(ASC_IRNCR_RIR, AMAZON_ASC_IRNCR1);
226 amazonasc_rx_chars((struct uart_port *) port);
227 return IRQ_HANDLED;
228 }
229
230 static u_int amazonasc_tx_empty(struct uart_port *port)
231 {
232 int status;
233
234 /*
235 * FSTAT tells exactly how many bytes are in the FIFO.
236 * The question is whether we really need to wait for all
237 * 16 bytes to be transmitted before reporting that the
238 * transmitter is empty.
239 */
240 status = amazon_readl(AMAZON_ASC_FSTAT) & ASCFSTAT_TXFFLMASK;
241 return status ? 0 : TIOCSER_TEMT;
242 }
243
244 static u_int amazonasc_get_mctrl(struct uart_port *port)
245 {
246 /* no modem control signals - the readme says to pretend all are set */
247 return TIOCM_CTS|TIOCM_CAR|TIOCM_DSR;
248 }
249
250 static void amazonasc_set_mctrl(struct uart_port *port, u_int mctrl)
251 {
252 /* no modem control - just return */
253 return;
254 }
255
256 static void amazonasc_break_ctl(struct uart_port *port, int break_state)
257 {
258 /* no way to send a break */
259 return;
260 }
261
262 static int amazonasc_startup(struct uart_port *port)
263 {
264 unsigned int con = 0;
265 unsigned long flags;
266 int retval;
267
268 /* this assumes: CON.BRS = CON.FDE = 0 */
269 if (uartclk == 0)
270 uartclk = amazon_get_fpi_hz();
271
272 amazonasc_ports[0].uartclk = uartclk;
273
274 local_irq_save(flags);
275
276 /* this setup was probably already done in u-boot */
277 /* ASC and GPIO Port 1 bits 3 and 4 share the same pins
278 * P1.3 (RX) in, Alternate 10
279 * P1.4 (TX) in, Alternate 10
280 */
281 amazon_writel_masked(AMAZON_GPIO_P1_DIR, 0x18, 0x10); //P1.4 output, P1.3 input
282 amazon_writel_masked(AMAZON_GPIO_P1_ALTSEL0, 0x18, 0x18); //ALTSETL0 11
283 amazon_writel_masked(AMAZON_GPIO_P1_ALTSEL1, 0x18, 0); //ALTSETL1 00
284 amazon_writel_masked(AMAZON_GPIO_P1_OD, 0x18, 0x10);
285
286 /* set up the CLC */
287 amazon_writel_masked(AMAZON_ASC_CLC, AMAZON_ASC_CLC_DISS, 0);
288 amazon_writel_masked(AMAZON_ASC_CLC, ASCCLC_RMCMASK, 1 << ASCCLC_RMCOFFSET);
289
290 /* asynchronous mode */
291 con = ASCCON_M_8ASYNC | ASCCON_FEN | ASCCON_OEN | ASCCON_PEN;
292
293 /* choose the line - there's only one */
294 amazon_writel(0, AMAZON_ASC_PISEL);
295 amazon_writel(((AMAZONASC_TXFIFO_FL << ASCTXFCON_TXFITLOFF) & ASCTXFCON_TXFITLMASK) | ASCTXFCON_TXFEN | ASCTXFCON_TXFFLU,
296 AMAZON_ASC_TXFCON);
297 amazon_writel(((AMAZONASC_RXFIFO_FL << ASCRXFCON_RXFITLOFF) & ASCRXFCON_RXFITLMASK) | ASCRXFCON_RXFEN | ASCRXFCON_RXFFLU,
298 AMAZON_ASC_RXFCON);
299 wmb();
300
301 amazon_writel_masked(AMAZON_ASC_CON, con, con);
302
303 retval = request_irq(AMAZONASC_RIR, amazonasc_rx_int, 0, "asc_rx", port);
304 if (retval){
305 printk("failed to request amazonasc_rx_int\n");
306 return retval;
307 }
308 retval = request_irq(AMAZONASC_TIR, amazonasc_tx_int, 0, "asc_tx", port);
309 if (retval){
310 printk("failed to request amazonasc_tx_int\n");
311 goto err1;
312 }
313
314 retval = request_irq(AMAZONASC_EIR, amazonasc_er_int, 0, "asc_er", port);
315 if (retval){
316 printk("failed to request amazonasc_er_int\n");
317 goto err2;
318 }
319
320 local_irq_restore(flags);
321 return 0;
322
323 err2:
324 free_irq(AMAZONASC_TIR, port);
325
326 err1:
327 free_irq(AMAZONASC_RIR, port);
328 local_irq_restore(flags);
329 return retval;
330 }
331
332 static void amazonasc_shutdown(struct uart_port *port)
333 {
334 free_irq(AMAZONASC_RIR, port);
335 free_irq(AMAZONASC_TIR, port);
336 free_irq(AMAZONASC_EIR, port);
337 /*
338 * disable the baudrate generator to disable the ASC
339 */
340 amazon_writel(0, AMAZON_ASC_CON);
341
342 /* flush and then disable the fifos */
343 amazon_writel_masked(AMAZON_ASC_RXFCON, ASCRXFCON_RXFFLU, ASCRXFCON_RXFFLU);
344 amazon_writel_masked(AMAZON_ASC_RXFCON, ASCRXFCON_RXFEN, 0);
345 amazon_writel_masked(AMAZON_ASC_TXFCON, ASCTXFCON_TXFFLU, ASCTXFCON_TXFFLU);
346 amazon_writel_masked(AMAZON_ASC_TXFCON, ASCTXFCON_TXFEN, 0);
347 }
348
349 static void amazonasc_set_termios(struct uart_port *port, struct ktermios *new, struct ktermios *old)
350 {
351 unsigned int cflag;
352 unsigned int iflag;
353 unsigned int baud, quot;
354 unsigned int con = 0;
355 unsigned long flags;
356
357 cflag = new->c_cflag;
358 iflag = new->c_iflag;
359
360 /* byte size and parity */
361 switch (cflag & CSIZE) {
362 /* 7 bits are always with parity */
363 case CS7: con = ASCCON_M_7ASYNCPAR; break;
364 /* the ASC only suports 7 and 8 bits */
365 case CS5:
366 case CS6:
367 default:
368 if (cflag & PARENB)
369 con = ASCCON_M_8ASYNCPAR;
370 else
371 con = ASCCON_M_8ASYNC;
372 break;
373 }
374 if (cflag & CSTOPB)
375 con |= ASCCON_STP;
376 if (cflag & PARENB) {
377 if (!(cflag & PARODD))
378 con &= ~ASCCON_ODD;
379 else
380 con |= ASCCON_ODD;
381 }
382
383 port->read_status_mask = ASCCON_OE;
384 if (iflag & INPCK)
385 port->read_status_mask |= ASCCON_FE | ASCCON_PE;
386
387 port->ignore_status_mask = 0;
388 if (iflag & IGNPAR)
389 port->ignore_status_mask |= ASCCON_FE | ASCCON_PE;
390
391 if (iflag & IGNBRK) {
392 /*
393 * If we're ignoring parity and break indicators,
394 * ignore overruns too (for real raw support).
395 */
396 if (iflag & IGNPAR)
397 port->ignore_status_mask |= ASCCON_OE;
398 }
399
400 /*
401 * Ignore all characters if CREAD is not set.
402 */
403 if ((cflag & CREAD) == 0)
404 port->ignore_status_mask |= UART_DUMMY_UER_RX;
405
406 /* set error signals - framing, parity and overrun */
407 con |= ASCCON_FEN;
408 con |= ASCCON_OEN;
409 con |= ASCCON_PEN;
410 /* enable the receiver */
411 con |= ASCCON_REN;
412
413 /* block the IRQs */
414 local_irq_save(flags);
415
416 /* set up CON */
417 amazon_writel(con, AMAZON_ASC_CON);
418
419 /* Set baud rate - take a divider of 2 into account */
420 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16);
421 quot = uart_get_divisor(port, baud);
422 quot = quot/2 - 1;
423
424 /* the next 3 probably already happened when we set CON above */
425 /* disable the baudrate generator */
426 amazon_writel_masked(AMAZON_ASC_CON, ASCCON_R, 0);
427 /* make sure the fractional divider is off */
428 amazon_writel_masked(AMAZON_ASC_CON, ASCCON_FDE, 0);
429 /* set up to use divisor of 2 */
430 amazon_writel_masked(AMAZON_ASC_CON, ASCCON_BRS, 0);
431 /* now we can write the new baudrate into the register */
432 amazon_writel(quot, AMAZON_ASC_BTR);
433 /* turn the baudrate generator back on */
434 amazon_writel_masked(AMAZON_ASC_CON, ASCCON_R, ASCCON_R);
435
436 local_irq_restore(flags);
437 }
438
439 static const char *amazonasc_type(struct uart_port *port)
440 {
441 return port->type == PORT_AMAZONASC ? "AMAZONASC" : NULL;
442 }
443
444 /*
445 * Release the memory region(s) being used by 'port'
446 */
447 static void amazonasc_release_port(struct uart_port *port)
448 {
449 return;
450 }
451
452 /*
453 * Request the memory region(s) being used by 'port'
454 */
455 static int amazonasc_request_port(struct uart_port *port)
456 {
457 return 0;
458 }
459
460 /*
461 * Configure/autoconfigure the port.
462 */
463 static void amazonasc_config_port(struct uart_port *port, int flags)
464 {
465 if (flags & UART_CONFIG_TYPE) {
466 port->type = PORT_AMAZONASC;
467 amazonasc_request_port(port);
468 }
469 }
470
471 /*
472 * verify the new serial_struct (for TIOCSSERIAL).
473 */
474 static int amazonasc_verify_port(struct uart_port *port, struct serial_struct *ser)
475 {
476 int ret = 0;
477 if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMAZONASC)
478 ret = -EINVAL;
479 if (ser->irq < 0 || ser->irq >= NR_IRQS)
480 ret = -EINVAL;
481 if (ser->baud_base < 9600)
482 ret = -EINVAL;
483 return ret;
484 }
485
486 static struct uart_ops amazonasc_pops = {
487 .tx_empty = amazonasc_tx_empty,
488 .set_mctrl = amazonasc_set_mctrl,
489 .get_mctrl = amazonasc_get_mctrl,
490 .stop_tx = amazonasc_stop_tx,
491 .start_tx = amazonasc_start_tx,
492 .stop_rx = amazonasc_stop_rx,
493 .enable_ms = amazonasc_enable_ms,
494 .break_ctl = amazonasc_break_ctl,
495 .startup = amazonasc_startup,
496 .shutdown = amazonasc_shutdown,
497 .set_termios = amazonasc_set_termios,
498 .type = amazonasc_type,
499 .release_port = amazonasc_release_port,
500 .request_port = amazonasc_request_port,
501 .config_port = amazonasc_config_port,
502 .verify_port = amazonasc_verify_port,
503 };
504
505 static struct uart_port amazonasc_ports[UART_NR] = {
506 {
507 membase: (void *)AMAZON_ASC,
508 mapbase: AMAZON_ASC,
509 iotype: SERIAL_IO_MEM,
510 irq: AMAZONASC_RIR, /* RIR */
511 uartclk: 0, /* filled in dynamically */
512 fifosize: 16,
513 unused: { AMAZONASC_TIR, AMAZONASC_EIR}, /* xmit/error/xmit-buffer-empty IRQ */
514 type: PORT_AMAZONASC,
515 ops: &amazonasc_pops,
516 flags: ASYNC_BOOT_AUTOCONF,
517 },
518 };
519
520 static void amazonasc_console_write(struct console *co, const char *s, u_int count)
521 {
522 int i, fifocnt;
523 unsigned long flags;
524 local_irq_save(flags);
525 for (i = 0; i < count;)
526 {
527 /* wait until the FIFO is not full */
528 do
529 {
530 fifocnt = (amazon_readl(AMAZON_ASC_FSTAT) & ASCFSTAT_TXFFLMASK)
531 >> ASCFSTAT_TXFFLOFF;
532 } while (fifocnt == AMAZONASC_TXFIFO_FULL);
533 if (s[i] == '\0')
534 {
535 break;
536 }
537 if (s[i] == '\n')
538 {
539 amazon_writel('\r', AMAZON_ASC_TBUF);
540 do
541 {
542 fifocnt = (amazon_readl(AMAZON_ASC_FSTAT) &
543 ASCFSTAT_TXFFLMASK) >> ASCFSTAT_TXFFLOFF;
544 } while (fifocnt == AMAZONASC_TXFIFO_FULL);
545 }
546 amazon_writel(s[i], AMAZON_ASC_TBUF);
547 i++;
548 }
549
550 local_irq_restore(flags);
551 }
552
553 static void __init
554 amazonasc_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
555 {
556 u_int lcr_h;
557
558 lcr_h = amazon_readl(AMAZON_ASC_CON);
559 /* do this only if the ASC is turned on */
560 if (lcr_h & ASCCON_R) {
561 u_int quot, div, fdiv, frac;
562
563 *parity = 'n';
564 if ((lcr_h & ASCCON_MODEMASK) == ASCCON_M_7ASYNCPAR ||
565 (lcr_h & ASCCON_MODEMASK) == ASCCON_M_8ASYNCPAR) {
566 if (lcr_h & ASCCON_ODD)
567 *parity = 'o';
568 else
569 *parity = 'e';
570 }
571
572 if ((lcr_h & ASCCON_MODEMASK) == ASCCON_M_7ASYNCPAR)
573 *bits = 7;
574 else
575 *bits = 8;
576
577 quot = amazon_readl(AMAZON_ASC_BTR) + 1;
578
579 /* this gets hairy if the fractional divider is used */
580 if (lcr_h & ASCCON_FDE)
581 {
582 div = 1;
583 fdiv = amazon_readl(AMAZON_ASC_FDV);
584 if (fdiv == 0)
585 fdiv = 512;
586 frac = 512;
587 }
588 else
589 {
590 div = lcr_h & ASCCON_BRS ? 3 : 2;
591 fdiv = frac = 1;
592 }
593 /*
594 * This doesn't work exactly because we use integer
595 * math to calculate baud which results in rounding
596 * errors when we try to go from quot -> baud !!
597 * Try to make this work for both the fractional divider
598 * and the simple divider. Also try to avoid rounding
599 * errors using integer math.
600 */
601
602 *baud = frac * (port->uartclk / (div * 512 * 16 * quot));
603 if (*baud > 1100 && *baud < 2400)
604 *baud = 1200;
605 if (*baud > 2300 && *baud < 4800)
606 *baud = 2400;
607 if (*baud > 4700 && *baud < 9600)
608 *baud = 4800;
609 if (*baud > 9500 && *baud < 19200)
610 *baud = 9600;
611 if (*baud > 19000 && *baud < 38400)
612 *baud = 19200;
613 if (*baud > 38400 && *baud < 57600)
614 *baud = 38400;
615 if (*baud > 57600 && *baud < 115200)
616 *baud = 57600;
617 if (*baud > 115200 && *baud < 230400)
618 *baud = 115200;
619 }
620 }
621
622 static int __init amazonasc_console_setup(struct console *co, char *options)
623 {
624 struct uart_port *port;
625 int baud = 115200;
626 int bits = 8;
627 int parity = 'n';
628 int flow = 'n';
629
630 /* this assumes: CON.BRS = CON.FDE = 0 */
631 if (uartclk == 0)
632 uartclk = amazon_get_fpi_hz();
633 co->index = 0;
634 port = &amazonasc_ports[0];
635 amazonasc_ports[0].uartclk = uartclk;
636 amazonasc_ports[0].type = PORT_AMAZONASC;
637
638 if (options){
639 uart_parse_options(options, &baud, &parity, &bits, &flow);
640 }
641
642 return uart_set_options(port, co, baud, parity, bits, flow);
643 }
644
645 static struct uart_driver amazonasc_reg;
646 static struct console amazonasc_console = {
647 name: "ttyS",
648 write: amazonasc_console_write,
649 device: uart_console_device,
650 setup: amazonasc_console_setup,
651 flags: CON_PRINTBUFFER,
652 index: -1,
653 data: &amazonasc_reg,
654 };
655
656 static int __init amazonasc_console_init(void)
657 {
658 register_console(&amazonasc_console);
659 return 0;
660 }
661 console_initcall(amazonasc_console_init);
662
663 static struct uart_driver amazonasc_reg = {
664 .owner = THIS_MODULE,
665 .driver_name = "serial",
666 .dev_name = "ttyS",
667 .major = TTY_MAJOR,
668 .minor = 64,
669 .nr = UART_NR,
670 .cons = &amazonasc_console,
671 };
672
673 static int __init amazonasc_init(void)
674 {
675 unsigned char res;
676 uart_register_driver(&amazonasc_reg);
677 res = uart_add_one_port(&amazonasc_reg, &amazonasc_ports[0]);
678 return res;
679 }
680
681 static void __exit amazonasc_exit(void)
682 {
683 uart_unregister_driver(&amazonasc_reg);
684 }
685
686 module_init(amazonasc_init);
687 module_exit(amazonasc_exit);
688
689 MODULE_AUTHOR("Gary Jennejohn, Felix Fietkau, John Crispin");
690 MODULE_DESCRIPTION("MIPS AMAZONASC serial port driver");
691 MODULE_LICENSE("GPL");
This page took 0.075388 seconds and 5 git commands to generate.