1 /*****************************************************************************/
4 * istallion.c -- stallion intelligent multiport serial driver.
6 * Copyright (C) 1996-1999 Stallion Technologies (support@stallion.oz.au).
7 * Copyright (C) 1994-1996 Greg Ungerer.
9 * This code is loosely based on the Linux serial driver, written by
10 * Linus Torvalds, Theodore T'so and others.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 /*****************************************************************************/
29 #include <linux/config.h>
30 #include <linux/module.h>
31 #include <linux/malloc.h>
32 #include <linux/interrupt.h>
33 #include <linux/tty_flip.h>
34 #include <linux/serial.h>
35 #include <linux/cdk.h>
36 #include <linux/comstats.h>
37 #include <linux/version.h>
38 #include <linux/istallion.h>
39 #include <linux/ioport.h>
40 #include <linux/delay.h>
41 #include <linux/init.h>
42 #include <linux/devfs_fs_kernel.h>
45 #include <asm/uaccess.h>
48 #include <linux/pci.h>
51 /*****************************************************************************/
54 * Define different board types. Not all of the following board types
55 * are supported by this driver. But I will use the standard "assigned"
56 * board numbers. Currently supported boards are abbreviated as:
57 * ECP = EasyConnection 8/64, ONB = ONboard, BBY = Brumby and
61 #define BRD_STALLION 1
63 #define BRD_ONBOARD2 3
66 #define BRD_BRUMBY16 6
67 #define BRD_ONBOARDE 7
68 #define BRD_ONBOARD32 9
69 #define BRD_ONBOARD2_32 10
70 #define BRD_ONBOARDRS 11
78 #define BRD_ECH64PCI 27
79 #define BRD_EASYIOPCI 28
82 #define BRD_BRUMBY BRD_BRUMBY4
85 * Define a configuration structure to hold the board configuration.
86 * Need to set this up in the code (for now) with the boards that are
87 * to be configured into the system. This is what needs to be modified
88 * when adding/removing/modifying boards. Each line entry in the
89 * stli_brdconf[] array is a board. Each line contains io/irq/memory
90 * ranges for that board (as well as what type of board it is).
92 * { BRD_ECP, 0x2a0, 0, 0xcc000, 0, 0 },
93 * This line will configure an EasyConnection 8/64 at io address 2a0,
94 * and shared memory address of cc000. Multiple EasyConnection 8/64
95 * boards can share the same shared memory address space. No interrupt
96 * is required for this board type.
98 * { BRD_ECPE, 0x5000, 0, 0x80000000, 0, 0 },
99 * This line will configure an EasyConnection 8/64 EISA in slot 5 and
100 * shared memory address of 0x80000000 (2 GByte). Multiple
101 * EasyConnection 8/64 EISA boards can share the same shared memory
102 * address space. No interrupt is required for this board type.
104 * { BRD_ONBOARD, 0x240, 0, 0xd0000, 0, 0 },
105 * This line will configure an ONboard (ISA type) at io address 240,
106 * and shared memory address of d0000. Multiple ONboards can share
107 * the same shared memory address space. No interrupt required.
109 * { BRD_BRUMBY4, 0x360, 0, 0xc8000, 0, 0 },
110 * This line will configure a Brumby board (any number of ports!) at
111 * io address 360 and shared memory address of c8000. All Brumby boards
112 * configured into a system must have their own separate io and memory
113 * addresses. No interrupt is required.
115 * { BRD_STALLION, 0x330, 0, 0xd0000, 0, 0 },
116 * This line will configure an original Stallion board at io address 330
117 * and shared memory address d0000 (this would only be valid for a "V4.0"
118 * or Rev.O Stallion board). All Stallion boards configured into the
119 * system must have their own separate io and memory addresses. No
120 * interrupt is required.
127 unsigned long memaddr
;
132 static stlconf_t stli_brdconf
[] = {
133 /*{ BRD_ECP, 0x2a0, 0, 0xcc000, 0, 0 },*/
136 static int stli_nrbrds
= sizeof(stli_brdconf
) / sizeof(stlconf_t
);
139 * There is some experimental EISA board detection code in this driver.
140 * By default it is disabled, but for those that want to try it out,
141 * then set the define below to be 1.
143 #define STLI_EISAPROBE 0
145 static devfs_handle_t devfs_handle
= NULL
;
147 /*****************************************************************************/
150 * Define some important driver characteristics. Device major numbers
151 * allocated as per Linux Device Registry.
153 #ifndef STL_SIOMEMMAJOR
154 #define STL_SIOMEMMAJOR 28
156 #ifndef STL_SERIALMAJOR
157 #define STL_SERIALMAJOR 24
159 #ifndef STL_CALLOUTMAJOR
160 #define STL_CALLOUTMAJOR 25
163 #define STL_DRVTYPSERIAL 1
164 #define STL_DRVTYPCALLOUT 2
166 /*****************************************************************************/
169 * Define our local driver identity first. Set up stuff to deal with
170 * all the local structures required by a serial tty driver.
172 static char *stli_drvtitle
= "Stallion Intelligent Multiport Serial Driver";
173 static char *stli_drvname
= "istallion";
174 static char *stli_drvversion
= "5.6.0";
175 static char *stli_serialname
= "ttyE";
176 static char *stli_calloutname
= "cue";
178 static struct tty_driver stli_serial
;
179 static struct tty_driver stli_callout
;
180 static struct tty_struct
*stli_ttys
[STL_MAXDEVS
];
181 static struct termios
*stli_termios
[STL_MAXDEVS
];
182 static struct termios
*stli_termioslocked
[STL_MAXDEVS
];
183 static int stli_refcount
;
186 * We will need to allocate a temporary write buffer for chars that
187 * come direct from user space. The problem is that a copy from user
188 * space might cause a page fault (typically on a system that is
189 * swapping!). All ports will share one buffer - since if the system
190 * is already swapping a shared buffer won't make things any worse.
192 static char *stli_tmpwritebuf
= (char *) NULL
;
193 static DECLARE_MUTEX(stli_tmpwritesem
);
195 #define STLI_TXBUFSIZE 4096
198 * Use a fast local buffer for cooked characters. Typically a whole
199 * bunch of cooked characters come in for a port, 1 at a time. So we
200 * save those up into a local buffer, then write out the whole lot
201 * with a large memcpy. Just use 1 buffer for all ports, since its
202 * use it is only need for short periods of time by each port.
204 static char *stli_txcookbuf
= (char *) NULL
;
205 static int stli_txcooksize
= 0;
206 static int stli_txcookrealsize
= 0;
207 static struct tty_struct
*stli_txcooktty
= (struct tty_struct
*) NULL
;
210 * Define a local default termios struct. All ports will be created
211 * with this termios initially. Basically all it defines is a raw port
212 * at 9600 baud, 8 data bits, no parity, 1 stop bit.
214 static struct termios stli_deftermios
= {
217 (B9600
| CS8
| CREAD
| HUPCL
| CLOCAL
),
224 * Define global stats structures. Not used often, and can be
225 * re-used for each stats call.
227 static comstats_t stli_comstats
;
228 static combrd_t stli_brdstats
;
229 static asystats_t stli_cdkstats
;
230 static stlibrd_t stli_dummybrd
;
231 static stliport_t stli_dummyport
;
233 /*****************************************************************************/
235 static stlibrd_t
*stli_brds
[STL_MAXBRDS
];
237 static int stli_shared
= 0;
240 * Per board state flags. Used with the state field of the board struct.
241 * Not really much here... All we need to do is keep track of whether
242 * the board has been detected, and whether it is actually running a slave
245 #define BST_FOUND 0x1
246 #define BST_STARTED 0x2
249 * Define the set of port state flags. These are marked for internal
250 * state purposes only, usually to do with the state of communications
251 * with the slave. Most of them need to be updated atomically, so always
252 * use the bit setting operations (unless protected by cli/sti).
254 #define ST_INITIALIZING 1
260 #define ST_DOFLUSHRX 7
261 #define ST_DOFLUSHTX 8
264 #define ST_GETSIGS 11
267 * Define an array of board names as printable strings. Handy for
268 * referencing boards when printing trace and stuff.
270 static char *stli_brdnames
[] = {
303 /*****************************************************************************/
307 * Define some string labels for arguments passed from the module
308 * load line. These allow for easy board definitions, and easy
309 * modification of the io, memory and irq resoucres.
312 static char *board0
[8];
313 static char *board1
[8];
314 static char *board2
[8];
315 static char *board3
[8];
317 static char **stli_brdsp
[] = {
325 * Define a set of common board names, and types. This is used to
326 * parse any module arguments.
329 typedef struct stlibrdtype
{
334 static stlibrdtype_t stli_brdstr
[] = {
335 { "stallion", BRD_STALLION
},
336 { "1", BRD_STALLION
},
337 { "brumby", BRD_BRUMBY
},
338 { "brumby4", BRD_BRUMBY
},
339 { "brumby/4", BRD_BRUMBY
},
340 { "brumby-4", BRD_BRUMBY
},
341 { "brumby8", BRD_BRUMBY
},
342 { "brumby/8", BRD_BRUMBY
},
343 { "brumby-8", BRD_BRUMBY
},
344 { "brumby16", BRD_BRUMBY
},
345 { "brumby/16", BRD_BRUMBY
},
346 { "brumby-16", BRD_BRUMBY
},
348 { "onboard2", BRD_ONBOARD2
},
349 { "onboard-2", BRD_ONBOARD2
},
350 { "onboard/2", BRD_ONBOARD2
},
351 { "onboard-mc", BRD_ONBOARD2
},
352 { "onboard/mc", BRD_ONBOARD2
},
353 { "onboard-mca", BRD_ONBOARD2
},
354 { "onboard/mca", BRD_ONBOARD2
},
355 { "3", BRD_ONBOARD2
},
356 { "onboard", BRD_ONBOARD
},
357 { "onboardat", BRD_ONBOARD
},
358 { "4", BRD_ONBOARD
},
359 { "onboarde", BRD_ONBOARDE
},
360 { "onboard-e", BRD_ONBOARDE
},
361 { "onboard/e", BRD_ONBOARDE
},
362 { "onboard-ei", BRD_ONBOARDE
},
363 { "onboard/ei", BRD_ONBOARDE
},
364 { "7", BRD_ONBOARDE
},
366 { "ecpat", BRD_ECP
},
367 { "ec8/64", BRD_ECP
},
368 { "ec8/64-at", BRD_ECP
},
369 { "ec8/64-isa", BRD_ECP
},
371 { "ecpe", BRD_ECPE
},
372 { "ecpei", BRD_ECPE
},
373 { "ec8/64-e", BRD_ECPE
},
374 { "ec8/64-ei", BRD_ECPE
},
376 { "ecpmc", BRD_ECPMC
},
377 { "ec8/64-mc", BRD_ECPMC
},
378 { "ec8/64-mca", BRD_ECPMC
},
380 { "ecppci", BRD_ECPPCI
},
381 { "ec/ra", BRD_ECPPCI
},
382 { "ec/ra-pc", BRD_ECPPCI
},
383 { "ec/ra-pci", BRD_ECPPCI
},
384 { "29", BRD_ECPPCI
},
388 * Define the module agruments.
390 MODULE_AUTHOR("Greg Ungerer");
391 MODULE_DESCRIPTION("Stallion Intelligent Multiport Serial Driver");
393 MODULE_PARM(board0
, "1-3s");
394 MODULE_PARM_DESC(board0
, "Board 0 config -> name[,ioaddr[,memaddr]");
395 MODULE_PARM(board1
, "1-3s");
396 MODULE_PARM_DESC(board1
, "Board 1 config -> name[,ioaddr[,memaddr]");
397 MODULE_PARM(board2
, "1-3s");
398 MODULE_PARM_DESC(board2
, "Board 2 config -> name[,ioaddr[,memaddr]");
399 MODULE_PARM(board3
, "1-3s");
400 MODULE_PARM_DESC(board3
, "Board 3 config -> name[,ioaddr[,memaddr]");
405 * Set up a default memory address table for EISA board probing.
406 * The default addresses are all bellow 1Mbyte, which has to be the
407 * case anyway. They should be safe, since we only read values from
408 * them, and interrupts are disabled while we do it. If the higher
409 * memory support is compiled in then we also try probing around
410 * the 1Gb, 2Gb and 3Gb areas as well...
412 static unsigned long stli_eisamemprobeaddrs
[] = {
413 0xc0000, 0xd0000, 0xe0000, 0xf0000,
414 0x80000000, 0x80010000, 0x80020000, 0x80030000,
415 0x40000000, 0x40010000, 0x40020000, 0x40030000,
416 0xc0000000, 0xc0010000, 0xc0020000, 0xc0030000,
417 0xff000000, 0xff010000, 0xff020000, 0xff030000,
420 static int stli_eisamempsize
= sizeof(stli_eisamemprobeaddrs
) / sizeof(unsigned long);
421 int stli_eisaprobe
= STLI_EISAPROBE
;
424 * Define the Stallion PCI vendor and device IDs.
427 #ifndef PCI_VENDOR_ID_STALLION
428 #define PCI_VENDOR_ID_STALLION 0x124d
430 #ifndef PCI_DEVICE_ID_ECRA
431 #define PCI_DEVICE_ID_ECRA 0x0004
435 /*****************************************************************************/
438 * Hardware configuration info for ECP boards. These defines apply
439 * to the directly accessible io ports of the ECP. There is a set of
440 * defines for each ECP board type, ISA, EISA, MCA and PCI.
444 #define ECP_MEMSIZE (128 * 1024)
445 #define ECP_PCIMEMSIZE (256 * 1024)
447 #define ECP_ATPAGESIZE (4 * 1024)
448 #define ECP_MCPAGESIZE (4 * 1024)
449 #define ECP_EIPAGESIZE (64 * 1024)
450 #define ECP_PCIPAGESIZE (64 * 1024)
452 #define STL_EISAID 0x8c4e
455 * Important defines for the ISA class of ECP board.
458 #define ECP_ATCONFR 1
459 #define ECP_ATMEMAR 2
460 #define ECP_ATMEMPR 3
461 #define ECP_ATSTOP 0x1
462 #define ECP_ATINTENAB 0x10
463 #define ECP_ATENABLE 0x20
464 #define ECP_ATDISABLE 0x00
465 #define ECP_ATADDRMASK 0x3f000
466 #define ECP_ATADDRSHFT 12
469 * Important defines for the EISA class of ECP board.
472 #define ECP_EIMEMARL 1
473 #define ECP_EICONFR 2
474 #define ECP_EIMEMARH 3
475 #define ECP_EIENABLE 0x1
476 #define ECP_EIDISABLE 0x0
477 #define ECP_EISTOP 0x4
478 #define ECP_EIEDGE 0x00
479 #define ECP_EILEVEL 0x80
480 #define ECP_EIADDRMASKL 0x00ff0000
481 #define ECP_EIADDRSHFTL 16
482 #define ECP_EIADDRMASKH 0xff000000
483 #define ECP_EIADDRSHFTH 24
484 #define ECP_EIBRDENAB 0xc84
486 #define ECP_EISAID 0x4
489 * Important defines for the Micro-channel class of ECP board.
490 * (It has a lot in common with the ISA boards.)
493 #define ECP_MCCONFR 1
494 #define ECP_MCSTOP 0x20
495 #define ECP_MCENABLE 0x80
496 #define ECP_MCDISABLE 0x00
499 * Important defines for the PCI class of ECP board.
500 * (It has a lot in common with the other ECP boards.)
502 #define ECP_PCIIREG 0
503 #define ECP_PCICONFR 1
504 #define ECP_PCISTOP 0x01
507 * Hardware configuration info for ONboard and Brumby boards. These
508 * defines apply to the directly accessible io ports of these boards.
510 #define ONB_IOSIZE 16
511 #define ONB_MEMSIZE (64 * 1024)
512 #define ONB_ATPAGESIZE (64 * 1024)
513 #define ONB_MCPAGESIZE (64 * 1024)
514 #define ONB_EIMEMSIZE (128 * 1024)
515 #define ONB_EIPAGESIZE (64 * 1024)
518 * Important defines for the ISA class of ONboard board.
521 #define ONB_ATMEMAR 1
522 #define ONB_ATCONFR 2
523 #define ONB_ATSTOP 0x4
524 #define ONB_ATENABLE 0x01
525 #define ONB_ATDISABLE 0x00
526 #define ONB_ATADDRMASK 0xff0000
527 #define ONB_ATADDRSHFT 16
529 #define ONB_MEMENABLO 0
530 #define ONB_MEMENABHI 0x02
533 * Important defines for the EISA class of ONboard board.
536 #define ONB_EIMEMARL 1
537 #define ONB_EICONFR 2
538 #define ONB_EIMEMARH 3
539 #define ONB_EIENABLE 0x1
540 #define ONB_EIDISABLE 0x0
541 #define ONB_EISTOP 0x4
542 #define ONB_EIEDGE 0x00
543 #define ONB_EILEVEL 0x80
544 #define ONB_EIADDRMASKL 0x00ff0000
545 #define ONB_EIADDRSHFTL 16
546 #define ONB_EIADDRMASKH 0xff000000
547 #define ONB_EIADDRSHFTH 24
548 #define ONB_EIBRDENAB 0xc84
550 #define ONB_EISAID 0x1
553 * Important defines for the Brumby boards. They are pretty simple,
554 * there is not much that is programmably configurable.
556 #define BBY_IOSIZE 16
557 #define BBY_MEMSIZE (64 * 1024)
558 #define BBY_PAGESIZE (16 * 1024)
561 #define BBY_ATCONFR 1
562 #define BBY_ATSTOP 0x4
565 * Important defines for the Stallion boards. They are pretty simple,
566 * there is not much that is programmably configurable.
568 #define STAL_IOSIZE 16
569 #define STAL_MEMSIZE (64 * 1024)
570 #define STAL_PAGESIZE (64 * 1024)
573 * Define the set of status register values for EasyConnection panels.
574 * The signature will return with the status value for each panel. From
575 * this we can determine what is attached to the board - before we have
576 * actually down loaded any code to it.
578 #define ECH_PNLSTATUS 2
579 #define ECH_PNL16PORT 0x20
580 #define ECH_PNLIDMASK 0x07
581 #define ECH_PNLXPID 0x40
582 #define ECH_PNLINTRPEND 0x80
585 * Define some macros to do things to the board. Even those these boards
586 * are somewhat related there is often significantly different ways of
587 * doing some operation on it (like enable, paging, reset, etc). So each
588 * board class has a set of functions which do the commonly required
589 * operations. The macros below basically just call these functions,
590 * generally checking for a NULL function - which means that the board
591 * needs nothing done to it to achieve this operation!
593 #define EBRDINIT(brdp) \
594 if (brdp->init != NULL) \
597 #define EBRDENABLE(brdp) \
598 if (brdp->enable != NULL) \
599 (* brdp->enable)(brdp);
601 #define EBRDDISABLE(brdp) \
602 if (brdp->disable != NULL) \
603 (* brdp->disable)(brdp);
605 #define EBRDINTR(brdp) \
606 if (brdp->intr != NULL) \
607 (* brdp->intr)(brdp);
609 #define EBRDRESET(brdp) \
610 if (brdp->reset != NULL) \
611 (* brdp->reset)(brdp);
613 #define EBRDGETMEMPTR(brdp,offset) \
614 (* brdp->getmemptr)(brdp, offset, __LINE__)
617 * Define the maximal baud rate, and the default baud base for ports.
619 #define STL_MAXBAUD 460800
620 #define STL_BAUDBASE 115200
621 #define STL_CLOSEDELAY (5 * HZ / 10)
623 /*****************************************************************************/
626 * Define macros to extract a brd or port number from a minor number.
628 #define MINOR2BRD(min) (((min) & 0xc0) >> 6)
629 #define MINOR2PORT(min) ((min) & 0x3f)
632 * Define a baud rate table that converts termios baud rate selector
633 * into the actual baud rate value. All baud rate calculations are based
634 * on the actual baud rate required.
636 static unsigned int stli_baudrates
[] = {
637 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
638 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
641 /*****************************************************************************/
644 * Define some handy local macros...
647 #define MIN(a,b) (((a) <= (b)) ? (a) : (b))
650 #define TOLOWER(x) ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x))
652 /*****************************************************************************/
655 * Prototype all functions in this driver!
659 int init_module(void);
660 void cleanup_module(void);
661 static void stli_argbrds(void);
662 static int stli_parsebrd(stlconf_t
*confp
, char **argp
);
664 static unsigned long stli_atol(char *str
);
668 static int stli_open(struct tty_struct
*tty
, struct file
*filp
);
669 static void stli_close(struct tty_struct
*tty
, struct file
*filp
);
670 static int stli_write(struct tty_struct
*tty
, int from_user
, const unsigned char *buf
, int count
);
671 static void stli_putchar(struct tty_struct
*tty
, unsigned char ch
);
672 static void stli_flushchars(struct tty_struct
*tty
);
673 static int stli_writeroom(struct tty_struct
*tty
);
674 static int stli_charsinbuffer(struct tty_struct
*tty
);
675 static int stli_ioctl(struct tty_struct
*tty
, struct file
*file
, unsigned int cmd
, unsigned long arg
);
676 static void stli_settermios(struct tty_struct
*tty
, struct termios
*old
);
677 static void stli_throttle(struct tty_struct
*tty
);
678 static void stli_unthrottle(struct tty_struct
*tty
);
679 static void stli_stop(struct tty_struct
*tty
);
680 static void stli_start(struct tty_struct
*tty
);
681 static void stli_flushbuffer(struct tty_struct
*tty
);
682 static void stli_breakctl(struct tty_struct
*tty
, int state
);
683 static void stli_waituntilsent(struct tty_struct
*tty
, int timeout
);
684 static void stli_sendxchar(struct tty_struct
*tty
, char ch
);
685 static void stli_hangup(struct tty_struct
*tty
);
686 static int stli_portinfo(stlibrd_t
*brdp
, stliport_t
*portp
, int portnr
, char *pos
);
688 static int stli_brdinit(stlibrd_t
*brdp
);
689 static int stli_startbrd(stlibrd_t
*brdp
);
690 static int stli_memopen(struct inode
*ip
, struct file
*fp
);
691 static int stli_memclose(struct inode
*ip
, struct file
*fp
);
692 static ssize_t
stli_memread(struct file
*fp
, char *buf
, size_t count
, loff_t
*offp
);
693 static ssize_t
stli_memwrite(struct file
*fp
, const char *buf
, size_t count
, loff_t
*offp
);
694 static int stli_memioctl(struct inode
*ip
, struct file
*fp
, unsigned int cmd
, unsigned long arg
);
695 static void stli_brdpoll(stlibrd_t
*brdp
, volatile cdkhdr_t
*hdrp
);
696 static void stli_poll(unsigned long arg
);
697 static int stli_hostcmd(stlibrd_t
*brdp
, stliport_t
*portp
);
698 static int stli_initopen(stlibrd_t
*brdp
, stliport_t
*portp
);
699 static int stli_rawopen(stlibrd_t
*brdp
, stliport_t
*portp
, unsigned long arg
, int wait
);
700 static int stli_rawclose(stlibrd_t
*brdp
, stliport_t
*portp
, unsigned long arg
, int wait
);
701 static int stli_waitcarrier(stlibrd_t
*brdp
, stliport_t
*portp
, struct file
*filp
);
702 static void stli_dohangup(void *arg
);
703 static void stli_delay(int len
);
704 static int stli_setport(stliport_t
*portp
);
705 static int stli_cmdwait(stlibrd_t
*brdp
, stliport_t
*portp
, unsigned long cmd
, void *arg
, int size
, int copyback
);
706 static void stli_sendcmd(stlibrd_t
*brdp
, stliport_t
*portp
, unsigned long cmd
, void *arg
, int size
, int copyback
);
707 static void stli_dodelaycmd(stliport_t
*portp
, volatile cdkctrl_t
*cp
);
708 static void stli_mkasyport(stliport_t
*portp
, asyport_t
*pp
, struct termios
*tiosp
);
709 static void stli_mkasysigs(asysigs_t
*sp
, int dtr
, int rts
);
710 static long stli_mktiocm(unsigned long sigvalue
);
711 static void stli_read(stlibrd_t
*brdp
, stliport_t
*portp
);
712 static void stli_getserial(stliport_t
*portp
, struct serial_struct
*sp
);
713 static int stli_setserial(stliport_t
*portp
, struct serial_struct
*sp
);
714 static int stli_getbrdstats(combrd_t
*bp
);
715 static int stli_getportstats(stliport_t
*portp
, comstats_t
*cp
);
716 static int stli_portcmdstats(stliport_t
*portp
);
717 static int stli_clrportstats(stliport_t
*portp
, comstats_t
*cp
);
718 static int stli_getportstruct(unsigned long arg
);
719 static int stli_getbrdstruct(unsigned long arg
);
720 static void *stli_memalloc(int len
);
721 static stlibrd_t
*stli_allocbrd(void);
723 static void stli_ecpinit(stlibrd_t
*brdp
);
724 static void stli_ecpenable(stlibrd_t
*brdp
);
725 static void stli_ecpdisable(stlibrd_t
*brdp
);
726 static char *stli_ecpgetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
);
727 static void stli_ecpreset(stlibrd_t
*brdp
);
728 static void stli_ecpintr(stlibrd_t
*brdp
);
729 static void stli_ecpeiinit(stlibrd_t
*brdp
);
730 static void stli_ecpeienable(stlibrd_t
*brdp
);
731 static void stli_ecpeidisable(stlibrd_t
*brdp
);
732 static char *stli_ecpeigetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
);
733 static void stli_ecpeireset(stlibrd_t
*brdp
);
734 static void stli_ecpmcenable(stlibrd_t
*brdp
);
735 static void stli_ecpmcdisable(stlibrd_t
*brdp
);
736 static char *stli_ecpmcgetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
);
737 static void stli_ecpmcreset(stlibrd_t
*brdp
);
738 static void stli_ecppciinit(stlibrd_t
*brdp
);
739 static char *stli_ecppcigetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
);
740 static void stli_ecppcireset(stlibrd_t
*brdp
);
742 static void stli_onbinit(stlibrd_t
*brdp
);
743 static void stli_onbenable(stlibrd_t
*brdp
);
744 static void stli_onbdisable(stlibrd_t
*brdp
);
745 static char *stli_onbgetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
);
746 static void stli_onbreset(stlibrd_t
*brdp
);
747 static void stli_onbeinit(stlibrd_t
*brdp
);
748 static void stli_onbeenable(stlibrd_t
*brdp
);
749 static void stli_onbedisable(stlibrd_t
*brdp
);
750 static char *stli_onbegetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
);
751 static void stli_onbereset(stlibrd_t
*brdp
);
752 static void stli_bbyinit(stlibrd_t
*brdp
);
753 static char *stli_bbygetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
);
754 static void stli_bbyreset(stlibrd_t
*brdp
);
755 static void stli_stalinit(stlibrd_t
*brdp
);
756 static char *stli_stalgetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
);
757 static void stli_stalreset(stlibrd_t
*brdp
);
759 static stliport_t
*stli_getport(int brdnr
, int panelnr
, int portnr
);
761 static inline int stli_initbrds(void);
762 static inline int stli_initecp(stlibrd_t
*brdp
);
763 static inline int stli_initonb(stlibrd_t
*brdp
);
764 static inline int stli_findeisabrds(void);
765 static inline int stli_eisamemprobe(stlibrd_t
*brdp
);
766 static inline int stli_initports(stlibrd_t
*brdp
);
767 static inline int stli_getbrdnr(void);
770 static inline int stli_findpcibrds(void);
771 static inline int stli_initpcibrd(int brdtype
, struct pci_dev
*devp
);
774 /*****************************************************************************/
777 * Define the driver info for a user level shared memory device. This
778 * device will work sort of like the /dev/kmem device - except that it
779 * will give access to the shared memory on the Stallion intelligent
780 * board. This is also a very useful debugging tool.
782 static struct file_operations stli_fsiomem
= {
784 write
: stli_memwrite
,
785 ioctl
: stli_memioctl
,
787 release
: stli_memclose
,
790 /*****************************************************************************/
793 * Define a timer_list entry for our poll routine. The slave board
794 * is polled every so often to see if anything needs doing. This is
795 * much cheaper on host cpu than using interrupts. It turns out to
796 * not increase character latency by much either...
798 static struct timer_list stli_timerlist
= {
799 NULL
, NULL
, 0, 0, stli_poll
802 static int stli_timeron
= 0;
805 * Define the calculation for the timeout routine.
807 #define STLI_TIMEOUT (jiffies + 1)
809 /*****************************************************************************/
814 * Loadable module initialization stuff.
822 printk("init_module()\n");
828 restore_flags(flags
);
833 /*****************************************************************************/
835 void cleanup_module()
843 printk("cleanup_module()\n");
846 printk(KERN_INFO
"Unloading %s: version %s\n", stli_drvtitle
,
853 * Free up all allocated resources used by the ports. This includes
854 * memory and interrupts.
858 del_timer(&stli_timerlist
);
861 i
= tty_unregister_driver(&stli_serial
);
862 j
= tty_unregister_driver(&stli_callout
);
864 printk("STALLION: failed to un-register tty driver, "
865 "errno=%d,%d\n", -i
, -j
);
866 restore_flags(flags
);
869 devfs_unregister (devfs_handle
);
870 if ((i
= devfs_unregister_chrdev(STL_SIOMEMMAJOR
, "staliomem")))
871 printk("STALLION: failed to un-register serial memory device, "
873 if (stli_tmpwritebuf
!= (char *) NULL
)
874 kfree_s(stli_tmpwritebuf
, STLI_TXBUFSIZE
);
875 if (stli_txcookbuf
!= (char *) NULL
)
876 kfree_s(stli_txcookbuf
, STLI_TXBUFSIZE
);
878 for (i
= 0; (i
< stli_nrbrds
); i
++) {
879 if ((brdp
= stli_brds
[i
]) == (stlibrd_t
*) NULL
)
881 for (j
= 0; (j
< STL_MAXPORTS
); j
++) {
882 portp
= brdp
->ports
[j
];
883 if (portp
!= (stliport_t
*) NULL
) {
884 if (portp
->tty
!= (struct tty_struct
*) NULL
)
885 tty_hangup(portp
->tty
);
886 kfree_s(portp
, sizeof(stliport_t
));
890 iounmap(brdp
->membase
);
891 if (brdp
->iosize
> 0)
892 release_region(brdp
->iobase
, brdp
->iosize
);
893 kfree_s(brdp
, sizeof(stlibrd_t
));
894 stli_brds
[i
] = (stlibrd_t
*) NULL
;
897 restore_flags(flags
);
900 /*****************************************************************************/
903 * Check for any arguments passed in on the module load command line.
906 static void stli_argbrds()
913 printk("stli_argbrds()\n");
916 nrargs
= sizeof(stli_brdsp
) / sizeof(char **);
918 for (i
= stli_nrbrds
; (i
< nrargs
); i
++) {
919 memset(&conf
, 0, sizeof(conf
));
920 if (stli_parsebrd(&conf
, stli_brdsp
[i
]) == 0)
922 if ((brdp
= stli_allocbrd()) == (stlibrd_t
*) NULL
)
926 brdp
->brdtype
= conf
.brdtype
;
927 brdp
->iobase
= conf
.ioaddr1
;
928 brdp
->memaddr
= conf
.memaddr
;
933 /*****************************************************************************/
936 * Convert an ascii string number into an unsigned long.
939 static unsigned long stli_atol(char *str
)
947 if ((*sp
== '0') && (*(sp
+1) == 'x')) {
950 } else if (*sp
== '0') {
957 for (; (*sp
!= 0); sp
++) {
958 c
= (*sp
> '9') ? (TOLOWER(*sp
) - 'a' + 10) : (*sp
- '0');
959 if ((c
< 0) || (c
>= base
)) {
960 printk("STALLION: invalid argument %s\n", str
);
964 val
= (val
* base
) + c
;
969 /*****************************************************************************/
972 * Parse the supplied argument string, into the board conf struct.
975 static int stli_parsebrd(stlconf_t
*confp
, char **argp
)
981 printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp
, (int) argp
);
984 if ((argp
[0] == (char *) NULL
) || (*argp
[0] == 0))
987 for (sp
= argp
[0], i
= 0; ((*sp
!= 0) && (i
< 25)); sp
++, i
++)
990 nrbrdnames
= sizeof(stli_brdstr
) / sizeof(stlibrdtype_t
);
991 for (i
= 0; (i
< nrbrdnames
); i
++) {
992 if (strcmp(stli_brdstr
[i
].name
, argp
[0]) == 0)
995 if (i
>= nrbrdnames
) {
996 printk("STALLION: unknown board name, %s?\n", argp
[0]);
1000 confp
->brdtype
= stli_brdstr
[i
].type
;
1001 if ((argp
[1] != (char *) NULL
) && (*argp
[1] != 0))
1002 confp
->ioaddr1
= stli_atol(argp
[1]);
1003 if ((argp
[2] != (char *) NULL
) && (*argp
[2] != 0))
1004 confp
->memaddr
= stli_atol(argp
[2]);
1010 /*****************************************************************************/
1013 * Local driver kernel malloc routine.
1016 static void *stli_memalloc(int len
)
1018 return((void *) kmalloc(len
, GFP_KERNEL
));
1021 /*****************************************************************************/
1023 static int stli_open(struct tty_struct
*tty
, struct file
*filp
)
1027 unsigned int minordev
;
1028 int brdnr
, portnr
, rc
;
1031 printk("stli_open(tty=%x,filp=%x): device=%x\n", (int) tty
,
1032 (int) filp
, tty
->device
);
1035 minordev
= MINOR(tty
->device
);
1036 brdnr
= MINOR2BRD(minordev
);
1037 if (brdnr
>= stli_nrbrds
)
1039 brdp
= stli_brds
[brdnr
];
1040 if (brdp
== (stlibrd_t
*) NULL
)
1042 if ((brdp
->state
& BST_STARTED
) == 0)
1044 portnr
= MINOR2PORT(minordev
);
1045 if ((portnr
< 0) || (portnr
> brdp
->nrports
))
1048 portp
= brdp
->ports
[portnr
];
1049 if (portp
== (stliport_t
*) NULL
)
1051 if (portp
->devnr
< 1)
1057 * Check if this port is in the middle of closing. If so then wait
1058 * until it is closed then return error status based on flag settings.
1059 * The sleep here does not need interrupt protection since the wakeup
1060 * for it is done with the same context.
1062 if (portp
->flags
& ASYNC_CLOSING
) {
1063 interruptible_sleep_on(&portp
->close_wait
);
1064 if (portp
->flags
& ASYNC_HUP_NOTIFY
)
1066 return(-ERESTARTSYS
);
1070 * On the first open of the device setup the port hardware, and
1071 * initialize the per port data structure. Since initializing the port
1072 * requires several commands to the board we will need to wait for any
1073 * other open that is already initializing the port.
1076 tty
->driver_data
= portp
;
1079 while (test_bit(ST_INITIALIZING
, &portp
->state
)) {
1080 if (signal_pending(current
))
1081 return(-ERESTARTSYS
);
1082 interruptible_sleep_on(&portp
->raw_wait
);
1085 if ((portp
->flags
& ASYNC_INITIALIZED
) == 0) {
1086 set_bit(ST_INITIALIZING
, &portp
->state
);
1087 if ((rc
= stli_initopen(brdp
, portp
)) >= 0) {
1088 portp
->flags
|= ASYNC_INITIALIZED
;
1089 clear_bit(TTY_IO_ERROR
, &tty
->flags
);
1091 clear_bit(ST_INITIALIZING
, &portp
->state
);
1092 wake_up_interruptible(&portp
->raw_wait
);
1098 * Check if this port is in the middle of closing. If so then wait
1099 * until it is closed then return error status, based on flag settings.
1100 * The sleep here does not need interrupt protection since the wakeup
1101 * for it is done with the same context.
1103 if (portp
->flags
& ASYNC_CLOSING
) {
1104 interruptible_sleep_on(&portp
->close_wait
);
1105 if (portp
->flags
& ASYNC_HUP_NOTIFY
)
1107 return(-ERESTARTSYS
);
1111 * Based on type of open being done check if it can overlap with any
1112 * previous opens still in effect. If we are a normal serial device
1113 * then also we might have to wait for carrier.
1115 if (tty
->driver
.subtype
== STL_DRVTYPCALLOUT
) {
1116 if (portp
->flags
& ASYNC_NORMAL_ACTIVE
)
1118 if (portp
->flags
& ASYNC_CALLOUT_ACTIVE
) {
1119 if ((portp
->flags
& ASYNC_SESSION_LOCKOUT
) &&
1120 (portp
->session
!= current
->session
))
1122 if ((portp
->flags
& ASYNC_PGRP_LOCKOUT
) &&
1123 (portp
->pgrp
!= current
->pgrp
))
1126 portp
->flags
|= ASYNC_CALLOUT_ACTIVE
;
1128 if (filp
->f_flags
& O_NONBLOCK
) {
1129 if (portp
->flags
& ASYNC_CALLOUT_ACTIVE
)
1132 if ((rc
= stli_waitcarrier(brdp
, portp
, filp
)) != 0)
1135 portp
->flags
|= ASYNC_NORMAL_ACTIVE
;
1138 if ((portp
->refcount
== 1) && (portp
->flags
& ASYNC_SPLIT_TERMIOS
)) {
1139 if (tty
->driver
.subtype
== STL_DRVTYPSERIAL
)
1140 *tty
->termios
= portp
->normaltermios
;
1142 *tty
->termios
= portp
->callouttermios
;
1143 stli_setport(portp
);
1146 portp
->session
= current
->session
;
1147 portp
->pgrp
= current
->pgrp
;
1151 /*****************************************************************************/
1153 static void stli_close(struct tty_struct
*tty
, struct file
*filp
)
1157 unsigned long flags
;
1160 printk("stli_close(tty=%x,filp=%x)\n", (int) tty
, (int) filp
);
1163 portp
= tty
->driver_data
;
1164 if (portp
== (stliport_t
*) NULL
)
1169 if (tty_hung_up_p(filp
)) {
1171 restore_flags(flags
);
1174 if ((tty
->count
== 1) && (portp
->refcount
!= 1))
1175 portp
->refcount
= 1;
1176 if (portp
->refcount
-- > 1) {
1178 restore_flags(flags
);
1182 portp
->flags
|= ASYNC_CLOSING
;
1184 if (portp
->flags
& ASYNC_NORMAL_ACTIVE
)
1185 portp
->normaltermios
= *tty
->termios
;
1186 if (portp
->flags
& ASYNC_CALLOUT_ACTIVE
)
1187 portp
->callouttermios
= *tty
->termios
;
1190 * May want to wait for data to drain before closing. The BUSY flag
1191 * keeps track of whether we are still transmitting or not. It is
1192 * updated by messages from the slave - indicating when all chars
1193 * really have drained.
1195 if (tty
== stli_txcooktty
)
1196 stli_flushchars(tty
);
1198 if (portp
->closing_wait
!= ASYNC_CLOSING_WAIT_NONE
)
1199 tty_wait_until_sent(tty
, portp
->closing_wait
);
1201 portp
->flags
&= ~ASYNC_INITIALIZED
;
1202 brdp
= stli_brds
[portp
->brdnr
];
1203 stli_rawclose(brdp
, portp
, 0, 0);
1204 if (tty
->termios
->c_cflag
& HUPCL
) {
1205 stli_mkasysigs(&portp
->asig
, 0, 0);
1206 if (test_bit(ST_CMDING
, &portp
->state
))
1207 set_bit(ST_DOSIGS
, &portp
->state
);
1209 stli_sendcmd(brdp
, portp
, A_SETSIGNALS
, &portp
->asig
,
1210 sizeof(asysigs_t
), 0);
1212 clear_bit(ST_TXBUSY
, &portp
->state
);
1213 clear_bit(ST_RXSTOP
, &portp
->state
);
1214 set_bit(TTY_IO_ERROR
, &tty
->flags
);
1215 if (tty
->ldisc
.flush_buffer
)
1216 (tty
->ldisc
.flush_buffer
)(tty
);
1217 set_bit(ST_DOFLUSHRX
, &portp
->state
);
1218 stli_flushbuffer(tty
);
1221 portp
->tty
= (struct tty_struct
*) NULL
;
1223 if (portp
->openwaitcnt
) {
1224 if (portp
->close_delay
)
1225 stli_delay(portp
->close_delay
);
1226 wake_up_interruptible(&portp
->open_wait
);
1229 portp
->flags
&= ~(ASYNC_CALLOUT_ACTIVE
| ASYNC_NORMAL_ACTIVE
|
1231 wake_up_interruptible(&portp
->close_wait
);
1233 restore_flags(flags
);
1236 /*****************************************************************************/
1239 * Carry out first open operations on a port. This involves a number of
1240 * commands to be sent to the slave. We need to open the port, set the
1241 * notification events, set the initial port settings, get and set the
1242 * initial signal values. We sleep and wait in between each one. But
1243 * this still all happens pretty quickly.
1246 static int stli_initopen(stlibrd_t
*brdp
, stliport_t
*portp
)
1248 struct tty_struct
*tty
;
1254 printk("stli_initopen(brdp=%x,portp=%x)\n", (int) brdp
, (int) portp
);
1257 if ((rc
= stli_rawopen(brdp
, portp
, 0, 1)) < 0)
1260 memset(&nt
, 0, sizeof(asynotify_t
));
1261 nt
.data
= (DT_TXLOW
| DT_TXEMPTY
| DT_RXBUSY
| DT_RXBREAK
);
1263 if ((rc
= stli_cmdwait(brdp
, portp
, A_SETNOTIFY
, &nt
,
1264 sizeof(asynotify_t
), 0)) < 0)
1268 if (tty
== (struct tty_struct
*) NULL
)
1270 stli_mkasyport(portp
, &aport
, tty
->termios
);
1271 if ((rc
= stli_cmdwait(brdp
, portp
, A_SETPORT
, &aport
,
1272 sizeof(asyport_t
), 0)) < 0)
1275 set_bit(ST_GETSIGS
, &portp
->state
);
1276 if ((rc
= stli_cmdwait(brdp
, portp
, A_GETSIGNALS
, &portp
->asig
,
1277 sizeof(asysigs_t
), 1)) < 0)
1279 if (test_and_clear_bit(ST_GETSIGS
, &portp
->state
))
1280 portp
->sigs
= stli_mktiocm(portp
->asig
.sigvalue
);
1281 stli_mkasysigs(&portp
->asig
, 1, 1);
1282 if ((rc
= stli_cmdwait(brdp
, portp
, A_SETSIGNALS
, &portp
->asig
,
1283 sizeof(asysigs_t
), 0)) < 0)
1289 /*****************************************************************************/
1292 * Send an open message to the slave. This will sleep waiting for the
1293 * acknowledgement, so must have user context. We need to co-ordinate
1294 * with close events here, since we don't want open and close events
1298 static int stli_rawopen(stlibrd_t
*brdp
, stliport_t
*portp
, unsigned long arg
, int wait
)
1300 volatile cdkhdr_t
*hdrp
;
1301 volatile cdkctrl_t
*cp
;
1302 volatile unsigned char *bits
;
1303 unsigned long flags
;
1307 printk("stli_rawopen(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1308 (int) brdp
, (int) portp
, (int) arg
, wait
);
1312 * Send a message to the slave to open this port.
1318 * Slave is already closing this port. This can happen if a hangup
1319 * occurs on this port. So we must wait until it is complete. The
1320 * order of opens and closes may not be preserved across shared
1321 * memory, so we must wait until it is complete.
1323 while (test_bit(ST_CLOSING
, &portp
->state
)) {
1324 if (signal_pending(current
)) {
1325 restore_flags(flags
);
1326 return(-ERESTARTSYS
);
1328 interruptible_sleep_on(&portp
->raw_wait
);
1332 * Everything is ready now, so write the open message into shared
1333 * memory. Once the message is in set the service bits to say that
1334 * this port wants service.
1337 cp
= &((volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
))->ctrl
;
1340 hdrp
= (volatile cdkhdr_t
*) EBRDGETMEMPTR(brdp
, CDK_CDKADDR
);
1341 bits
= ((volatile unsigned char *) hdrp
) + brdp
->slaveoffset
+
1343 *bits
|= portp
->portbit
;
1347 restore_flags(flags
);
1352 * Slave is in action, so now we must wait for the open acknowledgment
1356 set_bit(ST_OPENING
, &portp
->state
);
1357 while (test_bit(ST_OPENING
, &portp
->state
)) {
1358 if (signal_pending(current
)) {
1362 interruptible_sleep_on(&portp
->raw_wait
);
1364 restore_flags(flags
);
1366 if ((rc
== 0) && (portp
->rc
!= 0))
1371 /*****************************************************************************/
1374 * Send a close message to the slave. Normally this will sleep waiting
1375 * for the acknowledgement, but if wait parameter is 0 it will not. If
1376 * wait is true then must have user context (to sleep).
1379 static int stli_rawclose(stlibrd_t
*brdp
, stliport_t
*portp
, unsigned long arg
, int wait
)
1381 volatile cdkhdr_t
*hdrp
;
1382 volatile cdkctrl_t
*cp
;
1383 volatile unsigned char *bits
;
1384 unsigned long flags
;
1388 printk("stli_rawclose(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1389 (int) brdp
, (int) portp
, (int) arg
, wait
);
1396 * Slave is already closing this port. This can happen if a hangup
1397 * occurs on this port.
1400 while (test_bit(ST_CLOSING
, &portp
->state
)) {
1401 if (signal_pending(current
)) {
1402 restore_flags(flags
);
1403 return(-ERESTARTSYS
);
1405 interruptible_sleep_on(&portp
->raw_wait
);
1410 * Write the close command into shared memory.
1413 cp
= &((volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
))->ctrl
;
1416 hdrp
= (volatile cdkhdr_t
*) EBRDGETMEMPTR(brdp
, CDK_CDKADDR
);
1417 bits
= ((volatile unsigned char *) hdrp
) + brdp
->slaveoffset
+
1419 *bits
|= portp
->portbit
;
1422 set_bit(ST_CLOSING
, &portp
->state
);
1424 restore_flags(flags
);
1429 * Slave is in action, so now we must wait for the open acknowledgment
1433 while (test_bit(ST_CLOSING
, &portp
->state
)) {
1434 if (signal_pending(current
)) {
1438 interruptible_sleep_on(&portp
->raw_wait
);
1440 restore_flags(flags
);
1442 if ((rc
== 0) && (portp
->rc
!= 0))
1447 /*****************************************************************************/
1450 * Send a command to the slave and wait for the response. This must
1451 * have user context (it sleeps). This routine is generic in that it
1452 * can send any type of command. Its purpose is to wait for that command
1453 * to complete (as opposed to initiating the command then returning).
1456 static int stli_cmdwait(stlibrd_t
*brdp
, stliport_t
*portp
, unsigned long cmd
, void *arg
, int size
, int copyback
)
1458 unsigned long flags
;
1461 printk("stli_cmdwait(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
1462 "copyback=%d)\n", (int) brdp
, (int) portp
, (int) cmd
,
1463 (int) arg
, size
, copyback
);
1468 while (test_bit(ST_CMDING
, &portp
->state
)) {
1469 if (signal_pending(current
)) {
1470 restore_flags(flags
);
1471 return(-ERESTARTSYS
);
1473 interruptible_sleep_on(&portp
->raw_wait
);
1476 stli_sendcmd(brdp
, portp
, cmd
, arg
, size
, copyback
);
1478 while (test_bit(ST_CMDING
, &portp
->state
)) {
1479 if (signal_pending(current
)) {
1480 restore_flags(flags
);
1481 return(-ERESTARTSYS
);
1483 interruptible_sleep_on(&portp
->raw_wait
);
1485 restore_flags(flags
);
1492 /*****************************************************************************/
1495 * Send the termios settings for this port to the slave. This sleeps
1496 * waiting for the command to complete - so must have user context.
1499 static int stli_setport(stliport_t
*portp
)
1505 printk("stli_setport(portp=%x)\n", (int) portp
);
1508 if (portp
== (stliport_t
*) NULL
)
1510 if (portp
->tty
== (struct tty_struct
*) NULL
)
1512 if ((portp
->brdnr
< 0) && (portp
->brdnr
>= stli_nrbrds
))
1514 brdp
= stli_brds
[portp
->brdnr
];
1515 if (brdp
== (stlibrd_t
*) NULL
)
1518 stli_mkasyport(portp
, &aport
, portp
->tty
->termios
);
1519 return(stli_cmdwait(brdp
, portp
, A_SETPORT
, &aport
, sizeof(asyport_t
), 0));
1522 /*****************************************************************************/
1525 * Wait for a specified delay period, this is not a busy-loop. It will
1526 * give up the processor while waiting. Unfortunately this has some
1527 * rather intimate knowledge of the process management stuff.
1530 static void stli_delay(int len
)
1533 printk("stli_delay(len=%d)\n", len
);
1536 current
->state
= TASK_INTERRUPTIBLE
;
1537 schedule_timeout(len
);
1538 current
->state
= TASK_RUNNING
;
1542 /*****************************************************************************/
1545 * Possibly need to wait for carrier (DCD signal) to come high. Say
1546 * maybe because if we are clocal then we don't need to wait...
1549 static int stli_waitcarrier(stlibrd_t
*brdp
, stliport_t
*portp
, struct file
*filp
)
1551 unsigned long flags
;
1555 printk("stli_waitcarrier(brdp=%x,portp=%x,filp=%x)\n",
1556 (int) brdp
, (int) portp
, (int) filp
);
1562 if (portp
->flags
& ASYNC_CALLOUT_ACTIVE
) {
1563 if (portp
->normaltermios
.c_cflag
& CLOCAL
)
1566 if (portp
->tty
->termios
->c_cflag
& CLOCAL
)
1572 portp
->openwaitcnt
++;
1573 if (! tty_hung_up_p(filp
))
1577 if ((portp
->flags
& ASYNC_CALLOUT_ACTIVE
) == 0) {
1578 stli_mkasysigs(&portp
->asig
, 1, 1);
1579 if ((rc
= stli_cmdwait(brdp
, portp
, A_SETSIGNALS
,
1580 &portp
->asig
, sizeof(asysigs_t
), 0)) < 0)
1583 if (tty_hung_up_p(filp
) ||
1584 ((portp
->flags
& ASYNC_INITIALIZED
) == 0)) {
1585 if (portp
->flags
& ASYNC_HUP_NOTIFY
)
1591 if (((portp
->flags
& ASYNC_CALLOUT_ACTIVE
) == 0) &&
1592 ((portp
->flags
& ASYNC_CLOSING
) == 0) &&
1593 (doclocal
|| (portp
->sigs
& TIOCM_CD
))) {
1596 if (signal_pending(current
)) {
1600 interruptible_sleep_on(&portp
->open_wait
);
1603 if (! tty_hung_up_p(filp
))
1605 portp
->openwaitcnt
--;
1606 restore_flags(flags
);
1611 /*****************************************************************************/
1614 * Write routine. Take the data and put it in the shared memory ring
1615 * queue. If port is not already sending chars then need to mark the
1616 * service bits for this port.
1619 static int stli_write(struct tty_struct
*tty
, int from_user
, const unsigned char *buf
, int count
)
1621 volatile cdkasy_t
*ap
;
1622 volatile cdkhdr_t
*hdrp
;
1623 volatile unsigned char *bits
;
1624 unsigned char *shbuf
, *chbuf
;
1627 unsigned int len
, stlen
, head
, tail
, size
;
1628 unsigned long flags
;
1631 printk("stli_write(tty=%x,from_user=%d,buf=%x,count=%d)\n",
1632 (int) tty
, from_user
, (int) buf
, count
);
1635 if ((tty
== (struct tty_struct
*) NULL
) ||
1636 (stli_tmpwritebuf
== (char *) NULL
))
1638 if (tty
== stli_txcooktty
)
1639 stli_flushchars(tty
);
1640 portp
= tty
->driver_data
;
1641 if (portp
== (stliport_t
*) NULL
)
1643 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
1645 brdp
= stli_brds
[portp
->brdnr
];
1646 if (brdp
== (stlibrd_t
*) NULL
)
1648 chbuf
= (unsigned char *) buf
;
1651 * If copying direct from user space we need to be able to handle page
1652 * faults while we are copying. To do this copy as much as we can now
1653 * into a kernel buffer. From there we copy it into shared memory. The
1654 * big problem is that we do not want shared memory enabled when we are
1655 * sleeping (other boards may be serviced while asleep). Something else
1656 * to note here is the reading of the tail twice. Since the boards
1657 * shared memory can be on an 8-bit bus then we need to be very careful
1658 * reading 16 bit quantities - since both the board (slave) and host
1659 * could be writing and reading at the same time.
1665 ap
= (volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
);
1666 head
= (unsigned int) ap
->txq
.head
;
1667 tail
= (unsigned int) ap
->txq
.tail
;
1668 if (tail
!= ((unsigned int) ap
->txq
.tail
))
1669 tail
= (unsigned int) ap
->txq
.tail
;
1670 len
= (head
>= tail
) ? (portp
->txsize
- (head
- tail
) - 1) :
1672 count
= MIN(len
, count
);
1674 restore_flags(flags
);
1676 down(&stli_tmpwritesem
);
1677 copy_from_user(stli_tmpwritebuf
, chbuf
, count
);
1678 chbuf
= &stli_tmpwritebuf
[0];
1682 * All data is now local, shove as much as possible into shared memory.
1687 ap
= (volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
);
1688 head
= (unsigned int) ap
->txq
.head
;
1689 tail
= (unsigned int) ap
->txq
.tail
;
1690 if (tail
!= ((unsigned int) ap
->txq
.tail
))
1691 tail
= (unsigned int) ap
->txq
.tail
;
1692 size
= portp
->txsize
;
1694 len
= size
- (head
- tail
) - 1;
1695 stlen
= size
- head
;
1697 len
= tail
- head
- 1;
1701 len
= MIN(len
, count
);
1703 shbuf
= (char *) EBRDGETMEMPTR(brdp
, portp
->txoffset
);
1706 stlen
= MIN(len
, stlen
);
1707 memcpy((shbuf
+ head
), chbuf
, stlen
);
1718 ap
= (volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
);
1719 ap
->txq
.head
= head
;
1720 if (test_bit(ST_TXBUSY
, &portp
->state
)) {
1721 if (ap
->changed
.data
& DT_TXEMPTY
)
1722 ap
->changed
.data
&= ~DT_TXEMPTY
;
1724 hdrp
= (volatile cdkhdr_t
*) EBRDGETMEMPTR(brdp
, CDK_CDKADDR
);
1725 bits
= ((volatile unsigned char *) hdrp
) + brdp
->slaveoffset
+
1727 *bits
|= portp
->portbit
;
1728 set_bit(ST_TXBUSY
, &portp
->state
);
1732 up(&stli_tmpwritesem
);
1733 restore_flags(flags
);
1738 /*****************************************************************************/
1741 * Output a single character. We put it into a temporary local buffer
1742 * (for speed) then write out that buffer when the flushchars routine
1743 * is called. There is a safety catch here so that if some other port
1744 * writes chars before the current buffer has been, then we write them
1745 * first them do the new ports.
1748 static void stli_putchar(struct tty_struct
*tty
, unsigned char ch
)
1751 printk("stli_putchar(tty=%x,ch=%x)\n", (int) tty
, (int) ch
);
1754 if (tty
== (struct tty_struct
*) NULL
)
1756 if (tty
!= stli_txcooktty
) {
1757 if (stli_txcooktty
!= (struct tty_struct
*) NULL
)
1758 stli_flushchars(stli_txcooktty
);
1759 stli_txcooktty
= tty
;
1762 stli_txcookbuf
[stli_txcooksize
++] = ch
;
1765 /*****************************************************************************/
1768 * Transfer characters from the local TX cooking buffer to the board.
1769 * We sort of ignore the tty that gets passed in here. We rely on the
1770 * info stored with the TX cook buffer to tell us which port to flush
1771 * the data on. In any case we clean out the TX cook buffer, for re-use
1775 static void stli_flushchars(struct tty_struct
*tty
)
1777 volatile cdkhdr_t
*hdrp
;
1778 volatile unsigned char *bits
;
1779 volatile cdkasy_t
*ap
;
1780 struct tty_struct
*cooktty
;
1783 unsigned int len
, stlen
, head
, tail
, size
, count
, cooksize
;
1784 unsigned char *buf
, *shbuf
;
1785 unsigned long flags
;
1788 printk("stli_flushchars(tty=%x)\n", (int) tty
);
1791 cooksize
= stli_txcooksize
;
1792 cooktty
= stli_txcooktty
;
1793 stli_txcooksize
= 0;
1794 stli_txcookrealsize
= 0;
1795 stli_txcooktty
= (struct tty_struct
*) NULL
;
1797 if (tty
== (struct tty_struct
*) NULL
)
1799 if (cooktty
== (struct tty_struct
*) NULL
)
1806 portp
= tty
->driver_data
;
1807 if (portp
== (stliport_t
*) NULL
)
1809 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
1811 brdp
= stli_brds
[portp
->brdnr
];
1812 if (brdp
== (stlibrd_t
*) NULL
)
1819 ap
= (volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
);
1820 head
= (unsigned int) ap
->txq
.head
;
1821 tail
= (unsigned int) ap
->txq
.tail
;
1822 if (tail
!= ((unsigned int) ap
->txq
.tail
))
1823 tail
= (unsigned int) ap
->txq
.tail
;
1824 size
= portp
->txsize
;
1826 len
= size
- (head
- tail
) - 1;
1827 stlen
= size
- head
;
1829 len
= tail
- head
- 1;
1833 len
= MIN(len
, cooksize
);
1835 shbuf
= (char *) EBRDGETMEMPTR(brdp
, portp
->txoffset
);
1836 buf
= stli_txcookbuf
;
1839 stlen
= MIN(len
, stlen
);
1840 memcpy((shbuf
+ head
), buf
, stlen
);
1851 ap
= (volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
);
1852 ap
->txq
.head
= head
;
1854 if (test_bit(ST_TXBUSY
, &portp
->state
)) {
1855 if (ap
->changed
.data
& DT_TXEMPTY
)
1856 ap
->changed
.data
&= ~DT_TXEMPTY
;
1858 hdrp
= (volatile cdkhdr_t
*) EBRDGETMEMPTR(brdp
, CDK_CDKADDR
);
1859 bits
= ((volatile unsigned char *) hdrp
) + brdp
->slaveoffset
+
1861 *bits
|= portp
->portbit
;
1862 set_bit(ST_TXBUSY
, &portp
->state
);
1865 restore_flags(flags
);
1868 /*****************************************************************************/
1870 static int stli_writeroom(struct tty_struct
*tty
)
1872 volatile cdkasyrq_t
*rp
;
1875 unsigned int head
, tail
, len
;
1876 unsigned long flags
;
1879 printk("stli_writeroom(tty=%x)\n", (int) tty
);
1882 if (tty
== (struct tty_struct
*) NULL
)
1884 if (tty
== stli_txcooktty
) {
1885 if (stli_txcookrealsize
!= 0) {
1886 len
= stli_txcookrealsize
- stli_txcooksize
;
1891 portp
= tty
->driver_data
;
1892 if (portp
== (stliport_t
*) NULL
)
1894 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
1896 brdp
= stli_brds
[portp
->brdnr
];
1897 if (brdp
== (stlibrd_t
*) NULL
)
1903 rp
= &((volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
))->txq
;
1904 head
= (unsigned int) rp
->head
;
1905 tail
= (unsigned int) rp
->tail
;
1906 if (tail
!= ((unsigned int) rp
->tail
))
1907 tail
= (unsigned int) rp
->tail
;
1908 len
= (head
>= tail
) ? (portp
->txsize
- (head
- tail
)) : (tail
- head
);
1911 restore_flags(flags
);
1913 if (tty
== stli_txcooktty
) {
1914 stli_txcookrealsize
= len
;
1915 len
-= stli_txcooksize
;
1920 /*****************************************************************************/
1923 * Return the number of characters in the transmit buffer. Normally we
1924 * will return the number of chars in the shared memory ring queue.
1925 * We need to kludge around the case where the shared memory buffer is
1926 * empty but not all characters have drained yet, for this case just
1927 * return that there is 1 character in the buffer!
1930 static int stli_charsinbuffer(struct tty_struct
*tty
)
1932 volatile cdkasyrq_t
*rp
;
1935 unsigned int head
, tail
, len
;
1936 unsigned long flags
;
1939 printk("stli_charsinbuffer(tty=%x)\n", (int) tty
);
1942 if (tty
== (struct tty_struct
*) NULL
)
1944 if (tty
== stli_txcooktty
)
1945 stli_flushchars(tty
);
1946 portp
= tty
->driver_data
;
1947 if (portp
== (stliport_t
*) NULL
)
1949 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
1951 brdp
= stli_brds
[portp
->brdnr
];
1952 if (brdp
== (stlibrd_t
*) NULL
)
1958 rp
= &((volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
))->txq
;
1959 head
= (unsigned int) rp
->head
;
1960 tail
= (unsigned int) rp
->tail
;
1961 if (tail
!= ((unsigned int) rp
->tail
))
1962 tail
= (unsigned int) rp
->tail
;
1963 len
= (head
>= tail
) ? (head
- tail
) : (portp
->txsize
- (tail
- head
));
1964 if ((len
== 0) && test_bit(ST_TXBUSY
, &portp
->state
))
1967 restore_flags(flags
);
1972 /*****************************************************************************/
1975 * Generate the serial struct info.
1978 static void stli_getserial(stliport_t
*portp
, struct serial_struct
*sp
)
1980 struct serial_struct sio
;
1984 printk("stli_getserial(portp=%x,sp=%x)\n", (int) portp
, (int) sp
);
1987 memset(&sio
, 0, sizeof(struct serial_struct
));
1988 sio
.type
= PORT_UNKNOWN
;
1989 sio
.line
= portp
->portnr
;
1991 sio
.flags
= portp
->flags
;
1992 sio
.baud_base
= portp
->baud_base
;
1993 sio
.close_delay
= portp
->close_delay
;
1994 sio
.closing_wait
= portp
->closing_wait
;
1995 sio
.custom_divisor
= portp
->custom_divisor
;
1996 sio
.xmit_fifo_size
= 0;
1999 brdp
= stli_brds
[portp
->brdnr
];
2000 if (brdp
!= (stlibrd_t
*) NULL
)
2001 sio
.port
= brdp
->iobase
;
2003 copy_to_user(sp
, &sio
, sizeof(struct serial_struct
));
2006 /*****************************************************************************/
2009 * Set port according to the serial struct info.
2010 * At this point we do not do any auto-configure stuff, so we will
2011 * just quietly ignore any requests to change irq, etc.
2014 static int stli_setserial(stliport_t
*portp
, struct serial_struct
*sp
)
2016 struct serial_struct sio
;
2020 printk("stli_setserial(portp=%x,sp=%x)\n", (int) portp
, (int) sp
);
2023 copy_from_user(&sio
, sp
, sizeof(struct serial_struct
));
2024 if (!capable(CAP_SYS_ADMIN
)) {
2025 if ((sio
.baud_base
!= portp
->baud_base
) ||
2026 (sio
.close_delay
!= portp
->close_delay
) ||
2027 ((sio
.flags
& ~ASYNC_USR_MASK
) !=
2028 (portp
->flags
& ~ASYNC_USR_MASK
)))
2032 portp
->flags
= (portp
->flags
& ~ASYNC_USR_MASK
) |
2033 (sio
.flags
& ASYNC_USR_MASK
);
2034 portp
->baud_base
= sio
.baud_base
;
2035 portp
->close_delay
= sio
.close_delay
;
2036 portp
->closing_wait
= sio
.closing_wait
;
2037 portp
->custom_divisor
= sio
.custom_divisor
;
2039 if ((rc
= stli_setport(portp
)) < 0)
2044 /*****************************************************************************/
2046 static int stli_ioctl(struct tty_struct
*tty
, struct file
*file
, unsigned int cmd
, unsigned long arg
)
2055 printk("stli_ioctl(tty=%x,file=%x,cmd=%x,arg=%x)\n",
2056 (int) tty
, (int) file
, cmd
, (int) arg
);
2059 if (tty
== (struct tty_struct
*) NULL
)
2061 portp
= tty
->driver_data
;
2062 if (portp
== (stliport_t
*) NULL
)
2064 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
2066 brdp
= stli_brds
[portp
->brdnr
];
2067 if (brdp
== (stlibrd_t
*) NULL
)
2070 if ((cmd
!= TIOCGSERIAL
) && (cmd
!= TIOCSSERIAL
) &&
2071 (cmd
!= COM_GETPORTSTATS
) && (cmd
!= COM_CLRPORTSTATS
)) {
2072 if (tty
->flags
& (1 << TTY_IO_ERROR
))
2080 rc
= put_user(((tty
->termios
->c_cflag
& CLOCAL
) ? 1 : 0),
2081 (unsigned int *) arg
);
2084 if ((rc
= verify_area(VERIFY_READ
, (void *) arg
,
2085 sizeof(unsigned int))) == 0) {
2086 get_user(ival
, (unsigned int *) arg
);
2087 tty
->termios
->c_cflag
=
2088 (tty
->termios
->c_cflag
& ~CLOCAL
) |
2089 (ival
? CLOCAL
: 0);
2093 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
2094 sizeof(unsigned int))) == 0) {
2095 if ((rc
= stli_cmdwait(brdp
, portp
, A_GETSIGNALS
,
2096 &portp
->asig
, sizeof(asysigs_t
), 1)) < 0)
2098 lval
= stli_mktiocm(portp
->asig
.sigvalue
);
2099 put_user(lval
, (unsigned int *) arg
);
2103 if ((rc
= verify_area(VERIFY_READ
, (void *) arg
,
2104 sizeof(unsigned int))) == 0) {
2105 get_user(ival
, (unsigned int *) arg
);
2106 stli_mkasysigs(&portp
->asig
,
2107 ((ival
& TIOCM_DTR
) ? 1 : -1),
2108 ((ival
& TIOCM_RTS
) ? 1 : -1));
2109 rc
= stli_cmdwait(brdp
, portp
, A_SETSIGNALS
,
2110 &portp
->asig
, sizeof(asysigs_t
), 0);
2114 if ((rc
= verify_area(VERIFY_READ
, (void *) arg
,
2115 sizeof(unsigned int))) == 0) {
2116 get_user(ival
, (unsigned int *) arg
);
2117 stli_mkasysigs(&portp
->asig
,
2118 ((ival
& TIOCM_DTR
) ? 0 : -1),
2119 ((ival
& TIOCM_RTS
) ? 0 : -1));
2120 rc
= stli_cmdwait(brdp
, portp
, A_SETSIGNALS
,
2121 &portp
->asig
, sizeof(asysigs_t
), 0);
2125 if ((rc
= verify_area(VERIFY_READ
, (void *) arg
,
2126 sizeof(unsigned int))) == 0) {
2127 get_user(ival
, (unsigned int *) arg
);
2128 stli_mkasysigs(&portp
->asig
,
2129 ((ival
& TIOCM_DTR
) ? 1 : 0),
2130 ((ival
& TIOCM_RTS
) ? 1 : 0));
2131 rc
= stli_cmdwait(brdp
, portp
, A_SETSIGNALS
,
2132 &portp
->asig
, sizeof(asysigs_t
), 0);
2136 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
2137 sizeof(struct serial_struct
))) == 0)
2138 stli_getserial(portp
, (struct serial_struct
*) arg
);
2141 if ((rc
= verify_area(VERIFY_READ
, (void *) arg
,
2142 sizeof(struct serial_struct
))) == 0)
2143 rc
= stli_setserial(portp
, (struct serial_struct
*)arg
);
2146 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
2147 sizeof(unsigned long))) == 0)
2148 put_user(portp
->pflag
, (unsigned int *) arg
);
2151 if ((rc
= verify_area(VERIFY_READ
, (void *) arg
,
2152 sizeof(unsigned long))) == 0) {
2153 get_user(portp
->pflag
, (unsigned int *) arg
);
2154 stli_setport(portp
);
2157 case COM_GETPORTSTATS
:
2158 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
2159 sizeof(comstats_t
))) == 0)
2160 rc
= stli_getportstats(portp
, (comstats_t
*) arg
);
2162 case COM_CLRPORTSTATS
:
2163 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
2164 sizeof(comstats_t
))) == 0)
2165 rc
= stli_clrportstats(portp
, (comstats_t
*) arg
);
2171 case TIOCSERGSTRUCT
:
2172 case TIOCSERGETMULTI
:
2173 case TIOCSERSETMULTI
:
2182 /*****************************************************************************/
2185 * This routine assumes that we have user context and can sleep.
2186 * Looks like it is true for the current ttys implementation..!!
2189 static void stli_settermios(struct tty_struct
*tty
, struct termios
*old
)
2193 struct termios
*tiosp
;
2197 printk("stli_settermios(tty=%x,old=%x)\n", (int) tty
, (int) old
);
2200 if (tty
== (struct tty_struct
*) NULL
)
2202 portp
= tty
->driver_data
;
2203 if (portp
== (stliport_t
*) NULL
)
2205 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
2207 brdp
= stli_brds
[portp
->brdnr
];
2208 if (brdp
== (stlibrd_t
*) NULL
)
2211 tiosp
= tty
->termios
;
2212 if ((tiosp
->c_cflag
== old
->c_cflag
) &&
2213 (tiosp
->c_iflag
== old
->c_iflag
))
2216 stli_mkasyport(portp
, &aport
, tiosp
);
2217 stli_cmdwait(brdp
, portp
, A_SETPORT
, &aport
, sizeof(asyport_t
), 0);
2218 stli_mkasysigs(&portp
->asig
, ((tiosp
->c_cflag
& CBAUD
) ? 1 : 0), -1);
2219 stli_cmdwait(brdp
, portp
, A_SETSIGNALS
, &portp
->asig
,
2220 sizeof(asysigs_t
), 0);
2221 if ((old
->c_cflag
& CRTSCTS
) && ((tiosp
->c_cflag
& CRTSCTS
) == 0))
2222 tty
->hw_stopped
= 0;
2223 if (((old
->c_cflag
& CLOCAL
) == 0) && (tiosp
->c_cflag
& CLOCAL
))
2224 wake_up_interruptible(&portp
->open_wait
);
2227 /*****************************************************************************/
2230 * Attempt to flow control who ever is sending us data. We won't really
2231 * do any flow control action here. We can't directly, and even if we
2232 * wanted to we would have to send a command to the slave. The slave
2233 * knows how to flow control, and will do so when its buffers reach its
2234 * internal high water marks. So what we will do is set a local state
2235 * bit that will stop us sending any RX data up from the poll routine
2236 * (which is the place where RX data from the slave is handled).
2239 static void stli_throttle(struct tty_struct
*tty
)
2244 printk("stli_throttle(tty=%x)\n", (int) tty
);
2247 if (tty
== (struct tty_struct
*) NULL
)
2249 portp
= tty
->driver_data
;
2250 if (portp
== (stliport_t
*) NULL
)
2253 set_bit(ST_RXSTOP
, &portp
->state
);
2256 /*****************************************************************************/
2259 * Unflow control the device sending us data... That means that all
2260 * we have to do is clear the RXSTOP state bit. The next poll call
2261 * will then be able to pass the RX data back up.
2264 static void stli_unthrottle(struct tty_struct
*tty
)
2269 printk("stli_unthrottle(tty=%x)\n", (int) tty
);
2272 if (tty
== (struct tty_struct
*) NULL
)
2274 portp
= tty
->driver_data
;
2275 if (portp
== (stliport_t
*) NULL
)
2278 clear_bit(ST_RXSTOP
, &portp
->state
);
2281 /*****************************************************************************/
2284 * Stop the transmitter. Basically to do this we will just turn TX
2288 static void stli_stop(struct tty_struct
*tty
)
2295 printk("stli_stop(tty=%x)\n", (int) tty
);
2298 if (tty
== (struct tty_struct
*) NULL
)
2300 portp
= tty
->driver_data
;
2301 if (portp
== (stliport_t
*) NULL
)
2303 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
2305 brdp
= stli_brds
[portp
->brdnr
];
2306 if (brdp
== (stlibrd_t
*) NULL
)
2309 memset(&actrl
, 0, sizeof(asyctrl_t
));
2310 actrl
.txctrl
= CT_STOPFLOW
;
2312 stli_cmdwait(brdp
, portp
, A_PORTCTRL
, &actrl
, sizeof(asyctrl_t
), 0);
2316 /*****************************************************************************/
2319 * Start the transmitter again. Just turn TX interrupts back on.
2322 static void stli_start(struct tty_struct
*tty
)
2329 printk("stli_start(tty=%x)\n", (int) tty
);
2332 if (tty
== (struct tty_struct
*) NULL
)
2334 portp
= tty
->driver_data
;
2335 if (portp
== (stliport_t
*) NULL
)
2337 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
2339 brdp
= stli_brds
[portp
->brdnr
];
2340 if (brdp
== (stlibrd_t
*) NULL
)
2343 memset(&actrl
, 0, sizeof(asyctrl_t
));
2344 actrl
.txctrl
= CT_STARTFLOW
;
2346 stli_cmdwait(brdp
, portp
, A_PORTCTRL
, &actrl
, sizeof(asyctrl_t
), 0);
2350 /*****************************************************************************/
2353 * Scheduler called hang up routine. This is called from the scheduler,
2354 * not direct from the driver "poll" routine. We can't call it there
2355 * since the real local hangup code will enable/disable the board and
2356 * other things that we can't do while handling the poll. Much easier
2357 * to deal with it some time later (don't really care when, hangups
2358 * aren't that time critical).
2361 static void stli_dohangup(void *arg
)
2366 printk("stli_dohangup(portp=%x)\n", (int) arg
);
2369 portp
= (stliport_t
*) arg
;
2370 if (portp
== (stliport_t
*) NULL
)
2372 if (portp
->tty
== (struct tty_struct
*) NULL
)
2374 tty_hangup(portp
->tty
);
2377 /*****************************************************************************/
2380 * Hangup this port. This is pretty much like closing the port, only
2381 * a little more brutal. No waiting for data to drain. Shutdown the
2382 * port and maybe drop signals. This is rather tricky really. We want
2383 * to close the port as well.
2386 static void stli_hangup(struct tty_struct
*tty
)
2390 unsigned long flags
;
2393 printk("stli_hangup(tty=%x)\n", (int) tty
);
2396 if (tty
== (struct tty_struct
*) NULL
)
2398 portp
= tty
->driver_data
;
2399 if (portp
== (stliport_t
*) NULL
)
2401 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
2403 brdp
= stli_brds
[portp
->brdnr
];
2404 if (brdp
== (stlibrd_t
*) NULL
)
2407 portp
->flags
&= ~ASYNC_INITIALIZED
;
2411 if (! test_bit(ST_CLOSING
, &portp
->state
))
2412 stli_rawclose(brdp
, portp
, 0, 0);
2413 if (tty
->termios
->c_cflag
& HUPCL
) {
2414 stli_mkasysigs(&portp
->asig
, 0, 0);
2415 if (test_bit(ST_CMDING
, &portp
->state
)) {
2416 set_bit(ST_DOSIGS
, &portp
->state
);
2417 set_bit(ST_DOFLUSHTX
, &portp
->state
);
2418 set_bit(ST_DOFLUSHRX
, &portp
->state
);
2420 stli_sendcmd(brdp
, portp
, A_SETSIGNALSF
,
2421 &portp
->asig
, sizeof(asysigs_t
), 0);
2424 restore_flags(flags
);
2426 clear_bit(ST_TXBUSY
, &portp
->state
);
2427 clear_bit(ST_RXSTOP
, &portp
->state
);
2428 set_bit(TTY_IO_ERROR
, &tty
->flags
);
2429 portp
->tty
= (struct tty_struct
*) NULL
;
2430 portp
->flags
&= ~(ASYNC_NORMAL_ACTIVE
| ASYNC_CALLOUT_ACTIVE
);
2431 portp
->refcount
= 0;
2432 wake_up_interruptible(&portp
->open_wait
);
2435 /*****************************************************************************/
2438 * Flush characters from the lower buffer. We may not have user context
2439 * so we cannot sleep waiting for it to complete. Also we need to check
2440 * if there is chars for this port in the TX cook buffer, and flush them
2444 static void stli_flushbuffer(struct tty_struct
*tty
)
2448 unsigned long ftype
, flags
;
2451 printk("stli_flushbuffer(tty=%x)\n", (int) tty
);
2454 if (tty
== (struct tty_struct
*) NULL
)
2456 portp
= tty
->driver_data
;
2457 if (portp
== (stliport_t
*) NULL
)
2459 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
2461 brdp
= stli_brds
[portp
->brdnr
];
2462 if (brdp
== (stlibrd_t
*) NULL
)
2467 if (tty
== stli_txcooktty
) {
2468 stli_txcooktty
= (struct tty_struct
*) NULL
;
2469 stli_txcooksize
= 0;
2470 stli_txcookrealsize
= 0;
2472 if (test_bit(ST_CMDING
, &portp
->state
)) {
2473 set_bit(ST_DOFLUSHTX
, &portp
->state
);
2476 if (test_bit(ST_DOFLUSHRX
, &portp
->state
)) {
2478 clear_bit(ST_DOFLUSHRX
, &portp
->state
);
2480 stli_sendcmd(brdp
, portp
, A_FLUSH
, &ftype
,
2481 sizeof(unsigned long), 0);
2483 restore_flags(flags
);
2485 wake_up_interruptible(&tty
->write_wait
);
2486 if ((tty
->flags
& (1 << TTY_DO_WRITE_WAKEUP
)) &&
2487 tty
->ldisc
.write_wakeup
)
2488 (tty
->ldisc
.write_wakeup
)(tty
);
2491 /*****************************************************************************/
2493 static void stli_breakctl(struct tty_struct
*tty
, int state
)
2498 /* long savestate, savetime; */
2501 printk("stli_breakctl(tty=%x,state=%d)\n", (int) tty
, state
);
2504 if (tty
== (struct tty_struct
*) NULL
)
2506 portp
= tty
->driver_data
;
2507 if (portp
== (stliport_t
*) NULL
)
2509 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
2511 brdp
= stli_brds
[portp
->brdnr
];
2512 if (brdp
== (stlibrd_t
*) NULL
)
2516 * Due to a bug in the tty send_break() code we need to preserve
2517 * the current process state and timeout...
2518 savetime = current->timeout;
2519 savestate = current->state;
2522 arg
= (state
== -1) ? BREAKON
: BREAKOFF
;
2523 stli_cmdwait(brdp
, portp
, A_BREAK
, &arg
, sizeof(long), 0);
2527 current->timeout = savetime;
2528 current->state = savestate;
2532 /*****************************************************************************/
2534 static void stli_waituntilsent(struct tty_struct
*tty
, int timeout
)
2540 printk("stli_waituntilsent(tty=%x,timeout=%x)\n", (int) tty
, timeout
);
2543 if (tty
== (struct tty_struct
*) NULL
)
2545 portp
= tty
->driver_data
;
2546 if (portp
== (stliport_t
*) NULL
)
2551 tend
= jiffies
+ timeout
;
2553 while (test_bit(ST_TXBUSY
, &portp
->state
)) {
2554 if (signal_pending(current
))
2557 if (time_after_eq(jiffies
, tend
))
2562 /*****************************************************************************/
2564 static void stli_sendxchar(struct tty_struct
*tty
, char ch
)
2571 printk("stli_sendxchar(tty=%x,ch=%x)\n", (int) tty
, ch
);
2574 if (tty
== (struct tty_struct
*) NULL
)
2576 portp
= tty
->driver_data
;
2577 if (portp
== (stliport_t
*) NULL
)
2579 if ((portp
->brdnr
< 0) || (portp
->brdnr
>= stli_nrbrds
))
2581 brdp
= stli_brds
[portp
->brdnr
];
2582 if (brdp
== (stlibrd_t
*) NULL
)
2585 memset(&actrl
, 0, sizeof(asyctrl_t
));
2586 if (ch
== STOP_CHAR(tty
)) {
2587 actrl
.rxctrl
= CT_STOPFLOW
;
2588 } else if (ch
== START_CHAR(tty
)) {
2589 actrl
.rxctrl
= CT_STARTFLOW
;
2591 actrl
.txctrl
= CT_SENDCHR
;
2595 stli_cmdwait(brdp
, portp
, A_PORTCTRL
, &actrl
, sizeof(asyctrl_t
), 0);
2598 /*****************************************************************************/
2603 * Format info for a specified port. The line is deliberately limited
2604 * to 80 characters. (If it is too long it will be truncated, if too
2605 * short then padded with spaces).
2608 static int stli_portinfo(stlibrd_t
*brdp
, stliport_t
*portp
, int portnr
, char *pos
)
2613 rc
= stli_portcmdstats(portp
);
2616 if (brdp
->state
& BST_STARTED
) {
2617 switch (stli_comstats
.hwid
) {
2618 case 0: uart
= "2681"; break;
2619 case 1: uart
= "SC26198"; break;
2620 default: uart
= "CD1400"; break;
2625 sp
+= sprintf(sp
, "%d: uart:%s ", portnr
, uart
);
2627 if ((brdp
->state
& BST_STARTED
) && (rc
>= 0)) {
2628 sp
+= sprintf(sp
, "tx:%d rx:%d", (int) stli_comstats
.txtotal
,
2629 (int) stli_comstats
.rxtotal
);
2631 if (stli_comstats
.rxframing
)
2632 sp
+= sprintf(sp
, " fe:%d",
2633 (int) stli_comstats
.rxframing
);
2634 if (stli_comstats
.rxparity
)
2635 sp
+= sprintf(sp
, " pe:%d",
2636 (int) stli_comstats
.rxparity
);
2637 if (stli_comstats
.rxbreaks
)
2638 sp
+= sprintf(sp
, " brk:%d",
2639 (int) stli_comstats
.rxbreaks
);
2640 if (stli_comstats
.rxoverrun
)
2641 sp
+= sprintf(sp
, " oe:%d",
2642 (int) stli_comstats
.rxoverrun
);
2644 cnt
= sprintf(sp
, "%s%s%s%s%s ",
2645 (stli_comstats
.signals
& TIOCM_RTS
) ? "|RTS" : "",
2646 (stli_comstats
.signals
& TIOCM_CTS
) ? "|CTS" : "",
2647 (stli_comstats
.signals
& TIOCM_DTR
) ? "|DTR" : "",
2648 (stli_comstats
.signals
& TIOCM_CD
) ? "|DCD" : "",
2649 (stli_comstats
.signals
& TIOCM_DSR
) ? "|DSR" : "");
2654 for (cnt
= (sp
- pos
); (cnt
< (MAXLINE
- 1)); cnt
++)
2657 pos
[(MAXLINE
- 2)] = '+';
2658 pos
[(MAXLINE
- 1)] = '\n';
2663 /*****************************************************************************/
2666 * Port info, read from the /proc file system.
2669 static int stli_readproc(char *page
, char **start
, off_t off
, int count
, int *eof
, void *data
)
2673 int brdnr
, portnr
, totalport
;
2678 printk("stli_readproc(page=%x,start=%x,off=%x,count=%d,eof=%x,"
2679 "data=%x\n", (int) page
, (int) start
, (int) off
, count
,
2680 (int) eof
, (int) data
);
2688 pos
+= sprintf(pos
, "%s: version %s", stli_drvtitle
,
2690 while (pos
< (page
+ MAXLINE
- 1))
2697 * We scan through for each board, panel and port. The offset is
2698 * calculated on the fly, and irrelevant ports are skipped.
2700 for (brdnr
= 0; (brdnr
< stli_nrbrds
); brdnr
++) {
2701 brdp
= stli_brds
[brdnr
];
2702 if (brdp
== (stlibrd_t
*) NULL
)
2704 if (brdp
->state
== 0)
2707 maxoff
= curoff
+ (brdp
->nrports
* MAXLINE
);
2708 if (off
>= maxoff
) {
2713 totalport
= brdnr
* STL_MAXPORTS
;
2714 for (portnr
= 0; (portnr
< brdp
->nrports
); portnr
++,
2716 portp
= brdp
->ports
[portnr
];
2717 if (portp
== (stliport_t
*) NULL
)
2719 if (off
>= (curoff
+= MAXLINE
))
2721 if ((pos
- page
+ MAXLINE
) > count
)
2723 pos
+= stli_portinfo(brdp
, portp
, totalport
, pos
);
2734 /*****************************************************************************/
2737 * Generic send command routine. This will send a message to the slave,
2738 * of the specified type with the specified argument. Must be very
2739 * careful of data that will be copied out from shared memory -
2740 * containing command results. The command completion is all done from
2741 * a poll routine that does not have user context. Therefore you cannot
2742 * copy back directly into user space, or to the kernel stack of a
2743 * process. This routine does not sleep, so can be called from anywhere.
2746 static void stli_sendcmd(stlibrd_t
*brdp
, stliport_t
*portp
, unsigned long cmd
, void *arg
, int size
, int copyback
)
2748 volatile cdkhdr_t
*hdrp
;
2749 volatile cdkctrl_t
*cp
;
2750 volatile unsigned char *bits
;
2751 unsigned long flags
;
2754 printk("stli_sendcmd(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
2755 "copyback=%d)\n", (int) brdp
, (int) portp
, (int) cmd
,
2756 (int) arg
, size
, copyback
);
2762 if (test_bit(ST_CMDING
, &portp
->state
)) {
2763 printk("STALLION: command already busy, cmd=%x!\n", (int) cmd
);
2764 restore_flags(flags
);
2769 cp
= &((volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
))->ctrl
;
2771 memcpy((void *) &(cp
->args
[0]), arg
, size
);
2774 portp
->argsize
= size
;
2779 hdrp
= (volatile cdkhdr_t
*) EBRDGETMEMPTR(brdp
, CDK_CDKADDR
);
2780 bits
= ((volatile unsigned char *) hdrp
) + brdp
->slaveoffset
+
2782 *bits
|= portp
->portbit
;
2783 set_bit(ST_CMDING
, &portp
->state
);
2785 restore_flags(flags
);
2788 /*****************************************************************************/
2791 * Read data from shared memory. This assumes that the shared memory
2792 * is enabled and that interrupts are off. Basically we just empty out
2793 * the shared memory buffer into the tty buffer. Must be careful to
2794 * handle the case where we fill up the tty buffer, but still have
2795 * more chars to unload.
2798 static inline void stli_read(stlibrd_t
*brdp
, stliport_t
*portp
)
2800 volatile cdkasyrq_t
*rp
;
2801 volatile char *shbuf
;
2802 struct tty_struct
*tty
;
2803 unsigned int head
, tail
, size
;
2804 unsigned int len
, stlen
;
2807 printk("stli_read(brdp=%x,portp=%d)\n", (int) brdp
, (int) portp
);
2810 if (test_bit(ST_RXSTOP
, &portp
->state
))
2813 if (tty
== (struct tty_struct
*) NULL
)
2816 rp
= &((volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
))->rxq
;
2817 head
= (unsigned int) rp
->head
;
2818 if (head
!= ((unsigned int) rp
->head
))
2819 head
= (unsigned int) rp
->head
;
2820 tail
= (unsigned int) rp
->tail
;
2821 size
= portp
->rxsize
;
2826 len
= size
- (tail
- head
);
2827 stlen
= size
- tail
;
2830 len
= MIN(len
, (TTY_FLIPBUF_SIZE
- tty
->flip
.count
));
2831 shbuf
= (volatile char *) EBRDGETMEMPTR(brdp
, portp
->rxoffset
);
2834 stlen
= MIN(len
, stlen
);
2835 memcpy(tty
->flip
.char_buf_ptr
, (char *) (shbuf
+ tail
), stlen
);
2836 memset(tty
->flip
.flag_buf_ptr
, 0, stlen
);
2837 tty
->flip
.char_buf_ptr
+= stlen
;
2838 tty
->flip
.flag_buf_ptr
+= stlen
;
2839 tty
->flip
.count
+= stlen
;
2848 rp
= &((volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
))->rxq
;
2852 set_bit(ST_RXING
, &portp
->state
);
2854 tty_schedule_flip(tty
);
2857 /*****************************************************************************/
2860 * Set up and carry out any delayed commands. There is only a small set
2861 * of slave commands that can be done "off-level". So it is not too
2862 * difficult to deal with them here.
2865 static inline void stli_dodelaycmd(stliport_t
*portp
, volatile cdkctrl_t
*cp
)
2869 if (test_bit(ST_DOSIGS
, &portp
->state
)) {
2870 if (test_bit(ST_DOFLUSHTX
, &portp
->state
) &&
2871 test_bit(ST_DOFLUSHRX
, &portp
->state
))
2872 cmd
= A_SETSIGNALSF
;
2873 else if (test_bit(ST_DOFLUSHTX
, &portp
->state
))
2874 cmd
= A_SETSIGNALSFTX
;
2875 else if (test_bit(ST_DOFLUSHRX
, &portp
->state
))
2876 cmd
= A_SETSIGNALSFRX
;
2879 clear_bit(ST_DOFLUSHTX
, &portp
->state
);
2880 clear_bit(ST_DOFLUSHRX
, &portp
->state
);
2881 clear_bit(ST_DOSIGS
, &portp
->state
);
2882 memcpy((void *) &(cp
->args
[0]), (void *) &portp
->asig
,
2886 set_bit(ST_CMDING
, &portp
->state
);
2887 } else if (test_bit(ST_DOFLUSHTX
, &portp
->state
) ||
2888 test_bit(ST_DOFLUSHRX
, &portp
->state
)) {
2889 cmd
= ((test_bit(ST_DOFLUSHTX
, &portp
->state
)) ? FLUSHTX
: 0);
2890 cmd
|= ((test_bit(ST_DOFLUSHRX
, &portp
->state
)) ? FLUSHRX
: 0);
2891 clear_bit(ST_DOFLUSHTX
, &portp
->state
);
2892 clear_bit(ST_DOFLUSHRX
, &portp
->state
);
2893 memcpy((void *) &(cp
->args
[0]), (void *) &cmd
, sizeof(int));
2896 set_bit(ST_CMDING
, &portp
->state
);
2900 /*****************************************************************************/
2903 * Host command service checking. This handles commands or messages
2904 * coming from the slave to the host. Must have board shared memory
2905 * enabled and interrupts off when called. Notice that by servicing the
2906 * read data last we don't need to change the shared memory pointer
2907 * during processing (which is a slow IO operation).
2908 * Return value indicates if this port is still awaiting actions from
2909 * the slave (like open, command, or even TX data being sent). If 0
2910 * then port is still busy, otherwise no longer busy.
2913 static inline int stli_hostcmd(stlibrd_t
*brdp
, stliport_t
*portp
)
2915 volatile cdkasy_t
*ap
;
2916 volatile cdkctrl_t
*cp
;
2917 struct tty_struct
*tty
;
2919 unsigned long oldsigs
;
2923 printk("stli_hostcmd(brdp=%x,channr=%d)\n", (int) brdp
, channr
);
2926 ap
= (volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
);
2930 * Check if we are waiting for an open completion message.
2932 if (test_bit(ST_OPENING
, &portp
->state
)) {
2933 rc
= (int) cp
->openarg
;
2934 if ((cp
->open
== 0) && (rc
!= 0)) {
2939 clear_bit(ST_OPENING
, &portp
->state
);
2940 wake_up_interruptible(&portp
->raw_wait
);
2945 * Check if we are waiting for a close completion message.
2947 if (test_bit(ST_CLOSING
, &portp
->state
)) {
2948 rc
= (int) cp
->closearg
;
2949 if ((cp
->close
== 0) && (rc
!= 0)) {
2954 clear_bit(ST_CLOSING
, &portp
->state
);
2955 wake_up_interruptible(&portp
->raw_wait
);
2960 * Check if we are waiting for a command completion message. We may
2961 * need to copy out the command results associated with this command.
2963 if (test_bit(ST_CMDING
, &portp
->state
)) {
2965 if ((cp
->cmd
== 0) && (rc
!= 0)) {
2968 if (portp
->argp
!= (void *) NULL
) {
2969 memcpy(portp
->argp
, (void *) &(cp
->args
[0]),
2971 portp
->argp
= (void *) NULL
;
2975 clear_bit(ST_CMDING
, &portp
->state
);
2976 stli_dodelaycmd(portp
, cp
);
2977 wake_up_interruptible(&portp
->raw_wait
);
2982 * Check for any notification messages ready. This includes lots of
2983 * different types of events - RX chars ready, RX break received,
2984 * TX data low or empty in the slave, modem signals changed state.
2993 if (nt
.signal
& SG_DCD
) {
2994 oldsigs
= portp
->sigs
;
2995 portp
->sigs
= stli_mktiocm(nt
.sigvalue
);
2996 clear_bit(ST_GETSIGS
, &portp
->state
);
2997 if ((portp
->sigs
& TIOCM_CD
) &&
2998 ((oldsigs
& TIOCM_CD
) == 0))
2999 wake_up_interruptible(&portp
->open_wait
);
3000 if ((oldsigs
& TIOCM_CD
) &&
3001 ((portp
->sigs
& TIOCM_CD
) == 0)) {
3002 if (portp
->flags
& ASYNC_CHECK_CD
) {
3003 if (! ((portp
->flags
& ASYNC_CALLOUT_ACTIVE
) &&
3004 (portp
->flags
& ASYNC_CALLOUT_NOHUP
))) {
3005 if (tty
!= (struct tty_struct
*) NULL
)
3006 queue_task(&portp
->tqhangup
, &tq_scheduler
);
3012 if (nt
.data
& DT_TXEMPTY
)
3013 clear_bit(ST_TXBUSY
, &portp
->state
);
3014 if (nt
.data
& (DT_TXEMPTY
| DT_TXLOW
)) {
3015 if (tty
!= (struct tty_struct
*) NULL
) {
3016 if ((tty
->flags
& (1 << TTY_DO_WRITE_WAKEUP
)) &&
3017 tty
->ldisc
.write_wakeup
) {
3018 (tty
->ldisc
.write_wakeup
)(tty
);
3021 wake_up_interruptible(&tty
->write_wait
);
3025 if ((nt
.data
& DT_RXBREAK
) && (portp
->rxmarkmsk
& BRKINT
)) {
3026 if (tty
!= (struct tty_struct
*) NULL
) {
3027 if (tty
->flip
.count
< TTY_FLIPBUF_SIZE
) {
3029 *tty
->flip
.flag_buf_ptr
++ = TTY_BREAK
;
3030 *tty
->flip
.char_buf_ptr
++ = 0;
3031 if (portp
->flags
& ASYNC_SAK
) {
3035 tty_schedule_flip(tty
);
3040 if (nt
.data
& DT_RXBUSY
) {
3042 stli_read(brdp
, portp
);
3047 * It might seem odd that we are checking for more RX chars here.
3048 * But, we need to handle the case where the tty buffer was previously
3049 * filled, but we had more characters to pass up. The slave will not
3050 * send any more RX notify messages until the RX buffer has been emptied.
3051 * But it will leave the service bits on (since the buffer is not empty).
3052 * So from here we can try to process more RX chars.
3054 if ((!donerx
) && test_bit(ST_RXING
, &portp
->state
)) {
3055 clear_bit(ST_RXING
, &portp
->state
);
3056 stli_read(brdp
, portp
);
3059 return((test_bit(ST_OPENING
, &portp
->state
) ||
3060 test_bit(ST_CLOSING
, &portp
->state
) ||
3061 test_bit(ST_CMDING
, &portp
->state
) ||
3062 test_bit(ST_TXBUSY
, &portp
->state
) ||
3063 test_bit(ST_RXING
, &portp
->state
)) ? 0 : 1);
3066 /*****************************************************************************/
3069 * Service all ports on a particular board. Assumes that the boards
3070 * shared memory is enabled, and that the page pointer is pointed
3071 * at the cdk header structure.
3074 static inline void stli_brdpoll(stlibrd_t
*brdp
, volatile cdkhdr_t
*hdrp
)
3077 unsigned char hostbits
[(STL_MAXCHANS
/ 8) + 1];
3078 unsigned char slavebits
[(STL_MAXCHANS
/ 8) + 1];
3079 unsigned char *slavep
;
3080 int bitpos
, bitat
, bitsize
;
3081 int channr
, nrdevs
, slavebitchange
;
3083 bitsize
= brdp
->bitsize
;
3084 nrdevs
= brdp
->nrdevs
;
3087 * Check if slave wants any service. Basically we try to do as
3088 * little work as possible here. There are 2 levels of service
3089 * bits. So if there is nothing to do we bail early. We check
3090 * 8 service bits at a time in the inner loop, so we can bypass
3091 * the lot if none of them want service.
3093 memcpy(&hostbits
[0], (((unsigned char *) hdrp
) + brdp
->hostoffset
),
3096 memset(&slavebits
[0], 0, bitsize
);
3099 for (bitpos
= 0; (bitpos
< bitsize
); bitpos
++) {
3100 if (hostbits
[bitpos
] == 0)
3102 channr
= bitpos
* 8;
3103 for (bitat
= 0x1; (channr
< nrdevs
); channr
++, bitat
<<= 1) {
3104 if (hostbits
[bitpos
] & bitat
) {
3105 portp
= brdp
->ports
[(channr
- 1)];
3106 if (stli_hostcmd(brdp
, portp
)) {
3108 slavebits
[bitpos
] |= bitat
;
3115 * If any of the ports are no longer busy then update them in the
3116 * slave request bits. We need to do this after, since a host port
3117 * service may initiate more slave requests.
3119 if (slavebitchange
) {
3120 hdrp
= (volatile cdkhdr_t
*) EBRDGETMEMPTR(brdp
, CDK_CDKADDR
);
3121 slavep
= ((unsigned char *) hdrp
) + brdp
->slaveoffset
;
3122 for (bitpos
= 0; (bitpos
< bitsize
); bitpos
++) {
3123 if (slavebits
[bitpos
])
3124 slavep
[bitpos
] &= ~slavebits
[bitpos
];
3129 /*****************************************************************************/
3132 * Driver poll routine. This routine polls the boards in use and passes
3133 * messages back up to host when necessary. This is actually very
3134 * CPU efficient, since we will always have the kernel poll clock, it
3135 * adds only a few cycles when idle (since board service can be
3136 * determined very easily), but when loaded generates no interrupts
3137 * (with their expensive associated context change).
3140 static void stli_poll(unsigned long arg
)
3142 volatile cdkhdr_t
*hdrp
;
3146 stli_timerlist
.expires
= STLI_TIMEOUT
;
3147 add_timer(&stli_timerlist
);
3150 * Check each board and do any servicing required.
3152 for (brdnr
= 0; (brdnr
< stli_nrbrds
); brdnr
++) {
3153 brdp
= stli_brds
[brdnr
];
3154 if (brdp
== (stlibrd_t
*) NULL
)
3156 if ((brdp
->state
& BST_STARTED
) == 0)
3160 hdrp
= (volatile cdkhdr_t
*) EBRDGETMEMPTR(brdp
, CDK_CDKADDR
);
3162 stli_brdpoll(brdp
, hdrp
);
3167 /*****************************************************************************/
3170 * Translate the termios settings into the port setting structure of
3174 static void stli_mkasyport(stliport_t
*portp
, asyport_t
*pp
, struct termios
*tiosp
)
3177 printk("stli_mkasyport(portp=%x,pp=%x,tiosp=%d)\n",
3178 (int) portp
, (int) pp
, (int) tiosp
);
3181 memset(pp
, 0, sizeof(asyport_t
));
3184 * Start of by setting the baud, char size, parity and stop bit info.
3186 pp
->baudout
= tiosp
->c_cflag
& CBAUD
;
3187 if (pp
->baudout
& CBAUDEX
) {
3188 pp
->baudout
&= ~CBAUDEX
;
3189 if ((pp
->baudout
< 1) || (pp
->baudout
> 4))
3190 tiosp
->c_cflag
&= ~CBAUDEX
;
3194 pp
->baudout
= stli_baudrates
[pp
->baudout
];
3195 if ((tiosp
->c_cflag
& CBAUD
) == B38400
) {
3196 if ((portp
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_HI
)
3197 pp
->baudout
= 57600;
3198 else if ((portp
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_VHI
)
3199 pp
->baudout
= 115200;
3200 else if ((portp
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_SHI
)
3201 pp
->baudout
= 230400;
3202 else if ((portp
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_WARP
)
3203 pp
->baudout
= 460800;
3204 else if ((portp
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_CUST
)
3205 pp
->baudout
= (portp
->baud_base
/ portp
->custom_divisor
);
3207 if (pp
->baudout
> STL_MAXBAUD
)
3208 pp
->baudout
= STL_MAXBAUD
;
3209 pp
->baudin
= pp
->baudout
;
3211 switch (tiosp
->c_cflag
& CSIZE
) {
3226 if (tiosp
->c_cflag
& CSTOPB
)
3227 pp
->stopbs
= PT_STOP2
;
3229 pp
->stopbs
= PT_STOP1
;
3231 if (tiosp
->c_cflag
& PARENB
) {
3232 if (tiosp
->c_cflag
& PARODD
)
3233 pp
->parity
= PT_ODDPARITY
;
3235 pp
->parity
= PT_EVENPARITY
;
3237 pp
->parity
= PT_NOPARITY
;
3241 * Set up any flow control options enabled.
3243 if (tiosp
->c_iflag
& IXON
) {
3245 if (tiosp
->c_iflag
& IXANY
)
3246 pp
->flow
|= F_IXANY
;
3248 if (tiosp
->c_cflag
& CRTSCTS
)
3249 pp
->flow
|= (F_RTSFLOW
| F_CTSFLOW
);
3251 pp
->startin
= tiosp
->c_cc
[VSTART
];
3252 pp
->stopin
= tiosp
->c_cc
[VSTOP
];
3253 pp
->startout
= tiosp
->c_cc
[VSTART
];
3254 pp
->stopout
= tiosp
->c_cc
[VSTOP
];
3257 * Set up the RX char marking mask with those RX error types we must
3258 * catch. We can get the slave to help us out a little here, it will
3259 * ignore parity errors and breaks for us, and mark parity errors in
3262 if (tiosp
->c_iflag
& IGNPAR
)
3263 pp
->iflag
|= FI_IGNRXERRS
;
3264 if (tiosp
->c_iflag
& IGNBRK
)
3265 pp
->iflag
|= FI_IGNBREAK
;
3267 portp
->rxmarkmsk
= 0;
3268 if (tiosp
->c_iflag
& (INPCK
| PARMRK
))
3269 pp
->iflag
|= FI_1MARKRXERRS
;
3270 if (tiosp
->c_iflag
& BRKINT
)
3271 portp
->rxmarkmsk
|= BRKINT
;
3274 * Set up clocal processing as required.
3276 if (tiosp
->c_cflag
& CLOCAL
)
3277 portp
->flags
&= ~ASYNC_CHECK_CD
;
3279 portp
->flags
|= ASYNC_CHECK_CD
;
3282 * Transfer any persistent flags into the asyport structure.
3284 pp
->pflag
= (portp
->pflag
& 0xffff);
3285 pp
->vmin
= (portp
->pflag
& P_RXIMIN
) ? 1 : 0;
3286 pp
->vtime
= (portp
->pflag
& P_RXITIME
) ? 1 : 0;
3287 pp
->cc
[1] = (portp
->pflag
& P_RXTHOLD
) ? 1 : 0;
3290 /*****************************************************************************/
3293 * Construct a slave signals structure for setting the DTR and RTS
3294 * signals as specified.
3297 static void stli_mkasysigs(asysigs_t
*sp
, int dtr
, int rts
)
3300 printk("stli_mkasysigs(sp=%x,dtr=%d,rts=%d)\n", (int) sp
, dtr
, rts
);
3303 memset(sp
, 0, sizeof(asysigs_t
));
3305 sp
->signal
|= SG_DTR
;
3306 sp
->sigvalue
|= ((dtr
> 0) ? SG_DTR
: 0);
3309 sp
->signal
|= SG_RTS
;
3310 sp
->sigvalue
|= ((rts
> 0) ? SG_RTS
: 0);
3314 /*****************************************************************************/
3317 * Convert the signals returned from the slave into a local TIOCM type
3318 * signals value. We keep them locally in TIOCM format.
3321 static long stli_mktiocm(unsigned long sigvalue
)
3326 printk("stli_mktiocm(sigvalue=%x)\n", (int) sigvalue
);
3330 tiocm
|= ((sigvalue
& SG_DCD
) ? TIOCM_CD
: 0);
3331 tiocm
|= ((sigvalue
& SG_CTS
) ? TIOCM_CTS
: 0);
3332 tiocm
|= ((sigvalue
& SG_RI
) ? TIOCM_RI
: 0);
3333 tiocm
|= ((sigvalue
& SG_DSR
) ? TIOCM_DSR
: 0);
3334 tiocm
|= ((sigvalue
& SG_DTR
) ? TIOCM_DTR
: 0);
3335 tiocm
|= ((sigvalue
& SG_RTS
) ? TIOCM_RTS
: 0);
3339 /*****************************************************************************/
3342 * All panels and ports actually attached have been worked out. All
3343 * we need to do here is set up the appropriate per port data structures.
3346 static inline int stli_initports(stlibrd_t
*brdp
)
3349 int i
, panelnr
, panelport
;
3352 printk("stli_initports(brdp=%x)\n", (int) brdp
);
3355 for (i
= 0, panelnr
= 0, panelport
= 0; (i
< brdp
->nrports
); i
++) {
3356 portp
= (stliport_t
*) stli_memalloc(sizeof(stliport_t
));
3357 if (portp
== (stliport_t
*) NULL
) {
3358 printk("STALLION: failed to allocate port structure\n");
3362 memset(portp
, 0, sizeof(stliport_t
));
3363 portp
->magic
= STLI_PORTMAGIC
;
3365 portp
->brdnr
= brdp
->brdnr
;
3366 portp
->panelnr
= panelnr
;
3367 portp
->baud_base
= STL_BAUDBASE
;
3368 portp
->close_delay
= STL_CLOSEDELAY
;
3369 portp
->closing_wait
= 30 * HZ
;
3370 portp
->tqhangup
.routine
= stli_dohangup
;
3371 portp
->tqhangup
.data
= portp
;
3372 init_waitqueue_head(&portp
->open_wait
);
3373 init_waitqueue_head(&portp
->close_wait
);
3374 init_waitqueue_head(&portp
->raw_wait
);
3375 portp
->normaltermios
= stli_deftermios
;
3376 portp
->callouttermios
= stli_deftermios
;
3378 if (panelport
>= brdp
->panels
[panelnr
]) {
3382 brdp
->ports
[i
] = portp
;
3388 /*****************************************************************************/
3391 * All the following routines are board specific hardware operations.
3394 static void stli_ecpinit(stlibrd_t
*brdp
)
3396 unsigned long memconf
;
3399 printk("stli_ecpinit(brdp=%d)\n", (int) brdp
);
3402 outb(ECP_ATSTOP
, (brdp
->iobase
+ ECP_ATCONFR
));
3404 outb(ECP_ATDISABLE
, (brdp
->iobase
+ ECP_ATCONFR
));
3407 memconf
= (brdp
->memaddr
& ECP_ATADDRMASK
) >> ECP_ATADDRSHFT
;
3408 outb(memconf
, (brdp
->iobase
+ ECP_ATMEMAR
));
3411 /*****************************************************************************/
3413 static void stli_ecpenable(stlibrd_t
*brdp
)
3416 printk("stli_ecpenable(brdp=%x)\n", (int) brdp
);
3418 outb(ECP_ATENABLE
, (brdp
->iobase
+ ECP_ATCONFR
));
3421 /*****************************************************************************/
3423 static void stli_ecpdisable(stlibrd_t
*brdp
)
3426 printk("stli_ecpdisable(brdp=%x)\n", (int) brdp
);
3428 outb(ECP_ATDISABLE
, (brdp
->iobase
+ ECP_ATCONFR
));
3431 /*****************************************************************************/
3433 static char *stli_ecpgetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
)
3439 printk("stli_ecpgetmemptr(brdp=%x,offset=%x)\n", (int) brdp
,
3443 if (offset
> brdp
->memsize
) {
3444 printk("STALLION: shared memory pointer=%x out of range at "
3445 "line=%d(%d), brd=%d\n", (int) offset
, line
,
3446 __LINE__
, brdp
->brdnr
);
3450 ptr
= brdp
->membase
+ (offset
% ECP_ATPAGESIZE
);
3451 val
= (unsigned char) (offset
/ ECP_ATPAGESIZE
);
3453 outb(val
, (brdp
->iobase
+ ECP_ATMEMPR
));
3457 /*****************************************************************************/
3459 static void stli_ecpreset(stlibrd_t
*brdp
)
3462 printk("stli_ecpreset(brdp=%x)\n", (int) brdp
);
3465 outb(ECP_ATSTOP
, (brdp
->iobase
+ ECP_ATCONFR
));
3467 outb(ECP_ATDISABLE
, (brdp
->iobase
+ ECP_ATCONFR
));
3471 /*****************************************************************************/
3473 static void stli_ecpintr(stlibrd_t
*brdp
)
3476 printk("stli_ecpintr(brdp=%x)\n", (int) brdp
);
3478 outb(0x1, brdp
->iobase
);
3481 /*****************************************************************************/
3484 * The following set of functions act on ECP EISA boards.
3487 static void stli_ecpeiinit(stlibrd_t
*brdp
)
3489 unsigned long memconf
;
3492 printk("stli_ecpeiinit(brdp=%x)\n", (int) brdp
);
3495 outb(0x1, (brdp
->iobase
+ ECP_EIBRDENAB
));
3496 outb(ECP_EISTOP
, (brdp
->iobase
+ ECP_EICONFR
));
3498 outb(ECP_EIDISABLE
, (brdp
->iobase
+ ECP_EICONFR
));
3501 memconf
= (brdp
->memaddr
& ECP_EIADDRMASKL
) >> ECP_EIADDRSHFTL
;
3502 outb(memconf
, (brdp
->iobase
+ ECP_EIMEMARL
));
3503 memconf
= (brdp
->memaddr
& ECP_EIADDRMASKH
) >> ECP_EIADDRSHFTH
;
3504 outb(memconf
, (brdp
->iobase
+ ECP_EIMEMARH
));
3507 /*****************************************************************************/
3509 static void stli_ecpeienable(stlibrd_t
*brdp
)
3511 outb(ECP_EIENABLE
, (brdp
->iobase
+ ECP_EICONFR
));
3514 /*****************************************************************************/
3516 static void stli_ecpeidisable(stlibrd_t
*brdp
)
3518 outb(ECP_EIDISABLE
, (brdp
->iobase
+ ECP_EICONFR
));
3521 /*****************************************************************************/
3523 static char *stli_ecpeigetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
)
3529 printk("stli_ecpeigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3530 (int) brdp
, (int) offset
, line
);
3533 if (offset
> brdp
->memsize
) {
3534 printk("STALLION: shared memory pointer=%x out of range at "
3535 "line=%d(%d), brd=%d\n", (int) offset
, line
,
3536 __LINE__
, brdp
->brdnr
);
3540 ptr
= brdp
->membase
+ (offset
% ECP_EIPAGESIZE
);
3541 if (offset
< ECP_EIPAGESIZE
)
3544 val
= ECP_EIENABLE
| 0x40;
3546 outb(val
, (brdp
->iobase
+ ECP_EICONFR
));
3550 /*****************************************************************************/
3552 static void stli_ecpeireset(stlibrd_t
*brdp
)
3554 outb(ECP_EISTOP
, (brdp
->iobase
+ ECP_EICONFR
));
3556 outb(ECP_EIDISABLE
, (brdp
->iobase
+ ECP_EICONFR
));
3560 /*****************************************************************************/
3563 * The following set of functions act on ECP MCA boards.
3566 static void stli_ecpmcenable(stlibrd_t
*brdp
)
3568 outb(ECP_MCENABLE
, (brdp
->iobase
+ ECP_MCCONFR
));
3571 /*****************************************************************************/
3573 static void stli_ecpmcdisable(stlibrd_t
*brdp
)
3575 outb(ECP_MCDISABLE
, (brdp
->iobase
+ ECP_MCCONFR
));
3578 /*****************************************************************************/
3580 static char *stli_ecpmcgetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
)
3585 if (offset
> brdp
->memsize
) {
3586 printk("STALLION: shared memory pointer=%x out of range at "
3587 "line=%d(%d), brd=%d\n", (int) offset
, line
,
3588 __LINE__
, brdp
->brdnr
);
3592 ptr
= brdp
->membase
+ (offset
% ECP_MCPAGESIZE
);
3593 val
= ((unsigned char) (offset
/ ECP_MCPAGESIZE
)) | ECP_MCENABLE
;
3595 outb(val
, (brdp
->iobase
+ ECP_MCCONFR
));
3599 /*****************************************************************************/
3601 static void stli_ecpmcreset(stlibrd_t
*brdp
)
3603 outb(ECP_MCSTOP
, (brdp
->iobase
+ ECP_MCCONFR
));
3605 outb(ECP_MCDISABLE
, (brdp
->iobase
+ ECP_MCCONFR
));
3609 /*****************************************************************************/
3612 * The following set of functions act on ECP PCI boards.
3615 static void stli_ecppciinit(stlibrd_t
*brdp
)
3618 printk("stli_ecppciinit(brdp=%x)\n", (int) brdp
);
3621 outb(ECP_PCISTOP
, (brdp
->iobase
+ ECP_PCICONFR
));
3623 outb(0, (brdp
->iobase
+ ECP_PCICONFR
));
3627 /*****************************************************************************/
3629 static char *stli_ecppcigetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
)
3635 printk("stli_ecppcigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3636 (int) brdp
, (int) offset
, line
);
3639 if (offset
> brdp
->memsize
) {
3640 printk("STALLION: shared memory pointer=%x out of range at "
3641 "line=%d(%d), board=%d\n", (int) offset
, line
,
3642 __LINE__
, brdp
->brdnr
);
3646 ptr
= brdp
->membase
+ (offset
% ECP_PCIPAGESIZE
);
3647 val
= (offset
/ ECP_PCIPAGESIZE
) << 1;
3649 outb(val
, (brdp
->iobase
+ ECP_PCICONFR
));
3653 /*****************************************************************************/
3655 static void stli_ecppcireset(stlibrd_t
*brdp
)
3657 outb(ECP_PCISTOP
, (brdp
->iobase
+ ECP_PCICONFR
));
3659 outb(0, (brdp
->iobase
+ ECP_PCICONFR
));
3663 /*****************************************************************************/
3666 * The following routines act on ONboards.
3669 static void stli_onbinit(stlibrd_t
*brdp
)
3671 unsigned long memconf
;
3674 printk("stli_onbinit(brdp=%d)\n", (int) brdp
);
3677 outb(ONB_ATSTOP
, (brdp
->iobase
+ ONB_ATCONFR
));
3679 outb(ONB_ATDISABLE
, (brdp
->iobase
+ ONB_ATCONFR
));
3682 memconf
= (brdp
->memaddr
& ONB_ATADDRMASK
) >> ONB_ATADDRSHFT
;
3683 outb(memconf
, (brdp
->iobase
+ ONB_ATMEMAR
));
3684 outb(0x1, brdp
->iobase
);
3688 /*****************************************************************************/
3690 static void stli_onbenable(stlibrd_t
*brdp
)
3693 printk("stli_onbenable(brdp=%x)\n", (int) brdp
);
3695 outb((brdp
->enabval
| ONB_ATENABLE
), (brdp
->iobase
+ ONB_ATCONFR
));
3698 /*****************************************************************************/
3700 static void stli_onbdisable(stlibrd_t
*brdp
)
3703 printk("stli_onbdisable(brdp=%x)\n", (int) brdp
);
3705 outb((brdp
->enabval
| ONB_ATDISABLE
), (brdp
->iobase
+ ONB_ATCONFR
));
3708 /*****************************************************************************/
3710 static char *stli_onbgetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
)
3715 printk("stli_onbgetmemptr(brdp=%x,offset=%x)\n", (int) brdp
,
3719 if (offset
> brdp
->memsize
) {
3720 printk("STALLION: shared memory pointer=%x out of range at "
3721 "line=%d(%d), brd=%d\n", (int) offset
, line
,
3722 __LINE__
, brdp
->brdnr
);
3725 ptr
= brdp
->membase
+ (offset
% ONB_ATPAGESIZE
);
3730 /*****************************************************************************/
3732 static void stli_onbreset(stlibrd_t
*brdp
)
3736 printk("stli_onbreset(brdp=%x)\n", (int) brdp
);
3739 outb(ONB_ATSTOP
, (brdp
->iobase
+ ONB_ATCONFR
));
3741 outb(ONB_ATDISABLE
, (brdp
->iobase
+ ONB_ATCONFR
));
3745 /*****************************************************************************/
3748 * The following routines act on ONboard EISA.
3751 static void stli_onbeinit(stlibrd_t
*brdp
)
3753 unsigned long memconf
;
3756 printk("stli_onbeinit(brdp=%d)\n", (int) brdp
);
3759 outb(0x1, (brdp
->iobase
+ ONB_EIBRDENAB
));
3760 outb(ONB_EISTOP
, (brdp
->iobase
+ ONB_EICONFR
));
3762 outb(ONB_EIDISABLE
, (brdp
->iobase
+ ONB_EICONFR
));
3765 memconf
= (brdp
->memaddr
& ONB_EIADDRMASKL
) >> ONB_EIADDRSHFTL
;
3766 outb(memconf
, (brdp
->iobase
+ ONB_EIMEMARL
));
3767 memconf
= (brdp
->memaddr
& ONB_EIADDRMASKH
) >> ONB_EIADDRSHFTH
;
3768 outb(memconf
, (brdp
->iobase
+ ONB_EIMEMARH
));
3769 outb(0x1, brdp
->iobase
);
3773 /*****************************************************************************/
3775 static void stli_onbeenable(stlibrd_t
*brdp
)
3778 printk("stli_onbeenable(brdp=%x)\n", (int) brdp
);
3780 outb(ONB_EIENABLE
, (brdp
->iobase
+ ONB_EICONFR
));
3783 /*****************************************************************************/
3785 static void stli_onbedisable(stlibrd_t
*brdp
)
3788 printk("stli_onbedisable(brdp=%x)\n", (int) brdp
);
3790 outb(ONB_EIDISABLE
, (brdp
->iobase
+ ONB_EICONFR
));
3793 /*****************************************************************************/
3795 static char *stli_onbegetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
)
3801 printk("stli_onbegetmemptr(brdp=%x,offset=%x,line=%d)\n",
3802 (int) brdp
, (int) offset
, line
);
3805 if (offset
> brdp
->memsize
) {
3806 printk("STALLION: shared memory pointer=%x out of range at "
3807 "line=%d(%d), brd=%d\n", (int) offset
, line
,
3808 __LINE__
, brdp
->brdnr
);
3812 ptr
= brdp
->membase
+ (offset
% ONB_EIPAGESIZE
);
3813 if (offset
< ONB_EIPAGESIZE
)
3816 val
= ONB_EIENABLE
| 0x40;
3818 outb(val
, (brdp
->iobase
+ ONB_EICONFR
));
3822 /*****************************************************************************/
3824 static void stli_onbereset(stlibrd_t
*brdp
)
3828 printk("stli_onbereset(brdp=%x)\n", (int) brdp
);
3831 outb(ONB_EISTOP
, (brdp
->iobase
+ ONB_EICONFR
));
3833 outb(ONB_EIDISABLE
, (brdp
->iobase
+ ONB_EICONFR
));
3837 /*****************************************************************************/
3840 * The following routines act on Brumby boards.
3843 static void stli_bbyinit(stlibrd_t
*brdp
)
3847 printk("stli_bbyinit(brdp=%d)\n", (int) brdp
);
3850 outb(BBY_ATSTOP
, (brdp
->iobase
+ BBY_ATCONFR
));
3852 outb(0, (brdp
->iobase
+ BBY_ATCONFR
));
3854 outb(0x1, brdp
->iobase
);
3858 /*****************************************************************************/
3860 static char *stli_bbygetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
)
3866 printk("stli_bbygetmemptr(brdp=%x,offset=%x)\n", (int) brdp
,
3870 if (offset
> brdp
->memsize
) {
3871 printk("STALLION: shared memory pointer=%x out of range at "
3872 "line=%d(%d), brd=%d\n", (int) offset
, line
,
3873 __LINE__
, brdp
->brdnr
);
3877 ptr
= brdp
->membase
+ (offset
% BBY_PAGESIZE
);
3878 val
= (unsigned char) (offset
/ BBY_PAGESIZE
);
3880 outb(val
, (brdp
->iobase
+ BBY_ATCONFR
));
3884 /*****************************************************************************/
3886 static void stli_bbyreset(stlibrd_t
*brdp
)
3890 printk("stli_bbyreset(brdp=%x)\n", (int) brdp
);
3893 outb(BBY_ATSTOP
, (brdp
->iobase
+ BBY_ATCONFR
));
3895 outb(0, (brdp
->iobase
+ BBY_ATCONFR
));
3899 /*****************************************************************************/
3902 * The following routines act on original old Stallion boards.
3905 static void stli_stalinit(stlibrd_t
*brdp
)
3909 printk("stli_stalinit(brdp=%d)\n", (int) brdp
);
3912 outb(0x1, brdp
->iobase
);
3916 /*****************************************************************************/
3918 static char *stli_stalgetmemptr(stlibrd_t
*brdp
, unsigned long offset
, int line
)
3923 printk("stli_stalgetmemptr(brdp=%x,offset=%x)\n", (int) brdp
,
3927 if (offset
> brdp
->memsize
) {
3928 printk("STALLION: shared memory pointer=%x out of range at "
3929 "line=%d(%d), brd=%d\n", (int) offset
, line
,
3930 __LINE__
, brdp
->brdnr
);
3933 ptr
= brdp
->membase
+ (offset
% STAL_PAGESIZE
);
3938 /*****************************************************************************/
3940 static void stli_stalreset(stlibrd_t
*brdp
)
3942 volatile unsigned long *vecp
;
3945 printk("stli_stalreset(brdp=%x)\n", (int) brdp
);
3948 vecp
= (volatile unsigned long *) (brdp
->membase
+ 0x30);
3950 outb(0, brdp
->iobase
);
3954 /*****************************************************************************/
3957 * Try to find an ECP board and initialize it. This handles only ECP
3961 static inline int stli_initecp(stlibrd_t
*brdp
)
3965 unsigned int status
, nxtid
;
3967 int panelnr
, nrports
;
3970 printk("stli_initecp(brdp=%x)\n", (int) brdp
);
3974 * Do a basic sanity check on the IO and memory addresses.
3976 if ((brdp
->iobase
== 0) || (brdp
->memaddr
== 0))
3979 brdp
->iosize
= ECP_IOSIZE
;
3980 if (check_region(brdp
->iobase
, brdp
->iosize
))
3981 printk("STALLION: Warning, board %d I/O address %x conflicts "
3982 "with another device\n", brdp
->brdnr
, brdp
->iobase
);
3985 * Based on the specific board type setup the common vars to access
3986 * and enable shared memory. Set all board specific information now
3989 switch (brdp
->brdtype
) {
3991 brdp
->membase
= (void *) brdp
->memaddr
;
3992 brdp
->memsize
= ECP_MEMSIZE
;
3993 brdp
->pagesize
= ECP_ATPAGESIZE
;
3994 brdp
->init
= stli_ecpinit
;
3995 brdp
->enable
= stli_ecpenable
;
3996 brdp
->reenable
= stli_ecpenable
;
3997 brdp
->disable
= stli_ecpdisable
;
3998 brdp
->getmemptr
= stli_ecpgetmemptr
;
3999 brdp
->intr
= stli_ecpintr
;
4000 brdp
->reset
= stli_ecpreset
;
4001 name
= "serial(EC8/64)";
4005 brdp
->membase
= (void *) brdp
->memaddr
;
4006 brdp
->memsize
= ECP_MEMSIZE
;
4007 brdp
->pagesize
= ECP_EIPAGESIZE
;
4008 brdp
->init
= stli_ecpeiinit
;
4009 brdp
->enable
= stli_ecpeienable
;
4010 brdp
->reenable
= stli_ecpeienable
;
4011 brdp
->disable
= stli_ecpeidisable
;
4012 brdp
->getmemptr
= stli_ecpeigetmemptr
;
4013 brdp
->intr
= stli_ecpintr
;
4014 brdp
->reset
= stli_ecpeireset
;
4015 name
= "serial(EC8/64-EI)";
4019 brdp
->membase
= (void *) brdp
->memaddr
;
4020 brdp
->memsize
= ECP_MEMSIZE
;
4021 brdp
->pagesize
= ECP_MCPAGESIZE
;
4023 brdp
->enable
= stli_ecpmcenable
;
4024 brdp
->reenable
= stli_ecpmcenable
;
4025 brdp
->disable
= stli_ecpmcdisable
;
4026 brdp
->getmemptr
= stli_ecpmcgetmemptr
;
4027 brdp
->intr
= stli_ecpintr
;
4028 brdp
->reset
= stli_ecpmcreset
;
4029 name
= "serial(EC8/64-MCA)";
4033 brdp
->membase
= (void *) brdp
->memaddr
;
4034 brdp
->memsize
= ECP_PCIMEMSIZE
;
4035 brdp
->pagesize
= ECP_PCIPAGESIZE
;
4036 brdp
->init
= stli_ecppciinit
;
4037 brdp
->enable
= NULL
;
4038 brdp
->reenable
= NULL
;
4039 brdp
->disable
= NULL
;
4040 brdp
->getmemptr
= stli_ecppcigetmemptr
;
4041 brdp
->intr
= stli_ecpintr
;
4042 brdp
->reset
= stli_ecppcireset
;
4043 name
= "serial(EC/RA-PCI)";
4051 * The per-board operations structure is all set up, so now let's go
4052 * and get the board operational. Firstly initialize board configuration
4053 * registers. Set the memory mapping info so we can get at the boards
4058 brdp
->membase
= ioremap(brdp
->memaddr
, brdp
->memsize
);
4059 if (brdp
->membase
== (void *) NULL
)
4063 * Now that all specific code is set up, enable the shared memory and
4064 * look for the a signature area that will tell us exactly what board
4065 * this is, and what it is connected to it.
4068 sigsp
= (cdkecpsig_t
*) EBRDGETMEMPTR(brdp
, CDK_SIGADDR
);
4069 memcpy(&sig
, sigsp
, sizeof(cdkecpsig_t
));
4073 printk("%s(%d): sig-> magic=%x rom=%x panel=%x,%x,%x,%x,%x,%x,%x,%x\n",
4074 __FILE__
, __LINE__
, (int) sig
.magic
, sig
.romver
, sig
.panelid
[0],
4075 (int) sig
.panelid
[1], (int) sig
.panelid
[2],
4076 (int) sig
.panelid
[3], (int) sig
.panelid
[4],
4077 (int) sig
.panelid
[5], (int) sig
.panelid
[6],
4078 (int) sig
.panelid
[7]);
4081 if (sig
.magic
!= ECP_MAGIC
)
4085 * Scan through the signature looking at the panels connected to the
4086 * board. Calculate the total number of ports as we go.
4088 for (panelnr
= 0, nxtid
= 0; (panelnr
< STL_MAXPANELS
); panelnr
++) {
4089 status
= sig
.panelid
[nxtid
];
4090 if ((status
& ECH_PNLIDMASK
) != nxtid
)
4093 brdp
->panelids
[panelnr
] = status
;
4094 nrports
= (status
& ECH_PNL16PORT
) ? 16 : 8;
4095 if ((nrports
== 16) && ((status
& ECH_PNLXPID
) == 0))
4097 brdp
->panels
[panelnr
] = nrports
;
4098 brdp
->nrports
+= nrports
;
4103 request_region(brdp
->iobase
, brdp
->iosize
, name
);
4104 brdp
->state
|= BST_FOUND
;
4108 /*****************************************************************************/
4111 * Try to find an ONboard, Brumby or Stallion board and initialize it.
4112 * This handles only these board types.
4115 static inline int stli_initonb(stlibrd_t
*brdp
)
4123 printk("stli_initonb(brdp=%x)\n", (int) brdp
);
4127 * Do a basic sanity check on the IO and memory addresses.
4129 if ((brdp
->iobase
== 0) || (brdp
->memaddr
== 0))
4132 brdp
->iosize
= ONB_IOSIZE
;
4133 if (check_region(brdp
->iobase
, brdp
->iosize
))
4134 printk("STALLION: Warning, board %d I/O address %x conflicts "
4135 "with another device\n", brdp
->brdnr
, brdp
->iobase
);
4138 * Based on the specific board type setup the common vars to access
4139 * and enable shared memory. Set all board specific information now
4142 switch (brdp
->brdtype
) {
4146 case BRD_ONBOARD2_32
:
4148 brdp
->membase
= (void *) brdp
->memaddr
;
4149 brdp
->memsize
= ONB_MEMSIZE
;
4150 brdp
->pagesize
= ONB_ATPAGESIZE
;
4151 brdp
->init
= stli_onbinit
;
4152 brdp
->enable
= stli_onbenable
;
4153 brdp
->reenable
= stli_onbenable
;
4154 brdp
->disable
= stli_onbdisable
;
4155 brdp
->getmemptr
= stli_onbgetmemptr
;
4156 brdp
->intr
= stli_ecpintr
;
4157 brdp
->reset
= stli_onbreset
;
4158 if (brdp
->memaddr
> 0x100000)
4159 brdp
->enabval
= ONB_MEMENABHI
;
4161 brdp
->enabval
= ONB_MEMENABLO
;
4162 name
= "serial(ONBoard)";
4166 brdp
->membase
= (void *) brdp
->memaddr
;
4167 brdp
->memsize
= ONB_EIMEMSIZE
;
4168 brdp
->pagesize
= ONB_EIPAGESIZE
;
4169 brdp
->init
= stli_onbeinit
;
4170 brdp
->enable
= stli_onbeenable
;
4171 brdp
->reenable
= stli_onbeenable
;
4172 brdp
->disable
= stli_onbedisable
;
4173 brdp
->getmemptr
= stli_onbegetmemptr
;
4174 brdp
->intr
= stli_ecpintr
;
4175 brdp
->reset
= stli_onbereset
;
4176 name
= "serial(ONBoard/E)";
4182 brdp
->membase
= (void *) brdp
->memaddr
;
4183 brdp
->memsize
= BBY_MEMSIZE
;
4184 brdp
->pagesize
= BBY_PAGESIZE
;
4185 brdp
->init
= stli_bbyinit
;
4186 brdp
->enable
= NULL
;
4187 brdp
->reenable
= NULL
;
4188 brdp
->disable
= NULL
;
4189 brdp
->getmemptr
= stli_bbygetmemptr
;
4190 brdp
->intr
= stli_ecpintr
;
4191 brdp
->reset
= stli_bbyreset
;
4192 name
= "serial(Brumby)";
4196 brdp
->membase
= (void *) brdp
->memaddr
;
4197 brdp
->memsize
= STAL_MEMSIZE
;
4198 brdp
->pagesize
= STAL_PAGESIZE
;
4199 brdp
->init
= stli_stalinit
;
4200 brdp
->enable
= NULL
;
4201 brdp
->reenable
= NULL
;
4202 brdp
->disable
= NULL
;
4203 brdp
->getmemptr
= stli_stalgetmemptr
;
4204 brdp
->intr
= stli_ecpintr
;
4205 brdp
->reset
= stli_stalreset
;
4206 name
= "serial(Stallion)";
4214 * The per-board operations structure is all set up, so now let's go
4215 * and get the board operational. Firstly initialize board configuration
4216 * registers. Set the memory mapping info so we can get at the boards
4221 brdp
->membase
= ioremap(brdp
->memaddr
, brdp
->memsize
);
4222 if (brdp
->membase
== (void *) NULL
)
4226 * Now that all specific code is set up, enable the shared memory and
4227 * look for the a signature area that will tell us exactly what board
4228 * this is, and how many ports.
4231 sigsp
= (cdkonbsig_t
*) EBRDGETMEMPTR(brdp
, CDK_SIGADDR
);
4232 memcpy(&sig
, sigsp
, sizeof(cdkonbsig_t
));
4236 printk("%s(%d): sig-> magic=%x:%x:%x:%x romver=%x amask=%x:%x:%x\n",
4237 __FILE__
, __LINE__
, sig
.magic0
, sig
.magic1
, sig
.magic2
,
4238 sig
.magic3
, sig
.romver
, sig
.amask0
, sig
.amask1
, sig
.amask2
);
4241 if ((sig
.magic0
!= ONB_MAGIC0
) || (sig
.magic1
!= ONB_MAGIC1
) ||
4242 (sig
.magic2
!= ONB_MAGIC2
) || (sig
.magic3
!= ONB_MAGIC3
))
4246 * Scan through the signature alive mask and calculate how many ports
4247 * there are on this board.
4253 for (i
= 0; (i
< 16); i
++) {
4254 if (((sig
.amask0
<< i
) & 0x8000) == 0)
4259 brdp
->panels
[0] = brdp
->nrports
;
4261 request_region(brdp
->iobase
, brdp
->iosize
, name
);
4262 brdp
->state
|= BST_FOUND
;
4266 /*****************************************************************************/
4269 * Start up a running board. This routine is only called after the
4270 * code has been down loaded to the board and is operational. It will
4271 * read in the memory map, and get the show on the road...
4274 static int stli_startbrd(stlibrd_t
*brdp
)
4276 volatile cdkhdr_t
*hdrp
;
4277 volatile cdkmem_t
*memp
;
4278 volatile cdkasy_t
*ap
;
4279 unsigned long flags
;
4281 int portnr
, nrdevs
, i
, rc
;
4284 printk("stli_startbrd(brdp=%x)\n", (int) brdp
);
4292 hdrp
= (volatile cdkhdr_t
*) EBRDGETMEMPTR(brdp
, CDK_CDKADDR
);
4293 nrdevs
= hdrp
->nrdevs
;
4296 printk("%s(%d): CDK version %d.%d.%d --> "
4297 "nrdevs=%d memp=%x hostp=%x slavep=%x\n",
4298 __FILE__
, __LINE__
, hdrp
->ver_release
, hdrp
->ver_modification
,
4299 hdrp
->ver_fix
, nrdevs
, (int) hdrp
->memp
, (int) hdrp
->hostp
,
4300 (int) hdrp
->slavep
);
4303 if (nrdevs
< (brdp
->nrports
+ 1)) {
4304 printk("STALLION: slave failed to allocate memory for all "
4305 "devices, devices=%d\n", nrdevs
);
4306 brdp
->nrports
= nrdevs
- 1;
4308 brdp
->nrdevs
= nrdevs
;
4309 brdp
->hostoffset
= hdrp
->hostp
- CDK_CDKADDR
;
4310 brdp
->slaveoffset
= hdrp
->slavep
- CDK_CDKADDR
;
4311 brdp
->bitsize
= (nrdevs
+ 7) / 8;
4312 memp
= (volatile cdkmem_t
*) hdrp
->memp
;
4313 if (((unsigned long) memp
) > brdp
->memsize
) {
4314 printk("STALLION: corrupted shared memory region?\n");
4316 goto stli_donestartup
;
4318 memp
= (volatile cdkmem_t
*) EBRDGETMEMPTR(brdp
, (unsigned long) memp
);
4319 if (memp
->dtype
!= TYP_ASYNCTRL
) {
4320 printk("STALLION: no slave control device found\n");
4321 goto stli_donestartup
;
4326 * Cycle through memory allocation of each port. We are guaranteed to
4327 * have all ports inside the first page of slave window, so no need to
4328 * change pages while reading memory map.
4330 for (i
= 1, portnr
= 0; (i
< nrdevs
); i
++, portnr
++, memp
++) {
4331 if (memp
->dtype
!= TYP_ASYNC
)
4333 portp
= brdp
->ports
[portnr
];
4334 if (portp
== (stliport_t
*) NULL
)
4337 portp
->addr
= memp
->offset
;
4338 portp
->reqbit
= (unsigned char) (0x1 << (i
* 8 / nrdevs
));
4339 portp
->portidx
= (unsigned char) (i
/ 8);
4340 portp
->portbit
= (unsigned char) (0x1 << (i
% 8));
4343 hdrp
->slavereq
= 0xff;
4346 * For each port setup a local copy of the RX and TX buffer offsets
4347 * and sizes. We do this separate from the above, because we need to
4348 * move the shared memory page...
4350 for (i
= 1, portnr
= 0; (i
< nrdevs
); i
++, portnr
++) {
4351 portp
= brdp
->ports
[portnr
];
4352 if (portp
== (stliport_t
*) NULL
)
4354 if (portp
->addr
== 0)
4356 ap
= (volatile cdkasy_t
*) EBRDGETMEMPTR(brdp
, portp
->addr
);
4357 if (ap
!= (volatile cdkasy_t
*) NULL
) {
4358 portp
->rxsize
= ap
->rxq
.size
;
4359 portp
->txsize
= ap
->txq
.size
;
4360 portp
->rxoffset
= ap
->rxq
.offset
;
4361 portp
->txoffset
= ap
->txq
.offset
;
4367 restore_flags(flags
);
4370 brdp
->state
|= BST_STARTED
;
4372 if (! stli_timeron
) {
4374 stli_timerlist
.expires
= STLI_TIMEOUT
;
4375 add_timer(&stli_timerlist
);
4381 /*****************************************************************************/
4384 * Probe and initialize the specified board.
4387 static int __init
stli_brdinit(stlibrd_t
*brdp
)
4390 printk("stli_brdinit(brdp=%x)\n", (int) brdp
);
4393 stli_brds
[brdp
->brdnr
] = brdp
;
4395 switch (brdp
->brdtype
) {
4406 case BRD_ONBOARD2_32
:
4418 printk("STALLION: %s board type not supported in this driver\n",
4419 stli_brdnames
[brdp
->brdtype
]);
4422 printk("STALLION: board=%d is unknown board type=%d\n",
4423 brdp
->brdnr
, brdp
->brdtype
);
4427 if ((brdp
->state
& BST_FOUND
) == 0) {
4428 printk("STALLION: %s board not found, board=%d io=%x mem=%x\n",
4429 stli_brdnames
[brdp
->brdtype
], brdp
->brdnr
,
4430 brdp
->iobase
, (int) brdp
->memaddr
);
4434 stli_initports(brdp
);
4435 printk("STALLION: %s found, board=%d io=%x mem=%x "
4436 "nrpanels=%d nrports=%d\n", stli_brdnames
[brdp
->brdtype
],
4437 brdp
->brdnr
, brdp
->iobase
, (int) brdp
->memaddr
,
4438 brdp
->nrpanels
, brdp
->nrports
);
4442 /*****************************************************************************/
4445 * Probe around trying to find where the EISA boards shared memory
4446 * might be. This is a bit if hack, but it is the best we can do.
4449 static inline int stli_eisamemprobe(stlibrd_t
*brdp
)
4451 cdkecpsig_t ecpsig
, *ecpsigp
;
4452 cdkonbsig_t onbsig
, *onbsigp
;
4456 printk("stli_eisamemprobe(brdp=%x)\n", (int) brdp
);
4460 * First up we reset the board, to get it into a known state. There
4461 * is only 2 board types here we need to worry about. Don;t use the
4462 * standard board init routine here, it programs up the shared
4463 * memory address, and we don't know it yet...
4465 if (brdp
->brdtype
== BRD_ECPE
) {
4466 outb(0x1, (brdp
->iobase
+ ECP_EIBRDENAB
));
4467 outb(ECP_EISTOP
, (brdp
->iobase
+ ECP_EICONFR
));
4469 outb(ECP_EIDISABLE
, (brdp
->iobase
+ ECP_EICONFR
));
4471 stli_ecpeienable(brdp
);
4472 } else if (brdp
->brdtype
== BRD_ONBOARDE
) {
4473 outb(0x1, (brdp
->iobase
+ ONB_EIBRDENAB
));
4474 outb(ONB_EISTOP
, (brdp
->iobase
+ ONB_EICONFR
));
4476 outb(ONB_EIDISABLE
, (brdp
->iobase
+ ONB_EICONFR
));
4478 outb(0x1, brdp
->iobase
);
4480 stli_onbeenable(brdp
);
4486 brdp
->memsize
= ECP_MEMSIZE
;
4489 * Board shared memory is enabled, so now we have a poke around and
4490 * see if we can find it.
4492 for (i
= 0; (i
< stli_eisamempsize
); i
++) {
4493 brdp
->memaddr
= stli_eisamemprobeaddrs
[i
];
4494 brdp
->membase
= (void *) brdp
->memaddr
;
4495 brdp
->membase
= ioremap(brdp
->memaddr
, brdp
->memsize
);
4496 if (brdp
->membase
== (void *) NULL
)
4499 if (brdp
->brdtype
== BRD_ECPE
) {
4500 ecpsigp
= (cdkecpsig_t
*) stli_ecpeigetmemptr(brdp
,
4501 CDK_SIGADDR
, __LINE__
);
4502 memcpy(&ecpsig
, ecpsigp
, sizeof(cdkecpsig_t
));
4503 if (ecpsig
.magic
== ECP_MAGIC
)
4506 onbsigp
= (cdkonbsig_t
*) stli_onbegetmemptr(brdp
,
4507 CDK_SIGADDR
, __LINE__
);
4508 memcpy(&onbsig
, onbsigp
, sizeof(cdkonbsig_t
));
4509 if ((onbsig
.magic0
== ONB_MAGIC0
) &&
4510 (onbsig
.magic1
== ONB_MAGIC1
) &&
4511 (onbsig
.magic2
== ONB_MAGIC2
) &&
4512 (onbsig
.magic3
== ONB_MAGIC3
))
4516 iounmap(brdp
->membase
);
4522 * Regardless of whether we found the shared memory or not we must
4523 * disable the region. After that return success or failure.
4525 if (brdp
->brdtype
== BRD_ECPE
)
4526 stli_ecpeidisable(brdp
);
4528 stli_onbedisable(brdp
);
4533 printk("STALLION: failed to probe shared memory region for "
4534 "%s in EISA slot=%d\n", stli_brdnames
[brdp
->brdtype
],
4535 (brdp
->iobase
>> 12));
4541 /*****************************************************************************/
4544 * Probe around and try to find any EISA boards in system. The biggest
4545 * problem here is finding out what memory address is associated with
4546 * an EISA board after it is found. The registers of the ECPE and
4547 * ONboardE are not readable - so we can't read them from there. We
4548 * don't have access to the EISA CMOS (or EISA BIOS) so we don't
4549 * actually have any way to find out the real value. The best we can
4550 * do is go probing around in the usual places hoping we can find it.
4553 static inline int stli_findeisabrds()
4556 unsigned int iobase
, eid
;
4560 printk("stli_findeisabrds()\n");
4564 * Firstly check if this is an EISA system. Do this by probing for
4565 * the system board EISA ID. If this is not an EISA system then
4566 * don't bother going any further!
4569 if (inb(0xc80) == 0xff)
4573 * Looks like an EISA system, so go searching for EISA boards.
4575 for (iobase
= 0x1000; (iobase
<= 0xc000); iobase
+= 0x1000) {
4576 outb(0xff, (iobase
+ 0xc80));
4577 eid
= inb(iobase
+ 0xc80);
4578 eid
|= inb(iobase
+ 0xc81) << 8;
4579 if (eid
!= STL_EISAID
)
4583 * We have found a board. Need to check if this board was
4584 * statically configured already (just in case!).
4586 for (i
= 0; (i
< STL_MAXBRDS
); i
++) {
4587 brdp
= stli_brds
[i
];
4588 if (brdp
== (stlibrd_t
*) NULL
)
4590 if (brdp
->iobase
== iobase
)
4593 if (i
< STL_MAXBRDS
)
4597 * We have found a Stallion board and it is not configured already.
4598 * Allocate a board structure and initialize it.
4600 if ((brdp
= stli_allocbrd()) == (stlibrd_t
*) NULL
)
4602 if ((brdp
->brdnr
= stli_getbrdnr()) < 0)
4604 eid
= inb(iobase
+ 0xc82);
4605 if (eid
== ECP_EISAID
)
4606 brdp
->brdtype
= BRD_ECPE
;
4607 else if (eid
== ONB_EISAID
)
4608 brdp
->brdtype
= BRD_ONBOARDE
;
4610 brdp
->brdtype
= BRD_UNKNOWN
;
4611 brdp
->iobase
= iobase
;
4612 outb(0x1, (iobase
+ 0xc84));
4613 if (stli_eisamemprobe(brdp
))
4614 outb(0, (iobase
+ 0xc84));
4621 /*****************************************************************************/
4624 * Find the next available board number that is free.
4627 static inline int stli_getbrdnr()
4631 for (i
= 0; (i
< STL_MAXBRDS
); i
++) {
4632 if (stli_brds
[i
] == (stlibrd_t
*) NULL
) {
4633 if (i
>= stli_nrbrds
)
4634 stli_nrbrds
= i
+ 1;
4641 /*****************************************************************************/
4646 * We have a Stallion board. Allocate a board structure and
4647 * initialize it. Read its IO and MEMORY resources from PCI
4648 * configuration space.
4651 static inline int stli_initpcibrd(int brdtype
, struct pci_dev
*devp
)
4656 printk("stli_initpcibrd(brdtype=%d,busnr=%x,devnr=%x)\n", brdtype
,
4657 dev
->bus
->number
, dev
->devfn
);
4660 if ((brdp
= stli_allocbrd()) == (stlibrd_t
*) NULL
)
4662 if ((brdp
->brdnr
= stli_getbrdnr()) < 0) {
4663 printk("STALLION: too many boards found, "
4664 "maximum supported %d\n", STL_MAXBRDS
);
4667 brdp
->brdtype
= brdtype
;
4670 printk("%s(%d): BAR[]=%x,%x,%x,%x\n", __FILE__
, __LINE__
,
4671 devp
->resource
[0].start
, devp
->resource
[1].start
,
4672 devp
->resource
[2].start
, devp
->resource
[3].start
);
4676 * We have all resources from the board, so lets setup the actual
4677 * board structure now.
4679 brdp
->iobase
= (devp
->resource
[3].start
& PCI_BASE_ADDRESS_IO_MASK
);
4680 brdp
->memaddr
= (devp
->resource
[2].start
& PCI_BASE_ADDRESS_MEM_MASK
);
4686 /*****************************************************************************/
4689 * Find all Stallion PCI boards that might be installed. Initialize each
4690 * one as it is found.
4693 static inline int stli_findpcibrds()
4695 struct pci_dev
*dev
= NULL
;
4699 printk("stli_findpcibrds()\n");
4702 if (! pci_present())
4705 while ((dev
= pci_find_device(PCI_VENDOR_ID_STALLION
,
4706 PCI_DEVICE_ID_ECRA
, dev
))) {
4707 if ((rc
= stli_initpcibrd(BRD_ECPPCI
, dev
)))
4716 /*****************************************************************************/
4719 * Allocate a new board structure. Fill out the basic info in it.
4722 static stlibrd_t
*stli_allocbrd()
4726 brdp
= (stlibrd_t
*) stli_memalloc(sizeof(stlibrd_t
));
4727 if (brdp
== (stlibrd_t
*) NULL
) {
4728 printk("STALLION: failed to allocate memory (size=%d)\n",
4730 return((stlibrd_t
*) NULL
);
4733 memset(brdp
, 0, sizeof(stlibrd_t
));
4734 brdp
->magic
= STLI_BOARDMAGIC
;
4738 /*****************************************************************************/
4741 * Scan through all the boards in the configuration and see what we
4745 static inline int stli_initbrds()
4747 stlibrd_t
*brdp
, *nxtbrdp
;
4752 printk("stli_initbrds()\n");
4755 if (stli_nrbrds
> STL_MAXBRDS
) {
4756 printk("STALLION: too many boards in configuration table, "
4757 "truncating to %d\n", STL_MAXBRDS
);
4758 stli_nrbrds
= STL_MAXBRDS
;
4762 * Firstly scan the list of static boards configured. Allocate
4763 * resources and initialize the boards as found. If this is a
4764 * module then let the module args override static configuration.
4766 for (i
= 0; (i
< stli_nrbrds
); i
++) {
4767 confp
= &stli_brdconf
[i
];
4769 stli_parsebrd(confp
, stli_brdsp
[i
]);
4771 if ((brdp
= stli_allocbrd()) == (stlibrd_t
*) NULL
)
4774 brdp
->brdtype
= confp
->brdtype
;
4775 brdp
->iobase
= confp
->ioaddr1
;
4776 brdp
->memaddr
= confp
->memaddr
;
4781 * Static configuration table done, so now use dynamic methods to
4782 * see if any more boards should be configured.
4788 stli_findeisabrds();
4794 * All found boards are initialized. Now for a little optimization, if
4795 * no boards are sharing the "shared memory" regions then we can just
4796 * leave them all enabled. This is in fact the usual case.
4799 if (stli_nrbrds
> 1) {
4800 for (i
= 0; (i
< stli_nrbrds
); i
++) {
4801 brdp
= stli_brds
[i
];
4802 if (brdp
== (stlibrd_t
*) NULL
)
4804 for (j
= i
+ 1; (j
< stli_nrbrds
); j
++) {
4805 nxtbrdp
= stli_brds
[j
];
4806 if (nxtbrdp
== (stlibrd_t
*) NULL
)
4808 if ((brdp
->membase
>= nxtbrdp
->membase
) &&
4809 (brdp
->membase
<= (nxtbrdp
->membase
+
4810 nxtbrdp
->memsize
- 1))) {
4818 if (stli_shared
== 0) {
4819 for (i
= 0; (i
< stli_nrbrds
); i
++) {
4820 brdp
= stli_brds
[i
];
4821 if (brdp
== (stlibrd_t
*) NULL
)
4823 if (brdp
->state
& BST_FOUND
) {
4825 brdp
->enable
= NULL
;
4826 brdp
->disable
= NULL
;
4834 /*****************************************************************************/
4837 * Code to handle an "staliomem" read operation. This device is the
4838 * contents of the board shared memory. It is used for down loading
4839 * the slave image (and debugging :-)
4842 static ssize_t
stli_memread(struct file
*fp
, char *buf
, size_t count
, loff_t
*offp
)
4844 unsigned long flags
;
4850 printk("stli_memread(fp=%x,buf=%x,count=%x,offp=%x)\n", (int) fp
,
4851 (int) buf
, count
, (int) offp
);
4854 brdnr
= MINOR(fp
->f_dentry
->d_inode
->i_rdev
);
4855 if (brdnr
>= stli_nrbrds
)
4857 brdp
= stli_brds
[brdnr
];
4858 if (brdp
== (stlibrd_t
*) NULL
)
4860 if (brdp
->state
== 0)
4862 if (fp
->f_pos
>= brdp
->memsize
)
4865 size
= MIN(count
, (brdp
->memsize
- fp
->f_pos
));
4871 memptr
= (void *) EBRDGETMEMPTR(brdp
, fp
->f_pos
);
4872 n
= MIN(size
, (brdp
->pagesize
- (((unsigned long) fp
->f_pos
) % brdp
->pagesize
)));
4873 copy_to_user(buf
, memptr
, n
);
4879 restore_flags(flags
);
4884 /*****************************************************************************/
4887 * Code to handle an "staliomem" write operation. This device is the
4888 * contents of the board shared memory. It is used for down loading
4889 * the slave image (and debugging :-)
4892 static ssize_t
stli_memwrite(struct file
*fp
, const char *buf
, size_t count
, loff_t
*offp
)
4894 unsigned long flags
;
4901 printk("stli_memwrite(fp=%x,buf=%x,count=%x,offp=%x)\n", (int) fp
,
4902 (int) buf
, count
, (int) offp
);
4905 brdnr
= MINOR(fp
->f_dentry
->d_inode
->i_rdev
);
4906 if (brdnr
>= stli_nrbrds
)
4908 brdp
= stli_brds
[brdnr
];
4909 if (brdp
== (stlibrd_t
*) NULL
)
4911 if (brdp
->state
== 0)
4913 if (fp
->f_pos
>= brdp
->memsize
)
4916 chbuf
= (char *) buf
;
4917 size
= MIN(count
, (brdp
->memsize
- fp
->f_pos
));
4923 memptr
= (void *) EBRDGETMEMPTR(brdp
, fp
->f_pos
);
4924 n
= MIN(size
, (brdp
->pagesize
- (((unsigned long) fp
->f_pos
) % brdp
->pagesize
)));
4925 copy_from_user(memptr
, chbuf
, n
);
4931 restore_flags(flags
);
4936 /*****************************************************************************/
4939 * Return the board stats structure to user app.
4942 static int stli_getbrdstats(combrd_t
*bp
)
4947 copy_from_user(&stli_brdstats
, bp
, sizeof(combrd_t
));
4948 if (stli_brdstats
.brd
>= STL_MAXBRDS
)
4950 brdp
= stli_brds
[stli_brdstats
.brd
];
4951 if (brdp
== (stlibrd_t
*) NULL
)
4954 memset(&stli_brdstats
, 0, sizeof(combrd_t
));
4955 stli_brdstats
.brd
= brdp
->brdnr
;
4956 stli_brdstats
.type
= brdp
->brdtype
;
4957 stli_brdstats
.hwid
= 0;
4958 stli_brdstats
.state
= brdp
->state
;
4959 stli_brdstats
.ioaddr
= brdp
->iobase
;
4960 stli_brdstats
.memaddr
= brdp
->memaddr
;
4961 stli_brdstats
.nrpanels
= brdp
->nrpanels
;
4962 stli_brdstats
.nrports
= brdp
->nrports
;
4963 for (i
= 0; (i
< brdp
->nrpanels
); i
++) {
4964 stli_brdstats
.panels
[i
].panel
= i
;
4965 stli_brdstats
.panels
[i
].hwid
= brdp
->panelids
[i
];
4966 stli_brdstats
.panels
[i
].nrports
= brdp
->panels
[i
];
4969 copy_to_user(bp
, &stli_brdstats
, sizeof(combrd_t
));
4973 /*****************************************************************************/
4976 * Resolve the referenced port number into a port struct pointer.
4979 static stliport_t
*stli_getport(int brdnr
, int panelnr
, int portnr
)
4984 if ((brdnr
< 0) || (brdnr
>= STL_MAXBRDS
))
4985 return((stliport_t
*) NULL
);
4986 brdp
= stli_brds
[brdnr
];
4987 if (brdp
== (stlibrd_t
*) NULL
)
4988 return((stliport_t
*) NULL
);
4989 for (i
= 0; (i
< panelnr
); i
++)
4990 portnr
+= brdp
->panels
[i
];
4991 if ((portnr
< 0) || (portnr
>= brdp
->nrports
))
4992 return((stliport_t
*) NULL
);
4993 return(brdp
->ports
[portnr
]);
4996 /*****************************************************************************/
4999 * Return the port stats structure to user app. A NULL port struct
5000 * pointer passed in means that we need to find out from the app
5001 * what port to get stats for (used through board control device).
5004 static int stli_portcmdstats(stliport_t
*portp
)
5006 unsigned long flags
;
5010 memset(&stli_comstats
, 0, sizeof(comstats_t
));
5012 if (portp
== (stliport_t
*) NULL
)
5014 brdp
= stli_brds
[portp
->brdnr
];
5015 if (brdp
== (stlibrd_t
*) NULL
)
5018 if (brdp
->state
& BST_STARTED
) {
5019 if ((rc
= stli_cmdwait(brdp
, portp
, A_GETSTATS
,
5020 &stli_cdkstats
, sizeof(asystats_t
), 1)) < 0)
5023 memset(&stli_cdkstats
, 0, sizeof(asystats_t
));
5026 stli_comstats
.brd
= portp
->brdnr
;
5027 stli_comstats
.panel
= portp
->panelnr
;
5028 stli_comstats
.port
= portp
->portnr
;
5029 stli_comstats
.state
= portp
->state
;
5030 stli_comstats
.flags
= portp
->flags
;
5034 if (portp
->tty
!= (struct tty_struct
*) NULL
) {
5035 if (portp
->tty
->driver_data
== portp
) {
5036 stli_comstats
.ttystate
= portp
->tty
->flags
;
5037 stli_comstats
.rxbuffered
= portp
->tty
->flip
.count
;
5038 if (portp
->tty
->termios
!= (struct termios
*) NULL
) {
5039 stli_comstats
.cflags
= portp
->tty
->termios
->c_cflag
;
5040 stli_comstats
.iflags
= portp
->tty
->termios
->c_iflag
;
5041 stli_comstats
.oflags
= portp
->tty
->termios
->c_oflag
;
5042 stli_comstats
.lflags
= portp
->tty
->termios
->c_lflag
;
5046 restore_flags(flags
);
5048 stli_comstats
.txtotal
= stli_cdkstats
.txchars
;
5049 stli_comstats
.rxtotal
= stli_cdkstats
.rxchars
+ stli_cdkstats
.ringover
;
5050 stli_comstats
.txbuffered
= stli_cdkstats
.txringq
;
5051 stli_comstats
.rxbuffered
+= stli_cdkstats
.rxringq
;
5052 stli_comstats
.rxoverrun
= stli_cdkstats
.overruns
;
5053 stli_comstats
.rxparity
= stli_cdkstats
.parity
;
5054 stli_comstats
.rxframing
= stli_cdkstats
.framing
;
5055 stli_comstats
.rxlost
= stli_cdkstats
.ringover
;
5056 stli_comstats
.rxbreaks
= stli_cdkstats
.rxbreaks
;
5057 stli_comstats
.txbreaks
= stli_cdkstats
.txbreaks
;
5058 stli_comstats
.txxon
= stli_cdkstats
.txstart
;
5059 stli_comstats
.txxoff
= stli_cdkstats
.txstop
;
5060 stli_comstats
.rxxon
= stli_cdkstats
.rxstart
;
5061 stli_comstats
.rxxoff
= stli_cdkstats
.rxstop
;
5062 stli_comstats
.rxrtsoff
= stli_cdkstats
.rtscnt
/ 2;
5063 stli_comstats
.rxrtson
= stli_cdkstats
.rtscnt
- stli_comstats
.rxrtsoff
;
5064 stli_comstats
.modem
= stli_cdkstats
.dcdcnt
;
5065 stli_comstats
.hwid
= stli_cdkstats
.hwid
;
5066 stli_comstats
.signals
= stli_mktiocm(stli_cdkstats
.signals
);
5071 /*****************************************************************************/
5074 * Return the port stats structure to user app. A NULL port struct
5075 * pointer passed in means that we need to find out from the app
5076 * what port to get stats for (used through board control device).
5079 static int stli_getportstats(stliport_t
*portp
, comstats_t
*cp
)
5084 if (portp
== (stliport_t
*) NULL
) {
5085 copy_from_user(&stli_comstats
, cp
, sizeof(comstats_t
));
5086 portp
= stli_getport(stli_comstats
.brd
, stli_comstats
.panel
,
5087 stli_comstats
.port
);
5088 if (portp
== (stliport_t
*) NULL
)
5092 brdp
= stli_brds
[portp
->brdnr
];
5093 if (brdp
== (stlibrd_t
*) NULL
)
5096 if ((rc
= stli_portcmdstats(portp
)) < 0)
5099 copy_to_user(cp
, &stli_comstats
, sizeof(comstats_t
));
5103 /*****************************************************************************/
5106 * Clear the port stats structure. We also return it zeroed out...
5109 static int stli_clrportstats(stliport_t
*portp
, comstats_t
*cp
)
5114 if (portp
== (stliport_t
*) NULL
) {
5115 copy_from_user(&stli_comstats
, cp
, sizeof(comstats_t
));
5116 portp
= stli_getport(stli_comstats
.brd
, stli_comstats
.panel
,
5117 stli_comstats
.port
);
5118 if (portp
== (stliport_t
*) NULL
)
5122 brdp
= stli_brds
[portp
->brdnr
];
5123 if (brdp
== (stlibrd_t
*) NULL
)
5126 if (brdp
->state
& BST_STARTED
) {
5127 if ((rc
= stli_cmdwait(brdp
, portp
, A_CLEARSTATS
, 0, 0, 0)) < 0)
5131 memset(&stli_comstats
, 0, sizeof(comstats_t
));
5132 stli_comstats
.brd
= portp
->brdnr
;
5133 stli_comstats
.panel
= portp
->panelnr
;
5134 stli_comstats
.port
= portp
->portnr
;
5136 copy_to_user(cp
, &stli_comstats
, sizeof(comstats_t
));
5140 /*****************************************************************************/
5143 * Return the entire driver ports structure to a user app.
5146 static int stli_getportstruct(unsigned long arg
)
5150 copy_from_user(&stli_dummyport
, (void *) arg
, sizeof(stliport_t
));
5151 portp
= stli_getport(stli_dummyport
.brdnr
, stli_dummyport
.panelnr
,
5152 stli_dummyport
.portnr
);
5153 if (portp
== (stliport_t
*) NULL
)
5155 copy_to_user((void *) arg
, portp
, sizeof(stliport_t
));
5159 /*****************************************************************************/
5162 * Return the entire driver board structure to a user app.
5165 static int stli_getbrdstruct(unsigned long arg
)
5169 copy_from_user(&stli_dummybrd
, (void *) arg
, sizeof(stlibrd_t
));
5170 if ((stli_dummybrd
.brdnr
< 0) || (stli_dummybrd
.brdnr
>= STL_MAXBRDS
))
5172 brdp
= stli_brds
[stli_dummybrd
.brdnr
];
5173 if (brdp
== (stlibrd_t
*) NULL
)
5175 copy_to_user((void *) arg
, brdp
, sizeof(stlibrd_t
));
5179 /*****************************************************************************/
5182 * Memory device open code. Need to keep track of opens and close
5183 * for module handling.
5186 static int stli_memopen(struct inode
*ip
, struct file
*fp
)
5192 /*****************************************************************************/
5194 static int stli_memclose(struct inode
*ip
, struct file
*fp
)
5200 /*****************************************************************************/
5203 * The "staliomem" device is also required to do some special operations on
5204 * the board. We need to be able to send an interrupt to the board,
5205 * reset it, and start/stop it.
5208 static int stli_memioctl(struct inode
*ip
, struct file
*fp
, unsigned int cmd
, unsigned long arg
)
5211 int brdnr
, rc
, done
;
5214 printk("stli_memioctl(ip=%x,fp=%x,cmd=%x,arg=%x)\n", (int) ip
,
5215 (int) fp
, cmd
, (int) arg
);
5219 * First up handle the board independent ioctls.
5225 case COM_GETPORTSTATS
:
5226 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
5227 sizeof(comstats_t
))) == 0)
5228 rc
= stli_getportstats((stliport_t
*) NULL
,
5229 (comstats_t
*) arg
);
5232 case COM_CLRPORTSTATS
:
5233 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
5234 sizeof(comstats_t
))) == 0)
5235 rc
= stli_clrportstats((stliport_t
*) NULL
,
5236 (comstats_t
*) arg
);
5239 case COM_GETBRDSTATS
:
5240 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
5241 sizeof(combrd_t
))) == 0)
5242 rc
= stli_getbrdstats((combrd_t
*) arg
);
5246 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
5247 sizeof(stliport_t
))) == 0)
5248 rc
= stli_getportstruct(arg
);
5252 if ((rc
= verify_area(VERIFY_WRITE
, (void *) arg
,
5253 sizeof(stlibrd_t
))) == 0)
5254 rc
= stli_getbrdstruct(arg
);
5265 * Now handle the board specific ioctls. These all depend on the
5266 * minor number of the device they were called from.
5268 brdnr
= MINOR(ip
->i_rdev
);
5269 if (brdnr
>= STL_MAXBRDS
)
5271 brdp
= stli_brds
[brdnr
];
5272 if (brdp
== (stlibrd_t
*) NULL
)
5274 if (brdp
->state
== 0)
5282 rc
= stli_startbrd(brdp
);
5285 brdp
->state
&= ~BST_STARTED
;
5288 brdp
->state
&= ~BST_STARTED
;
5290 if (stli_shared
== 0) {
5291 if (brdp
->reenable
!= NULL
)
5292 (* brdp
->reenable
)(brdp
);
5303 /*****************************************************************************/
5305 int __init
stli_init(void)
5307 printk(KERN_INFO
"%s: version %s\n", stli_drvtitle
, stli_drvversion
);
5312 * Allocate a temporary write buffer.
5314 stli_tmpwritebuf
= (char *) stli_memalloc(STLI_TXBUFSIZE
);
5315 if (stli_tmpwritebuf
== (char *) NULL
)
5316 printk("STALLION: failed to allocate memory (size=%d)\n",
5318 stli_txcookbuf
= (char *) stli_memalloc(STLI_TXBUFSIZE
);
5319 if (stli_txcookbuf
== (char *) NULL
)
5320 printk("STALLION: failed to allocate memory (size=%d)\n",
5324 * Set up a character driver for the shared memory region. We need this
5325 * to down load the slave code image. Also it is a useful debugging tool.
5327 if (devfs_register_chrdev(STL_SIOMEMMAJOR
, "staliomem", &stli_fsiomem
))
5328 printk("STALLION: failed to register serial memory device\n");
5330 devfs_handle
= devfs_mk_dir (NULL
, "staliomem", 9, NULL
);
5331 devfs_register_series (devfs_handle
, "%u", 4, DEVFS_FL_DEFAULT
,
5333 S_IFCHR
| S_IRUSR
| S_IWUSR
, 0, 0,
5334 &stli_fsiomem
, NULL
);
5337 * Set up the tty driver structure and register us as a driver.
5338 * Also setup the callout tty device.
5340 memset(&stli_serial
, 0, sizeof(struct tty_driver
));
5341 stli_serial
.magic
= TTY_DRIVER_MAGIC
;
5342 stli_serial
.driver_name
= stli_drvname
;
5343 stli_serial
.name
= stli_serialname
;
5344 stli_serial
.major
= STL_SERIALMAJOR
;
5345 stli_serial
.minor_start
= 0;
5346 stli_serial
.num
= STL_MAXBRDS
* STL_MAXPORTS
;
5347 stli_serial
.type
= TTY_DRIVER_TYPE_SERIAL
;
5348 stli_serial
.subtype
= STL_DRVTYPSERIAL
;
5349 stli_serial
.init_termios
= stli_deftermios
;
5350 stli_serial
.flags
= TTY_DRIVER_REAL_RAW
;
5351 stli_serial
.refcount
= &stli_refcount
;
5352 stli_serial
.table
= stli_ttys
;
5353 stli_serial
.termios
= stli_termios
;
5354 stli_serial
.termios_locked
= stli_termioslocked
;
5356 stli_serial
.open
= stli_open
;
5357 stli_serial
.close
= stli_close
;
5358 stli_serial
.write
= stli_write
;
5359 stli_serial
.put_char
= stli_putchar
;
5360 stli_serial
.flush_chars
= stli_flushchars
;
5361 stli_serial
.write_room
= stli_writeroom
;
5362 stli_serial
.chars_in_buffer
= stli_charsinbuffer
;
5363 stli_serial
.ioctl
= stli_ioctl
;
5364 stli_serial
.set_termios
= stli_settermios
;
5365 stli_serial
.throttle
= stli_throttle
;
5366 stli_serial
.unthrottle
= stli_unthrottle
;
5367 stli_serial
.stop
= stli_stop
;
5368 stli_serial
.start
= stli_start
;
5369 stli_serial
.hangup
= stli_hangup
;
5370 stli_serial
.flush_buffer
= stli_flushbuffer
;
5371 stli_serial
.break_ctl
= stli_breakctl
;
5372 stli_serial
.wait_until_sent
= stli_waituntilsent
;
5373 stli_serial
.send_xchar
= stli_sendxchar
;
5374 stli_serial
.read_proc
= stli_readproc
;
5376 stli_callout
= stli_serial
;
5377 stli_callout
.name
= stli_calloutname
;
5378 stli_callout
.major
= STL_CALLOUTMAJOR
;
5379 stli_callout
.subtype
= STL_DRVTYPCALLOUT
;
5380 stli_callout
.read_proc
= 0;
5382 if (tty_register_driver(&stli_serial
))
5383 printk("STALLION: failed to register serial driver\n");
5384 if (tty_register_driver(&stli_callout
))
5385 printk("STALLION: failed to register callout driver\n");
5390 /*****************************************************************************/