2 * Driver for the Solos PCI ADSL2+ card, designed to support Linux by
3 * Traverse Technologies -- http://www.traverse.com.au/
4 * Xrio Limited -- http://www.xrio.com/
7 * Copyright © 2008 Traverse Technologies
8 * Copyright © 2008 Intel Corporation
10 * Authors: Nathan Williams <nathan@traverse.com.au>
11 * David Woodhouse <dwmw2@infradead.org>
12 * Treker Chen <treker@xrio.com>
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * version 2, as published by the Free Software Foundation.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
27 #include <linux/interrupt.h>
28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/errno.h>
31 #include <linux/ioport.h>
32 #include <linux/types.h>
33 #include <linux/pci.h>
34 #include <linux/atm.h>
35 #include <linux/atmdev.h>
36 #include <linux/skbuff.h>
37 #include <linux/sysfs.h>
38 #include <linux/device.h>
39 #include <linux/kobject.h>
40 #include <linux/firmware.h>
42 #define VERSION "0.07"
43 #define PTAG "solos-pci"
45 #define CONFIG_RAM_SIZE 128
46 #define FLAGS_ADDR 0x7C
47 #define IRQ_EN_ADDR 0x78
49 #define IRQ_CLEAR 0x70
50 #define WRITE_FLASH 0x6C
52 #define FLASH_BLOCK 0x64
53 #define FLASH_BUSY 0x60
54 #define FPGA_MODE 0x5C
55 #define FLASH_MODE 0x58
57 #define DATA_RAM_SIZE 32768
59 #define FPGA_PAGE 528 /* FPGA flash page size*/
60 #define SOLOS_PAGE 512 /* Solos flash page size*/
61 #define FPGA_BLOCK (FPGA_PAGE * 8) /* FPGA flash block size*/
62 #define SOLOS_BLOCK (SOLOS_PAGE * 8) /* Solos flash block size*/
64 #define RX_BUF(card, nr) ((card->buffers) + (nr)*BUF_SIZE*2)
65 #define TX_BUF(card, nr) ((card->buffers) + (nr)*BUF_SIZE*2 + BUF_SIZE)
68 static int atmdebug = 0;
69 static int firmware_upgrade = 0;
70 static int fpga_upgrade = 0;
85 void __iomem *config_regs;
86 void __iomem *buffers;
89 struct atm_dev *atmdev[4];
90 struct tasklet_struct tlet;
92 spinlock_t tx_queue_lock;
93 spinlock_t cli_queue_lock;
94 struct sk_buff_head tx_queue[4];
95 struct sk_buff_head cli_queue[4];
99 #define SOLOS_CHAN(atmdev) ((int)(unsigned long)(atmdev)->phy_data)
101 MODULE_AUTHOR("Traverse Technologies <support@traverse.com.au>");
102 MODULE_DESCRIPTION("Solos PCI driver");
103 MODULE_VERSION(VERSION);
104 MODULE_LICENSE("GPL");
105 MODULE_PARM_DESC(debug, "Enable Loopback");
106 MODULE_PARM_DESC(atmdebug, "Print ATM data");
107 MODULE_PARM_DESC(firmware_upgrade, "Initiate Solos firmware upgrade");
108 MODULE_PARM_DESC(fpga_upgrade, "Initiate FPGA upgrade");
109 module_param(debug, int, 0444);
110 module_param(atmdebug, int, 0644);
111 module_param(firmware_upgrade, int, 0444);
112 module_param(fpga_upgrade, int, 0444);
115 static struct firmware *fw;
116 static int flash_offset;
118 void flash_upgrade(struct solos_card *);
119 void flash_write(struct solos_card *);
120 static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb,
121 struct atm_vcc *vcc);
122 static int fpga_tx(struct solos_card *);
123 static irqreturn_t solos_irq(int irq, void *dev_id);
124 static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci);
125 static int list_vccs(int vci);
126 static int atm_init(struct solos_card *);
127 static void atm_remove(struct solos_card *);
128 static int send_command(struct solos_card *card, int dev, const char *buf, size_t size);
129 static void solos_bh(unsigned long);
130 static int print_buffer(struct sk_buff *buf);
132 static inline void solos_pop(struct atm_vcc *vcc, struct sk_buff *skb)
137 dev_kfree_skb_any(skb);
140 static ssize_t console_show(struct device *dev, struct device_attribute *attr,
143 struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev);
144 struct solos_card *card = atmdev->dev_data;
147 spin_lock(&card->cli_queue_lock);
148 skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]);
149 spin_unlock(&card->cli_queue_lock);
151 return sprintf(buf, "No data.\n");
153 memcpy(buf, skb->data, skb->len);
154 dev_dbg(&card->dev->dev, "len: %d\n", skb->len);
160 static int send_command(struct solos_card *card, int dev, const char *buf, size_t size)
163 struct pkt_hdr *header;
165 // dev_dbg(&card->dev->dev, "size: %d\n", size);
167 if (size > (BUF_SIZE - sizeof(*header))) {
168 dev_dbg(&card->dev->dev, "Command is too big. Dropping request\n");
171 skb = alloc_skb(size + sizeof(*header), GFP_ATOMIC);
173 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in send_command()\n");
177 header = (void *)skb_put(skb, sizeof(*header));
179 header->size = cpu_to_le16(size);
180 header->vpi = cpu_to_le16(0);
181 header->vci = cpu_to_le16(0);
182 header->type = cpu_to_le16(PKT_COMMAND);
184 memcpy(skb_put(skb, size), buf, size);
186 fpga_queue(card, dev, skb, NULL);
191 static ssize_t console_store(struct device *dev, struct device_attribute *attr,
192 const char *buf, size_t count)
194 struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev);
195 struct solos_card *card = atmdev->dev_data;
198 err = send_command(card, SOLOS_CHAN(atmdev), buf, count);
203 static DEVICE_ATTR(console, 0644, console_show, console_store);
205 void flash_upgrade(struct solos_card *card){
209 dev_info(&card->dev->dev, "Flash upgrade started\n");
210 if (card->flash_chip == 0) {
211 if (request_firmware((const struct firmware **)&fw,
212 "solos-FPGA.bin",&card->dev->dev))
214 dev_info(&card->dev->dev,
215 "Failed to find firmware\n");
218 blocksize = FPGA_BLOCK;
220 if (request_firmware((const struct firmware **)&fw,
221 "solos-Firmware.bin",&card->dev->dev))
223 dev_info(&card->dev->dev,
224 "Failed to find firmware\n");
227 blocksize = SOLOS_BLOCK;
229 numblocks = fw->size/blocksize;
230 dev_info(&card->dev->dev, "Firmware size: %d\n", fw->size);
231 dev_info(&card->dev->dev, "Number of blocks: %d\n", numblocks);
234 dev_info(&card->dev->dev, "Changing FPGA to Update mode\n");
235 iowrite32(1, card->config_regs + FPGA_MODE);
236 data32 = ioread32(card->config_regs + FPGA_MODE);
237 /*Set mode to Chip Erase*/
238 if (card->flash_chip == 0) {
239 dev_info(&card->dev->dev,
240 "Set FPGA Flash mode to FPGA Chip Erase\n");
242 dev_info(&card->dev->dev,
243 "Set FPGA Flash mode to Solos Chip Erase\n");
245 iowrite32((card->flash_chip * 2), card->config_regs + FLASH_MODE);
247 iowrite32(1, card->config_regs + WRITE_FLASH);
251 void flash_write(struct solos_card *card){
259 iowrite32(0, card->config_regs + WRITE_FLASH);
260 /*Set mode to Block Write*/
261 /*dev_info(&card->dev->dev, "Set FPGA Flash mode to Block Write\n");*/
262 iowrite32(((card->flash_chip * 2) + 1), card->config_regs + FLASH_MODE);
264 /*When finished programming flash, release firmware and exit*/
265 if (fw->size - flash_offset == 0) {
266 //release_firmware(fw); /* This crashes for some reason */
267 iowrite32(0, card->config_regs + WRITE_FLASH);
268 iowrite32(0, card->config_regs + FPGA_MODE);
269 iowrite32(0, card->config_regs + FLASH_MODE);
270 dev_info(&card->dev->dev, "Returning FPGA to Data mode\n");
273 if (card->flash_chip == 0) {
274 blocksize = FPGA_BLOCK;
276 blocksize = SOLOS_BLOCK;
279 /*Calculate block size*/
280 if ((fw->size - flash_offset) > blocksize) {
283 block = fw->size - flash_offset;
285 block_num = flash_offset / blocksize;
286 //dev_info(&card->dev->dev, "block %d/%d\n",block_num + 1,(fw->size/512/8));
288 /*Copy block into RAM*/
289 for(i=0;i<block;i++){
291 //dev_info(&card->dev->dev, "i: %d\n", i);
297 data32 |= 0x0000FF00 &
298 (*(fw->data + i + flash_offset) << 8);
301 data32 |= 0x000000FF & *(fw->data + i + flash_offset);
304 data32 |= 0xFF000000 &
305 (*(fw->data + i + flash_offset) << 24);
308 data32 |= 0x00FF0000 &
309 (*(fw->data + i + flash_offset) << 16);
314 iowrite32(data32, RX_BUF(card, 3) + i - 3);
319 iowrite32(data32, RX_BUF(card, 3) + i - (i%4));
322 /*Specify block number and then trigger flash write*/
323 iowrite32(block_num, card->config_regs + FLASH_BLOCK);
324 iowrite32(1, card->config_regs + WRITE_FLASH);
325 // iowrite32(0, card->config_regs + WRITE_FLASH);
326 flash_offset += block;
330 static irqreturn_t solos_irq(int irq, void *dev_id)
332 struct solos_card *card = dev_id;
336 iowrite32(0, card->config_regs + IRQ_CLEAR);
337 //Disable IRQs from FPGA
338 iowrite32(0, card->config_regs + IRQ_EN_ADDR);
340 /* If we only do it when the device is open, we lose console
343 tasklet_schedule(&card->tlet);
345 //Enable IRQs from FPGA
346 iowrite32(1, card->config_regs + IRQ_EN_ADDR);
347 return IRQ_RETVAL(handled);
350 void solos_bh(unsigned long card_arg)
352 struct solos_card *card = (void *)card_arg;
356 uint32_t rx_done = 0;
359 data32 = ioread32(card->config_regs + FPGA_MODE);
361 data32 = ioread32(card->config_regs + FLASH_BUSY);
369 card_flags = ioread32(card->config_regs + FLAGS_ADDR);
371 /* The TX bits are set if the channel is busy; clear if not. We want to
372 invoke fpga_tx() unless _all_ the bits for active channels are set */
373 tx_mask = (1 << card->nr_ports) - 1;
374 if ((card_flags & tx_mask) != tx_mask)
377 for (port = 0; port < card->nr_ports; port++) {
378 if (card_flags & (0x10 << port)) {
379 struct pkt_hdr header;
384 rx_done |= 0x10 << port;
386 memcpy_fromio(&header, RX_BUF(card, port), sizeof(header));
388 size = le16_to_cpu(header.size);
390 skb = alloc_skb(size, GFP_ATOMIC);
393 dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n");
397 memcpy_fromio(skb_put(skb, size),
398 RX_BUF(card, port) + sizeof(header),
402 dev_info(&card->dev->dev, "Received: device %d\n", port);
403 dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n",
404 size, le16_to_cpu(header.vpi),
405 le16_to_cpu(header.vci));
409 switch (le16_to_cpu(header.type)) {
411 vcc = find_vcc(card->atmdev[port], le16_to_cpu(header.vpi),
412 le16_to_cpu(header.vci));
415 dev_warn(&card->dev->dev, "Received packet for unknown VCI.VPI %d.%d on port %d\n",
416 le16_to_cpu(header.vci), le16_to_cpu(header.vpi),
420 atm_charge(vcc, skb->truesize);
422 atomic_inc(&vcc->stats->rx);
426 default: /* FIXME: Not really, surely? */
427 spin_lock(&card->cli_queue_lock);
428 if (skb_queue_len(&card->cli_queue[port]) > 10) {
430 dev_warn(&card->dev->dev, "Dropping console response on port %d\n",
433 skb_queue_tail(&card->cli_queue[port], skb);
434 spin_unlock(&card->cli_queue_lock);
440 iowrite32(rx_done, card->config_regs + FLAGS_ADDR);
445 static struct atm_vcc *find_vcc(struct atm_dev *dev, short vpi, int vci)
447 struct hlist_head *head;
448 struct atm_vcc *vcc = NULL;
449 struct hlist_node *node;
452 read_lock(&vcc_sklist_lock);
453 head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)];
454 sk_for_each(s, node, head) {
456 if (vcc->dev == dev && vcc->vci == vci &&
457 vcc->vpi == vpi && vcc->qos.rxtp.traffic_class != ATM_NONE)
462 read_unlock(&vcc_sklist_lock);
466 static int list_vccs(int vci)
468 struct hlist_head *head;
470 struct hlist_node *node;
475 read_lock(&vcc_sklist_lock);
477 head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)];
478 sk_for_each(s, node, head) {
481 printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n",
489 sk_for_each(s, node, head) {
492 printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n",
499 read_unlock(&vcc_sklist_lock);
504 static int popen(struct atm_vcc *vcc)
506 struct solos_card *card = vcc->dev->dev_data;
508 struct pkt_hdr *header;
510 skb = alloc_skb(sizeof(*header), GFP_ATOMIC);
511 if (!skb && net_ratelimit()) {
512 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n");
515 header = (void *)skb_put(skb, sizeof(*header));
517 header->size = cpu_to_le16(0);
518 header->vpi = cpu_to_le16(vcc->vpi);
519 header->vci = cpu_to_le16(vcc->vci);
520 header->type = cpu_to_le16(PKT_POPEN);
522 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL);
524 // dev_dbg(&card->dev->dev, "Open for vpi %d and vci %d on interface %d\n", vcc->vpi, vcc->vci, SOLOS_CHAN(vcc->dev));
525 set_bit(ATM_VF_ADDR, &vcc->flags); // accept the vpi / vci
526 set_bit(ATM_VF_READY, &vcc->flags);
530 iowrite32(1, card->config_regs + IRQ_EN_ADDR);
532 opens++; //count open PVCs
537 static void pclose(struct atm_vcc *vcc)
539 struct solos_card *card = vcc->dev->dev_data;
541 struct pkt_hdr *header;
543 skb = alloc_skb(sizeof(*header), GFP_ATOMIC);
545 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n");
548 header = (void *)skb_put(skb, sizeof(*header));
550 header->size = cpu_to_le16(0);
551 header->vpi = cpu_to_le16(vcc->vpi);
552 header->vci = cpu_to_le16(vcc->vci);
553 header->type = cpu_to_le16(PKT_PCLOSE);
555 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL);
557 // dev_dbg(&card->dev->dev, "Close for vpi %d and vci %d on interface %d\n", vcc->vpi, vcc->vci, SOLOS_CHAN(vcc->dev));
559 iowrite32(0, card->config_regs + IRQ_EN_ADDR);
561 clear_bit(ATM_VF_ADDR, &vcc->flags);
562 clear_bit(ATM_VF_READY, &vcc->flags);
567 static int print_buffer(struct sk_buff *buf)
574 for (i = 0; i < len; i++){
576 sprintf(msg, "%02X: ", i);
578 sprintf(item,"%02X ",*(buf->data + i));
583 printk(KERN_DEBUG "%s", msg);
589 printk(KERN_DEBUG "%s", msg);
591 printk(KERN_DEBUG "\n");
596 static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb,
601 *(void **)skb->cb = vcc;
603 spin_lock(&card->tx_queue_lock);
604 old_len = skb_queue_len(&card->tx_queue[port]);
605 skb_queue_tail(&card->tx_queue[port], skb);
606 spin_unlock(&card->tx_queue_lock);
608 /* If TX might need to be started, do so */
613 static int fpga_tx(struct solos_card *card)
616 uint32_t tx_started = 0;
622 spin_lock_irqsave(&card->tx_lock, flags);
624 tx_pending = ioread32(card->config_regs + FLAGS_ADDR);
626 dev_vdbg(&card->dev->dev, "TX Flags are %X\n", tx_pending);
628 for (port = 0; port < card->nr_ports; port++) {
629 if (!(tx_pending & (1 << port))) {
631 spin_lock(&card->tx_queue_lock);
632 skb = skb_dequeue(&card->tx_queue[port]);
633 spin_unlock(&card->tx_queue_lock);
639 dev_info(&card->dev->dev, "Transmitted: port %d\n",
643 memcpy_toio(TX_BUF(card, port), skb->data, skb->len);
645 vcc = *(void **)skb->cb;
648 atomic_inc(&vcc->stats->tx);
651 dev_kfree_skb_irq(skb);
653 tx_started |= 1 << port; //Set TX full flag
657 iowrite32(tx_started, card->config_regs + FLAGS_ADDR);
659 spin_unlock_irqrestore(&card->tx_lock, flags);
663 static int psend(struct atm_vcc *vcc, struct sk_buff *skb)
665 struct solos_card *card = vcc->dev->dev_data;
666 struct sk_buff *skb2 = NULL;
667 struct pkt_hdr *header;
670 //dev_dbg(&card->dev->dev, "psend called.\n");
671 //dev_dbg(&card->dev->dev, "dev,vpi,vci = %d,%d,%d\n",SOLOS_CHAN(vcc->dev),vcc->vpi,vcc->vci);
674 skb2 = atm_alloc_charge(vcc, skb->len, GFP_ATOMIC);
676 memcpy(skb2->data, skb->data, skb->len);
677 skb_put(skb2, skb->len);
678 vcc->push(vcc, skb2);
679 atomic_inc(&vcc->stats->rx);
681 atomic_inc(&vcc->stats->tx);
687 if (pktlen > (BUF_SIZE - sizeof(*header))) {
688 dev_warn(&card->dev->dev, "Length of PDU is too large. Dropping PDU.\n");
693 if (!skb_clone_writable(skb, sizeof(*header))) {
697 if (skb_headroom(skb) < sizeof(*header))
698 expand_by = sizeof(*header) - skb_headroom(skb);
700 ret = pskb_expand_head(skb, expand_by, 0, GFP_ATOMIC);
702 dev_warn(&card->dev->dev, "pskb_expand_head failed.\n");
708 header = (void *)skb_push(skb, sizeof(*header));
710 /* This does _not_ include the size of the header */
711 header->size = cpu_to_le16(pktlen);
712 header->vpi = cpu_to_le16(vcc->vpi);
713 header->vci = cpu_to_le16(vcc->vci);
714 header->type = cpu_to_le16(PKT_DATA);
716 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, vcc);
721 static struct atmdev_ops fpga_ops = {
736 static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
740 uint8_t major_ver, minor_ver;
742 struct solos_card *card;
747 card = kzalloc(sizeof(*card), GFP_KERNEL);
753 err = pci_enable_device(dev);
755 dev_warn(&dev->dev, "Failed to enable PCI device\n");
759 err = pci_request_regions(dev, "solos");
761 dev_warn(&dev->dev, "Failed to request regions\n");
765 card->config_regs = pci_iomap(dev, 0, CONFIG_RAM_SIZE);
766 if (!card->config_regs) {
767 dev_warn(&dev->dev, "Failed to ioremap config registers\n");
768 goto out_release_regions;
770 card->buffers = pci_iomap(dev, 1, DATA_RAM_SIZE);
771 if (!card->buffers) {
772 dev_warn(&dev->dev, "Failed to ioremap data buffers\n");
773 goto out_unmap_config;
776 // for(i=0;i<64 ;i+=4){
777 // data32=ioread32(card->buffers + i);
778 // dev_dbg(&card->dev->dev, "%08lX\n",(unsigned long)data32);
781 //Fill Config Mem with zeros
782 for(i = 0; i < 128; i += 4)
783 iowrite32(0, card->config_regs + i);
786 iowrite32(0xF0, card->config_regs + FLAGS_ADDR);
788 data32 = ioread32(card->config_regs + FPGA_VER);
789 fpga_ver = (data32 & 0x0000FFFF);
790 major_ver = ((data32 & 0xFF000000) >> 24);
791 minor_ver = ((data32 & 0x00FF0000) >> 16);
792 dev_info(&dev->dev, "Solos FPGA Version %d.%02d svn-%d\n",
793 major_ver, minor_ver, fpga_ver);
795 card->nr_ports = 2; /* FIXME: Detect daughterboard */
797 err = atm_init(card);
801 pci_set_drvdata(dev, card);
802 tasklet_init(&card->tlet, solos_bh, (unsigned long)card);
803 spin_lock_init(&card->tx_lock);
804 spin_lock_init(&card->tx_queue_lock);
805 spin_lock_init(&card->cli_queue_lock);
809 iowrite32(data32,card->config_regs + FLAGS_ADDR);
812 // Fill Buffers with zeros
813 for (i = 0; i < BUF_SIZE * 8; i += 4)
814 iowrite32(0, card->buffers + i);
817 for(i = 0; i < (BUF_SIZE * 1); i += 4)
818 iowrite32(0x12345678, card->buffers + i + (0*BUF_SIZE));
819 for(i = 0; i < (BUF_SIZE * 1); i += 4)
820 iowrite32(0xabcdef98, card->buffers + i + (1*BUF_SIZE));
822 // Read Config Memory
823 printk(KERN_DEBUG "Reading Config MEM\n");
825 for(i = 0; i < 16; i++) {
826 data32=ioread32(card->buffers + i*(BUF_SIZE/2));
827 printk(KERN_ALERT "Addr: %lX Data: %08lX\n",
828 (unsigned long)(addr_start + i*(BUF_SIZE/2)),
829 (unsigned long)data32);
832 //dev_dbg(&card->dev->dev, "Requesting IRQ: %d\n",dev->irq);
833 err = request_irq(dev->irq, solos_irq, IRQF_DISABLED|IRQF_SHARED,
836 dev_dbg(&card->dev->dev, "Failed to request interrupt IRQ: %d\n", dev->irq);
839 iowrite32(1, card->config_regs + IRQ_EN_ADDR);
841 if(firmware_upgrade != 0){
842 card->flash_chip = 1;
845 if(fpga_upgrade != 0){
846 card->flash_chip = 0;
853 pci_iounmap(dev, card->config_regs);
855 pci_iounmap(dev, card->buffers);
857 pci_release_regions(dev);
862 static int atm_init(struct solos_card *card)
868 for (i = 0; i < card->nr_ports; i++) {
869 skb_queue_head_init(&card->tx_queue[i]);
870 skb_queue_head_init(&card->cli_queue[i]);
872 card->atmdev[i] = atm_dev_register("solos-pci", &fpga_ops, -1, NULL);
873 if (!card->atmdev[i]) {
874 dev_err(&card->dev->dev, "Could not register ATM device %d\n", i);
878 if (device_create_file(&card->atmdev[i]->class_dev, &dev_attr_console))
879 dev_err(&card->dev->dev, "Could not register console for ATM device %d\n", i);
881 dev_info(&card->dev->dev, "Registered ATM device %d\n", card->atmdev[i]->number);
883 card->atmdev[i]->ci_range.vpi_bits = 8;
884 card->atmdev[i]->ci_range.vci_bits = 16;
885 card->atmdev[i]->dev_data = card;
886 card->atmdev[i]->phy_data = (void *)(unsigned long)i;
891 static void atm_remove(struct solos_card *card)
895 for (i = 0; i < card->nr_ports; i++) {
896 if (card->atmdev[i]) {
897 dev_info(&card->dev->dev, "Unregistering ATM device %d\n", card->atmdev[i]->number);
898 atm_dev_deregister(card->atmdev[i]);
903 static void fpga_remove(struct pci_dev *dev)
905 struct solos_card *card = pci_get_drvdata(dev);
912 dev_vdbg(&dev->dev, "Freeing IRQ\n");
913 // Disable IRQs from FPGA
914 iowrite32(0, card->config_regs + IRQ_EN_ADDR);
915 free_irq(dev->irq, card);
916 tasklet_kill(&card->tlet);
918 // iowrite32(0x01,pciregs);
919 dev_vdbg(&dev->dev, "Unmapping PCI resource\n");
920 pci_iounmap(dev, card->buffers);
921 pci_iounmap(dev, card->config_regs);
923 dev_vdbg(&dev->dev, "Releasing PCI Region\n");
924 pci_release_regions(dev);
925 pci_disable_device(dev);
927 pci_set_drvdata(dev, NULL);
929 // dev_dbg(&card->dev->dev, "fpga_remove\n");
933 static struct pci_device_id fpga_pci_tbl[] __devinitdata = {
934 { 0x10ee, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
938 MODULE_DEVICE_TABLE(pci,fpga_pci_tbl);
940 static struct pci_driver fpga_driver = {
942 .id_table = fpga_pci_tbl,
944 .remove = fpga_remove,
948 static int __init solos_pci_init(void)
950 printk(KERN_INFO "Solos PCI Driver Version %s\n", VERSION);
951 return pci_register_driver(&fpga_driver);
954 static void __exit solos_pci_exit(void)
956 pci_unregister_driver(&fpga_driver);
957 printk(KERN_INFO "Solos PCI Driver %s Unloaded\n", VERSION);
960 module_init(solos_pci_init);
961 module_exit(solos_pci_exit);