1 /* drivers/char/ser_a2232.c */
3 /* $Id: ser_a2232.c,v 0.4 2000/01/25 12:00:00 ehaase Exp $ */
5 /* Linux serial driver for the Amiga A2232 board */
7 /* This driver is MAINTAINED. Before applying any changes, please contact
11 /* Copyright (c) 2000-2001 Enver Haase <ehaase@inf.fu-berlin.de>
12 * alias The A2232 driver project <A2232@gmx.net>
13 * All rights reserved.
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 /***************************** Documentation ************************/
32 * This driver is in EXPERIMENTAL state. That means I could not find
33 * someone with five A2232 boards with 35 ports running at 19200 bps
34 * at the same time and test the machine's behaviour.
35 * However, I know that you can performance-tweak this driver (see
37 * One thing to consider is the time this driver consumes during the
38 * Amiga's vertical blank interrupt. Everything that is to be done
39 * _IS DONE_ when entering the vertical blank interrupt handler of
41 * However, it would be more sane to only do the job for only ONE card
42 * instead of ALL cards at a time; or, more generally, to handle only
43 * SOME ports instead of ALL ports at a time.
44 * However, as long as no-one runs into problems I guess I shouldn't
45 * change the driver as it runs fine for me :) .
47 * Version history of this file:
48 * 0.4 Resolved licensing issues.
49 * 0.3 Inclusion in the Linux/m68k tree, small fixes.
50 * 0.2 Added documentation, minor typo fixes.
51 * 0.1 Initial release.
54 * - Handle incoming BREAK events. I guess "Stevens: Advanced
55 * Programming in the UNIX(R) Environment" is a good reference
56 * on what is to be done.
57 * - When installing as a module, don't simply 'printk' text, but
58 * send it to the TTY used by the user.
61 * - Jukka Marin (65EC02 code).
62 * - The other NetBSD developers on whose A2232 driver I had a
63 * pretty close look. However, I didn't copy any code so it
64 * is okay to put my code under the GPL and include it into
67 /***************************** End of Documentation *****************/
69 /***************************** Defines ******************************/
71 * Enables experimental 115200 (normal) 230400 (turbo) baud rate.
72 * The A2232 specification states it can only operate at speeds up to
73 * 19200 bits per second, and I was not able to send a file via
74 * "sz"/"rz" and a null-modem cable from one A2232 port to another
75 * at 115200 bits per second.
76 * However, this might work for you.
78 #undef A2232_SPEEDHACK
80 * Default is not to use RTS/CTS so you could be talked to death.
82 #define A2232_SUPPRESS_RTSCTS_WARNING
83 /************************* End of Defines ***************************/
85 /***************************** Includes *****************************/
86 #include <linux/module.h>
88 #include <linux/types.h>
89 #include <linux/sched.h>
90 #include <linux/interrupt.h>
91 #include <linux/kernel.h>
92 #include <linux/errno.h>
93 #include <linux/tty.h>
95 #include <asm/setup.h>
96 #include <asm/amigaints.h>
97 #include <asm/amigahw.h>
98 #include <linux/zorro.h>
100 #include <asm/semaphore.h>
102 #include <linux/delay.h>
104 #include <linux/serial.h>
105 #include <linux/generic_serial.h>
107 #include "ser_a2232.h"
108 #include "ser_a2232fw.h"
109 /************************* End of Includes **************************/
111 /***************************** Prototypes ***************************/
112 /* The interrupt service routine */
113 static irqreturn_t a2232_vbl_inter(int irq, void *data, struct pt_regs *fp);
114 /* Initialize the port structures */
115 static void a2232_init_portstructs(void);
116 /* Initialize and register TTY drivers. */
117 /* returns 0 IFF successful */
118 static int a2232_init_drivers(void);
120 /* BEGIN GENERIC_SERIAL PROTOTYPES */
121 static void a2232_disable_tx_interrupts(void *ptr);
122 static void a2232_enable_tx_interrupts(void *ptr);
123 static void a2232_disable_rx_interrupts(void *ptr);
124 static void a2232_enable_rx_interrupts(void *ptr);
125 static int a2232_get_CD(void *ptr);
126 static void a2232_shutdown_port(void *ptr);
127 static int a2232_set_real_termios(void *ptr);
128 static int a2232_chars_in_buffer(void *ptr);
129 static void a2232_close(void *ptr);
130 static void a2232_hungup(void *ptr);
131 /* static void a2232_getserial (void *ptr, struct serial_struct *sp); */
132 /* END GENERIC_SERIAL PROTOTYPES */
134 /* Functions that the TTY driver struct expects */
135 static int a2232_ioctl(struct tty_struct *tty, struct file *file,
136 unsigned int cmd, unsigned long arg);
137 static void a2232_throttle(struct tty_struct *tty);
138 static void a2232_unthrottle(struct tty_struct *tty);
139 static int a2232_open(struct tty_struct * tty, struct file * filp);
140 /************************* End of Prototypes ************************/
142 /***************************** Global variables *********************/
143 /*---------------------------------------------------------------------------
144 * Interface from generic_serial.c back here
145 *--------------------------------------------------------------------------*/
146 static struct real_driver a2232_real_driver = {
147 a2232_disable_tx_interrupts,
148 a2232_enable_tx_interrupts,
149 a2232_disable_rx_interrupts,
150 a2232_enable_rx_interrupts,
153 a2232_set_real_termios,
154 a2232_chars_in_buffer,
157 NULL /* a2232_getserial */
160 static void *a2232_driver_ID = &a2232_driver_ID; // Some memory address WE own.
163 static struct a2232_port a2232_ports[MAX_A2232_BOARDS*NUMLINES];
165 /* TTY driver structs */
166 static struct tty_driver *a2232_driver;
168 /* nr of cards completely (all ports) and correctly configured */
171 /* zorro_dev structs for the A2232's */
172 static struct zorro_dev *zd_a2232[MAX_A2232_BOARDS];
173 /***************************** End of Global variables **************/
175 /* Helper functions */
177 static inline volatile struct a2232memory *a2232mem(unsigned int board)
179 return (volatile struct a2232memory *)ZTWO_VADDR(zd_a2232[board]->resource.start);
182 static inline volatile struct a2232status *a2232stat(unsigned int board,
183 unsigned int portonboard)
185 volatile struct a2232memory *mem = a2232mem(board);
186 return &(mem->Status[portonboard]);
189 static inline void a2232_receive_char(struct a2232_port *port, int ch, int err)
191 /* Mostly stolen from other drivers.
192 Maybe one could implement a more efficient version by not only
193 transferring one character at a time.
195 struct tty_struct *tty = port->gs.tty;
197 if (tty->flip.count >= TTY_FLIPBUF_SIZE)
215 *tty->flip.flag_buf_ptr++ = err;
216 *tty->flip.char_buf_ptr++ = ch;
217 tty_flip_buffer_push(tty);
220 /***************************** Functions ****************************/
221 /*** BEGIN OF REAL_DRIVER FUNCTIONS ***/
223 static void a2232_disable_tx_interrupts(void *ptr)
225 struct a2232_port *port;
226 volatile struct a2232status *stat;
230 stat = a2232stat(port->which_a2232, port->which_port_on_a2232);
231 stat->OutDisable = -1;
233 /* Does this here really have to be? */
234 local_irq_save(flags);
235 port->gs.flags &= ~GS_TX_INTEN;
236 local_irq_restore(flags);
239 static void a2232_enable_tx_interrupts(void *ptr)
241 struct a2232_port *port;
242 volatile struct a2232status *stat;
246 stat = a2232stat(port->which_a2232, port->which_port_on_a2232);
247 stat->OutDisable = 0;
249 /* Does this here really have to be? */
250 local_irq_save(flags);
251 port->gs.flags |= GS_TX_INTEN;
252 local_irq_restore(flags);
255 static void a2232_disable_rx_interrupts(void *ptr)
257 struct a2232_port *port;
259 port->disable_rx = -1;
262 static void a2232_enable_rx_interrupts(void *ptr)
264 struct a2232_port *port;
266 port->disable_rx = 0;
269 static int a2232_get_CD(void *ptr)
271 return ((struct a2232_port *) ptr)->cd_status;
274 static void a2232_shutdown_port(void *ptr)
276 struct a2232_port *port;
277 volatile struct a2232status *stat;
281 stat = a2232stat(port->which_a2232, port->which_port_on_a2232);
283 local_irq_save(flags);
285 port->gs.flags &= ~GS_ACTIVE;
287 if (port->gs.tty && port->gs.tty->termios->c_cflag & HUPCL) {
288 /* Set DTR and RTS to Low, flush output.
289 The NetBSD driver "msc.c" does it this way. */
290 stat->Command = ( (stat->Command & ~A2232CMD_CMask) |
296 local_irq_restore(flags);
298 /* After analyzing control flow, I think a2232_shutdown_port
299 is actually the last call from the system when at application
300 level someone issues a "echo Hello >>/dev/ttyY0".
301 Therefore I think the MOD_DEC_USE_COUNT should be here and
302 not in "a2232_close()". See the comment in "sx.c", too.
303 If you run into problems, compile this driver into the
304 kernel instead of compiling it as a module. */
307 static int a2232_set_real_termios(void *ptr)
309 unsigned int cflag, baud, chsize, stopb, parity, softflow;
311 int a2232_param, a2232_cmd;
314 struct a2232_port *port = ptr;
315 volatile struct a2232status *status;
316 volatile struct a2232memory *mem;
318 if (!port->gs.tty || !port->gs.tty->termios) return 0;
320 status = a2232stat(port->which_a2232, port->which_port_on_a2232);
321 mem = a2232mem(port->which_a2232);
323 a2232_param = a2232_cmd = 0;
326 baud = port->gs.baud;
328 /* speed == 0 -> drop DTR, do nothing else */
329 local_irq_save(flags);
330 // Clear DTR (and RTS... mhhh).
331 status->Command = ( (status->Command & ~A2232CMD_CMask) |
333 status->OutFlush = -1;
336 local_irq_restore(flags);
340 rate = A2232_BAUD_TABLE_NOAVAIL;
341 for (i=0; i < A2232_BAUD_TABLE_NUM_RATES * 3; i += 3){
342 if (a2232_baud_table[i] == baud){
343 if (mem->Common.Crystal == A2232_TURBO) rate = a2232_baud_table[i+2];
344 else rate = a2232_baud_table[i+1];
347 if (rate == A2232_BAUD_TABLE_NOAVAIL){
348 printk("a2232: Board %d Port %d unsupported baud rate: %d baud. Using another.\n",port->which_a2232,port->which_port_on_a2232,baud);
349 // This is useful for both (turbo or normal) Crystal versions.
350 rate = A2232PARAM_B9600;
354 cflag = port->gs.tty->termios->c_cflag;
356 // get character size
357 chsize = cflag & CSIZE;
359 case CS8: a2232_param |= A2232PARAM_8Bit; break;
360 case CS7: a2232_param |= A2232PARAM_7Bit; break;
361 case CS6: a2232_param |= A2232PARAM_6Bit; break;
362 case CS5: a2232_param |= A2232PARAM_5Bit; break;
363 default: printk("a2232: Board %d Port %d unsupported character size: %d. Using 8 data bits.\n",
364 port->which_a2232,port->which_port_on_a2232,chsize);
365 a2232_param |= A2232PARAM_8Bit; break;
368 // get number of stop bits
369 stopb = cflag & CSTOPB;
370 if (stopb){ // two stop bits instead of one
371 printk("a2232: Board %d Port %d 2 stop bits unsupported. Using 1 stop bit.\n",
372 port->which_a2232,port->which_port_on_a2232);
375 // Warn if RTS/CTS not wanted
376 if (!(cflag & CRTSCTS)){
377 #ifndef A2232_SUPPRESS_RTSCTS_WARNING
378 printk("a2232: Board %d Port %d cannot switch off firmware-implemented RTS/CTS hardware flow control.\n",
379 port->which_a2232,port->which_port_on_a2232);
383 /* I think this is correct.
384 However, IXOFF means _input_ flow control and I wonder
385 if one should care about IXON _output_ flow control,
386 too. If this makes problems, one should turn the A2232
387 firmware XON/XOFF "SoftFlow" flow control off and use
388 the conventional way of inserting START/STOP characters
389 by hand in throttle()/unthrottle().
391 softflow = !!( port->gs.tty->termios->c_iflag & IXOFF );
393 // get Parity (Enabled/Disabled? If Enabled, Odd or Even?)
394 parity = cflag & (PARENB | PARODD);
395 if (parity & PARENB){
396 if (parity & PARODD){
397 a2232_cmd |= A2232CMD_OddParity;
400 a2232_cmd |= A2232CMD_EvenParity;
403 else a2232_cmd |= A2232CMD_NoParity;
406 /* Hmm. Maybe an own a2232_port structure
407 member would be cleaner? */
409 port->gs.flags &= ~ASYNC_CHECK_CD;
411 port->gs.flags |= ASYNC_CHECK_CD;
414 /* Now we have all parameters and can go to set them: */
415 local_irq_save(flags);
417 status->Param = a2232_param | A2232PARAM_RcvBaud;
418 status->Command = a2232_cmd | A2232CMD_Open | A2232CMD_Enable;
419 status->SoftFlow = softflow;
420 status->OutDisable = 0;
423 local_irq_restore(flags);
427 static int a2232_chars_in_buffer(void *ptr)
429 struct a2232_port *port;
430 volatile struct a2232status *status;
431 unsigned char ret; /* we need modulo-256 arithmetics */
433 status = a2232stat(port->which_a2232, port->which_port_on_a2232);
434 #if A2232_IOBUFLEN != 256
435 #error "Re-Implement a2232_chars_in_buffer()!"
437 ret = (status->OutHead - status->OutTail);
441 static void a2232_close(void *ptr)
443 a2232_disable_tx_interrupts(ptr);
444 a2232_disable_rx_interrupts(ptr);
445 /* see the comment in a2232_shutdown_port above. */
448 static void a2232_hungup(void *ptr)
452 /*** END OF REAL_DRIVER FUNCTIONS ***/
454 /*** BEGIN FUNCTIONS EXPECTED BY TTY DRIVER STRUCTS ***/
455 static int a2232_ioctl( struct tty_struct *tty, struct file *file,
456 unsigned int cmd, unsigned long arg)
461 static void a2232_throttle(struct tty_struct *tty)
463 /* Throttle: System cannot take another chars: Drop RTS or
464 send the STOP char or whatever.
465 The A2232 firmware does RTS/CTS anyway, and XON/XOFF
466 if switched on. So the only thing we can do at this
467 layer here is not taking any characters out of the
468 A2232 buffer any more. */
469 struct a2232_port *port = (struct a2232_port *) tty->driver_data;
470 port->throttle_input = -1;
473 static void a2232_unthrottle(struct tty_struct *tty)
475 /* Unthrottle: dual to "throttle()" above. */
476 struct a2232_port *port = (struct a2232_port *) tty->driver_data;
477 port->throttle_input = 0;
480 static int a2232_open(struct tty_struct * tty, struct file * filp)
482 /* More or less stolen from other drivers. */
485 struct a2232_port *port;
488 port = &a2232_ports[line];
490 tty->driver_data = port;
493 retval = gs_init_port(&port->gs);
498 port->gs.flags |= GS_ACTIVE;
499 retval = gs_block_til_ready(port, filp);
506 a2232_enable_rx_interrupts(port);
510 /*** END OF FUNCTIONS EXPECTED BY TTY DRIVER STRUCTS ***/
512 static irqreturn_t a2232_vbl_inter(int irq, void *data, struct pt_regs *fp)
514 #if A2232_IOBUFLEN != 256
515 #error "Re-Implement a2232_vbl_inter()!"
518 struct a2232_port *port;
519 volatile struct a2232memory *mem;
520 volatile struct a2232status *status;
521 unsigned char newhead;
522 unsigned char bufpos; /* Must be unsigned char. We need the modulo-256 arithmetics */
523 unsigned char ncd, ocd, ccd; /* names consistent with the NetBSD driver */
524 volatile u_char *ibuf, *cbuf, *obuf;
526 for (n = 0; n < nr_a2232; n++){ /* for every completely initialized A2232 board */
528 for (p = 0; p < NUMLINES; p++){ /* for every port on this board */
530 port = &a2232_ports[n*NUMLINES+p];
531 if ( port->gs.flags & GS_ACTIVE ){ /* if the port is used */
533 status = a2232stat(n,p);
535 if (!port->disable_rx && !port->throttle_input){ /* If input is not disabled */
536 newhead = status->InHead; /* 65EC02 write pointer */
537 bufpos = status->InTail;
539 /* check for input for this port */
540 if (newhead != bufpos) {
541 /* buffer for input chars/events */
542 ibuf = mem->InBuf[p];
544 /* data types of bytes in ibuf */
545 cbuf = mem->InCtl[p];
547 /* do for all chars */
548 while (bufpos != newhead) {
549 /* which type of input data? */
550 switch (cbuf[bufpos]) {
551 /* switch on input event (CD, BREAK, etc.) */
552 case A2232INCTL_EVENT:
553 switch (ibuf[bufpos++]) {
554 case A2232EVENT_Break:
555 /* TODO: Handle BREAK signal */
557 /* A2232EVENT_CarrierOn and A2232EVENT_CarrierOff are
558 handled in a separate queue and should not occur here. */
559 case A2232EVENT_Sync:
560 printk("A2232: 65EC02 software sent SYNC event, don't know what to do. Ignoring.");
563 printk("A2232: 65EC02 software broken, unknown event type %d occurred.\n",ibuf[bufpos-1]);
564 } /* event type switch */
566 case A2232INCTL_CHAR:
567 /* Receive incoming char */
568 a2232_receive_char(port, ibuf[bufpos], err);
572 printk("A2232: 65EC02 software broken, unknown data type %d occurred.\n",cbuf[bufpos]);
574 } /* switch on input data type */
575 } /* while there's something in the buffer */
577 status->InTail = bufpos; /* tell 65EC02 what we've read */
579 } /* if there was something in the buffer */
580 } /* If input is not disabled */
582 /* Now check if there's something to output */
583 obuf = mem->OutBuf[p];
584 bufpos = status->OutHead;
585 while ( (port->gs.xmit_cnt > 0) &&
586 (!port->gs.tty->stopped) &&
587 (!port->gs.tty->hw_stopped) ){ /* While there are chars to transmit */
588 if (((bufpos+1) & A2232_IOBUFLENMASK) != status->OutTail) { /* If the A2232 buffer is not full */
589 ch = port->gs.xmit_buf[port->gs.xmit_tail]; /* get the next char to transmit */
590 port->gs.xmit_tail = (port->gs.xmit_tail+1) & (SERIAL_XMIT_SIZE-1); /* modulo-addition for the gs.xmit_buf ring-buffer */
591 obuf[bufpos++] = ch; /* put it into the A2232 buffer */
594 else{ /* If A2232 the buffer is full */
595 break; /* simply stop filling it. */
598 status->OutHead = bufpos;
600 /* WakeUp if output buffer runs low */
601 if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.tty) {
602 tty_wakeup(port->gs.tty);
604 } // if the port is used
605 } // for every port on the board
607 /* Now check the CD message queue */
608 newhead = mem->Common.CDHead;
609 bufpos = mem->Common.CDTail;
610 if (newhead != bufpos){ /* There are CD events in queue */
611 ocd = mem->Common.CDStatus; /* get old status bits */
612 while (newhead != bufpos){ /* read all events */
613 ncd = mem->CDBuf[bufpos++]; /* get one event */
614 ccd = ncd ^ ocd; /* mask of changed lines */
615 ocd = ncd; /* save new status bits */
616 for(p=0; p < NUMLINES; p++){ /* for all ports */
617 if (ccd & 1){ /* this one changed */
619 struct a2232_port *port = &a2232_ports[n*7+p];
620 port->cd_status = !(ncd & 1); /* ncd&1 <=> CD is now off */
622 if (!(port->gs.flags & ASYNC_CHECK_CD))
623 ; /* Don't report DCD changes */
624 else if (port->cd_status) { // if DCD on: DCD went UP!
626 /* Are we blocking in open?*/
627 wake_up_interruptible(&port->gs.open_wait);
629 else { // if DCD off: DCD went DOWN!
631 tty_hangup (port->gs.tty);
634 } // if CD changed for this port
636 ncd >>= 1; /* Shift bits for next line */
638 } // while CD events in queue
639 mem->Common.CDStatus = ocd; /* save new status */
640 mem->Common.CDTail = bufpos; /* remove events */
641 } // if events in CD queue
643 } // for every completely initialized A2232 board
647 static void a2232_init_portstructs(void)
649 struct a2232_port *port;
652 for (i = 0; i < MAX_A2232_BOARDS*NUMLINES; i++) {
653 port = a2232_ports + i;
654 port->which_a2232 = i/NUMLINES;
655 port->which_port_on_a2232 = i%NUMLINES;
656 port->disable_rx = port->throttle_input = port->cd_status = 0;
657 port->gs.magic = A2232_MAGIC;
658 port->gs.close_delay = HZ/2;
659 port->gs.closing_wait = 30 * HZ;
660 port->gs.rd = &a2232_real_driver;
661 #ifdef NEW_WRITE_LOCKING
662 init_MUTEX(&(port->gs.port_write_sem));
664 init_waitqueue_head(&port->gs.open_wait);
665 init_waitqueue_head(&port->gs.close_wait);
669 static struct tty_operations a2232_ops = {
673 .put_char = gs_put_char,
674 .flush_chars = gs_flush_chars,
675 .write_room = gs_write_room,
676 .chars_in_buffer = gs_chars_in_buffer,
677 .flush_buffer = gs_flush_buffer,
678 .ioctl = a2232_ioctl,
679 .throttle = a2232_throttle,
680 .unthrottle = a2232_unthrottle,
681 .set_termios = gs_set_termios,
687 static int a2232_init_drivers(void)
691 a2232_driver = alloc_tty_driver(NUMLINES * nr_a2232);
694 a2232_driver->owner = THIS_MODULE;
695 a2232_driver->driver_name = "commodore_a2232";
696 a2232_driver->name = "ttyY";
697 a2232_driver->major = A2232_NORMAL_MAJOR;
698 a2232_driver->type = TTY_DRIVER_TYPE_SERIAL;
699 a2232_driver->subtype = SERIAL_TYPE_NORMAL;
700 a2232_driver->init_termios = tty_std_termios;
701 a2232_driver->init_termios.c_cflag =
702 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
703 a2232_driver->flags = TTY_DRIVER_REAL_RAW;
704 tty_set_operations(a2232_driver, &a2232_ops);
705 if ((error = tty_register_driver(a2232_driver))) {
706 printk(KERN_ERR "A2232: Couldn't register A2232 driver, error = %d\n",
708 put_tty_driver(a2232_driver);
714 static int __init a2232board_init(void)
718 unsigned int boardaddr;
723 volatile struct a2232memory *mem;
726 return -ENODEV; /* This driver is not SMP aware. Is there an SMP ZorroII-bus-machine? */
733 printk("Commodore A2232 driver initializing.\n"); /* Say that we're alive. */
737 while ( (z = zorro_find_device(ZORRO_WILDCARD, z)) ){
738 if ( (z->id != ZORRO_PROD_CBM_A2232_PROTOTYPE) &&
739 (z->id != ZORRO_PROD_CBM_A2232) ){
740 continue; // The board found was no A2232
742 if (!zorro_request_device(z,"A2232 driver"))
745 printk("Commodore A2232 found (#%d).\n",nr_a2232);
747 zd_a2232[nr_a2232] = z;
749 boardaddr = ZTWO_VADDR( z->resource.start );
750 printk("Board is located at address 0x%x, size is 0x%x.\n", boardaddr, (unsigned int) ((z->resource.end+1) - (z->resource.start)));
752 mem = (volatile struct a2232memory *) boardaddr;
754 (void) mem->Enable6502Reset; /* copy the code across to the board */
755 to = (u_char *)mem; from = a2232_65EC02code; bcount = sizeof(a2232_65EC02code) - 2;
756 start = *(short *)from;
757 from += sizeof(start);
759 while(bcount--) *to++ = *from++;
760 printk("65EC02 software uploaded to the A2232 memory.\n");
762 mem->Common.Crystal = A2232_UNKNOWN; /* use automatic speed check */
764 /* start 6502 running */
765 (void) mem->ResetBoard;
766 printk("A2232's 65EC02 CPU up and running.\n");
768 /* wait until speed detector has finished */
769 for (bcount = 0; bcount < 2000; bcount++) {
771 if (mem->Common.Crystal)
774 printk((mem->Common.Crystal?"A2232 oscillator crystal detected by 65EC02 software: ":"65EC02 software could not determine A2232 oscillator crystal: "));
775 switch (mem->Common.Crystal){
777 printk("Unknown crystal.\n");
780 printk ("Normal crystal.\n");
783 printk ("Turbo crystal.\n");
786 printk ("0x%x. Huh?\n",mem->Common.Crystal);
793 printk("Total: %d A2232 boards initialized.\n.", nr_a2232); /* Some status report if no card was found */
795 a2232_init_portstructs();
798 a2232_init_drivers also registers the drivers. Must be here because all boards
799 have to be detected first.
801 if (a2232_init_drivers()) return -ENODEV; // maybe we should use a different -Exxx?
803 request_irq(IRQ_AMIGA_VERTB, a2232_vbl_inter, 0, "A2232 serial VBL", a2232_driver_ID);
807 static void __exit a2232board_exit(void)
811 for (i = 0; i < nr_a2232; i++) {
812 zorro_release_device(zd_a2232[i]);
815 tty_unregister_driver(a2232_driver);
816 put_tty_driver(a2232_driver);
817 free_irq(IRQ_AMIGA_VERTB, a2232_driver_ID);
820 module_init(a2232board_init);
821 module_exit(a2232board_exit);
823 MODULE_AUTHOR("Enver Haase");
824 MODULE_DESCRIPTION("Amiga A2232 multi-serial board driver");
825 MODULE_LICENSE("GPL");