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