| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * PCBIT-D module support | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 1996 Universidade de Lisboa | 
|  | 5 | * | 
|  | 6 | * Written by Pedro Roque Marques (roque@di.fc.ul.pt) | 
|  | 7 | * | 
|  | 8 | * This software may be used and distributed according to the terms of | 
|  | 9 | * the GNU General Public License, incorporated herein by reference. | 
|  | 10 | */ | 
|  | 11 |  | 
|  | 12 | #include <linux/module.h> | 
|  | 13 | #include <linux/init.h> | 
|  | 14 | #include <linux/sched.h> | 
|  | 15 | #include <linux/string.h> | 
|  | 16 | #include <linux/kernel.h> | 
|  | 17 | #include <linux/skbuff.h> | 
|  | 18 |  | 
|  | 19 | #include <linux/isdnif.h> | 
|  | 20 | #include "pcbit.h" | 
|  | 21 |  | 
|  | 22 | MODULE_DESCRIPTION("ISDN4Linux: Driver for PCBIT-T card"); | 
|  | 23 | MODULE_AUTHOR("Pedro Roque Marques"); | 
|  | 24 | MODULE_LICENSE("GPL"); | 
|  | 25 |  | 
|  | 26 | static int mem[MAX_PCBIT_CARDS]; | 
|  | 27 | static int irq[MAX_PCBIT_CARDS]; | 
|  | 28 |  | 
|  | 29 | module_param_array(mem, int, NULL, 0); | 
|  | 30 | module_param_array(irq, int, NULL, 0); | 
|  | 31 |  | 
|  | 32 | static int num_boards; | 
|  | 33 | struct pcbit_dev * dev_pcbit[MAX_PCBIT_CARDS]; | 
|  | 34 |  | 
|  | 35 | extern void pcbit_terminate(int board); | 
|  | 36 | extern int pcbit_init_dev(int board, int mem_base, int irq); | 
|  | 37 |  | 
|  | 38 | static int __init pcbit_init(void) | 
|  | 39 | { | 
|  | 40 | int board; | 
|  | 41 |  | 
|  | 42 | num_boards = 0; | 
|  | 43 |  | 
|  | 44 | printk(KERN_NOTICE | 
|  | 45 | "PCBIT-D device driver v 0.5-fjpc0 19991204 - " | 
|  | 46 | "Copyright (C) 1996 Universidade de Lisboa\n"); | 
|  | 47 |  | 
|  | 48 | if (mem[0] || irq[0]) | 
|  | 49 | { | 
|  | 50 | for (board=0; board < MAX_PCBIT_CARDS && mem[board] && irq[board]; board++) | 
|  | 51 | { | 
|  | 52 | if (!mem[board]) | 
|  | 53 | mem[board] = 0xD0000; | 
|  | 54 | if (!irq[board]) | 
|  | 55 | irq[board] = 5; | 
|  | 56 |  | 
|  | 57 | if (pcbit_init_dev(board, mem[board], irq[board]) == 0) | 
|  | 58 | num_boards++; | 
|  | 59 |  | 
|  | 60 | else | 
|  | 61 | { | 
|  | 62 | printk(KERN_WARNING | 
|  | 63 | "pcbit_init failed for dev %d", | 
|  | 64 | board + 1); | 
|  | 65 | return -EIO; | 
|  | 66 | } | 
|  | 67 | } | 
|  | 68 | } | 
|  | 69 |  | 
|  | 70 | /* Hardcoded default settings detection */ | 
|  | 71 |  | 
|  | 72 | if (!num_boards) | 
|  | 73 | { | 
|  | 74 | printk(KERN_INFO | 
|  | 75 | "Trying to detect board using default settings\n"); | 
|  | 76 | if (pcbit_init_dev(0, 0xD0000, 5) == 0) | 
|  | 77 | num_boards++; | 
|  | 78 | else | 
|  | 79 | return -EIO; | 
|  | 80 | } | 
|  | 81 | return 0; | 
|  | 82 | } | 
|  | 83 |  | 
|  | 84 | static void __exit pcbit_exit(void) | 
|  | 85 | { | 
|  | 86 | #ifdef MODULE | 
|  | 87 | int board; | 
|  | 88 |  | 
|  | 89 | for (board = 0; board < num_boards; board++) | 
|  | 90 | pcbit_terminate(board); | 
|  | 91 | printk(KERN_NOTICE | 
|  | 92 | "PCBIT-D module unloaded\n"); | 
|  | 93 | #endif | 
|  | 94 | } | 
|  | 95 |  | 
|  | 96 | #ifndef MODULE | 
|  | 97 | #define MAX_PARA	(MAX_PCBIT_CARDS * 2) | 
|  | 98 | static int __init pcbit_setup(char *line) | 
|  | 99 | { | 
|  | 100 | int i, j, argc; | 
|  | 101 | char *str; | 
|  | 102 | int ints[MAX_PARA+1]; | 
|  | 103 |  | 
|  | 104 | str = get_options(line, MAX_PARA, ints); | 
|  | 105 | argc = ints[0]; | 
|  | 106 | i = 0; | 
|  | 107 | j = 1; | 
|  | 108 |  | 
|  | 109 | while (argc && (i<MAX_PCBIT_CARDS)) { | 
|  | 110 |  | 
|  | 111 | if (argc) { | 
|  | 112 | mem[i]	= ints[j]; | 
|  | 113 | j++; argc--; | 
|  | 114 | } | 
|  | 115 |  | 
|  | 116 | if (argc) { | 
|  | 117 | irq[i]	= ints[j]; | 
|  | 118 | j++; argc--; | 
|  | 119 | } | 
|  | 120 |  | 
|  | 121 | i++; | 
|  | 122 | } | 
|  | 123 | return(1); | 
|  | 124 | } | 
|  | 125 | __setup("pcbit=", pcbit_setup); | 
|  | 126 | #endif | 
|  | 127 |  | 
|  | 128 | module_init(pcbit_init); | 
|  | 129 | module_exit(pcbit_exit); | 
|  | 130 |  |