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