2 * Copyright 2003 Digi International (www.digi.com)
3 * Scott H Kilau <Scott_Kilau at digi dot com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
12 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE!
22 * This is shared code between Digi's CVS archive and the
23 * Linux Kernel sources.
24 * Changing the source just for reformatting needlessly breaks
25 * our CVS diff history.
27 * Send any bug fixes/changes to: Eng.Linux at digi dot com.
33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 #include <linux/pci.h>
36 #include <linux/slab.h>
37 #include <linux/sched.h>
38 #include "dgnc_driver.h"
40 #include "dpacompat.h"
41 #include "dgnc_mgmt.h"
43 #include "dgnc_trace.h"
46 #include "dgnc_sysfs.h"
48 MODULE_LICENSE("GPL");
49 MODULE_AUTHOR("Digi International, http://www.digi.com");
50 MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line");
51 MODULE_SUPPORTED_DEVICE("dgnc");
54 * insmod command line overrideable parameters
56 * NOTE: we use a set of macros to create the variables, which allows
57 * us to specify the variable type, name, initial value, and description.
59 PARM_INT(debug, 0x00, 0644, "Driver debugging level");
60 PARM_INT(rawreadok, 1, 0644, "Bypass flip buffers on input");
61 PARM_INT(trcbuf_size, 0x100000, 0644, "Debugging trace buffer size.");
63 /**************************************************************************
65 * protos for this file
68 static int dgnc_start(void);
69 static int dgnc_finalize_board_init(struct dgnc_board *brd);
70 static void dgnc_init_globals(void);
71 static int dgnc_found_board(struct pci_dev *pdev, int id);
72 static void dgnc_cleanup_board(struct dgnc_board *brd);
73 static void dgnc_poll_handler(ulong dummy);
74 static int dgnc_init_pci(void);
75 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
76 static void dgnc_remove_one(struct pci_dev *dev);
77 static int dgnc_probe1(struct pci_dev *pdev, int card_type);
78 static void dgnc_do_remap(struct dgnc_board *brd);
80 /* Driver load/unload functions */
81 int dgnc_init_module(void);
82 void dgnc_cleanup_module(void);
84 module_init(dgnc_init_module);
85 module_exit(dgnc_cleanup_module);
89 * File operations permitted on Control/Management major.
91 static const struct file_operations dgnc_BoardFops =
94 .unlocked_ioctl = dgnc_mgmt_ioctl,
95 .open = dgnc_mgmt_open,
96 .release = dgnc_mgmt_close
104 struct dgnc_board *dgnc_Board[MAXBOARDS];
105 DEFINE_SPINLOCK(dgnc_global_lock);
106 int dgnc_driver_state = DRIVER_INITIALIZED;
107 ulong dgnc_poll_counter;
109 int dgnc_poll_tick = 20; /* Poll interval - 20 ms */
114 static uint dgnc_Major_Control_Registered = FALSE;
115 static uint dgnc_driver_start = FALSE;
117 static struct class *dgnc_class;
122 static DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
123 static ulong dgnc_poll_time; /* Time of next poll */
124 static uint dgnc_poll_stop; /* Used to tell poller to stop */
125 static struct timer_list dgnc_poll_timer;
128 static struct pci_device_id dgnc_pci_tbl[] = {
129 { DIGI_VID, PCI_DEVICE_CLASSIC_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
130 { DIGI_VID, PCI_DEVICE_CLASSIC_4_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
131 { DIGI_VID, PCI_DEVICE_CLASSIC_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
132 { DIGI_VID, PCI_DEVICE_CLASSIC_8_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 },
133 { DIGI_VID, PCI_DEVICE_NEO_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
134 { DIGI_VID, PCI_DEVICE_NEO_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 },
135 { DIGI_VID, PCI_DEVICE_NEO_2DB9_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 },
136 { DIGI_VID, PCI_DEVICE_NEO_2DB9PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 },
137 { DIGI_VID, PCI_DEVICE_NEO_2RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 },
138 { DIGI_VID, PCI_DEVICE_NEO_2RJ45PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 },
139 { DIGI_VID, PCI_DEVICE_NEO_1_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 },
140 { DIGI_VID, PCI_DEVICE_NEO_1_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 },
141 { DIGI_VID, PCI_DEVICE_NEO_2_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 },
142 { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 },
143 { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 },
144 { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 },
145 { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 },
146 {0,} /* 0 terminated list. */
148 MODULE_DEVICE_TABLE(pci, dgnc_pci_tbl);
153 unsigned int is_pci_express;
156 static struct board_id dgnc_Ids[] = {
157 { PCI_DEVICE_CLASSIC_4_PCI_NAME, 4, 0 },
158 { PCI_DEVICE_CLASSIC_4_422_PCI_NAME, 4, 0 },
159 { PCI_DEVICE_CLASSIC_8_PCI_NAME, 8, 0 },
160 { PCI_DEVICE_CLASSIC_8_422_PCI_NAME, 8, 0 },
161 { PCI_DEVICE_NEO_4_PCI_NAME, 4, 0 },
162 { PCI_DEVICE_NEO_8_PCI_NAME, 8, 0 },
163 { PCI_DEVICE_NEO_2DB9_PCI_NAME, 2, 0 },
164 { PCI_DEVICE_NEO_2DB9PRI_PCI_NAME, 2, 0 },
165 { PCI_DEVICE_NEO_2RJ45_PCI_NAME, 2, 0 },
166 { PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME, 2, 0 },
167 { PCI_DEVICE_NEO_1_422_PCI_NAME, 1, 0 },
168 { PCI_DEVICE_NEO_1_422_485_PCI_NAME, 1, 0 },
169 { PCI_DEVICE_NEO_2_422_485_PCI_NAME, 2, 0 },
170 { PCI_DEVICE_NEO_EXPRESS_8_PCI_NAME, 8, 1 },
171 { PCI_DEVICE_NEO_EXPRESS_4_PCI_NAME, 4, 1 },
172 { PCI_DEVICE_NEO_EXPRESS_4RJ45_PCI_NAME, 4, 1 },
173 { PCI_DEVICE_NEO_EXPRESS_8RJ45_PCI_NAME, 8, 1 },
177 static struct pci_driver dgnc_driver = {
179 .probe = dgnc_init_one,
180 .id_table = dgnc_pci_tbl,
181 .remove = dgnc_remove_one,
185 char *dgnc_state_text[] = {
191 char *dgnc_driver_state_text[] = {
192 "Driver Initialized",
198 /************************************************************************
200 * Driver load/unload functions
202 ************************************************************************/
208 * Module load. This is where it all starts.
210 int dgnc_init_module(void)
214 APR(("%s, Digi International Part Number %s\n", DG_NAME, DG_PART));
217 * Initialize global stuff
225 * Find and configure all the cards
227 rc = dgnc_init_pci();
230 * If something went wrong in the scan, bail out of driver.
233 /* Only unregister the pci driver if it was actually registered. */
235 pci_unregister_driver(&dgnc_driver);
237 pr_warn("WARNING: dgnc driver load failed. No Digi Neo or Classic boards found.\n");
239 dgnc_cleanup_module();
241 dgnc_create_driver_sysfiles(&dgnc_driver);
244 DPR_INIT(("Finished init_module. Returning %d\n", rc));
252 static int dgnc_start(void)
257 if (dgnc_driver_start == FALSE) {
259 dgnc_driver_start = TRUE;
261 /* make sure that the globals are init'd before we do anything else */
266 APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
269 * Register our base character device into the kernel.
270 * This allows the download daemon to connect to the downld device
271 * before any of the boards are init'ed.
273 if (!dgnc_Major_Control_Registered) {
275 * Register management/dpa devices
277 rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
279 APR(("Can't register dgnc driver device (%d)\n", rc));
285 dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
286 device_create(dgnc_class, NULL,
287 MKDEV(dgnc_Major, 0),
289 dgnc_Major_Control_Registered = TRUE;
293 * Init any global tty stuff.
295 rc = dgnc_tty_preinit();
298 APR(("tty preinit - not enough memory (%d)\n", rc));
302 /* Start the poller */
303 DGNC_LOCK(dgnc_poll_lock, flags);
304 init_timer(&dgnc_poll_timer);
305 dgnc_poll_timer.function = dgnc_poll_handler;
306 dgnc_poll_timer.data = 0;
307 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
308 dgnc_poll_timer.expires = dgnc_poll_time;
309 DGNC_UNLOCK(dgnc_poll_lock, flags);
311 add_timer(&dgnc_poll_timer);
313 dgnc_driver_state = DRIVER_READY;
320 * Register pci driver, and return how many boards we have.
322 static int dgnc_init_pci(void)
324 return pci_register_driver(&dgnc_driver);
328 /* returns count (>= 0), or negative on error */
329 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
333 /* wake up and enable device */
334 rc = pci_enable_device(pdev);
339 rc = dgnc_probe1(pdev, ent->driver_data);
342 DPR_INIT(("Incrementing numboards to %d\n", dgnc_NumBoards));
348 static int dgnc_probe1(struct pci_dev *pdev, int card_type)
350 return dgnc_found_board(pdev, card_type);
354 static void dgnc_remove_one(struct pci_dev *dev)
360 * dgnc_cleanup_module()
362 * Module unload. This is where it all ends.
364 void dgnc_cleanup_module(void)
369 DGNC_LOCK(dgnc_poll_lock, lock_flags);
371 DGNC_UNLOCK(dgnc_poll_lock, lock_flags);
373 /* Turn off poller right away. */
374 del_timer_sync(&dgnc_poll_timer);
376 dgnc_remove_driver_sysfiles(&dgnc_driver);
378 if (dgnc_Major_Control_Registered) {
379 device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
380 class_destroy(dgnc_class);
381 unregister_chrdev(dgnc_Major, "dgnc");
384 for (i = 0; i < dgnc_NumBoards; ++i) {
385 dgnc_remove_ports_sysfiles(dgnc_Board[i]);
386 dgnc_tty_uninit(dgnc_Board[i]);
387 dgnc_cleanup_board(dgnc_Board[i]);
390 dgnc_tty_post_uninit();
392 #if defined(DGNC_TRACER)
393 /* last thing, make sure we release the tracebuffer */
397 pci_unregister_driver(&dgnc_driver);
402 * dgnc_cleanup_board()
404 * Free all the memory associated with a board
406 static void dgnc_cleanup_board(struct dgnc_board *brd)
410 if(!brd || brd->magic != DGNC_BOARD_MAGIC)
413 switch (brd->device) {
414 case PCI_DEVICE_CLASSIC_4_DID:
415 case PCI_DEVICE_CLASSIC_8_DID:
416 case PCI_DEVICE_CLASSIC_4_422_DID:
417 case PCI_DEVICE_CLASSIC_8_422_DID:
419 /* Tell card not to interrupt anymore. */
420 outb(0, brd->iobase + 0x4c);
428 free_irq(brd->irq, brd);
430 tasklet_kill(&brd->helper_tasklet);
432 if (brd->re_map_membase) {
433 iounmap(brd->re_map_membase);
434 brd->re_map_membase = NULL;
437 if (brd->msgbuf_head) {
440 DGNC_LOCK(dgnc_global_lock, flags);
442 printk("%s", brd->msgbuf_head);
443 kfree(brd->msgbuf_head);
444 brd->msgbuf_head = NULL;
445 DGNC_UNLOCK(dgnc_global_lock, flags);
448 /* Free all allocated channels structs */
449 for (i = 0; i < MAXPORTS ; i++) {
450 if (brd->channels[i]) {
451 kfree(brd->channels[i]->ch_rqueue);
452 kfree(brd->channels[i]->ch_equeue);
453 kfree(brd->channels[i]->ch_wqueue);
454 kfree(brd->channels[i]);
455 brd->channels[i] = NULL;
461 dgnc_Board[brd->boardnum] = NULL;
470 * A board has been found, init it.
472 static int dgnc_found_board(struct pci_dev *pdev, int id)
474 struct dgnc_board *brd;
475 unsigned int pci_irq;
480 /* get the board structure and prep it */
481 brd = dgnc_Board[dgnc_NumBoards] =
482 kzalloc(sizeof(*brd), GFP_KERNEL);
486 /* make a temporary message buffer for the boot messages */
487 brd->msgbuf = brd->msgbuf_head =
488 kzalloc(sizeof(u8) * 8192, GFP_KERNEL);
494 /* store the info for the board we've found */
495 brd->magic = DGNC_BOARD_MAGIC;
496 brd->boardnum = dgnc_NumBoards;
497 brd->vendor = dgnc_pci_tbl[id].vendor;
498 brd->device = dgnc_pci_tbl[id].device;
500 brd->pci_bus = pdev->bus->number;
501 brd->pci_slot = PCI_SLOT(pdev->devfn);
502 brd->name = dgnc_Ids[id].name;
503 brd->maxports = dgnc_Ids[id].maxports;
504 if (dgnc_Ids[i].is_pci_express)
505 brd->bd_flags |= BD_IS_PCI_EXPRESS;
506 brd->dpastatus = BD_NOFEP;
507 init_waitqueue_head(&brd->state_wait);
509 DGNC_SPINLOCK_INIT(brd->bd_lock);
510 DGNC_SPINLOCK_INIT(brd->bd_intr_lock);
512 brd->state = BOARD_FOUND;
514 for (i = 0; i < MAXPORTS; i++)
515 brd->channels[i] = NULL;
517 /* store which card & revision we have */
518 pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor);
519 pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice);
520 pci_read_config_byte(pdev, PCI_REVISION_ID, &brd->rev);
526 switch(brd->device) {
528 case PCI_DEVICE_CLASSIC_4_DID:
529 case PCI_DEVICE_CLASSIC_8_DID:
530 case PCI_DEVICE_CLASSIC_4_422_DID:
531 case PCI_DEVICE_CLASSIC_8_422_DID:
533 brd->dpatype = T_CLASSIC | T_PCIBUS;
535 DPR_INIT(("dgnc_found_board - Classic.\n"));
538 * For PCI ClassicBoards
539 * PCI Local Address (i.e. "resource" number) space
540 * 0 PLX Memory Mapped Config
541 * 1 PLX I/O Mapped Config
542 * 2 I/O Mapped UARTs and Status
543 * 3 Memory Mapped VPD
544 * 4 Memory Mapped UARTs and Status
548 /* get the PCI Base Address Registers */
549 brd->membase = pci_resource_start(pdev, 4);
552 APR(("card has no PCI IO resources, failing board.\n"));
556 brd->membase_end = pci_resource_end(pdev, 4);
558 if (brd->membase & 1)
563 brd->iobase = pci_resource_start(pdev, 1);
564 brd->iobase_end = pci_resource_end(pdev, 1);
565 brd->iobase = ((unsigned int) (brd->iobase)) & 0xFFFE;
567 /* Assign the board_ops struct */
568 brd->bd_ops = &dgnc_cls_ops;
570 brd->bd_uart_offset = 0x8;
571 brd->bd_dividend = 921600;
575 /* Get and store the board VPD, if it exists */
576 brd->bd_ops->vpd(brd);
579 * Enable Local Interrupt 1 (0x1),
580 * Local Interrupt 1 Polarity Active high (0x2),
581 * Enable PCI interrupt (0x40)
583 outb(0x43, brd->iobase + 0x4c);
588 case PCI_DEVICE_NEO_4_DID:
589 case PCI_DEVICE_NEO_8_DID:
590 case PCI_DEVICE_NEO_2DB9_DID:
591 case PCI_DEVICE_NEO_2DB9PRI_DID:
592 case PCI_DEVICE_NEO_2RJ45_DID:
593 case PCI_DEVICE_NEO_2RJ45PRI_DID:
594 case PCI_DEVICE_NEO_1_422_DID:
595 case PCI_DEVICE_NEO_1_422_485_DID:
596 case PCI_DEVICE_NEO_2_422_485_DID:
597 case PCI_DEVICE_NEO_EXPRESS_8_DID:
598 case PCI_DEVICE_NEO_EXPRESS_4_DID:
599 case PCI_DEVICE_NEO_EXPRESS_4RJ45_DID:
600 case PCI_DEVICE_NEO_EXPRESS_8RJ45_DID:
603 * This chip is set up 100% when we get to it.
604 * No need to enable global interrupts or anything.
606 if (brd->bd_flags & BD_IS_PCI_EXPRESS)
607 brd->dpatype = T_NEO_EXPRESS | T_PCIBUS;
609 brd->dpatype = T_NEO | T_PCIBUS;
611 DPR_INIT(("dgnc_found_board - NEO.\n"));
613 /* get the PCI Base Address Registers */
614 brd->membase = pci_resource_start(pdev, 0);
615 brd->membase_end = pci_resource_end(pdev, 0);
617 if (brd->membase & 1)
622 /* Assign the board_ops struct */
623 brd->bd_ops = &dgnc_neo_ops;
625 brd->bd_uart_offset = 0x200;
626 brd->bd_dividend = 921600;
630 if (brd->re_map_membase) {
632 /* After remap is complete, we need to read and store the dvid */
633 brd->dvid = readb(brd->re_map_membase + 0x8D);
635 /* Get and store the board VPD, if it exists */
636 brd->bd_ops->vpd(brd);
641 APR(("Did not find any compatible Neo or Classic PCI boards in system.\n"));
647 * Do tty device initialization.
650 rc = dgnc_tty_register(brd);
652 dgnc_tty_uninit(brd);
653 APR(("Can't register tty devices (%d)\n", rc));
654 brd->state = BOARD_FAILED;
655 brd->dpastatus = BD_NOFEP;
659 rc = dgnc_finalize_board_init(brd);
661 APR(("Can't finalize board init (%d)\n", rc));
662 brd->state = BOARD_FAILED;
663 brd->dpastatus = BD_NOFEP;
668 rc = dgnc_tty_init(brd);
670 dgnc_tty_uninit(brd);
671 APR(("Can't init tty devices (%d)\n", rc));
672 brd->state = BOARD_FAILED;
673 brd->dpastatus = BD_NOFEP;
678 brd->state = BOARD_READY;
679 brd->dpastatus = BD_RUNNING;
681 dgnc_create_ports_sysfiles(brd);
683 /* init our poll helper tasklet */
684 tasklet_init(&brd->helper_tasklet, brd->bd_ops->tasklet, (unsigned long) brd);
686 DPR_INIT(("dgnc_scan(%d) - printing out the msgbuf\n", i));
687 DGNC_LOCK(dgnc_global_lock, flags);
689 printk("%s", brd->msgbuf_head);
690 kfree(brd->msgbuf_head);
691 brd->msgbuf_head = NULL;
692 DGNC_UNLOCK(dgnc_global_lock, flags);
695 * allocate flip buffer for board.
697 * Okay to malloc with GFP_KERNEL, we are not at interrupt
698 * context, and there are no locks held.
700 brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
702 wake_up_interruptible(&brd->state_wait);
713 static int dgnc_finalize_board_init(struct dgnc_board *brd) {
716 DPR_INIT(("dgnc_finalize_board_init() - start\n"));
718 if (!brd || brd->magic != DGNC_BOARD_MAGIC)
721 DPR_INIT(("dgnc_finalize_board_init() - start #2\n"));
724 rc = request_irq(brd->irq, brd->bd_ops->intr,
725 IRQF_SHARED, "DGNC", brd);
728 dev_err(&brd->pdev->dev,
729 "Failed to hook IRQ %d\n", brd->irq);
730 brd->state = BOARD_FAILED;
731 brd->dpastatus = BD_NOFEP;
734 DPR_INIT(("Requested and received usage of IRQ %d\n",
744 static void dgnc_do_remap(struct dgnc_board *brd)
747 if (!brd || brd->magic != DGNC_BOARD_MAGIC)
750 brd->re_map_membase = ioremap(brd->membase, 0x1000);
752 DPR_INIT(("remapped mem: 0x%p\n", brd->re_map_membase));
756 /*****************************************************************************
776 * As each timer expires, it determines (a) whether the "transmit"
777 * waiter needs to be woken up, and (b) whether the poller needs to
780 ******************************************************************************/
782 static void dgnc_poll_handler(ulong dummy)
784 struct dgnc_board *brd;
785 unsigned long lock_flags;
787 unsigned long new_time;
792 * Do not start the board state machine until
793 * driver tells us its up and running, and has
794 * everything it needs.
796 if (dgnc_driver_state != DRIVER_READY)
797 goto schedule_poller;
799 /* Go thru each board, kicking off a tasklet for each if needed */
800 for (i = 0; i < dgnc_NumBoards; i++) {
803 DGNC_LOCK(brd->bd_lock, lock_flags);
805 /* If board is in a failed state, don't bother scheduling a tasklet */
806 if (brd->state == BOARD_FAILED) {
807 DGNC_UNLOCK(brd->bd_lock, lock_flags);
811 /* Schedule a poll helper task */
812 tasklet_schedule(&brd->helper_tasklet);
814 DGNC_UNLOCK(brd->bd_lock, lock_flags);
820 * Schedule ourself back at the nominal wakeup interval.
822 DGNC_LOCK(dgnc_poll_lock, lock_flags);
823 dgnc_poll_time += dgnc_jiffies_from_ms(dgnc_poll_tick);
825 new_time = dgnc_poll_time - jiffies;
827 if ((ulong) new_time >= 2 * dgnc_poll_tick)
828 dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
830 init_timer(&dgnc_poll_timer);
831 dgnc_poll_timer.function = dgnc_poll_handler;
832 dgnc_poll_timer.data = 0;
833 dgnc_poll_timer.expires = dgnc_poll_time;
834 DGNC_UNLOCK(dgnc_poll_lock, lock_flags);
837 add_timer(&dgnc_poll_timer);
841 * dgnc_init_globals()
843 * This is where we initialize the globals from the static insmod
844 * configuration variables. These are declared near the head of
847 static void dgnc_init_globals(void)
851 dgnc_rawreadok = rawreadok;
852 dgnc_trcbuf_size = trcbuf_size;
855 for (i = 0; i < MAXBOARDS; i++)
856 dgnc_Board[i] = NULL;
858 init_timer(&dgnc_poll_timer);
862 /************************************************************************
866 ************************************************************************/
871 * Put the driver to sleep for x ms's
873 * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal.
875 int dgnc_ms_sleep(ulong ms)
877 current->state = TASK_INTERRUPTIBLE;
878 schedule_timeout((ms * HZ) / 1000);
879 return signal_pending(current);
885 * dgnc_ioctl_name() : Returns a text version of each ioctl value.
887 char *dgnc_ioctl_name(int cmd)
891 case TCGETA: return "TCGETA";
892 case TCGETS: return "TCGETS";
893 case TCSETA: return "TCSETA";
894 case TCSETS: return "TCSETS";
895 case TCSETAW: return "TCSETAW";
896 case TCSETSW: return "TCSETSW";
897 case TCSETAF: return "TCSETAF";
898 case TCSETSF: return "TCSETSF";
899 case TCSBRK: return "TCSBRK";
900 case TCXONC: return "TCXONC";
901 case TCFLSH: return "TCFLSH";
902 case TIOCGSID: return "TIOCGSID";
904 case TIOCGETD: return "TIOCGETD";
905 case TIOCSETD: return "TIOCSETD";
906 case TIOCGWINSZ: return "TIOCGWINSZ";
907 case TIOCSWINSZ: return "TIOCSWINSZ";
909 case TIOCMGET: return "TIOCMGET";
910 case TIOCMSET: return "TIOCMSET";
911 case TIOCMBIS: return "TIOCMBIS";
912 case TIOCMBIC: return "TIOCMBIC";
915 case DIGI_SETA: return "DIGI_SETA";
916 case DIGI_SETAW: return "DIGI_SETAW";
917 case DIGI_SETAF: return "DIGI_SETAF";
918 case DIGI_SETFLOW: return "DIGI_SETFLOW";
919 case DIGI_SETAFLOW: return "DIGI_SETAFLOW";
920 case DIGI_GETFLOW: return "DIGI_GETFLOW";
921 case DIGI_GETAFLOW: return "DIGI_GETAFLOW";
922 case DIGI_GETA: return "DIGI_GETA";
923 case DIGI_GEDELAY: return "DIGI_GEDELAY";
924 case DIGI_SEDELAY: return "DIGI_SEDELAY";
925 case DIGI_GETCUSTOMBAUD: return "DIGI_GETCUSTOMBAUD";
926 case DIGI_SETCUSTOMBAUD: return "DIGI_SETCUSTOMBAUD";
927 case TIOCMODG: return "TIOCMODG";
928 case TIOCMODS: return "TIOCMODS";
929 case TIOCSDTR: return "TIOCSDTR";
930 case TIOCCDTR: return "TIOCCDTR";
932 default: return "unknown";