2 * Copyright (C) 2007, 2011 Wolfgang Grandegger <wg@grandegger.com>
3 * Copyright (C) 2012 Stephane Grosjean <s.grosjean@peak-system.com>
5 * Derived from the PCAN project file driver/src/pcan_pci.c:
7 * Copyright (C) 2001-2006 PEAK System-Technik GmbH
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the version 2 of the GNU General Public License
11 * as published by the Free Software Foundation
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/interrupt.h>
22 #include <linux/netdevice.h>
23 #include <linux/delay.h>
24 #include <linux/pci.h>
26 #include <linux/i2c.h>
27 #include <linux/i2c-algo-bit.h>
28 #include <linux/can.h>
29 #include <linux/can/dev.h>
33 MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>");
34 MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCI family cards");
35 MODULE_SUPPORTED_DEVICE("PEAK PCAN PCI/PCIe/PCIeC miniPCI CAN cards");
36 MODULE_LICENSE("GPL v2");
38 #define DRV_NAME "peak_pci"
40 struct peak_pciec_card
;
41 struct peak_pci_chan
{
42 void __iomem
*cfg_base
; /* Common for all channels */
43 struct net_device
*prev_dev
; /* Chain of network devices */
44 u16 icr_mask
; /* Interrupt mask for fast ack */
45 struct peak_pciec_card
*pciec_card
; /* only for PCIeC LEDs */
48 #define PEAK_PCI_CAN_CLOCK (16000000 / 2)
50 #define PEAK_PCI_CDR (CDR_CBP | CDR_CLKOUT_MASK)
51 #define PEAK_PCI_OCR OCR_TX0_PUSHPULL
54 * Important PITA registers
56 #define PITA_ICR 0x00 /* Interrupt control register */
57 #define PITA_GPIOICR 0x18 /* GPIO interface control register */
58 #define PITA_MISC 0x1C /* Miscellaneous register */
60 #define PEAK_PCI_CFG_SIZE 0x1000 /* Size of the config PCI bar */
61 #define PEAK_PCI_CHAN_SIZE 0x0400 /* Size used by the channel */
63 #define PEAK_PCI_VENDOR_ID 0x001C /* The PCI device and vendor IDs */
64 #define PEAK_PCI_DEVICE_ID 0x0001 /* for PCI/PCIe slot cards */
65 #define PEAK_PCIEC_DEVICE_ID 0x0002 /* for ExpressCard slot cards */
66 #define PEAK_PCIE_DEVICE_ID 0x0003 /* for nextgen PCIe slot cards */
67 #define PEAK_MPCI_DEVICE_ID 0x0008 /* The miniPCI slot cards */
69 #define PEAK_PCI_CHAN_MAX 4
71 static const u16 peak_pci_icr_masks
[PEAK_PCI_CHAN_MAX
] = {
72 0x02, 0x01, 0x40, 0x80
75 static DEFINE_PCI_DEVICE_TABLE(peak_pci_tbl
) = {
76 {PEAK_PCI_VENDOR_ID
, PEAK_PCI_DEVICE_ID
, PCI_ANY_ID
, PCI_ANY_ID
,},
77 {PEAK_PCI_VENDOR_ID
, PEAK_PCIE_DEVICE_ID
, PCI_ANY_ID
, PCI_ANY_ID
,},
78 {PEAK_PCI_VENDOR_ID
, PEAK_MPCI_DEVICE_ID
, PCI_ANY_ID
, PCI_ANY_ID
,},
79 #ifdef CONFIG_CAN_PEAK_PCIEC
80 {PEAK_PCI_VENDOR_ID
, PEAK_PCIEC_DEVICE_ID
, PCI_ANY_ID
, PCI_ANY_ID
,},
85 MODULE_DEVICE_TABLE(pci
, peak_pci_tbl
);
87 #ifdef CONFIG_CAN_PEAK_PCIEC
89 * PCAN-ExpressCard needs I2C bit-banging configuration option.
92 /* GPIOICR byte access offsets */
93 #define PITA_GPOUT 0x18 /* GPx output value */
94 #define PITA_GPIN 0x19 /* GPx input value */
95 #define PITA_GPOEN 0x1A /* configure GPx as ouput pin */
98 #define PITA_GPIN_SCL 0x01 /* Serial Clock Line */
99 #define PITA_GPIN_SDA 0x04 /* Serial DAta line */
101 #define PCA9553_1_SLAVEADDR (0xC4 >> 1)
103 /* PCA9553 LS0 fields values */
112 #define PCA9553_ON PCA9553_LOW
113 #define PCA9553_OFF PCA9553_HIGHZ
114 #define PCA9553_SLOW PCA9553_PWM0
115 #define PCA9553_FAST PCA9553_PWM1
117 #define PCA9553_LED(c) (1 << (c))
118 #define PCA9553_LED_STATE(s, c) ((s) << ((c) << 1))
120 #define PCA9553_LED_ON(c) PCA9553_LED_STATE(PCA9553_ON, c)
121 #define PCA9553_LED_OFF(c) PCA9553_LED_STATE(PCA9553_OFF, c)
122 #define PCA9553_LED_SLOW(c) PCA9553_LED_STATE(PCA9553_SLOW, c)
123 #define PCA9553_LED_FAST(c) PCA9553_LED_STATE(PCA9553_FAST, c)
124 #define PCA9553_LED_MASK(c) PCA9553_LED_STATE(0x03, c)
126 #define PCA9553_LED_OFF_ALL (PCA9553_LED_OFF(0) | PCA9553_LED_OFF(1))
128 #define PCA9553_LS0_INIT 0x40 /* initial value (!= from 0x00) */
130 struct peak_pciec_chan
{
131 struct net_device
*netdev
;
132 unsigned long prev_rx_bytes
;
133 unsigned long prev_tx_bytes
;
136 struct peak_pciec_card
{
137 void __iomem
*cfg_base
; /* Common for all channels */
138 void __iomem
*reg_base
; /* first channel base address */
139 u8 led_cache
; /* leds state cache */
141 /* PCIExpressCard i2c data */
142 struct i2c_algo_bit_data i2c_bit
;
143 struct i2c_adapter led_chip
;
144 struct delayed_work led_work
; /* led delayed work */
146 struct peak_pciec_chan channel
[PEAK_PCI_CHAN_MAX
];
149 /* "normal" pci register write callback is overloaded for leds control */
150 static void peak_pci_write_reg(const struct sja1000_priv
*priv
,
153 static inline void pita_set_scl_highz(struct peak_pciec_card
*card
)
155 u8 gp_outen
= readb(card
->cfg_base
+ PITA_GPOEN
) & ~PITA_GPIN_SCL
;
156 writeb(gp_outen
, card
->cfg_base
+ PITA_GPOEN
);
159 static inline void pita_set_sda_highz(struct peak_pciec_card
*card
)
161 u8 gp_outen
= readb(card
->cfg_base
+ PITA_GPOEN
) & ~PITA_GPIN_SDA
;
162 writeb(gp_outen
, card
->cfg_base
+ PITA_GPOEN
);
165 static void peak_pciec_init_pita_gpio(struct peak_pciec_card
*card
)
167 /* raise SCL & SDA GPIOs to high-Z */
168 pita_set_scl_highz(card
);
169 pita_set_sda_highz(card
);
172 static void pita_setsda(void *data
, int state
)
174 struct peak_pciec_card
*card
= (struct peak_pciec_card
*)data
;
177 /* set output sda always to 0 */
178 gp_out
= readb(card
->cfg_base
+ PITA_GPOUT
) & ~PITA_GPIN_SDA
;
179 writeb(gp_out
, card
->cfg_base
+ PITA_GPOUT
);
181 /* control output sda with GPOEN */
182 gp_outen
= readb(card
->cfg_base
+ PITA_GPOEN
);
184 gp_outen
&= ~PITA_GPIN_SDA
;
186 gp_outen
|= PITA_GPIN_SDA
;
188 writeb(gp_outen
, card
->cfg_base
+ PITA_GPOEN
);
191 static void pita_setscl(void *data
, int state
)
193 struct peak_pciec_card
*card
= (struct peak_pciec_card
*)data
;
196 /* set output scl always to 0 */
197 gp_out
= readb(card
->cfg_base
+ PITA_GPOUT
) & ~PITA_GPIN_SCL
;
198 writeb(gp_out
, card
->cfg_base
+ PITA_GPOUT
);
200 /* control output scl with GPOEN */
201 gp_outen
= readb(card
->cfg_base
+ PITA_GPOEN
);
203 gp_outen
&= ~PITA_GPIN_SCL
;
205 gp_outen
|= PITA_GPIN_SCL
;
207 writeb(gp_outen
, card
->cfg_base
+ PITA_GPOEN
);
210 static int pita_getsda(void *data
)
212 struct peak_pciec_card
*card
= (struct peak_pciec_card
*)data
;
215 pita_set_sda_highz(card
);
217 return (readb(card
->cfg_base
+ PITA_GPIN
) & PITA_GPIN_SDA
) ? 1 : 0;
220 static int pita_getscl(void *data
)
222 struct peak_pciec_card
*card
= (struct peak_pciec_card
*)data
;
225 pita_set_scl_highz(card
);
227 return (readb(card
->cfg_base
+ PITA_GPIN
) & PITA_GPIN_SCL
) ? 1 : 0;
231 * write commands to the LED chip though the I2C-bus of the PCAN-PCIeC
233 static int peak_pciec_write_pca9553(struct peak_pciec_card
*card
,
240 struct i2c_msg msg
= {
241 .addr
= PCA9553_1_SLAVEADDR
,
248 if ((offset
== 5) && (data
== card
->led_cache
))
251 ret
= i2c_transfer(&card
->led_chip
, &msg
, 1);
256 card
->led_cache
= data
;
262 * delayed work callback used to control the LEDs
264 static void peak_pciec_led_work(struct work_struct
*work
)
266 struct peak_pciec_card
*card
=
267 container_of(work
, struct peak_pciec_card
, led_work
.work
);
268 struct net_device
*netdev
;
269 u8 new_led
= card
->led_cache
;
272 /* first check what is to do */
273 for (i
= 0; i
< card
->chan_count
; i
++) {
274 /* default is: not configured */
275 new_led
&= ~PCA9553_LED_MASK(i
);
276 new_led
|= PCA9553_LED_ON(i
);
278 netdev
= card
->channel
[i
].netdev
;
279 if (!netdev
|| !(netdev
->flags
& IFF_UP
))
284 /* no activity (but configured) */
285 new_led
&= ~PCA9553_LED_MASK(i
);
286 new_led
|= PCA9553_LED_SLOW(i
);
288 /* if bytes counters changed, set fast blinking led */
289 if (netdev
->stats
.rx_bytes
!= card
->channel
[i
].prev_rx_bytes
) {
290 card
->channel
[i
].prev_rx_bytes
= netdev
->stats
.rx_bytes
;
291 new_led
&= ~PCA9553_LED_MASK(i
);
292 new_led
|= PCA9553_LED_FAST(i
);
294 if (netdev
->stats
.tx_bytes
!= card
->channel
[i
].prev_tx_bytes
) {
295 card
->channel
[i
].prev_tx_bytes
= netdev
->stats
.tx_bytes
;
296 new_led
&= ~PCA9553_LED_MASK(i
);
297 new_led
|= PCA9553_LED_FAST(i
);
301 /* check if LS0 settings changed, only update i2c if so */
302 peak_pciec_write_pca9553(card
, 5, new_led
);
304 /* restart timer (except if no more configured channels) */
306 schedule_delayed_work(&card
->led_work
, HZ
);
310 * set LEDs blinking state
312 static void peak_pciec_set_leds(struct peak_pciec_card
*card
, u8 led_mask
, u8 s
)
314 u8 new_led
= card
->led_cache
;
317 /* first check what is to do */
318 for (i
= 0; i
< card
->chan_count
; i
++)
319 if (led_mask
& PCA9553_LED(i
)) {
320 new_led
&= ~PCA9553_LED_MASK(i
);
321 new_led
|= PCA9553_LED_STATE(s
, i
);
324 /* check if LS0 settings changed, only update i2c if so */
325 peak_pciec_write_pca9553(card
, 5, new_led
);
329 * start one second delayed work to control LEDs
331 static void peak_pciec_start_led_work(struct peak_pciec_card
*card
)
333 if (!delayed_work_pending(&card
->led_work
))
334 schedule_delayed_work(&card
->led_work
, HZ
);
338 * stop LEDs delayed work
340 static void peak_pciec_stop_led_work(struct peak_pciec_card
*card
)
342 cancel_delayed_work_sync(&card
->led_work
);
346 * initialize the PCA9553 4-bit I2C-bus LED chip
348 static int peak_pciec_init_leds(struct peak_pciec_card
*card
)
352 /* prescaler for frequency 0: "SLOW" = 1 Hz = "44" */
353 err
= peak_pciec_write_pca9553(card
, 1, 44 / 1);
357 /* duty cycle 0: 50% */
358 err
= peak_pciec_write_pca9553(card
, 2, 0x80);
362 /* prescaler for frequency 1: "FAST" = 5 Hz */
363 err
= peak_pciec_write_pca9553(card
, 3, 44 / 5);
367 /* duty cycle 1: 50% */
368 err
= peak_pciec_write_pca9553(card
, 4, 0x80);
372 /* switch LEDs to initial state */
373 return peak_pciec_write_pca9553(card
, 5, PCA9553_LS0_INIT
);
377 * restore LEDs state to off peak_pciec_leds_exit
379 static void peak_pciec_leds_exit(struct peak_pciec_card
*card
)
381 /* switch LEDs to off */
382 peak_pciec_write_pca9553(card
, 5, PCA9553_LED_OFF_ALL
);
386 * normal write sja1000 register method overloaded to catch when controller
387 * is started or stopped, to control leds
389 static void peak_pciec_write_reg(const struct sja1000_priv
*priv
,
392 struct peak_pci_chan
*chan
= priv
->priv
;
393 struct peak_pciec_card
*card
= chan
->pciec_card
;
394 int c
= (priv
->reg_base
- card
->reg_base
) / PEAK_PCI_CHAN_SIZE
;
396 /* sja1000 register changes control the leds state */
400 /* Reset Mode: set led on */
401 peak_pciec_set_leds(card
, PCA9553_LED(c
), PCA9553_ON
);
404 /* Normal Mode: led slow blinking and start led timer */
405 peak_pciec_set_leds(card
, PCA9553_LED(c
), PCA9553_SLOW
);
406 peak_pciec_start_led_work(card
);
412 /* call base function */
413 peak_pci_write_reg(priv
, port
, val
);
416 static struct i2c_algo_bit_data peak_pciec_i2c_bit_ops
= {
417 .setsda
= pita_setsda
,
418 .setscl
= pita_setscl
,
419 .getsda
= pita_getsda
,
420 .getscl
= pita_getscl
,
425 static int peak_pciec_probe(struct pci_dev
*pdev
, struct net_device
*dev
)
427 struct sja1000_priv
*priv
= netdev_priv(dev
);
428 struct peak_pci_chan
*chan
= priv
->priv
;
429 struct peak_pciec_card
*card
;
432 /* copy i2c object address from 1st channel */
433 if (chan
->prev_dev
) {
434 struct sja1000_priv
*prev_priv
= netdev_priv(chan
->prev_dev
);
435 struct peak_pci_chan
*prev_chan
= prev_priv
->priv
;
437 card
= prev_chan
->pciec_card
;
441 /* channel is the first one: do the init part */
443 /* create the bit banging I2C adapter structure */
444 card
= kzalloc(sizeof(struct peak_pciec_card
), GFP_KERNEL
);
447 "failed allocating memory for i2c chip\n");
451 card
->cfg_base
= chan
->cfg_base
;
452 card
->reg_base
= priv
->reg_base
;
454 card
->led_chip
.owner
= THIS_MODULE
;
455 card
->led_chip
.dev
.parent
= &pdev
->dev
;
456 card
->led_chip
.algo_data
= &card
->i2c_bit
;
457 strncpy(card
->led_chip
.name
, "peak_i2c",
458 sizeof(card
->led_chip
.name
));
460 card
->i2c_bit
= peak_pciec_i2c_bit_ops
;
461 card
->i2c_bit
.udelay
= 10;
462 card
->i2c_bit
.timeout
= HZ
;
463 card
->i2c_bit
.data
= card
;
465 peak_pciec_init_pita_gpio(card
);
467 err
= i2c_bit_add_bus(&card
->led_chip
);
469 dev_err(&pdev
->dev
, "i2c init failed\n");
470 goto pciec_init_err_1
;
473 err
= peak_pciec_init_leds(card
);
475 dev_err(&pdev
->dev
, "leds hardware init failed\n");
476 goto pciec_init_err_2
;
479 INIT_DELAYED_WORK(&card
->led_work
, peak_pciec_led_work
);
480 /* PCAN-ExpressCard needs its own callback for leds */
481 priv
->write_reg
= peak_pciec_write_reg
;
484 chan
->pciec_card
= card
;
485 card
->channel
[card
->chan_count
++].netdev
= dev
;
490 i2c_del_adapter(&card
->led_chip
);
493 peak_pciec_init_pita_gpio(card
);
499 static void peak_pciec_remove(struct peak_pciec_card
*card
)
501 peak_pciec_stop_led_work(card
);
502 peak_pciec_leds_exit(card
);
503 i2c_del_adapter(&card
->led_chip
);
504 peak_pciec_init_pita_gpio(card
);
508 #else /* CONFIG_CAN_PEAK_PCIEC */
511 * Placebo functions when PCAN-ExpressCard support is not selected
513 static inline int peak_pciec_probe(struct pci_dev
*pdev
, struct net_device
*dev
)
518 static inline void peak_pciec_remove(struct peak_pciec_card
*card
)
521 #endif /* CONFIG_CAN_PEAK_PCIEC */
523 static u8
peak_pci_read_reg(const struct sja1000_priv
*priv
, int port
)
525 return readb(priv
->reg_base
+ (port
<< 2));
528 static void peak_pci_write_reg(const struct sja1000_priv
*priv
,
531 writeb(val
, priv
->reg_base
+ (port
<< 2));
534 static void peak_pci_post_irq(const struct sja1000_priv
*priv
)
536 struct peak_pci_chan
*chan
= priv
->priv
;
539 /* Select and clear in PITA stored interrupt */
540 icr
= readw(chan
->cfg_base
+ PITA_ICR
);
541 if (icr
& chan
->icr_mask
)
542 writew(chan
->icr_mask
, chan
->cfg_base
+ PITA_ICR
);
545 static int __devinit
peak_pci_probe(struct pci_dev
*pdev
,
546 const struct pci_device_id
*ent
)
548 struct sja1000_priv
*priv
;
549 struct peak_pci_chan
*chan
;
550 struct net_device
*dev
, *prev_dev
;
551 void __iomem
*cfg_base
, *reg_base
;
553 int i
, err
, channels
;
555 err
= pci_enable_device(pdev
);
559 err
= pci_request_regions(pdev
, DRV_NAME
);
561 goto failure_disable_pci
;
563 err
= pci_read_config_word(pdev
, 0x2e, &sub_sys_id
);
565 goto failure_release_regions
;
567 dev_dbg(&pdev
->dev
, "probing device %04x:%04x:%04x\n",
568 pdev
->vendor
, pdev
->device
, sub_sys_id
);
570 err
= pci_write_config_word(pdev
, 0x44, 0);
572 goto failure_release_regions
;
574 if (sub_sys_id
>= 12)
576 else if (sub_sys_id
>= 10)
578 else if (sub_sys_id
>= 4)
583 cfg_base
= pci_iomap(pdev
, 0, PEAK_PCI_CFG_SIZE
);
585 dev_err(&pdev
->dev
, "failed to map PCI resource #0\n");
586 goto failure_release_regions
;
589 reg_base
= pci_iomap(pdev
, 1, PEAK_PCI_CHAN_SIZE
* channels
);
591 dev_err(&pdev
->dev
, "failed to map PCI resource #1\n");
592 goto failure_unmap_cfg_base
;
595 /* Set GPIO control register */
596 writew(0x0005, cfg_base
+ PITA_GPIOICR
+ 2);
597 /* Enable all channels of this card */
598 writeb(0x00, cfg_base
+ PITA_GPIOICR
);
600 writeb(0x05, cfg_base
+ PITA_MISC
+ 3);
602 /* Leave parport mux mode */
603 writeb(0x04, cfg_base
+ PITA_MISC
+ 3);
605 icr
= readw(cfg_base
+ PITA_ICR
+ 2);
607 for (i
= 0; i
< channels
; i
++) {
608 dev
= alloc_sja1000dev(sizeof(struct peak_pci_chan
));
611 goto failure_remove_channels
;
614 priv
= netdev_priv(dev
);
617 chan
->cfg_base
= cfg_base
;
618 priv
->reg_base
= reg_base
+ i
* PEAK_PCI_CHAN_SIZE
;
620 priv
->read_reg
= peak_pci_read_reg
;
621 priv
->write_reg
= peak_pci_write_reg
;
622 priv
->post_irq
= peak_pci_post_irq
;
624 priv
->can
.clock
.freq
= PEAK_PCI_CAN_CLOCK
;
625 priv
->ocr
= PEAK_PCI_OCR
;
626 priv
->cdr
= PEAK_PCI_CDR
;
627 /* Neither a slave nor a single device distributes the clock */
628 if (channels
== 1 || i
> 0)
629 priv
->cdr
|= CDR_CLK_OFF
;
631 /* Setup interrupt handling */
632 priv
->irq_flags
= IRQF_SHARED
;
633 dev
->irq
= pdev
->irq
;
635 chan
->icr_mask
= peak_pci_icr_masks
[i
];
636 icr
|= chan
->icr_mask
;
638 SET_NETDEV_DEV(dev
, &pdev
->dev
);
640 /* Create chain of SJA1000 devices */
641 chan
->prev_dev
= pci_get_drvdata(pdev
);
642 pci_set_drvdata(pdev
, dev
);
645 * PCAN-ExpressCard needs some additional i2c init.
646 * This must be done *before* register_sja1000dev() but
647 * *after* devices linkage
649 if (pdev
->device
== PEAK_PCIEC_DEVICE_ID
) {
650 err
= peak_pciec_probe(pdev
, dev
);
653 "failed to probe device (err %d)\n",
655 goto failure_free_dev
;
659 err
= register_sja1000dev(dev
);
661 dev_err(&pdev
->dev
, "failed to register device\n");
662 goto failure_free_dev
;
666 "%s at reg_base=0x%p cfg_base=0x%p irq=%d\n",
667 dev
->name
, priv
->reg_base
, chan
->cfg_base
, dev
->irq
);
670 /* Enable interrupts */
671 writew(icr
, cfg_base
+ PITA_ICR
+ 2);
676 pci_set_drvdata(pdev
, chan
->prev_dev
);
677 free_sja1000dev(dev
);
679 failure_remove_channels
:
680 /* Disable interrupts */
681 writew(0x0, cfg_base
+ PITA_ICR
+ 2);
684 for (dev
= pci_get_drvdata(pdev
); dev
; dev
= prev_dev
) {
685 priv
= netdev_priv(dev
);
687 prev_dev
= chan
->prev_dev
;
689 unregister_sja1000dev(dev
);
690 free_sja1000dev(dev
);
693 /* free any PCIeC resources too */
694 if (chan
&& chan
->pciec_card
)
695 peak_pciec_remove(chan
->pciec_card
);
697 pci_iounmap(pdev
, reg_base
);
699 failure_unmap_cfg_base
:
700 pci_iounmap(pdev
, cfg_base
);
702 failure_release_regions
:
703 pci_release_regions(pdev
);
706 pci_disable_device(pdev
);
711 static void __devexit
peak_pci_remove(struct pci_dev
*pdev
)
713 struct net_device
*dev
= pci_get_drvdata(pdev
); /* Last device */
714 struct sja1000_priv
*priv
= netdev_priv(dev
);
715 struct peak_pci_chan
*chan
= priv
->priv
;
716 void __iomem
*cfg_base
= chan
->cfg_base
;
717 void __iomem
*reg_base
= priv
->reg_base
;
719 /* Disable interrupts */
720 writew(0x0, cfg_base
+ PITA_ICR
+ 2);
722 /* Loop over all registered devices */
724 struct net_device
*prev_dev
= chan
->prev_dev
;
726 dev_info(&pdev
->dev
, "removing device %s\n", dev
->name
);
727 unregister_sja1000dev(dev
);
728 free_sja1000dev(dev
);
732 /* do that only for first channel */
733 if (chan
->pciec_card
)
734 peak_pciec_remove(chan
->pciec_card
);
737 priv
= netdev_priv(dev
);
741 pci_iounmap(pdev
, reg_base
);
742 pci_iounmap(pdev
, cfg_base
);
743 pci_release_regions(pdev
);
744 pci_disable_device(pdev
);
746 pci_set_drvdata(pdev
, NULL
);
749 static struct pci_driver peak_pci_driver
= {
751 .id_table
= peak_pci_tbl
,
752 .probe
= peak_pci_probe
,
753 .remove
= __devexit_p(peak_pci_remove
),
756 static int __init
peak_pci_init(void)
758 return pci_register_driver(&peak_pci_driver
);
760 module_init(peak_pci_init
);
762 static void __exit
peak_pci_exit(void)
764 pci_unregister_driver(&peak_pci_driver
);
766 module_exit(peak_pci_exit
);