aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/atm/solos-pci.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/atm/solos-pci.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/atm/solos-pci.c')
-rw-r--r--drivers/atm/solos-pci.c284
1 files changed, 73 insertions, 211 deletions
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 0474a89170b..5d1d0764513 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -42,8 +42,7 @@
42#include <linux/swab.h> 42#include <linux/swab.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44 44
45#define VERSION "1.04" 45#define VERSION "0.07"
46#define DRIVER_VERSION 0x01
47#define PTAG "solos-pci" 46#define PTAG "solos-pci"
48 47
49#define CONFIG_RAM_SIZE 128 48#define CONFIG_RAM_SIZE 128
@@ -57,21 +56,16 @@
57#define FLASH_BUSY 0x60 56#define FLASH_BUSY 0x60
58#define FPGA_MODE 0x5C 57#define FPGA_MODE 0x5C
59#define FLASH_MODE 0x58 58#define FLASH_MODE 0x58
60#define GPIO_STATUS 0x54
61#define DRIVER_VER 0x50
62#define TX_DMA_ADDR(port) (0x40 + (4 * (port))) 59#define TX_DMA_ADDR(port) (0x40 + (4 * (port)))
63#define RX_DMA_ADDR(port) (0x30 + (4 * (port))) 60#define RX_DMA_ADDR(port) (0x30 + (4 * (port)))
64 61
65#define DATA_RAM_SIZE 32768 62#define DATA_RAM_SIZE 32768
66#define BUF_SIZE 2048 63#define BUF_SIZE 2048
67#define OLD_BUF_SIZE 4096 /* For FPGA versions <= 2*/ 64#define OLD_BUF_SIZE 4096 /* For FPGA versions <= 2*/
68/* Old boards use ATMEL AD45DB161D flash */ 65#define FPGA_PAGE 528 /* FPGA flash page size*/
69#define ATMEL_FPGA_PAGE 528 /* FPGA flash page size*/ 66#define SOLOS_PAGE 512 /* Solos flash page size*/
70#define ATMEL_SOLOS_PAGE 512 /* Solos flash page size*/ 67#define FPGA_BLOCK (FPGA_PAGE * 8) /* FPGA flash block size*/
71#define ATMEL_FPGA_BLOCK (ATMEL_FPGA_PAGE * 8) /* FPGA block size*/ 68#define SOLOS_BLOCK (SOLOS_PAGE * 8) /* Solos flash 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)
75 69
76#define RX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2) 70#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)) 71#define TX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2 + (card->buffer_size))
@@ -128,14 +122,11 @@ struct solos_card {
128 struct sk_buff_head cli_queue[4]; 122 struct sk_buff_head cli_queue[4];
129 struct sk_buff *tx_skb[4]; 123 struct sk_buff *tx_skb[4];
130 struct sk_buff *rx_skb[4]; 124 struct sk_buff *rx_skb[4];
131 unsigned char *dma_bounce;
132 wait_queue_head_t param_wq; 125 wait_queue_head_t param_wq;
133 wait_queue_head_t fw_wq; 126 wait_queue_head_t fw_wq;
134 int using_dma; 127 int using_dma;
135 int dma_alignment;
136 int fpga_version; 128 int fpga_version;
137 int buffer_size; 129 int buffer_size;
138 int atmel_flash;
139}; 130};
140 131
141 132
@@ -173,6 +164,7 @@ static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb,
173static uint32_t fpga_tx(struct solos_card *); 164static uint32_t fpga_tx(struct solos_card *);
174static irqreturn_t solos_irq(int irq, void *dev_id); 165static irqreturn_t solos_irq(int irq, void *dev_id);
175static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci); 166static struct atm_vcc* find_vcc(struct atm_dev *dev, short vpi, int vci);
167static int list_vccs(int vci);
176static int atm_init(struct solos_card *, struct device *); 168static int atm_init(struct solos_card *, struct device *);
177static void atm_remove(struct solos_card *); 169static void atm_remove(struct solos_card *);
178static int send_command(struct solos_card *card, int dev, const char *buf, size_t size); 170static int send_command(struct solos_card *card, int dev, const char *buf, size_t size);
@@ -460,6 +452,7 @@ static ssize_t console_show(struct device *dev, struct device_attribute *attr,
460 452
461 len = skb->len; 453 len = skb->len;
462 memcpy(buf, skb->data, len); 454 memcpy(buf, skb->data, len);
455 dev_dbg(&card->dev->dev, "len: %d\n", len);
463 456
464 kfree_skb(skb); 457 kfree_skb(skb);
465 return len; 458 return len;
@@ -506,78 +499,6 @@ static ssize_t console_store(struct device *dev, struct device_attribute *attr,
506 return err?:count; 499 return err?:count;
507} 500}
508 501
509struct geos_gpio_attr {
510 struct device_attribute attr;
511 int offset;
512};
513
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), \
517 .offset = _offset }
518
519static ssize_t geos_gpio_store(struct device *dev, struct device_attribute *attr,
520 const char *buf, size_t count)
521{
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);
525 uint32_t data32;
526
527 if (count != 1 && (count != 2 || buf[1] != '\n'))
528 return -EINVAL;
529
530 spin_lock_irq(&card->param_queue_lock);
531 data32 = ioread32(card->config_regs + GPIO_STATUS);
532 if (buf[0] == '1') {
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);
538 } else {
539 count = -EINVAL;
540 }
541 spin_unlock_irq(&card->param_queue_lock);
542 return count;
543}
544
545static ssize_t geos_gpio_show(struct device *dev, struct device_attribute *attr,
546 char *buf)
547{
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);
551 uint32_t data32;
552
553 data32 = ioread32(card->config_regs + GPIO_STATUS);
554 data32 = (data32 >> gattr->offset) & 1;
555
556 return sprintf(buf, "%d\n", data32);
557}
558
559static ssize_t hardware_show(struct device *dev, struct device_attribute *attr,
560 char *buf)
561{
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);
565 uint32_t data32;
566
567 data32 = ioread32(card->config_regs + GPIO_STATUS);
568 switch (gattr->offset) {
569 case 0:
570 /* HardwareVersion */
571 data32 = data32 & 0x1F;
572 break;
573 case 1:
574 /* HardwareVariant */
575 data32 = (data32 >> 5) & 0x0F;
576 break;
577 }
578 return sprintf(buf, "%d\n", data32);
579}
580
581static DEVICE_ATTR(console, 0644, console_show, console_store); 502static DEVICE_ATTR(console, 0644, console_show, console_store);
582 503
583 504
@@ -586,14 +507,6 @@ static DEVICE_ATTR(console, 0644, console_show, console_store);
586 507
587#include "solos-attrlist.c" 508#include "solos-attrlist.c"
588 509
589static SOLOS_GPIO_ATTR(GPIO1, 0644, geos_gpio_show, geos_gpio_store, 9);
590static SOLOS_GPIO_ATTR(GPIO2, 0644, geos_gpio_show, geos_gpio_store, 10);
591static SOLOS_GPIO_ATTR(GPIO3, 0644, geos_gpio_show, geos_gpio_store, 11);
592static SOLOS_GPIO_ATTR(GPIO4, 0644, geos_gpio_show, geos_gpio_store, 12);
593static SOLOS_GPIO_ATTR(GPIO5, 0644, geos_gpio_show, geos_gpio_store, 13);
594static SOLOS_GPIO_ATTR(PushButton, 0444, geos_gpio_show, NULL, 14);
595static SOLOS_GPIO_ATTR(HardwareVersion, 0444, hardware_show, NULL, 0);
596static SOLOS_GPIO_ATTR(HardwareVariant, 0444, hardware_show, NULL, 1);
597#undef SOLOS_ATTR_RO 510#undef SOLOS_ATTR_RO
598#undef SOLOS_ATTR_RW 511#undef SOLOS_ATTR_RW
599 512
@@ -610,23 +523,6 @@ static struct attribute_group solos_attr_group = {
610 .name = "parameters", 523 .name = "parameters",
611}; 524};
612 525
613static 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,
622 NULL
623};
624
625static struct attribute_group gpio_attr_group = {
626 .attrs = gpio_attrs,
627 .name = "gpio",
628};
629
630static int flash_upgrade(struct solos_card *card, int chip) 526static int flash_upgrade(struct solos_card *card, int chip)
631{ 527{
632 const struct firmware *fw; 528 const struct firmware *fw;
@@ -638,25 +534,16 @@ static int flash_upgrade(struct solos_card *card, int chip)
638 switch (chip) { 534 switch (chip) {
639 case 0: 535 case 0:
640 fw_name = "solos-FPGA.bin"; 536 fw_name = "solos-FPGA.bin";
641 if (card->atmel_flash) 537 blocksize = FPGA_BLOCK;
642 blocksize = ATMEL_FPGA_BLOCK;
643 else
644 blocksize = SPI_FLASH_BLOCK;
645 break; 538 break;
646 case 1: 539 case 1:
647 fw_name = "solos-Firmware.bin"; 540 fw_name = "solos-Firmware.bin";
648 if (card->atmel_flash) 541 blocksize = SOLOS_BLOCK;
649 blocksize = ATMEL_SOLOS_BLOCK;
650 else
651 blocksize = SPI_FLASH_BLOCK;
652 break; 542 break;
653 case 2: 543 case 2:
654 if (card->fpga_version > LEGACY_BUFFERS){ 544 if (card->fpga_version > LEGACY_BUFFERS){
655 fw_name = "solos-db-FPGA.bin"; 545 fw_name = "solos-db-FPGA.bin";
656 if (card->atmel_flash) 546 blocksize = FPGA_BLOCK;
657 blocksize = ATMEL_FPGA_BLOCK;
658 else
659 blocksize = SPI_FLASH_BLOCK;
660 } else { 547 } else {
661 dev_info(&card->dev->dev, "FPGA version doesn't support" 548 dev_info(&card->dev->dev, "FPGA version doesn't support"
662 " daughter board upgrades\n"); 549 " daughter board upgrades\n");
@@ -666,10 +553,7 @@ static int flash_upgrade(struct solos_card *card, int chip)
666 case 3: 553 case 3:
667 if (card->fpga_version > LEGACY_BUFFERS){ 554 if (card->fpga_version > LEGACY_BUFFERS){
668 fw_name = "solos-Firmware.bin"; 555 fw_name = "solos-Firmware.bin";
669 if (card->atmel_flash) 556 blocksize = SOLOS_BLOCK;
670 blocksize = ATMEL_SOLOS_BLOCK;
671 else
672 blocksize = SPI_FLASH_BLOCK;
673 } else { 557 } else {
674 dev_info(&card->dev->dev, "FPGA version doesn't support" 558 dev_info(&card->dev->dev, "FPGA version doesn't support"
675 " daughter board upgrades\n"); 559 " daughter board upgrades\n");
@@ -685,9 +569,6 @@ static int flash_upgrade(struct solos_card *card, int chip)
685 569
686 dev_info(&card->dev->dev, "Flash upgrade starting\n"); 570 dev_info(&card->dev->dev, "Flash upgrade starting\n");
687 571
688 /* New FPGAs require driver version before permitting flash upgrades */
689 iowrite32(DRIVER_VERSION, card->config_regs + DRIVER_VER);
690
691 numblocks = fw->size / blocksize; 572 numblocks = fw->size / blocksize;
692 dev_info(&card->dev->dev, "Firmware size: %zd\n", fw->size); 573 dev_info(&card->dev->dev, "Firmware size: %zd\n", fw->size);
693 dev_info(&card->dev->dev, "Number of blocks: %d\n", numblocks); 574 dev_info(&card->dev->dev, "Number of blocks: %d\n", numblocks);
@@ -717,13 +598,9 @@ static int flash_upgrade(struct solos_card *card, int chip)
717 /* dev_info(&card->dev->dev, "Set FPGA Flash mode to Block Write\n"); */ 598 /* dev_info(&card->dev->dev, "Set FPGA Flash mode to Block Write\n"); */
718 iowrite32(((chip * 2) + 1), card->config_regs + FLASH_MODE); 599 iowrite32(((chip * 2) + 1), card->config_regs + FLASH_MODE);
719 600
720 /* Copy block to buffer, swapping each 16 bits for Atmel flash */ 601 /* Copy block to buffer, swapping each 16 bits */
721 for(i = 0; i < blocksize; i += 4) { 602 for(i = 0; i < blocksize; i += 4) {
722 uint32_t word; 603 uint32_t word = swahb32p((uint32_t *)(fw->data + offset + i));
723 if (card->atmel_flash)
724 word = swahb32p((uint32_t *)(fw->data + offset + i));
725 else
726 word = *(uint32_t *)(fw->data + offset + i);
727 if(card->fpga_version > LEGACY_BUFFERS) 604 if(card->fpga_version > LEGACY_BUFFERS)
728 iowrite32(word, FLASH_BUF + i); 605 iowrite32(word, FLASH_BUF + i);
729 else 606 else
@@ -833,8 +710,7 @@ void solos_bh(unsigned long card_arg)
833 dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n", 710 dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n",
834 le16_to_cpu(header->vpi), le16_to_cpu(header->vci), 711 le16_to_cpu(header->vpi), le16_to_cpu(header->vci),
835 port); 712 port);
836 dev_kfree_skb_any(skb); 713 continue;
837 break;
838 } 714 }
839 atm_charge(vcc, skb->truesize); 715 atm_charge(vcc, skb->truesize);
840 vcc->push(vcc, skb); 716 vcc->push(vcc, skb);
@@ -914,6 +790,44 @@ static struct atm_vcc *find_vcc(struct atm_dev *dev, short vpi, int vci)
914 return vcc; 790 return vcc;
915} 791}
916 792
793static int list_vccs(int vci)
794{
795 struct hlist_head *head;
796 struct atm_vcc *vcc;
797 struct hlist_node *node;
798 struct sock *s;
799 int num_found = 0;
800 int i;
801
802 read_lock(&vcc_sklist_lock);
803 if (vci != 0){
804 head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)];
805 sk_for_each(s, node, head) {
806 num_found ++;
807 vcc = atm_sk(s);
808 printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n",
809 vcc->dev->number,
810 vcc->vpi,
811 vcc->vci);
812 }
813 } else {
814 for(i = 0; i < VCC_HTABLE_SIZE; i++){
815 head = &vcc_hash[i];
816 sk_for_each(s, node, head) {
817 num_found ++;
818 vcc = atm_sk(s);
819 printk(KERN_DEBUG "Device: %d Vpi: %d Vci: %d\n",
820 vcc->dev->number,
821 vcc->vpi,
822 vcc->vci);
823 }
824 }
825 }
826 read_unlock(&vcc_sklist_lock);
827 return num_found;
828}
829
830
917static int popen(struct atm_vcc *vcc) 831static int popen(struct atm_vcc *vcc)
918{ 832{
919 struct solos_card *card = vcc->dev->dev_data; 833 struct solos_card *card = vcc->dev->dev_data;
@@ -926,7 +840,7 @@ static int popen(struct atm_vcc *vcc)
926 return -EINVAL; 840 return -EINVAL;
927 } 841 }
928 842
929 skb = alloc_skb(sizeof(*header), GFP_KERNEL); 843 skb = alloc_skb(sizeof(*header), GFP_ATOMIC);
930 if (!skb) { 844 if (!skb) {
931 if (net_ratelimit()) 845 if (net_ratelimit())
932 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n"); 846 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n");
@@ -943,6 +857,8 @@ static int popen(struct atm_vcc *vcc)
943 857
944 set_bit(ATM_VF_ADDR, &vcc->flags); 858 set_bit(ATM_VF_ADDR, &vcc->flags);
945 set_bit(ATM_VF_READY, &vcc->flags); 859 set_bit(ATM_VF_READY, &vcc->flags);
860 list_vccs(0);
861
946 862
947 return 0; 863 return 0;
948} 864}
@@ -950,21 +866,10 @@ static int popen(struct atm_vcc *vcc)
950static void pclose(struct atm_vcc *vcc) 866static void pclose(struct atm_vcc *vcc)
951{ 867{
952 struct solos_card *card = vcc->dev->dev_data; 868 struct solos_card *card = vcc->dev->dev_data;
953 unsigned char port = SOLOS_CHAN(vcc->dev); 869 struct sk_buff *skb;
954 struct sk_buff *skb, *tmpskb;
955 struct pkt_hdr *header; 870 struct pkt_hdr *header;
956 871
957 /* Remove any yet-to-be-transmitted packets from the pending queue */ 872 skb = alloc_skb(sizeof(*header), GFP_ATOMIC);
958 spin_lock(&card->tx_queue_lock);
959 skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) {
960 if (SKB_CB(skb)->vcc == vcc) {
961 skb_unlink(skb, &card->tx_queue[port]);
962 solos_pop(vcc, skb);
963 }
964 }
965 spin_unlock(&card->tx_queue_lock);
966
967 skb = alloc_skb(sizeof(*header), GFP_KERNEL);
968 if (!skb) { 873 if (!skb) {
969 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n"); 874 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n");
970 return; 875 return;
@@ -976,22 +881,15 @@ static void pclose(struct atm_vcc *vcc)
976 header->vci = cpu_to_le16(vcc->vci); 881 header->vci = cpu_to_le16(vcc->vci);
977 header->type = cpu_to_le16(PKT_PCLOSE); 882 header->type = cpu_to_le16(PKT_PCLOSE);
978 883
979 skb_get(skb); 884 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL);
980 fpga_queue(card, port, skb, NULL);
981
982 if (!wait_event_timeout(card->param_wq, !skb_shared(skb), 5 * HZ))
983 dev_warn(&card->dev->dev,
984 "Timeout waiting for VCC close on port %d\n", port);
985 885
986 dev_kfree_skb(skb); 886 clear_bit(ATM_VF_ADDR, &vcc->flags);
887 clear_bit(ATM_VF_READY, &vcc->flags);
987 888
988 /* Hold up vcc_destroy_socket() (our caller) until solos_bh() in the 889 /* Hold up vcc_destroy_socket() (our caller) until solos_bh() in the
989 tasklet has finished processing any incoming packets (and, more to 890 tasklet has finished processing any incoming packets (and, more to
990 the point, using the vcc pointer). */ 891 the point, using the vcc pointer). */
991 tasklet_unlock_wait(&card->tlet); 892 tasklet_unlock_wait(&card->tlet);
992
993 clear_bit(ATM_VF_ADDR, &vcc->flags);
994
995 return; 893 return;
996} 894}
997 895
@@ -1069,11 +967,10 @@ static uint32_t fpga_tx(struct solos_card *card)
1069 for (port = 0; tx_pending; tx_pending >>= 1, port++) { 967 for (port = 0; tx_pending; tx_pending >>= 1, port++) {
1070 if (tx_pending & 1) { 968 if (tx_pending & 1) {
1071 struct sk_buff *oldskb = card->tx_skb[port]; 969 struct sk_buff *oldskb = card->tx_skb[port];
1072 if (oldskb) { 970 if (oldskb)
1073 pci_unmap_single(card->dev, SKB_CB(oldskb)->dma_addr, 971 pci_unmap_single(card->dev, SKB_CB(oldskb)->dma_addr,
1074 oldskb->len, PCI_DMA_TODEVICE); 972 oldskb->len, PCI_DMA_TODEVICE);
1075 card->tx_skb[port] = NULL; 973
1076 }
1077 spin_lock(&card->tx_queue_lock); 974 spin_lock(&card->tx_queue_lock);
1078 skb = skb_dequeue(&card->tx_queue[port]); 975 skb = skb_dequeue(&card->tx_queue[port]);
1079 if (!skb) 976 if (!skb)
@@ -1085,14 +982,8 @@ static uint32_t fpga_tx(struct solos_card *card)
1085 tx_started |= 1 << port; 982 tx_started |= 1 << port;
1086 oldskb = skb; /* We're done with this skb already */ 983 oldskb = skb; /* We're done with this skb already */
1087 } else if (skb && card->using_dma) { 984 } else if (skb && card->using_dma) {
1088 unsigned char *data = skb->data; 985 SKB_CB(skb)->dma_addr = pci_map_single(card->dev, skb->data,
1089 if ((unsigned long)data & card->dma_alignment) {
1090 data = card->dma_bounce + (BUF_SIZE * port);
1091 memcpy(data, skb->data, skb->len);
1092 }
1093 SKB_CB(skb)->dma_addr = pci_map_single(card->dev, data,
1094 skb->len, PCI_DMA_TODEVICE); 986 skb->len, PCI_DMA_TODEVICE);
1095 card->tx_skb[port] = skb;
1096 iowrite32(SKB_CB(skb)->dma_addr, 987 iowrite32(SKB_CB(skb)->dma_addr,
1097 card->config_regs + TX_DMA_ADDR(port)); 988 card->config_regs + TX_DMA_ADDR(port));
1098 } 989 }
@@ -1119,10 +1010,9 @@ static uint32_t fpga_tx(struct solos_card *card)
1119 if (vcc) { 1010 if (vcc) {
1120 atomic_inc(&vcc->stats->tx); 1011 atomic_inc(&vcc->stats->tx);
1121 solos_pop(vcc, oldskb); 1012 solos_pop(vcc, oldskb);
1122 } else { 1013 } else
1123 dev_kfree_skb_irq(oldskb); 1014 dev_kfree_skb_irq(oldskb);
1124 wake_up(&card->param_wq); 1015
1125 }
1126 } 1016 }
1127 } 1017 }
1128 /* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */ 1018 /* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */
@@ -1262,33 +1152,17 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1262 db_fpga_upgrade = db_firmware_upgrade = 0; 1152 db_fpga_upgrade = db_firmware_upgrade = 0;
1263 } 1153 }
1264 1154
1265 /* Stopped using Atmel flash after 0.03-38 */ 1155 if (card->fpga_version >= DMA_SUPPORTED){
1266 if (fpga_ver < 39)
1267 card->atmel_flash = 1;
1268 else
1269 card->atmel_flash = 0;
1270
1271 data32 = ioread32(card->config_regs + PORTS);
1272 card->nr_ports = (data32 & 0x000000FF);
1273
1274 if (card->fpga_version >= DMA_SUPPORTED) {
1275 pci_set_master(dev);
1276 card->using_dma = 1; 1156 card->using_dma = 1;
1277 if (1) { /* All known FPGA versions so far */
1278 card->dma_alignment = 3;
1279 card->dma_bounce = kmalloc(card->nr_ports * BUF_SIZE, GFP_KERNEL);
1280 if (!card->dma_bounce) {
1281 dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n");
1282 /* Fallback to MMIO doesn't work */
1283 goto out_unmap_both;
1284 }
1285 }
1286 } else { 1157 } else {
1287 card->using_dma = 0; 1158 card->using_dma = 0;
1288 /* Set RX empty flag for all ports */ 1159 /* Set RX empty flag for all ports */
1289 iowrite32(0xF0, card->config_regs + FLAGS_ADDR); 1160 iowrite32(0xF0, card->config_regs + FLAGS_ADDR);
1290 } 1161 }
1291 1162
1163 data32 = ioread32(card->config_regs + PORTS);
1164 card->nr_ports = (data32 & 0x000000FF);
1165
1292 pci_set_drvdata(dev, card); 1166 pci_set_drvdata(dev, card);
1293 1167
1294 tasklet_init(&card->tlet, solos_bh, (unsigned long)card); 1168 tasklet_init(&card->tlet, solos_bh, (unsigned long)card);
@@ -1323,10 +1197,6 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1323 if (err) 1197 if (err)
1324 goto out_free_irq; 1198 goto out_free_irq;
1325 1199
1326 if (card->fpga_version >= DMA_SUPPORTED &&
1327 sysfs_create_group(&card->dev->dev.kobj, &gpio_attr_group))
1328 dev_err(&card->dev->dev, "Could not register parameter group for GPIOs\n");
1329
1330 return 0; 1200 return 0;
1331 1201
1332 out_free_irq: 1202 out_free_irq:
@@ -1335,11 +1205,10 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1335 tasklet_kill(&card->tlet); 1205 tasklet_kill(&card->tlet);
1336 1206
1337 out_unmap_both: 1207 out_unmap_both:
1338 kfree(card->dma_bounce);
1339 pci_set_drvdata(dev, NULL); 1208 pci_set_drvdata(dev, NULL);
1340 pci_iounmap(dev, card->buffers);
1341 out_unmap_config:
1342 pci_iounmap(dev, card->config_regs); 1209 pci_iounmap(dev, card->config_regs);
1210 out_unmap_config:
1211 pci_iounmap(dev, card->buffers);
1343 out_release_regions: 1212 out_release_regions:
1344 pci_release_regions(dev); 1213 pci_release_regions(dev);
1345 out: 1214 out:
@@ -1377,7 +1246,7 @@ static int atm_init(struct solos_card *card, struct device *parent)
1377 card->atmdev[i]->phy_data = (void *)(unsigned long)i; 1246 card->atmdev[i]->phy_data = (void *)(unsigned long)i;
1378 atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND); 1247 atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND);
1379 1248
1380 skb = alloc_skb(sizeof(*header), GFP_KERNEL); 1249 skb = alloc_skb(sizeof(*header), GFP_ATOMIC);
1381 if (!skb) { 1250 if (!skb) {
1382 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n"); 1251 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n");
1383 continue; 1252 continue;
@@ -1438,16 +1307,11 @@ static void fpga_remove(struct pci_dev *dev)
1438 iowrite32(1, card->config_regs + FPGA_MODE); 1307 iowrite32(1, card->config_regs + FPGA_MODE);
1439 (void)ioread32(card->config_regs + FPGA_MODE); 1308 (void)ioread32(card->config_regs + FPGA_MODE);
1440 1309
1441 if (card->fpga_version >= DMA_SUPPORTED)
1442 sysfs_remove_group(&card->dev->dev.kobj, &gpio_attr_group);
1443
1444 atm_remove(card); 1310 atm_remove(card);
1445 1311
1446 free_irq(dev->irq, card); 1312 free_irq(dev->irq, card);
1447 tasklet_kill(&card->tlet); 1313 tasklet_kill(&card->tlet);
1448 1314
1449 kfree(card->dma_bounce);
1450
1451 /* Release device from reset */ 1315 /* Release device from reset */
1452 iowrite32(0, card->config_regs + FPGA_MODE); 1316 iowrite32(0, card->config_regs + FPGA_MODE);
1453 (void)ioread32(card->config_regs + FPGA_MODE); 1317 (void)ioread32(card->config_regs + FPGA_MODE);
@@ -1462,7 +1326,7 @@ static void fpga_remove(struct pci_dev *dev)
1462 kfree(card); 1326 kfree(card);
1463} 1327}
1464 1328
1465static struct pci_device_id fpga_pci_tbl[] = { 1329static struct pci_device_id fpga_pci_tbl[] __devinitdata = {
1466 { 0x10ee, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 1330 { 0x10ee, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
1467 { 0, } 1331 { 0, }
1468}; 1332};
@@ -1479,8 +1343,6 @@ static struct pci_driver fpga_driver = {
1479 1343
1480static int __init solos_pci_init(void) 1344static int __init solos_pci_init(void)
1481{ 1345{
1482 BUILD_BUG_ON(sizeof(struct solos_skb_cb) > sizeof(((struct sk_buff *)0)->cb));
1483
1484 printk(KERN_INFO "Solos PCI Driver Version %s\n", VERSION); 1346 printk(KERN_INFO "Solos PCI Driver Version %s\n", VERSION);
1485 return pci_register_driver(&fpga_driver); 1347 return pci_register_driver(&fpga_driver);
1486} 1348}