2 * Linux ARCnet driver - COM20020 PCI support
3 * Contemporary Controls PCI20 and SOHARD SH-ARC PCI
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.
10 * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
11 * for sponsoring the further development of this driver.
13 * **********************
15 * The original copyright of skeleton.c was as follows:
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.
23 * **********************
25 * For more details, see drivers/net/arcnet.c
27 * **********************
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>
45 #define VERSION "arcnet: COM20020 PCI support\n"
47 /* Module parameters */
50 static char device
[9]; /* use eg. device="arc1" to change name */
51 static int timeout
= 3;
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");
64 static int com20020pci_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
66 struct com20020_pci_channel_map
*cm
;
67 struct com20020_pci_card_info
*ci
;
68 struct net_device
*dev
;
69 struct arcnet_local
*lp
;
72 if (pci_enable_device(pdev
))
74 dev
= alloc_arcdev(device
);
78 dev
->netdev_ops
= &com20020_netdev_ops
;
80 ci
= (struct com20020_pci_card_info
*)id
->driver_data
;
82 lp
= netdev_priv(dev
);
84 pci_set_drvdata(pdev
, dev
);
86 cm
= &ci
->chan_map_tbl
[0];
87 BUGMSG(D_NORMAL
, "%s Controls\n", ci
->name
);
88 ioaddr
= pci_resource_start(pdev
, cm
->bar
);
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);
97 // Dummy access after Reset
98 // ARCNET controller needs this access to detect bustype
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
;
113 if (ASTATUS() == 0xFF) {
114 BUGMSG(D_NORMAL
, "IO address %Xh was reported by PCI BIOS, "
115 "but seems empty!\n", ioaddr
);
119 if (com20020_check(dev
)) {
124 if ((err
= com20020_found(dev
, IRQF_SHARED
)) != 0)
130 release_region(ioaddr
, ARCNET_TOTAL_SIZE
);
136 static void com20020pci_remove(struct pci_dev
*pdev
)
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
);
145 static struct com20020_pci_card_info card_info_10mbit
= {
151 .flags
= ARC_CAN_10MBIT
,
154 static struct com20020_pci_card_info card_info_5mbit
= {
160 .flags
= ARC_IS_5MBIT
,
163 static struct com20020_pci_card_info card_info_sohard
= {
166 /* SOHARD needs PCI base addr 4 */
170 .flags
= ARC_CAN_10MBIT
,
173 static const struct pci_device_id com20020pci_id_table
[] = {
176 PCI_ANY_ID
, PCI_ANY_ID
,
182 PCI_ANY_ID
, PCI_ANY_ID
,
188 PCI_ANY_ID
, PCI_ANY_ID
,
194 PCI_ANY_ID
, PCI_ANY_ID
,
200 PCI_ANY_ID
, PCI_ANY_ID
,
206 PCI_ANY_ID
, PCI_ANY_ID
,
212 PCI_ANY_ID
, PCI_ANY_ID
,
218 PCI_ANY_ID
, PCI_ANY_ID
,
224 PCI_ANY_ID
, PCI_ANY_ID
,
226 (kernel_ulong_t
)&card_info_5mbit
230 PCI_ANY_ID
, PCI_ANY_ID
,
232 (kernel_ulong_t
)&card_info_5mbit
236 PCI_ANY_ID
, PCI_ANY_ID
,
238 (kernel_ulong_t
)&card_info_5mbit
242 PCI_ANY_ID
, PCI_ANY_ID
,
244 (kernel_ulong_t
)&card_info_5mbit
248 PCI_ANY_ID
, PCI_ANY_ID
,
250 (kernel_ulong_t
)&card_info_5mbit
254 PCI_ANY_ID
, PCI_ANY_ID
,
256 (kernel_ulong_t
)&card_info_5mbit
260 PCI_ANY_ID
, PCI_ANY_ID
,
262 (kernel_ulong_t
)&card_info_10mbit
266 PCI_ANY_ID
, PCI_ANY_ID
,
268 (kernel_ulong_t
)&card_info_10mbit
272 PCI_ANY_ID
, PCI_ANY_ID
,
274 (kernel_ulong_t
)&card_info_10mbit
278 PCI_ANY_ID
, PCI_ANY_ID
,
280 (kernel_ulong_t
)&card_info_10mbit
284 PCI_ANY_ID
, PCI_ANY_ID
,
286 (kernel_ulong_t
)&card_info_10mbit
290 PCI_ANY_ID
, PCI_ANY_ID
,
292 (kernel_ulong_t
)&card_info_10mbit
298 (kernel_ulong_t
)&card_info_sohard
304 (kernel_ulong_t
)&card_info_sohard
308 PCI_ANY_ID
, PCI_ANY_ID
,
310 (kernel_ulong_t
)&card_info_10mbit
314 PCI_ANY_ID
, PCI_ANY_ID
,
316 (kernel_ulong_t
)&card_info_10mbit
321 MODULE_DEVICE_TABLE(pci
, com20020pci_id_table
);
323 static struct pci_driver com20020pci_driver
= {
325 .id_table
= com20020pci_id_table
,
326 .probe
= com20020pci_probe
,
327 .remove
= com20020pci_remove
,
330 static int __init
com20020pci_init(void)
332 BUGLVL(D_NORMAL
) printk(VERSION
);
333 return pci_register_driver(&com20020pci_driver
);
336 static void __exit
com20020pci_cleanup(void)
338 pci_unregister_driver(&com20020pci_driver
);
341 module_init(com20020pci_init
)
342 module_exit(com20020pci_cleanup
)