f9e55527739d2a9b8430cf763b125de600593b61
[deliverable/linux.git] / drivers / net / arcnet / com20020-pci.c
1 /*
2 * Linux ARCnet driver - COM20020 PCI support
3 * Contemporary Controls PCI20 and SOHARD SH-ARC PCI
4 *
5 * Written 1994-1999 by Avery Pennarun,
6 * based on an ISA version by David Woodhouse.
7 * Written 1999-2000 by Martin Mares <mj@ucw.cz>.
8 * Derived from skeleton.c by Donald Becker.
9 *
10 * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
11 * for sponsoring the further development of this driver.
12 *
13 * **********************
14 *
15 * The original copyright of skeleton.c was as follows:
16 *
17 * skeleton.c Written 1993 by Donald Becker.
18 * Copyright 1993 United States Government as represented by the
19 * Director, National Security Agency. This software may only be used
20 * and distributed according to the terms of the GNU General Public License as
21 * modified by SRC, incorporated herein by reference.
22 *
23 * **********************
24 *
25 * For more details, see drivers/net/arcnet.c
26 *
27 * **********************
28 */
29 #include <linux/module.h>
30 #include <linux/moduleparam.h>
31 #include <linux/kernel.h>
32 #include <linux/types.h>
33 #include <linux/ioport.h>
34 #include <linux/errno.h>
35 #include <linux/netdevice.h>
36 #include <linux/init.h>
37 #include <linux/interrupt.h>
38 #include <linux/pci.h>
39 #include <linux/arcdevice.h>
40 #include <linux/com20020.h>
41
42 #include <asm/io.h>
43
44
45 #define VERSION "arcnet: COM20020 PCI support\n"
46
47 /* Module parameters */
48
49 static int node;
50 static char device[9]; /* use eg. device="arc1" to change name */
51 static int timeout = 3;
52 static int backplane;
53 static int clockp;
54 static int clockm;
55
56 module_param(node, int, 0);
57 module_param_string(device, device, sizeof(device), 0);
58 module_param(timeout, int, 0);
59 module_param(backplane, int, 0);
60 module_param(clockp, int, 0);
61 module_param(clockm, int, 0);
62 MODULE_LICENSE("GPL");
63
64 static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
65 {
66 struct com20020_pci_channel_map *cm;
67 struct com20020_pci_card_info *ci;
68 struct net_device *dev;
69 struct arcnet_local *lp;
70 int ioaddr, err;
71
72 if (pci_enable_device(pdev))
73 return -EIO;
74 dev = alloc_arcdev(device);
75 if (!dev)
76 return -ENOMEM;
77
78 dev->netdev_ops = &com20020_netdev_ops;
79
80 ci = (struct com20020_pci_card_info *)id->driver_data;
81
82 lp = netdev_priv(dev);
83
84 pci_set_drvdata(pdev, dev);
85
86 cm = &ci->chan_map_tbl[0];
87 BUGMSG(D_NORMAL, "%s Controls\n", ci->name);
88 ioaddr = pci_resource_start(pdev, cm->bar);
89
90 if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com20020-pci")) {
91 BUGMSG(D_INIT, "IO region %xh-%xh already allocated.\n",
92 ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
93 err = -EBUSY;
94 goto out_dev;
95 }
96
97 // Dummy access after Reset
98 // ARCNET controller needs this access to detect bustype
99 outb(0x00,ioaddr+1);
100 inb(ioaddr+1);
101
102 dev->base_addr = ioaddr;
103 dev->irq = pdev->irq;
104 dev->dev_addr[0] = node;
105 lp->card_name = "PCI COM20020";
106 lp->card_flags = ci->flags;
107 lp->backplane = backplane;
108 lp->clockp = clockp & 7;
109 lp->clockm = clockm & 3;
110 lp->timeout = timeout;
111 lp->hw.owner = THIS_MODULE;
112
113 if (ASTATUS() == 0xFF) {
114 BUGMSG(D_NORMAL, "IO address %Xh was reported by PCI BIOS, "
115 "but seems empty!\n", ioaddr);
116 err = -EIO;
117 goto out_port;
118 }
119 if (com20020_check(dev)) {
120 err = -EIO;
121 goto out_port;
122 }
123
124 if ((err = com20020_found(dev, IRQF_SHARED)) != 0)
125 goto out_port;
126
127 return 0;
128
129 out_port:
130 release_region(ioaddr, ARCNET_TOTAL_SIZE);
131 out_dev:
132 free_netdev(dev);
133 return err;
134 }
135
136 static void com20020pci_remove(struct pci_dev *pdev)
137 {
138 struct net_device *dev = pci_get_drvdata(pdev);
139 unregister_netdev(dev);
140 free_irq(dev->irq, dev);
141 release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
142 free_netdev(dev);
143 }
144
145 static struct com20020_pci_card_info card_info_10mbit = {
146 .name = "ARC-PCI",
147 .devcount = 1,
148 .chan_map_tbl = {
149 { 2, 0x00, 0x08 },
150 },
151 .flags = ARC_CAN_10MBIT,
152 };
153
154 static struct com20020_pci_card_info card_info_5mbit = {
155 .name = "ARC-PCI",
156 .devcount = 1,
157 .chan_map_tbl = {
158 { 2, 0x00, 0x08 },
159 },
160 .flags = ARC_IS_5MBIT,
161 };
162
163 static struct com20020_pci_card_info card_info_sohard = {
164 .name = "PLX-PCI",
165 .devcount = 1,
166 /* SOHARD needs PCI base addr 4 */
167 .chan_map_tbl = {
168 {4, 0x00, 0x08},
169 },
170 .flags = ARC_CAN_10MBIT,
171 };
172
173 static const struct pci_device_id com20020pci_id_table[] = {
174 {
175 0x1571, 0xa001,
176 PCI_ANY_ID, PCI_ANY_ID,
177 0, 0,
178 0,
179 },
180 {
181 0x1571, 0xa002,
182 PCI_ANY_ID, PCI_ANY_ID,
183 0, 0,
184 0,
185 },
186 {
187 0x1571, 0xa003,
188 PCI_ANY_ID, PCI_ANY_ID,
189 0, 0,
190 0
191 },
192 {
193 0x1571, 0xa004,
194 PCI_ANY_ID, PCI_ANY_ID,
195 0, 0,
196 0,
197 },
198 {
199 0x1571, 0xa005,
200 PCI_ANY_ID, PCI_ANY_ID,
201 0, 0,
202 0
203 },
204 {
205 0x1571, 0xa006,
206 PCI_ANY_ID, PCI_ANY_ID,
207 0, 0,
208 0
209 },
210 {
211 0x1571, 0xa007,
212 PCI_ANY_ID, PCI_ANY_ID,
213 0, 0,
214 0
215 },
216 {
217 0x1571, 0xa008,
218 PCI_ANY_ID, PCI_ANY_ID,
219 0, 0,
220 0
221 },
222 {
223 0x1571, 0xa009,
224 PCI_ANY_ID, PCI_ANY_ID,
225 0, 0,
226 (kernel_ulong_t)&card_info_5mbit
227 },
228 {
229 0x1571, 0xa00a,
230 PCI_ANY_ID, PCI_ANY_ID,
231 0, 0,
232 (kernel_ulong_t)&card_info_5mbit
233 },
234 {
235 0x1571, 0xa00b,
236 PCI_ANY_ID, PCI_ANY_ID,
237 0, 0,
238 (kernel_ulong_t)&card_info_5mbit
239 },
240 {
241 0x1571, 0xa00c,
242 PCI_ANY_ID, PCI_ANY_ID,
243 0, 0,
244 (kernel_ulong_t)&card_info_5mbit
245 },
246 {
247 0x1571, 0xa00d,
248 PCI_ANY_ID, PCI_ANY_ID,
249 0, 0,
250 (kernel_ulong_t)&card_info_5mbit
251 },
252 {
253 0x1571, 0xa00e,
254 PCI_ANY_ID, PCI_ANY_ID,
255 0, 0,
256 (kernel_ulong_t)&card_info_5mbit
257 },
258 {
259 0x1571, 0xa201,
260 PCI_ANY_ID, PCI_ANY_ID,
261 0, 0,
262 (kernel_ulong_t)&card_info_10mbit
263 },
264 {
265 0x1571, 0xa202,
266 PCI_ANY_ID, PCI_ANY_ID,
267 0, 0,
268 (kernel_ulong_t)&card_info_10mbit
269 },
270 {
271 0x1571, 0xa203,
272 PCI_ANY_ID, PCI_ANY_ID,
273 0, 0,
274 (kernel_ulong_t)&card_info_10mbit
275 },
276 {
277 0x1571, 0xa204,
278 PCI_ANY_ID, PCI_ANY_ID,
279 0, 0,
280 (kernel_ulong_t)&card_info_10mbit
281 },
282 {
283 0x1571, 0xa205,
284 PCI_ANY_ID, PCI_ANY_ID,
285 0, 0,
286 (kernel_ulong_t)&card_info_10mbit
287 },
288 {
289 0x1571, 0xa206,
290 PCI_ANY_ID, PCI_ANY_ID,
291 0, 0,
292 (kernel_ulong_t)&card_info_10mbit
293 },
294 {
295 0x10B5, 0x9030,
296 0x10B5, 0x2978,
297 0, 0,
298 (kernel_ulong_t)&card_info_sohard
299 },
300 {
301 0x10B5, 0x9050,
302 0x10B5, 0x2273,
303 0, 0,
304 (kernel_ulong_t)&card_info_sohard
305 },
306 {
307 0x14BA, 0x6000,
308 PCI_ANY_ID, PCI_ANY_ID,
309 0, 0,
310 (kernel_ulong_t)&card_info_10mbit
311 },
312 {
313 0x10B5, 0x2200,
314 PCI_ANY_ID, PCI_ANY_ID,
315 0, 0,
316 (kernel_ulong_t)&card_info_10mbit
317 },
318 { 0, }
319 };
320
321 MODULE_DEVICE_TABLE(pci, com20020pci_id_table);
322
323 static struct pci_driver com20020pci_driver = {
324 .name = "com20020",
325 .id_table = com20020pci_id_table,
326 .probe = com20020pci_probe,
327 .remove = com20020pci_remove,
328 };
329
330 static int __init com20020pci_init(void)
331 {
332 BUGLVL(D_NORMAL) printk(VERSION);
333 return pci_register_driver(&com20020pci_driver);
334 }
335
336 static void __exit com20020pci_cleanup(void)
337 {
338 pci_unregister_driver(&com20020pci_driver);
339 }
340
341 module_init(com20020pci_init)
342 module_exit(com20020pci_cleanup)
This page took 0.039341 seconds and 4 git commands to generate.