Blame view
drivers/net/arcnet/com20020-pci.c
10.6 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 |
/* * Linux ARCnet driver - COM20020 PCI support * Contemporary Controls PCI20 and SOHARD SH-ARC PCI |
cb334648a arcnet: Use norma... |
4 |
* |
1da177e4c Linux-2.6.12-rc2 |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
* Written 1994-1999 by Avery Pennarun, * based on an ISA version by David Woodhouse. * Written 1999-2000 by Martin Mares <mj@ucw.cz>. * Derived from skeleton.c by Donald Becker. * * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com) * for sponsoring the further development of this driver. * * ********************** * * The original copyright of skeleton.c was as follows: * * skeleton.c Written 1993 by Donald Becker. * Copyright 1993 United States Government as represented by the * Director, National Security Agency. This software may only be used * and distributed according to the terms of the GNU General Public License as * modified by SRC, incorporated herein by reference. * * ********************** * * For more details, see drivers/net/arcnet.c * * ********************** */ |
05a24b234 arcnet: Convert p... |
29 30 |
#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt |
1da177e4c Linux-2.6.12-rc2 |
31 32 33 34 35 |
#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/ioport.h> |
1da177e4c Linux-2.6.12-rc2 |
36 37 38 |
#include <linux/errno.h> #include <linux/netdevice.h> #include <linux/init.h> |
a6b7a4078 net: remove inter... |
39 |
#include <linux/interrupt.h> |
1da177e4c Linux-2.6.12-rc2 |
40 |
#include <linux/pci.h> |
c51da42a6 ARCNET: add suppo... |
41 |
#include <linux/list.h> |
5e7ef9134 arcnet: Use inclu... |
42 |
#include <linux/io.h> |
8890624a4 arcnet: com20020-... |
43 |
#include <linux/leds.h> |
1da177e4c Linux-2.6.12-rc2 |
44 |
|
26c6d2816 arcnet: Move file... |
45 46 |
#include "arcdevice.h" #include "com20020.h" |
1da177e4c Linux-2.6.12-rc2 |
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
/* Module parameters */ static int node; static char device[9]; /* use eg. device="arc1" to change name */ static int timeout = 3; static int backplane; static int clockp; static int clockm; module_param(node, int, 0); module_param_string(device, device, sizeof(device), 0); module_param(timeout, int, 0); module_param(backplane, int, 0); module_param(clockp, int, 0); module_param(clockm, int, 0); MODULE_LICENSE("GPL"); |
8890624a4 arcnet: com20020-... |
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
static void led_tx_set(struct led_classdev *led_cdev, enum led_brightness value) { struct com20020_dev *card; struct com20020_priv *priv; struct com20020_pci_card_info *ci; card = container_of(led_cdev, struct com20020_dev, tx_led); priv = card->pci_priv; ci = priv->ci; outb(!!value, priv->misc + ci->leds[card->index].green); } static void led_recon_set(struct led_classdev *led_cdev, enum led_brightness value) { struct com20020_dev *card; struct com20020_priv *priv; struct com20020_pci_card_info *ci; card = container_of(led_cdev, struct com20020_dev, recon_led); priv = card->pci_priv; ci = priv->ci; outb(!!value, priv->misc + ci->leds[card->index].red); } |
c51da42a6 ARCNET: add suppo... |
92 |
static void com20020pci_remove(struct pci_dev *pdev); |
d6d7d3ed5 arcnet: Wrap some... |
93 94 |
static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
1da177e4c Linux-2.6.12-rc2 |
95 |
{ |
8c14f9c70 ARCNET: add com20... |
96 |
struct com20020_pci_card_info *ci; |
5ef216c1f arcnet: com20020-... |
97 |
struct com20020_pci_channel_map *mm; |
1da177e4c Linux-2.6.12-rc2 |
98 99 |
struct net_device *dev; struct arcnet_local *lp; |
c51da42a6 ARCNET: add suppo... |
100 101 102 |
struct com20020_priv *priv; int i, ioaddr, ret; struct resource *r; |
1da177e4c Linux-2.6.12-rc2 |
103 104 105 |
if (pci_enable_device(pdev)) return -EIO; |
a1799af4d com20020: convert... |
106 |
|
c51da42a6 ARCNET: add suppo... |
107 108 |
priv = devm_kzalloc(&pdev->dev, sizeof(struct com20020_priv), GFP_KERNEL); |
e8a308aff ARCNET: Add missi... |
109 110 |
if (!priv) return -ENOMEM; |
8c14f9c70 ARCNET: add com20... |
111 |
ci = (struct com20020_pci_card_info *)id->driver_data; |
c51da42a6 ARCNET: add suppo... |
112 |
priv->ci = ci; |
5ef216c1f arcnet: com20020-... |
113 |
mm = &ci->misc_map; |
c51da42a6 ARCNET: add suppo... |
114 115 |
INIT_LIST_HEAD(&priv->list_dev); |
5ef216c1f arcnet: com20020-... |
116 117 118 119 120 121 122 123 124 125 126 127 |
if (mm->size) { ioaddr = pci_resource_start(pdev, mm->bar) + mm->offset; r = devm_request_region(&pdev->dev, ioaddr, mm->size, "com20020-pci"); if (!r) { pr_err("IO region %xh-%xh already allocated. ", ioaddr, ioaddr + mm->size - 1); return -EBUSY; } priv->misc = ioaddr; } |
c51da42a6 ARCNET: add suppo... |
128 129 130 131 132 133 134 135 136 |
for (i = 0; i < ci->devcount; i++) { struct com20020_pci_channel_map *cm = &ci->chan_map_tbl[i]; struct com20020_dev *card; dev = alloc_arcdev(device); if (!dev) { ret = -ENOMEM; goto out_port; } |
ae8ede6a0 arcnet: com20020-... |
137 |
dev->dev_port = i; |
c51da42a6 ARCNET: add suppo... |
138 139 140 141 |
dev->netdev_ops = &com20020_netdev_ops; lp = netdev_priv(dev); |
a34c0932c arcnet: Convert B... |
142 143 |
arc_printk(D_NORMAL, dev, "%s Controls ", ci->name); |
c51da42a6 ARCNET: add suppo... |
144 145 146 147 148 |
ioaddr = pci_resource_start(pdev, cm->bar) + cm->offset; r = devm_request_region(&pdev->dev, ioaddr, cm->size, "com20020-pci"); if (!r) { |
05a24b234 arcnet: Convert p... |
149 150 |
pr_err("IO region %xh-%xh already allocated ", |
c51da42a6 ARCNET: add suppo... |
151 152 153 154 155 156 157 158 159 |
ioaddr, ioaddr + cm->size - 1); ret = -EBUSY; goto out_port; } /* Dummy access after Reset * ARCNET controller needs * this access to detect bustype */ |
0fec65130 arcnet: com20020:... |
160 161 |
arcnet_outb(0x00, ioaddr, COM20020_REG_W_COMMAND); arcnet_inb(ioaddr, COM20020_REG_R_DIAGSTAT); |
c51da42a6 ARCNET: add suppo... |
162 163 164 165 166 167 168 169 170 171 172 |
dev->base_addr = ioaddr; dev->dev_addr[0] = node; dev->irq = pdev->irq; lp->card_name = "PCI COM20020"; lp->card_flags = ci->flags; lp->backplane = backplane; lp->clockp = clockp & 7; lp->clockm = clockm & 3; lp->timeout = timeout; lp->hw.owner = THIS_MODULE; |
5ef216c1f arcnet: com20020-... |
173 174 175 176 177 178 |
/* Get the dev_id from the PLX rotary coder */ if (!strncmp(ci->name, "EAE PLX-PCI MA1", 15)) dev->dev_id = 0xc; dev->dev_id ^= inb(priv->misc + ci->rotary) >> 4; snprintf(dev->name, sizeof(dev->name), "arc%d-%d", dev->dev_id, i); |
0fec65130 arcnet: com20020:... |
179 |
if (arcnet_inb(ioaddr, COM20020_REG_R_STATUS) == 0xFF) { |
c51da42a6 ARCNET: add suppo... |
180 181 182 183 184 185 186 187 188 189 190 191 |
pr_err("IO address %Xh is empty! ", ioaddr); ret = -EIO; goto out_port; } if (com20020_check(dev)) { ret = -EIO; goto out_port; } card = devm_kzalloc(&pdev->dev, sizeof(struct com20020_dev), GFP_KERNEL); |
5628d98fc arcnet: Remove un... |
192 |
if (!card) |
c51da42a6 ARCNET: add suppo... |
193 |
return -ENOMEM; |
c51da42a6 ARCNET: add suppo... |
194 195 196 |
card->index = i; card->pci_priv = priv; |
8890624a4 arcnet: com20020-... |
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
card->tx_led.brightness_set = led_tx_set; card->tx_led.default_trigger = devm_kasprintf(&pdev->dev, GFP_KERNEL, "arc%d-%d-tx", dev->dev_id, i); card->tx_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "pci:green:tx:%d-%d", dev->dev_id, i); card->tx_led.dev = &dev->dev; card->recon_led.brightness_set = led_recon_set; card->recon_led.default_trigger = devm_kasprintf(&pdev->dev, GFP_KERNEL, "arc%d-%d-recon", dev->dev_id, i); card->recon_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "pci:red:recon:%d-%d", dev->dev_id, i); card->recon_led.dev = &dev->dev; |
c51da42a6 ARCNET: add suppo... |
214 |
card->dev = dev; |
8890624a4 arcnet: com20020-... |
215 216 217 218 219 220 221 |
ret = devm_led_classdev_register(&pdev->dev, &card->tx_led); if (ret) goto out_port; ret = devm_led_classdev_register(&pdev->dev, &card->recon_led); if (ret) goto out_port; |
c51da42a6 ARCNET: add suppo... |
222 223 224 225 226 |
dev_set_drvdata(&dev->dev, card); ret = com20020_found(dev, IRQF_SHARED); if (ret) goto out_port; |
8890624a4 arcnet: com20020-... |
227 |
devm_arcnet_led_init(dev, dev->dev_id, i); |
c51da42a6 ARCNET: add suppo... |
228 |
list_add(&card->list, &priv->list_dev); |
1da177e4c Linux-2.6.12-rc2 |
229 |
} |
c51da42a6 ARCNET: add suppo... |
230 |
pci_set_drvdata(pdev, priv); |
1da177e4c Linux-2.6.12-rc2 |
231 232 233 234 |
return 0; out_port: |
c51da42a6 ARCNET: add suppo... |
235 236 |
com20020pci_remove(pdev); return ret; |
1da177e4c Linux-2.6.12-rc2 |
237 |
} |
7c47bab62 ARCNET: remove __... |
238 |
static void com20020pci_remove(struct pci_dev *pdev) |
1da177e4c Linux-2.6.12-rc2 |
239 |
{ |
c51da42a6 ARCNET: add suppo... |
240 241 242 243 244 245 246 247 248 249 250 251 |
struct com20020_dev *card, *tmpcard; struct com20020_priv *priv; priv = pci_get_drvdata(pdev); list_for_each_entry_safe(card, tmpcard, &priv->list_dev, list) { struct net_device *dev = card->dev; unregister_netdev(dev); free_irq(dev->irq, dev); free_netdev(dev); } |
1da177e4c Linux-2.6.12-rc2 |
252 |
} |
8c14f9c70 ARCNET: add com20... |
253 254 255 256 |
static struct com20020_pci_card_info card_info_10mbit = { .name = "ARC-PCI", .devcount = 1, .chan_map_tbl = { |
54a84c618 arcnet: reformat ... |
257 258 259 260 261 |
{ .bar = 2, .offset = 0x00, .size = 0x08, }, |
8c14f9c70 ARCNET: add com20... |
262 263 264 265 266 267 268 269 |
}, .flags = ARC_CAN_10MBIT, }; static struct com20020_pci_card_info card_info_5mbit = { .name = "ARC-PCI", .devcount = 1, .chan_map_tbl = { |
54a84c618 arcnet: reformat ... |
270 271 272 273 274 |
{ .bar = 2, .offset = 0x00, .size = 0x08, }, |
8c14f9c70 ARCNET: add com20... |
275 276 277 278 279 280 281 282 283 |
}, .flags = ARC_IS_5MBIT, }; static struct com20020_pci_card_info card_info_sohard = { .name = "PLX-PCI", .devcount = 1, /* SOHARD needs PCI base addr 4 */ .chan_map_tbl = { |
54a84c618 arcnet: reformat ... |
284 285 286 287 288 |
{ .bar = 4, .offset = 0x00, .size = 0x08 }, |
8c14f9c70 ARCNET: add com20... |
289 290 291 |
}, .flags = ARC_CAN_10MBIT, }; |
d95e2fe0f com20020-pci: add... |
292 293 294 295 |
static struct com20020_pci_card_info card_info_eae_arc1 = { .name = "EAE PLX-PCI ARC1", .devcount = 1, .chan_map_tbl = { |
54a84c618 arcnet: reformat ... |
296 297 298 299 300 |
{ .bar = 2, .offset = 0x00, .size = 0x08, }, |
d95e2fe0f com20020-pci: add... |
301 |
}, |
5ef216c1f arcnet: com20020-... |
302 303 304 305 306 |
.misc_map = { .bar = 2, .offset = 0x10, .size = 0x04, }, |
8890624a4 arcnet: com20020-... |
307 308 309 310 311 312 |
.leds = { { .green = 0x0, .red = 0x1, }, }, |
5ef216c1f arcnet: com20020-... |
313 |
.rotary = 0x0, |
d95e2fe0f com20020-pci: add... |
314 315 316 317 318 |
.flags = ARC_CAN_10MBIT, }; static struct com20020_pci_card_info card_info_eae_ma1 = { .name = "EAE PLX-PCI MA1", |
5b85bad2a ARCNET: enable ea... |
319 320 |
.devcount = 2, .chan_map_tbl = { |
54a84c618 arcnet: reformat ... |
321 322 323 324 325 326 327 328 329 |
{ .bar = 2, .offset = 0x00, .size = 0x08, }, { .bar = 2, .offset = 0x08, .size = 0x08, } |
5b85bad2a ARCNET: enable ea... |
330 |
}, |
5ef216c1f arcnet: com20020-... |
331 332 333 334 335 |
.misc_map = { .bar = 2, .offset = 0x10, .size = 0x04, }, |
8890624a4 arcnet: com20020-... |
336 337 338 339 340 341 342 343 344 |
.leds = { { .green = 0x0, .red = 0x1, }, { .green = 0x2, .red = 0x3, }, }, |
5ef216c1f arcnet: com20020-... |
345 |
.rotary = 0x0, |
5b85bad2a ARCNET: enable ea... |
346 347 |
.flags = ARC_CAN_10MBIT, }; |
9baa3c34a PCI: Remove DEFIN... |
348 |
static const struct pci_device_id com20020pci_id_table[] = { |
8c14f9c70 ARCNET: add com20... |
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
{ 0x1571, 0xa001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, { 0x1571, 0xa002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, { 0x1571, 0xa003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1571, 0xa004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, { 0x1571, 0xa005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1571, 0xa006, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1571, 0xa007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1571, 0xa008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { 0x1571, 0xa009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_5mbit }, { 0x1571, 0xa00a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_5mbit }, { 0x1571, 0xa00b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_5mbit }, { 0x1571, 0xa00c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_5mbit }, { 0x1571, 0xa00d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_5mbit }, { 0x1571, 0xa00e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_5mbit }, { 0x1571, 0xa201, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_10mbit }, { 0x1571, 0xa202, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_10mbit }, { 0x1571, 0xa203, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_10mbit }, { 0x1571, 0xa204, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_10mbit }, { 0x1571, 0xa205, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_10mbit }, { 0x1571, 0xa206, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_10mbit }, { 0x10B5, 0x9030, 0x10B5, 0x2978, 0, 0, (kernel_ulong_t)&card_info_sohard }, { 0x10B5, 0x9050, 0x10B5, 0x2273, 0, 0, (kernel_ulong_t)&card_info_sohard }, { |
5b85bad2a ARCNET: enable ea... |
482 |
0x10B5, 0x9050, |
d95e2fe0f com20020-pci: add... |
483 484 485 486 487 488 |
0x10B5, 0x3263, 0, 0, (kernel_ulong_t)&card_info_eae_arc1 }, { 0x10B5, 0x9050, |
5b85bad2a ARCNET: enable ea... |
489 490 |
0x10B5, 0x3292, 0, 0, |
d95e2fe0f com20020-pci: add... |
491 |
(kernel_ulong_t)&card_info_eae_ma1 |
5b85bad2a ARCNET: enable ea... |
492 493 |
}, { |
8c14f9c70 ARCNET: add com20... |
494 495 496 497 498 499 500 501 502 503 504 505 |
0x14BA, 0x6000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_10mbit }, { 0x10B5, 0x2200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (kernel_ulong_t)&card_info_10mbit }, { 0, } |
1da177e4c Linux-2.6.12-rc2 |
506 507 508 509 510 511 512 513 |
}; MODULE_DEVICE_TABLE(pci, com20020pci_id_table); static struct pci_driver com20020pci_driver = { .name = "com20020", .id_table = com20020pci_id_table, .probe = com20020pci_probe, |
7c47bab62 ARCNET: remove __... |
514 |
.remove = com20020pci_remove, |
1da177e4c Linux-2.6.12-rc2 |
515 516 517 518 |
}; static int __init com20020pci_init(void) { |
72aeea484 arcnet: Expand od... |
519 |
if (BUGLVL(D_NORMAL)) |
05a24b234 arcnet: Convert p... |
520 521 |
pr_info("%s ", "COM20020 PCI support"); |
299176206 drivers/net: Remo... |
522 |
return pci_register_driver(&com20020pci_driver); |
1da177e4c Linux-2.6.12-rc2 |
523 524 525 526 527 528 529 530 531 |
} static void __exit com20020pci_cleanup(void) { pci_unregister_driver(&com20020pci_driver); } module_init(com20020pci_init) module_exit(com20020pci_cleanup) |