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>
41 #include <linux/ctype.h>
42 #include <linux/swab.h>
43 #include <linux/slab.h>
45 #define VERSION "1.04"
46 #define DRIVER_VERSION 0x01
47 #define PTAG "solos-pci"
49 #define CONFIG_RAM_SIZE 128
50 #define FLAGS_ADDR 0x7C
51 #define IRQ_EN_ADDR 0x78
53 #define IRQ_CLEAR 0x70
54 #define WRITE_FLASH 0x6C
56 #define FLASH_BLOCK 0x64
57 #define FLASH_BUSY 0x60
58 #define FPGA_MODE 0x5C
59 #define FLASH_MODE 0x58
60 #define GPIO_STATUS 0x54
61 #define DRIVER_VER 0x50
62 #define TX_DMA_ADDR(port) (0x40 + (4 * (port)))
63 #define RX_DMA_ADDR(port) (0x30 + (4 * (port)))
65 #define DATA_RAM_SIZE 32768
67 #define OLD_BUF_SIZE 4096 /* For FPGA versions <= 2*/
68 /* Old boards use ATMEL AD45DB161D flash */
69 #define ATMEL_FPGA_PAGE 528 /* FPGA flash page size*/
70 #define ATMEL_SOLOS_PAGE 512 /* Solos flash page size*/
71 #define ATMEL_FPGA_BLOCK (ATMEL_FPGA_PAGE * 8) /* FPGA block size*/
72 #define ATMEL_SOLOS_BLOCK (ATMEL_SOLOS_PAGE * 8) /* Solos block size*/
73 /* Current boards use M25P/M25PE SPI flash */
74 #define SPI_FLASH_BLOCK (256 * 64)
76 #define RX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2)
77 #define TX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2 + (card->buffer_size))
78 #define FLASH_BUF ((card->buffers) + 4*(card->buffer_size)*2)
80 #define RX_DMA_SIZE 2048
82 #define FPGA_VERSION(a,b) (((a) << 8) + (b))
83 #define LEGACY_BUFFERS 2
84 #define DMA_SUPPORTED 4
87 static int atmdebug
= 0;
88 static int firmware_upgrade
= 0;
89 static int fpga_upgrade
= 0;
90 static int db_firmware_upgrade
= 0;
91 static int db_fpga_upgrade
= 0;
100 struct solos_skb_cb
{
106 #define SKB_CB(skb) ((struct solos_skb_cb *)skb->cb)
109 #define PKT_COMMAND 1
115 void __iomem
*config_regs
;
116 void __iomem
*buffers
;
120 struct atm_dev
*atmdev
[4];
121 struct tasklet_struct tlet
;
123 spinlock_t tx_queue_lock
;
124 spinlock_t cli_queue_lock
;
125 spinlock_t param_queue_lock
;
126 struct list_head param_queue
;
127 struct sk_buff_head tx_queue
[4];
128 struct sk_buff_head cli_queue
[4];
129 struct sk_buff
*tx_skb
[4];
130 struct sk_buff
*rx_skb
[4];
131 unsigned char *dma_bounce
;
132 wait_queue_head_t param_wq
;
133 wait_queue_head_t fw_wq
;
143 struct list_head list
;
146 struct sk_buff
*response
;
149 #define SOLOS_CHAN(atmdev) ((int)(unsigned long)(atmdev)->phy_data)
151 MODULE_AUTHOR("Traverse Technologies <support@traverse.com.au>");
152 MODULE_DESCRIPTION("Solos PCI driver");
153 MODULE_VERSION(VERSION
);
154 MODULE_LICENSE("GPL");
155 MODULE_FIRMWARE("solos-FPGA.bin");
156 MODULE_FIRMWARE("solos-Firmware.bin");
157 MODULE_FIRMWARE("solos-db-FPGA.bin");
158 MODULE_PARM_DESC(reset
, "Reset Solos chips on startup");
159 MODULE_PARM_DESC(atmdebug
, "Print ATM data");
160 MODULE_PARM_DESC(firmware_upgrade
, "Initiate Solos firmware upgrade");
161 MODULE_PARM_DESC(fpga_upgrade
, "Initiate FPGA upgrade");
162 MODULE_PARM_DESC(db_firmware_upgrade
, "Initiate daughter board Solos firmware upgrade");
163 MODULE_PARM_DESC(db_fpga_upgrade
, "Initiate daughter board FPGA upgrade");
164 module_param(reset
, int, 0444);
165 module_param(atmdebug
, int, 0644);
166 module_param(firmware_upgrade
, int, 0444);
167 module_param(fpga_upgrade
, int, 0444);
168 module_param(db_firmware_upgrade
, int, 0444);
169 module_param(db_fpga_upgrade
, int, 0444);
171 static void fpga_queue(struct solos_card
*card
, int port
, struct sk_buff
*skb
,
172 struct atm_vcc
*vcc
);
173 static uint32_t fpga_tx(struct solos_card
*);
174 static irqreturn_t
solos_irq(int irq
, void *dev_id
);
175 static struct atm_vcc
* find_vcc(struct atm_dev
*dev
, short vpi
, int vci
);
176 static int atm_init(struct solos_card
*, struct device
*);
177 static void atm_remove(struct solos_card
*);
178 static int send_command(struct solos_card
*card
, int dev
, const char *buf
, size_t size
);
179 static void solos_bh(unsigned long);
180 static int print_buffer(struct sk_buff
*buf
);
182 static inline void solos_pop(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
187 dev_kfree_skb_any(skb
);
190 static ssize_t
solos_param_show(struct device
*dev
, struct device_attribute
*attr
,
193 struct atm_dev
*atmdev
= container_of(dev
, struct atm_dev
, class_dev
);
194 struct solos_card
*card
= atmdev
->dev_data
;
195 struct solos_param prm
;
197 struct pkt_hdr
*header
;
200 buflen
= strlen(attr
->attr
.name
) + 10;
202 skb
= alloc_skb(sizeof(*header
) + buflen
, GFP_KERNEL
);
204 dev_warn(&card
->dev
->dev
, "Failed to allocate sk_buff in solos_param_show()\n");
208 header
= (void *)skb_put(skb
, sizeof(*header
));
210 buflen
= snprintf((void *)&header
[1], buflen
- 1,
211 "L%05d\n%s\n", current
->pid
, attr
->attr
.name
);
212 skb_put(skb
, buflen
);
214 header
->size
= cpu_to_le16(buflen
);
215 header
->vpi
= cpu_to_le16(0);
216 header
->vci
= cpu_to_le16(0);
217 header
->type
= cpu_to_le16(PKT_COMMAND
);
219 prm
.pid
= current
->pid
;
221 prm
.port
= SOLOS_CHAN(atmdev
);
223 spin_lock_irq(&card
->param_queue_lock
);
224 list_add(&prm
.list
, &card
->param_queue
);
225 spin_unlock_irq(&card
->param_queue_lock
);
227 fpga_queue(card
, prm
.port
, skb
, NULL
);
229 wait_event_timeout(card
->param_wq
, prm
.response
, 5 * HZ
);
231 spin_lock_irq(&card
->param_queue_lock
);
233 spin_unlock_irq(&card
->param_queue_lock
);
238 buflen
= prm
.response
->len
;
239 memcpy(buf
, prm
.response
->data
, buflen
);
240 kfree_skb(prm
.response
);
245 static ssize_t
solos_param_store(struct device
*dev
, struct device_attribute
*attr
,
246 const char *buf
, size_t count
)
248 struct atm_dev
*atmdev
= container_of(dev
, struct atm_dev
, class_dev
);
249 struct solos_card
*card
= atmdev
->dev_data
;
250 struct solos_param prm
;
252 struct pkt_hdr
*header
;
256 buflen
= strlen(attr
->attr
.name
) + 11 + count
;
258 skb
= alloc_skb(sizeof(*header
) + buflen
, GFP_KERNEL
);
260 dev_warn(&card
->dev
->dev
, "Failed to allocate sk_buff in solos_param_store()\n");
264 header
= (void *)skb_put(skb
, sizeof(*header
));
266 buflen
= snprintf((void *)&header
[1], buflen
- 1,
267 "L%05d\n%s\n%s\n", current
->pid
, attr
->attr
.name
, buf
);
269 skb_put(skb
, buflen
);
270 header
->size
= cpu_to_le16(buflen
);
271 header
->vpi
= cpu_to_le16(0);
272 header
->vci
= cpu_to_le16(0);
273 header
->type
= cpu_to_le16(PKT_COMMAND
);
275 prm
.pid
= current
->pid
;
277 prm
.port
= SOLOS_CHAN(atmdev
);
279 spin_lock_irq(&card
->param_queue_lock
);
280 list_add(&prm
.list
, &card
->param_queue
);
281 spin_unlock_irq(&card
->param_queue_lock
);
283 fpga_queue(card
, prm
.port
, skb
, NULL
);
285 wait_event_timeout(card
->param_wq
, prm
.response
, 5 * HZ
);
287 spin_lock_irq(&card
->param_queue_lock
);
289 spin_unlock_irq(&card
->param_queue_lock
);
298 /* Sometimes it has a newline, sometimes it doesn't. */
299 if (skb
->data
[buflen
- 1] == '\n')
302 if (buflen
== 2 && !strncmp(skb
->data
, "OK", 2))
304 else if (buflen
== 5 && !strncmp(skb
->data
, "ERROR", 5))
307 /* We know we have enough space allocated for this; we allocated
309 skb
->data
[buflen
] = 0;
311 dev_warn(&card
->dev
->dev
, "Unexpected parameter response: '%s'\n",
320 static char *next_string(struct sk_buff
*skb
)
323 char *this = skb
->data
;
325 for (i
= 0; i
< skb
->len
; i
++) {
326 if (this[i
] == '\n') {
328 skb_pull(skb
, i
+ 1);
331 if (!isprint(this[i
]))
338 * Status packet has fields separated by \n, starting with a version number
339 * for the information therein. Fields are....
342 * RxBitRate (version >= 1)
343 * TxBitRate (version >= 1)
344 * State (version >= 1)
345 * LocalSNRMargin (version >= 1)
346 * LocalLineAttn (version >= 1)
348 static int process_status(struct solos_card
*card
, int port
, struct sk_buff
*skb
)
350 char *str
, *end
, *state_str
, *snr
, *attn
;
351 int ver
, rate_up
, rate_down
;
353 if (!card
->atmdev
[port
])
356 str
= next_string(skb
);
360 ver
= simple_strtol(str
, NULL
, 10);
362 dev_warn(&card
->dev
->dev
, "Unexpected status interrupt version %d\n",
367 str
= next_string(skb
);
370 if (!strcmp(str
, "ERROR")) {
371 dev_dbg(&card
->dev
->dev
, "Status packet indicated Solos error on port %d (starting up?)\n",
376 rate_down
= simple_strtol(str
, &end
, 10);
380 str
= next_string(skb
);
383 rate_up
= simple_strtol(str
, &end
, 10);
387 state_str
= next_string(skb
);
391 /* Anything but 'Showtime' is down */
392 if (strcmp(state_str
, "Showtime")) {
393 atm_dev_signal_change(card
->atmdev
[port
], ATM_PHY_SIG_LOST
);
394 dev_info(&card
->dev
->dev
, "Port %d: %s\n", port
, state_str
);
398 snr
= next_string(skb
);
401 attn
= next_string(skb
);
405 dev_info(&card
->dev
->dev
, "Port %d: %s @%d/%d kb/s%s%s%s%s\n",
406 port
, state_str
, rate_down
/1000, rate_up
/1000,
407 snr
[0]?", SNR ":"", snr
, attn
[0]?", Attn ":"", attn
);
409 card
->atmdev
[port
]->link_rate
= rate_down
/ 424;
410 atm_dev_signal_change(card
->atmdev
[port
], ATM_PHY_SIG_FOUND
);
415 static int process_command(struct solos_card
*card
, int port
, struct sk_buff
*skb
)
417 struct solos_param
*prm
;
425 if (skb
->data
[0] != 'L' || !isdigit(skb
->data
[1]) ||
426 !isdigit(skb
->data
[2]) || !isdigit(skb
->data
[3]) ||
427 !isdigit(skb
->data
[4]) || !isdigit(skb
->data
[5]) ||
428 skb
->data
[6] != '\n')
431 cmdpid
= simple_strtol(&skb
->data
[1], NULL
, 10);
433 spin_lock_irqsave(&card
->param_queue_lock
, flags
);
434 list_for_each_entry(prm
, &card
->param_queue
, list
) {
435 if (prm
->port
== port
&& prm
->pid
== cmdpid
) {
438 wake_up(&card
->param_wq
);
443 spin_unlock_irqrestore(&card
->param_queue_lock
, flags
);
447 static ssize_t
console_show(struct device
*dev
, struct device_attribute
*attr
,
450 struct atm_dev
*atmdev
= container_of(dev
, struct atm_dev
, class_dev
);
451 struct solos_card
*card
= atmdev
->dev_data
;
455 spin_lock(&card
->cli_queue_lock
);
456 skb
= skb_dequeue(&card
->cli_queue
[SOLOS_CHAN(atmdev
)]);
457 spin_unlock(&card
->cli_queue_lock
);
459 return sprintf(buf
, "No data.\n");
462 memcpy(buf
, skb
->data
, len
);
468 static int send_command(struct solos_card
*card
, int dev
, const char *buf
, size_t size
)
471 struct pkt_hdr
*header
;
473 if (size
> (BUF_SIZE
- sizeof(*header
))) {
474 dev_dbg(&card
->dev
->dev
, "Command is too big. Dropping request\n");
477 skb
= alloc_skb(size
+ sizeof(*header
), GFP_ATOMIC
);
479 dev_warn(&card
->dev
->dev
, "Failed to allocate sk_buff in send_command()\n");
483 header
= (void *)skb_put(skb
, sizeof(*header
));
485 header
->size
= cpu_to_le16(size
);
486 header
->vpi
= cpu_to_le16(0);
487 header
->vci
= cpu_to_le16(0);
488 header
->type
= cpu_to_le16(PKT_COMMAND
);
490 memcpy(skb_put(skb
, size
), buf
, size
);
492 fpga_queue(card
, dev
, skb
, NULL
);
497 static ssize_t
console_store(struct device
*dev
, struct device_attribute
*attr
,
498 const char *buf
, size_t count
)
500 struct atm_dev
*atmdev
= container_of(dev
, struct atm_dev
, class_dev
);
501 struct solos_card
*card
= atmdev
->dev_data
;
504 err
= send_command(card
, SOLOS_CHAN(atmdev
), buf
, count
);
509 struct geos_gpio_attr
{
510 struct device_attribute attr
;
514 #define SOLOS_GPIO_ATTR(_name, _mode, _show, _store, _offset) \
515 struct geos_gpio_attr gpio_attr_##_name = { \
516 .attr = __ATTR(_name, _mode, _show, _store), \
519 static ssize_t
geos_gpio_store(struct device
*dev
, struct device_attribute
*attr
,
520 const char *buf
, size_t count
)
522 struct pci_dev
*pdev
= container_of(dev
, struct pci_dev
, dev
);
523 struct geos_gpio_attr
*gattr
= container_of(attr
, struct geos_gpio_attr
, attr
);
524 struct solos_card
*card
= pci_get_drvdata(pdev
);
527 if (count
!= 1 && (count
!= 2 || buf
[1] != '\n'))
530 spin_lock_irq(&card
->param_queue_lock
);
531 data32
= ioread32(card
->config_regs
+ GPIO_STATUS
);
533 data32
|= 1 << gattr
->offset
;
534 iowrite32(data32
, card
->config_regs
+ GPIO_STATUS
);
535 } else if (buf
[0] == '0') {
536 data32
&= ~(1 << gattr
->offset
);
537 iowrite32(data32
, card
->config_regs
+ GPIO_STATUS
);
541 spin_unlock_irq(&card
->param_queue_lock
);
545 static ssize_t
geos_gpio_show(struct device
*dev
, struct device_attribute
*attr
,
548 struct pci_dev
*pdev
= container_of(dev
, struct pci_dev
, dev
);
549 struct geos_gpio_attr
*gattr
= container_of(attr
, struct geos_gpio_attr
, attr
);
550 struct solos_card
*card
= pci_get_drvdata(pdev
);
553 data32
= ioread32(card
->config_regs
+ GPIO_STATUS
);
554 data32
= (data32
>> gattr
->offset
) & 1;
556 return sprintf(buf
, "%d\n", data32
);
559 static ssize_t
hardware_show(struct device
*dev
, struct device_attribute
*attr
,
562 struct pci_dev
*pdev
= container_of(dev
, struct pci_dev
, dev
);
563 struct geos_gpio_attr
*gattr
= container_of(attr
, struct geos_gpio_attr
, attr
);
564 struct solos_card
*card
= pci_get_drvdata(pdev
);
567 data32
= ioread32(card
->config_regs
+ GPIO_STATUS
);
568 switch (gattr
->offset
) {
570 /* HardwareVersion */
571 data32
= data32
& 0x1F;
574 /* HardwareVariant */
575 data32
= (data32
>> 5) & 0x0F;
578 return sprintf(buf
, "%d\n", data32
);
581 static DEVICE_ATTR(console
, 0644, console_show
, console_store
);
584 #define SOLOS_ATTR_RO(x) static DEVICE_ATTR(x, 0444, solos_param_show, NULL);
585 #define SOLOS_ATTR_RW(x) static DEVICE_ATTR(x, 0644, solos_param_show, solos_param_store);
587 #include "solos-attrlist.c"
589 static SOLOS_GPIO_ATTR(GPIO1
, 0644, geos_gpio_show
, geos_gpio_store
, 9);
590 static SOLOS_GPIO_ATTR(GPIO2
, 0644, geos_gpio_show
, geos_gpio_store
, 10);
591 static SOLOS_GPIO_ATTR(GPIO3
, 0644, geos_gpio_show
, geos_gpio_store
, 11);
592 static SOLOS_GPIO_ATTR(GPIO4
, 0644, geos_gpio_show
, geos_gpio_store
, 12);
593 static SOLOS_GPIO_ATTR(GPIO5
, 0644, geos_gpio_show
, geos_gpio_store
, 13);
594 static SOLOS_GPIO_ATTR(PushButton
, 0444, geos_gpio_show
, NULL
, 14);
595 static SOLOS_GPIO_ATTR(HardwareVersion
, 0444, hardware_show
, NULL
, 0);
596 static SOLOS_GPIO_ATTR(HardwareVariant
, 0444, hardware_show
, NULL
, 1);
600 #define SOLOS_ATTR_RO(x) &dev_attr_##x.attr,
601 #define SOLOS_ATTR_RW(x) &dev_attr_##x.attr,
603 static struct attribute
*solos_attrs
[] = {
604 #include "solos-attrlist.c"
608 static struct attribute_group solos_attr_group
= {
609 .attrs
= solos_attrs
,
610 .name
= "parameters",
613 static struct attribute
*gpio_attrs
[] = {
614 &gpio_attr_GPIO1
.attr
.attr
,
615 &gpio_attr_GPIO2
.attr
.attr
,
616 &gpio_attr_GPIO3
.attr
.attr
,
617 &gpio_attr_GPIO4
.attr
.attr
,
618 &gpio_attr_GPIO5
.attr
.attr
,
619 &gpio_attr_PushButton
.attr
.attr
,
620 &gpio_attr_HardwareVersion
.attr
.attr
,
621 &gpio_attr_HardwareVariant
.attr
.attr
,
625 static struct attribute_group gpio_attr_group
= {
630 static int flash_upgrade(struct solos_card
*card
, int chip
)
632 const struct firmware
*fw
;
640 fw_name
= "solos-FPGA.bin";
641 if (card
->atmel_flash
)
642 blocksize
= ATMEL_FPGA_BLOCK
;
644 blocksize
= SPI_FLASH_BLOCK
;
647 fw_name
= "solos-Firmware.bin";
648 if (card
->atmel_flash
)
649 blocksize
= ATMEL_SOLOS_BLOCK
;
651 blocksize
= SPI_FLASH_BLOCK
;
654 if (card
->fpga_version
> LEGACY_BUFFERS
){
655 fw_name
= "solos-db-FPGA.bin";
656 if (card
->atmel_flash
)
657 blocksize
= ATMEL_FPGA_BLOCK
;
659 blocksize
= SPI_FLASH_BLOCK
;
661 dev_info(&card
->dev
->dev
, "FPGA version doesn't support"
662 " daughter board upgrades\n");
667 if (card
->fpga_version
> LEGACY_BUFFERS
){
668 fw_name
= "solos-Firmware.bin";
669 if (card
->atmel_flash
)
670 blocksize
= ATMEL_SOLOS_BLOCK
;
672 blocksize
= SPI_FLASH_BLOCK
;
674 dev_info(&card
->dev
->dev
, "FPGA version doesn't support"
675 " daughter board upgrades\n");
683 if (request_firmware(&fw
, fw_name
, &card
->dev
->dev
))
686 dev_info(&card
->dev
->dev
, "Flash upgrade starting\n");
688 /* New FPGAs require driver version before permitting flash upgrades */
689 iowrite32(DRIVER_VERSION
, card
->config_regs
+ DRIVER_VER
);
691 numblocks
= fw
->size
/ blocksize
;
692 dev_info(&card
->dev
->dev
, "Firmware size: %zd\n", fw
->size
);
693 dev_info(&card
->dev
->dev
, "Number of blocks: %d\n", numblocks
);
695 dev_info(&card
->dev
->dev
, "Changing FPGA to Update mode\n");
696 iowrite32(1, card
->config_regs
+ FPGA_MODE
);
697 (void) ioread32(card
->config_regs
+ FPGA_MODE
);
699 /* Set mode to Chip Erase */
700 if(chip
== 0 || chip
== 2)
701 dev_info(&card
->dev
->dev
, "Set FPGA Flash mode to FPGA Chip Erase\n");
702 if(chip
== 1 || chip
== 3)
703 dev_info(&card
->dev
->dev
, "Set FPGA Flash mode to Solos Chip Erase\n");
704 iowrite32((chip
* 2), card
->config_regs
+ FLASH_MODE
);
707 iowrite32(1, card
->config_regs
+ WRITE_FLASH
);
708 wait_event(card
->fw_wq
, !ioread32(card
->config_regs
+ FLASH_BUSY
));
710 for (offset
= 0; offset
< fw
->size
; offset
+= blocksize
) {
713 /* Clear write flag */
714 iowrite32(0, card
->config_regs
+ WRITE_FLASH
);
716 /* Set mode to Block Write */
717 /* dev_info(&card->dev->dev, "Set FPGA Flash mode to Block Write\n"); */
718 iowrite32(((chip
* 2) + 1), card
->config_regs
+ FLASH_MODE
);
720 /* Copy block to buffer, swapping each 16 bits for Atmel flash */
721 for(i
= 0; i
< blocksize
; i
+= 4) {
723 if (card
->atmel_flash
)
724 word
= swahb32p((uint32_t *)(fw
->data
+ offset
+ i
));
726 word
= *(uint32_t *)(fw
->data
+ offset
+ i
);
727 if(card
->fpga_version
> LEGACY_BUFFERS
)
728 iowrite32(word
, FLASH_BUF
+ i
);
730 iowrite32(word
, RX_BUF(card
, 3) + i
);
733 /* Specify block number and then trigger flash write */
734 iowrite32(offset
/ blocksize
, card
->config_regs
+ FLASH_BLOCK
);
735 iowrite32(1, card
->config_regs
+ WRITE_FLASH
);
736 wait_event(card
->fw_wq
, !ioread32(card
->config_regs
+ FLASH_BUSY
));
739 release_firmware(fw
);
740 iowrite32(0, card
->config_regs
+ WRITE_FLASH
);
741 iowrite32(0, card
->config_regs
+ FPGA_MODE
);
742 iowrite32(0, card
->config_regs
+ FLASH_MODE
);
743 dev_info(&card
->dev
->dev
, "Returning FPGA to Data mode\n");
747 static irqreturn_t
solos_irq(int irq
, void *dev_id
)
749 struct solos_card
*card
= dev_id
;
752 iowrite32(0, card
->config_regs
+ IRQ_CLEAR
);
754 /* If we're up and running, just kick the tasklet to process TX/RX */
756 tasklet_schedule(&card
->tlet
);
758 wake_up(&card
->fw_wq
);
760 return IRQ_RETVAL(handled
);
763 static void solos_bh(unsigned long card_arg
)
765 struct solos_card
*card
= (void *)card_arg
;
767 uint32_t rx_done
= 0;
771 * Since fpga_tx() is going to need to read the flags under its lock,
772 * it can return them to us so that we don't have to hit PCI MMIO
773 * again for the same information
775 card_flags
= fpga_tx(card
);
777 for (port
= 0; port
< card
->nr_ports
; port
++) {
778 if (card_flags
& (0x10 << port
)) {
779 struct pkt_hdr _hdr
, *header
;
784 if (card
->using_dma
) {
785 skb
= card
->rx_skb
[port
];
786 card
->rx_skb
[port
] = NULL
;
788 dma_unmap_single(&card
->dev
->dev
, SKB_CB(skb
)->dma_addr
,
789 RX_DMA_SIZE
, DMA_FROM_DEVICE
);
791 header
= (void *)skb
->data
;
792 size
= le16_to_cpu(header
->size
);
793 skb_put(skb
, size
+ sizeof(*header
));
794 skb_pull(skb
, sizeof(*header
));
798 rx_done
|= 0x10 << port
;
800 memcpy_fromio(header
, RX_BUF(card
, port
), sizeof(*header
));
802 size
= le16_to_cpu(header
->size
);
803 if (size
> (card
->buffer_size
- sizeof(*header
))){
804 dev_warn(&card
->dev
->dev
, "Invalid buffer size\n");
808 /* Use netdev_alloc_skb() because it adds NET_SKB_PAD of
809 * headroom, and ensures we can route packets back out an
810 * Ethernet interface (for example) without having to
811 * reallocate. Adding NET_IP_ALIGN also ensures that both
812 * PPPoATM and PPPoEoBR2684 packets end up aligned. */
813 skb
= netdev_alloc_skb_ip_align(NULL
, size
+ 1);
816 dev_warn(&card
->dev
->dev
, "Failed to allocate sk_buff for RX\n");
820 memcpy_fromio(skb_put(skb
, size
),
821 RX_BUF(card
, port
) + sizeof(*header
),
825 dev_info(&card
->dev
->dev
, "Received: port %d\n", port
);
826 dev_info(&card
->dev
->dev
, "size: %d VPI: %d VCI: %d\n",
827 size
, le16_to_cpu(header
->vpi
),
828 le16_to_cpu(header
->vci
));
832 switch (le16_to_cpu(header
->type
)) {
834 vcc
= find_vcc(card
->atmdev
[port
], le16_to_cpu(header
->vpi
),
835 le16_to_cpu(header
->vci
));
838 dev_warn(&card
->dev
->dev
, "Received packet for unknown VPI.VCI %d.%d on port %d\n",
839 le16_to_cpu(header
->vpi
), le16_to_cpu(header
->vci
),
841 dev_kfree_skb_any(skb
);
844 atm_charge(vcc
, skb
->truesize
);
846 atomic_inc(&vcc
->stats
->rx
);
850 if (process_status(card
, port
, skb
) &&
852 dev_warn(&card
->dev
->dev
, "Bad status packet of %d bytes on port %d:\n", skb
->len
, port
);
855 dev_kfree_skb_any(skb
);
859 default: /* FIXME: Not really, surely? */
860 if (process_command(card
, port
, skb
))
862 spin_lock(&card
->cli_queue_lock
);
863 if (skb_queue_len(&card
->cli_queue
[port
]) > 10) {
865 dev_warn(&card
->dev
->dev
, "Dropping console response on port %d\n",
867 dev_kfree_skb_any(skb
);
869 skb_queue_tail(&card
->cli_queue
[port
], skb
);
870 spin_unlock(&card
->cli_queue_lock
);
874 /* Allocate RX skbs for any ports which need them */
875 if (card
->using_dma
&& card
->atmdev
[port
] &&
876 !card
->rx_skb
[port
]) {
877 /* Unlike the MMIO case (qv) we can't add NET_IP_ALIGN
878 * here; the FPGA can only DMA to addresses which are
879 * aligned to 4 bytes. */
880 struct sk_buff
*skb
= dev_alloc_skb(RX_DMA_SIZE
);
882 SKB_CB(skb
)->dma_addr
=
883 dma_map_single(&card
->dev
->dev
, skb
->data
,
884 RX_DMA_SIZE
, DMA_FROM_DEVICE
);
885 iowrite32(SKB_CB(skb
)->dma_addr
,
886 card
->config_regs
+ RX_DMA_ADDR(port
));
887 card
->rx_skb
[port
] = skb
;
890 dev_warn(&card
->dev
->dev
, "Failed to allocate RX skb");
892 /* We'll have to try again later */
893 tasklet_schedule(&card
->tlet
);
898 iowrite32(rx_done
, card
->config_regs
+ FLAGS_ADDR
);
903 static struct atm_vcc
*find_vcc(struct atm_dev
*dev
, short vpi
, int vci
)
905 struct hlist_head
*head
;
906 struct atm_vcc
*vcc
= NULL
;
909 read_lock(&vcc_sklist_lock
);
910 head
= &vcc_hash
[vci
& (VCC_HTABLE_SIZE
-1)];
911 sk_for_each(s
, head
) {
913 if (vcc
->dev
== dev
&& vcc
->vci
== vci
&&
914 vcc
->vpi
== vpi
&& vcc
->qos
.rxtp
.traffic_class
!= ATM_NONE
&&
915 test_bit(ATM_VF_READY
, &vcc
->flags
))
920 read_unlock(&vcc_sklist_lock
);
924 static int popen(struct atm_vcc
*vcc
)
926 struct solos_card
*card
= vcc
->dev
->dev_data
;
928 struct pkt_hdr
*header
;
930 if (vcc
->qos
.aal
!= ATM_AAL5
) {
931 dev_warn(&card
->dev
->dev
, "Unsupported ATM type %d\n",
936 skb
= alloc_skb(sizeof(*header
), GFP_KERNEL
);
939 dev_warn(&card
->dev
->dev
, "Failed to allocate sk_buff in popen()\n");
942 header
= (void *)skb_put(skb
, sizeof(*header
));
944 header
->size
= cpu_to_le16(0);
945 header
->vpi
= cpu_to_le16(vcc
->vpi
);
946 header
->vci
= cpu_to_le16(vcc
->vci
);
947 header
->type
= cpu_to_le16(PKT_POPEN
);
949 fpga_queue(card
, SOLOS_CHAN(vcc
->dev
), skb
, NULL
);
951 set_bit(ATM_VF_ADDR
, &vcc
->flags
);
952 set_bit(ATM_VF_READY
, &vcc
->flags
);
957 static void pclose(struct atm_vcc
*vcc
)
959 struct solos_card
*card
= vcc
->dev
->dev_data
;
960 unsigned char port
= SOLOS_CHAN(vcc
->dev
);
961 struct sk_buff
*skb
, *tmpskb
;
962 struct pkt_hdr
*header
;
964 /* Remove any yet-to-be-transmitted packets from the pending queue */
965 spin_lock(&card
->tx_queue_lock
);
966 skb_queue_walk_safe(&card
->tx_queue
[port
], skb
, tmpskb
) {
967 if (SKB_CB(skb
)->vcc
== vcc
) {
968 skb_unlink(skb
, &card
->tx_queue
[port
]);
972 spin_unlock(&card
->tx_queue_lock
);
974 skb
= alloc_skb(sizeof(*header
), GFP_KERNEL
);
976 dev_warn(&card
->dev
->dev
, "Failed to allocate sk_buff in pclose()\n");
979 header
= (void *)skb_put(skb
, sizeof(*header
));
981 header
->size
= cpu_to_le16(0);
982 header
->vpi
= cpu_to_le16(vcc
->vpi
);
983 header
->vci
= cpu_to_le16(vcc
->vci
);
984 header
->type
= cpu_to_le16(PKT_PCLOSE
);
987 fpga_queue(card
, port
, skb
, NULL
);
989 if (!wait_event_timeout(card
->param_wq
, !skb_shared(skb
), 5 * HZ
))
990 dev_warn(&card
->dev
->dev
,
991 "Timeout waiting for VCC close on port %d\n", port
);
995 /* Hold up vcc_destroy_socket() (our caller) until solos_bh() in the
996 tasklet has finished processing any incoming packets (and, more to
997 the point, using the vcc pointer). */
998 tasklet_unlock_wait(&card
->tlet
);
1000 clear_bit(ATM_VF_ADDR
, &vcc
->flags
);
1005 static int print_buffer(struct sk_buff
*buf
)
1012 for (i
= 0; i
< len
; i
++){
1014 sprintf(msg
, "%02X: ", i
);
1016 sprintf(item
,"%02X ",*(buf
->data
+ i
));
1019 sprintf(item
, "\n");
1021 printk(KERN_DEBUG
"%s", msg
);
1025 sprintf(item
, "\n");
1027 printk(KERN_DEBUG
"%s", msg
);
1029 printk(KERN_DEBUG
"\n");
1034 static void fpga_queue(struct solos_card
*card
, int port
, struct sk_buff
*skb
,
1035 struct atm_vcc
*vcc
)
1038 unsigned long flags
;
1040 SKB_CB(skb
)->vcc
= vcc
;
1042 spin_lock_irqsave(&card
->tx_queue_lock
, flags
);
1043 old_len
= skb_queue_len(&card
->tx_queue
[port
]);
1044 skb_queue_tail(&card
->tx_queue
[port
], skb
);
1046 card
->tx_mask
|= (1 << port
);
1047 spin_unlock_irqrestore(&card
->tx_queue_lock
, flags
);
1049 /* Theoretically we could just schedule the tasklet here, but
1050 that introduces latency we don't want -- it's noticeable */
1055 static uint32_t fpga_tx(struct solos_card
*card
)
1057 uint32_t tx_pending
, card_flags
;
1058 uint32_t tx_started
= 0;
1059 struct sk_buff
*skb
;
1060 struct atm_vcc
*vcc
;
1062 unsigned long flags
;
1064 spin_lock_irqsave(&card
->tx_lock
, flags
);
1066 card_flags
= ioread32(card
->config_regs
+ FLAGS_ADDR
);
1068 * The queue lock is required for _writing_ to tx_mask, but we're
1069 * OK to read it here without locking. The only potential update
1070 * that we could race with is in fpga_queue() where it sets a bit
1071 * for a new port... but it's going to call this function again if
1072 * it's doing that, anyway.
1074 tx_pending
= card
->tx_mask
& ~card_flags
;
1076 for (port
= 0; tx_pending
; tx_pending
>>= 1, port
++) {
1077 if (tx_pending
& 1) {
1078 struct sk_buff
*oldskb
= card
->tx_skb
[port
];
1080 dma_unmap_single(&card
->dev
->dev
, SKB_CB(oldskb
)->dma_addr
,
1081 oldskb
->len
, DMA_TO_DEVICE
);
1082 card
->tx_skb
[port
] = NULL
;
1084 spin_lock(&card
->tx_queue_lock
);
1085 skb
= skb_dequeue(&card
->tx_queue
[port
]);
1087 card
->tx_mask
&= ~(1 << port
);
1088 spin_unlock(&card
->tx_queue_lock
);
1090 if (skb
&& !card
->using_dma
) {
1091 memcpy_toio(TX_BUF(card
, port
), skb
->data
, skb
->len
);
1092 tx_started
|= 1 << port
;
1093 oldskb
= skb
; /* We're done with this skb already */
1094 } else if (skb
&& card
->using_dma
) {
1095 unsigned char *data
= skb
->data
;
1096 if ((unsigned long)data
& card
->dma_alignment
) {
1097 data
= card
->dma_bounce
+ (BUF_SIZE
* port
);
1098 memcpy(data
, skb
->data
, skb
->len
);
1100 SKB_CB(skb
)->dma_addr
= dma_map_single(&card
->dev
->dev
, data
,
1101 skb
->len
, DMA_TO_DEVICE
);
1102 card
->tx_skb
[port
] = skb
;
1103 iowrite32(SKB_CB(skb
)->dma_addr
,
1104 card
->config_regs
+ TX_DMA_ADDR(port
));
1110 /* Clean up and free oldskb now it's gone */
1112 struct pkt_hdr
*header
= (void *)oldskb
->data
;
1113 int size
= le16_to_cpu(header
->size
);
1115 skb_pull(oldskb
, sizeof(*header
));
1116 dev_info(&card
->dev
->dev
, "Transmitted: port %d\n",
1118 dev_info(&card
->dev
->dev
, "size: %d VPI: %d VCI: %d\n",
1119 size
, le16_to_cpu(header
->vpi
),
1120 le16_to_cpu(header
->vci
));
1121 print_buffer(oldskb
);
1124 vcc
= SKB_CB(oldskb
)->vcc
;
1127 atomic_inc(&vcc
->stats
->tx
);
1128 solos_pop(vcc
, oldskb
);
1130 dev_kfree_skb_irq(oldskb
);
1131 wake_up(&card
->param_wq
);
1135 /* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */
1137 iowrite32(tx_started
, card
->config_regs
+ FLAGS_ADDR
);
1139 spin_unlock_irqrestore(&card
->tx_lock
, flags
);
1143 static int psend(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
1145 struct solos_card
*card
= vcc
->dev
->dev_data
;
1146 struct pkt_hdr
*header
;
1150 if (pktlen
> (BUF_SIZE
- sizeof(*header
))) {
1151 dev_warn(&card
->dev
->dev
, "Length of PDU is too large. Dropping PDU.\n");
1152 solos_pop(vcc
, skb
);
1156 if (!skb_clone_writable(skb
, sizeof(*header
))) {
1160 if (skb_headroom(skb
) < sizeof(*header
))
1161 expand_by
= sizeof(*header
) - skb_headroom(skb
);
1163 ret
= pskb_expand_head(skb
, expand_by
, 0, GFP_ATOMIC
);
1165 dev_warn(&card
->dev
->dev
, "pskb_expand_head failed.\n");
1166 solos_pop(vcc
, skb
);
1171 header
= (void *)skb_push(skb
, sizeof(*header
));
1173 /* This does _not_ include the size of the header */
1174 header
->size
= cpu_to_le16(pktlen
);
1175 header
->vpi
= cpu_to_le16(vcc
->vpi
);
1176 header
->vci
= cpu_to_le16(vcc
->vci
);
1177 header
->type
= cpu_to_le16(PKT_DATA
);
1179 fpga_queue(card
, SOLOS_CHAN(vcc
->dev
), skb
, vcc
);
1184 static struct atmdev_ops fpga_ops
= {
1196 .owner
= THIS_MODULE
1199 static int fpga_probe(struct pci_dev
*dev
, const struct pci_device_id
*id
)
1203 uint8_t major_ver
, minor_ver
;
1205 struct solos_card
*card
;
1207 card
= kzalloc(sizeof(*card
), GFP_KERNEL
);
1212 init_waitqueue_head(&card
->fw_wq
);
1213 init_waitqueue_head(&card
->param_wq
);
1215 err
= pci_enable_device(dev
);
1217 dev_warn(&dev
->dev
, "Failed to enable PCI device\n");
1221 err
= dma_set_mask_and_coherent(&dev
->dev
, DMA_BIT_MASK(32));
1223 dev_warn(&dev
->dev
, "Failed to set 32-bit DMA mask\n");
1227 err
= pci_request_regions(dev
, "solos");
1229 dev_warn(&dev
->dev
, "Failed to request regions\n");
1233 card
->config_regs
= pci_iomap(dev
, 0, CONFIG_RAM_SIZE
);
1234 if (!card
->config_regs
) {
1235 dev_warn(&dev
->dev
, "Failed to ioremap config registers\n");
1237 goto out_release_regions
;
1239 card
->buffers
= pci_iomap(dev
, 1, DATA_RAM_SIZE
);
1240 if (!card
->buffers
) {
1241 dev_warn(&dev
->dev
, "Failed to ioremap data buffers\n");
1243 goto out_unmap_config
;
1247 iowrite32(1, card
->config_regs
+ FPGA_MODE
);
1248 data32
= ioread32(card
->config_regs
+ FPGA_MODE
);
1250 iowrite32(0, card
->config_regs
+ FPGA_MODE
);
1251 data32
= ioread32(card
->config_regs
+ FPGA_MODE
);
1254 data32
= ioread32(card
->config_regs
+ FPGA_VER
);
1255 fpga_ver
= (data32
& 0x0000FFFF);
1256 major_ver
= ((data32
& 0xFF000000) >> 24);
1257 minor_ver
= ((data32
& 0x00FF0000) >> 16);
1258 card
->fpga_version
= FPGA_VERSION(major_ver
,minor_ver
);
1259 if (card
->fpga_version
> LEGACY_BUFFERS
)
1260 card
->buffer_size
= BUF_SIZE
;
1262 card
->buffer_size
= OLD_BUF_SIZE
;
1263 dev_info(&dev
->dev
, "Solos FPGA Version %d.%02d svn-%d\n",
1264 major_ver
, minor_ver
, fpga_ver
);
1266 if (fpga_ver
< 37 && (fpga_upgrade
|| firmware_upgrade
||
1267 db_fpga_upgrade
|| db_firmware_upgrade
)) {
1269 "FPGA too old; cannot upgrade flash. Use JTAG.\n");
1270 fpga_upgrade
= firmware_upgrade
= 0;
1271 db_fpga_upgrade
= db_firmware_upgrade
= 0;
1274 /* Stopped using Atmel flash after 0.03-38 */
1276 card
->atmel_flash
= 1;
1278 card
->atmel_flash
= 0;
1280 data32
= ioread32(card
->config_regs
+ PORTS
);
1281 card
->nr_ports
= (data32
& 0x000000FF);
1283 if (card
->fpga_version
>= DMA_SUPPORTED
) {
1284 pci_set_master(dev
);
1285 card
->using_dma
= 1;
1286 if (1) { /* All known FPGA versions so far */
1287 card
->dma_alignment
= 3;
1288 card
->dma_bounce
= kmalloc(card
->nr_ports
* BUF_SIZE
, GFP_KERNEL
);
1289 if (!card
->dma_bounce
) {
1290 dev_warn(&card
->dev
->dev
, "Failed to allocate DMA bounce buffers\n");
1292 /* Fallback to MMIO doesn't work */
1293 goto out_unmap_both
;
1297 card
->using_dma
= 0;
1298 /* Set RX empty flag for all ports */
1299 iowrite32(0xF0, card
->config_regs
+ FLAGS_ADDR
);
1302 pci_set_drvdata(dev
, card
);
1304 tasklet_init(&card
->tlet
, solos_bh
, (unsigned long)card
);
1305 spin_lock_init(&card
->tx_lock
);
1306 spin_lock_init(&card
->tx_queue_lock
);
1307 spin_lock_init(&card
->cli_queue_lock
);
1308 spin_lock_init(&card
->param_queue_lock
);
1309 INIT_LIST_HEAD(&card
->param_queue
);
1311 err
= request_irq(dev
->irq
, solos_irq
, IRQF_SHARED
,
1314 dev_dbg(&card
->dev
->dev
, "Failed to request interrupt IRQ: %d\n", dev
->irq
);
1315 goto out_unmap_both
;
1318 iowrite32(1, card
->config_regs
+ IRQ_EN_ADDR
);
1321 flash_upgrade(card
, 0);
1323 if (firmware_upgrade
)
1324 flash_upgrade(card
, 1);
1326 if (db_fpga_upgrade
)
1327 flash_upgrade(card
, 2);
1329 if (db_firmware_upgrade
)
1330 flash_upgrade(card
, 3);
1332 err
= atm_init(card
, &dev
->dev
);
1336 if (card
->fpga_version
>= DMA_SUPPORTED
&&
1337 sysfs_create_group(&card
->dev
->dev
.kobj
, &gpio_attr_group
))
1338 dev_err(&card
->dev
->dev
, "Could not register parameter group for GPIOs\n");
1343 iowrite32(0, card
->config_regs
+ IRQ_EN_ADDR
);
1344 free_irq(dev
->irq
, card
);
1345 tasklet_kill(&card
->tlet
);
1348 kfree(card
->dma_bounce
);
1349 pci_iounmap(dev
, card
->buffers
);
1351 pci_iounmap(dev
, card
->config_regs
);
1352 out_release_regions
:
1353 pci_release_regions(dev
);
1359 static int atm_init(struct solos_card
*card
, struct device
*parent
)
1363 for (i
= 0; i
< card
->nr_ports
; i
++) {
1364 struct sk_buff
*skb
;
1365 struct pkt_hdr
*header
;
1367 skb_queue_head_init(&card
->tx_queue
[i
]);
1368 skb_queue_head_init(&card
->cli_queue
[i
]);
1370 card
->atmdev
[i
] = atm_dev_register("solos-pci", parent
, &fpga_ops
, -1, NULL
);
1371 if (!card
->atmdev
[i
]) {
1372 dev_err(&card
->dev
->dev
, "Could not register ATM device %d\n", i
);
1376 if (device_create_file(&card
->atmdev
[i
]->class_dev
, &dev_attr_console
))
1377 dev_err(&card
->dev
->dev
, "Could not register console for ATM device %d\n", i
);
1378 if (sysfs_create_group(&card
->atmdev
[i
]->class_dev
.kobj
, &solos_attr_group
))
1379 dev_err(&card
->dev
->dev
, "Could not register parameter group for ATM device %d\n", i
);
1381 dev_info(&card
->dev
->dev
, "Registered ATM device %d\n", card
->atmdev
[i
]->number
);
1383 card
->atmdev
[i
]->ci_range
.vpi_bits
= 8;
1384 card
->atmdev
[i
]->ci_range
.vci_bits
= 16;
1385 card
->atmdev
[i
]->dev_data
= card
;
1386 card
->atmdev
[i
]->phy_data
= (void *)(unsigned long)i
;
1387 atm_dev_signal_change(card
->atmdev
[i
], ATM_PHY_SIG_FOUND
);
1389 skb
= alloc_skb(sizeof(*header
), GFP_KERNEL
);
1391 dev_warn(&card
->dev
->dev
, "Failed to allocate sk_buff in atm_init()\n");
1395 header
= (void *)skb_put(skb
, sizeof(*header
));
1397 header
->size
= cpu_to_le16(0);
1398 header
->vpi
= cpu_to_le16(0);
1399 header
->vci
= cpu_to_le16(0);
1400 header
->type
= cpu_to_le16(PKT_STATUS
);
1402 fpga_queue(card
, i
, skb
, NULL
);
1407 static void atm_remove(struct solos_card
*card
)
1411 for (i
= 0; i
< card
->nr_ports
; i
++) {
1412 if (card
->atmdev
[i
]) {
1413 struct sk_buff
*skb
;
1415 dev_info(&card
->dev
->dev
, "Unregistering ATM device %d\n", card
->atmdev
[i
]->number
);
1417 sysfs_remove_group(&card
->atmdev
[i
]->class_dev
.kobj
, &solos_attr_group
);
1418 atm_dev_deregister(card
->atmdev
[i
]);
1420 skb
= card
->rx_skb
[i
];
1422 dma_unmap_single(&card
->dev
->dev
, SKB_CB(skb
)->dma_addr
,
1423 RX_DMA_SIZE
, DMA_FROM_DEVICE
);
1426 skb
= card
->tx_skb
[i
];
1428 dma_unmap_single(&card
->dev
->dev
, SKB_CB(skb
)->dma_addr
,
1429 skb
->len
, DMA_TO_DEVICE
);
1432 while ((skb
= skb_dequeue(&card
->tx_queue
[i
])))
1439 static void fpga_remove(struct pci_dev
*dev
)
1441 struct solos_card
*card
= pci_get_drvdata(dev
);
1444 iowrite32(0, card
->config_regs
+ IRQ_EN_ADDR
);
1447 iowrite32(1, card
->config_regs
+ FPGA_MODE
);
1448 (void)ioread32(card
->config_regs
+ FPGA_MODE
);
1450 if (card
->fpga_version
>= DMA_SUPPORTED
)
1451 sysfs_remove_group(&card
->dev
->dev
.kobj
, &gpio_attr_group
);
1455 free_irq(dev
->irq
, card
);
1456 tasklet_kill(&card
->tlet
);
1458 kfree(card
->dma_bounce
);
1460 /* Release device from reset */
1461 iowrite32(0, card
->config_regs
+ FPGA_MODE
);
1462 (void)ioread32(card
->config_regs
+ FPGA_MODE
);
1464 pci_iounmap(dev
, card
->buffers
);
1465 pci_iounmap(dev
, card
->config_regs
);
1467 pci_release_regions(dev
);
1468 pci_disable_device(dev
);
1473 static struct pci_device_id fpga_pci_tbl
[] = {
1474 { 0x10ee, 0x0300, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
1478 MODULE_DEVICE_TABLE(pci
,fpga_pci_tbl
);
1480 static struct pci_driver fpga_driver
= {
1482 .id_table
= fpga_pci_tbl
,
1483 .probe
= fpga_probe
,
1484 .remove
= fpga_remove
,
1488 static int __init
solos_pci_init(void)
1490 BUILD_BUG_ON(sizeof(struct solos_skb_cb
) > sizeof(((struct sk_buff
*)0)->cb
));
1492 printk(KERN_INFO
"Solos PCI Driver Version %s\n", VERSION
);
1493 return pci_register_driver(&fpga_driver
);
1496 static void __exit
solos_pci_exit(void)
1498 pci_unregister_driver(&fpga_driver
);
1499 printk(KERN_INFO
"Solos PCI Driver %s Unloaded\n", VERSION
);
1502 module_init(solos_pci_init
);
1503 module_exit(solos_pci_exit
);