Lines Matching +full:ports +full:- +full:block +full:- +full:group +full:- +full:count
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Traverse Technologies -- https://www.traverse.com.au/
5 * Xrio Limited -- http://www.xrio.com/
38 #define PTAG "solos-pci"
46 #define PORTS 0x68 macro
62 #define ATMEL_FPGA_BLOCK (ATMEL_FPGA_PAGE * 8) /* FPGA block size*/
63 #define ATMEL_SOLOS_BLOCK (ATMEL_SOLOS_PAGE * 8) /* Solos block size*/
67 #define RX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2)
68 #define TX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2 + (card->buffer_size))
69 #define FLASH_BUF ((card->buffers) + 4*(card->buffer_size)*2)
97 #define SKB_CB(skb) ((struct solos_skb_cb *)skb->cb)
140 #define SOLOS_CHAN(atmdev) ((int)(unsigned long)(atmdev)->phy_data)
146 MODULE_FIRMWARE("solos-FPGA.bin");
147 MODULE_FIRMWARE("solos-Firmware.bin");
148 MODULE_FIRMWARE("solos-db-FPGA.bin");
175 if (vcc->pop) in solos_pop()
176 vcc->pop(vcc, skb); in solos_pop()
185 struct solos_card *card = atmdev->dev_data; in solos_param_show()
191 buflen = strlen(attr->attr.name) + 10; in solos_param_show()
195 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in solos_param_show()\n"); in solos_param_show()
196 return -ENOMEM; in solos_param_show()
201 buflen = snprintf((void *)&header[1], buflen - 1, in solos_param_show()
202 "L%05d\n%s\n", current->pid, attr->attr.name); in solos_param_show()
205 header->size = cpu_to_le16(buflen); in solos_param_show()
206 header->vpi = cpu_to_le16(0); in solos_param_show()
207 header->vci = cpu_to_le16(0); in solos_param_show()
208 header->type = cpu_to_le16(PKT_COMMAND); in solos_param_show()
210 prm.pid = current->pid; in solos_param_show()
214 spin_lock_irq(&card->param_queue_lock); in solos_param_show()
215 list_add(&prm.list, &card->param_queue); in solos_param_show()
216 spin_unlock_irq(&card->param_queue_lock); in solos_param_show()
220 wait_event_timeout(card->param_wq, prm.response, 5 * HZ); in solos_param_show()
222 spin_lock_irq(&card->param_queue_lock); in solos_param_show()
224 spin_unlock_irq(&card->param_queue_lock); in solos_param_show()
227 return -EIO; in solos_param_show()
229 buflen = prm.response->len; in solos_param_show()
230 memcpy(buf, prm.response->data, buflen); in solos_param_show()
237 const char *buf, size_t count) in solos_param_store() argument
240 struct solos_card *card = atmdev->dev_data; in solos_param_store()
247 buflen = strlen(attr->attr.name) + 11 + count; in solos_param_store()
251 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in solos_param_store()\n"); in solos_param_store()
252 return -ENOMEM; in solos_param_store()
257 buflen = snprintf((void *)&header[1], buflen - 1, in solos_param_store()
258 "L%05d\n%s\n%s\n", current->pid, attr->attr.name, buf); in solos_param_store()
261 header->size = cpu_to_le16(buflen); in solos_param_store()
262 header->vpi = cpu_to_le16(0); in solos_param_store()
263 header->vci = cpu_to_le16(0); in solos_param_store()
264 header->type = cpu_to_le16(PKT_COMMAND); in solos_param_store()
266 prm.pid = current->pid; in solos_param_store()
270 spin_lock_irq(&card->param_queue_lock); in solos_param_store()
271 list_add(&prm.list, &card->param_queue); in solos_param_store()
272 spin_unlock_irq(&card->param_queue_lock); in solos_param_store()
276 wait_event_timeout(card->param_wq, prm.response, 5 * HZ); in solos_param_store()
278 spin_lock_irq(&card->param_queue_lock); in solos_param_store()
280 spin_unlock_irq(&card->param_queue_lock); in solos_param_store()
285 return -EIO; in solos_param_store()
287 buflen = skb->len; in solos_param_store()
290 if (skb->data[buflen - 1] == '\n') in solos_param_store()
291 buflen--; in solos_param_store()
293 if (buflen == 2 && !strncmp(skb->data, "OK", 2)) in solos_param_store()
294 ret = count; in solos_param_store()
295 else if (buflen == 5 && !strncmp(skb->data, "ERROR", 5)) in solos_param_store()
296 ret = -EIO; in solos_param_store()
300 skb->data[buflen] = 0; in solos_param_store()
302 dev_warn(&card->dev->dev, "Unexpected parameter response: '%s'\n", in solos_param_store()
303 skb->data); in solos_param_store()
304 ret = -EIO; in solos_param_store()
314 char *this = skb->data; in next_string()
316 for (i = 0; i < skb->len; i++) { in next_string()
344 if (!card->atmdev[port]) in process_status()
345 return -ENODEV; in process_status()
349 return -EIO; in process_status()
353 dev_warn(&card->dev->dev, "Unexpected status interrupt version\n"); in process_status()
357 dev_warn(&card->dev->dev, "Unexpected status interrupt version %d\n", in process_status()
359 return -EIO; in process_status()
364 return -EIO; in process_status()
366 dev_dbg(&card->dev->dev, "Status packet indicated Solos error on port %d (starting up?)\n", in process_status()
377 return -EIO; in process_status()
384 return -EIO; in process_status()
388 atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_LOST); in process_status()
389 dev_info(&card->dev->dev, "Port %d: %s\n", port, state_str); in process_status()
395 return -EIO; in process_status()
398 return -EIO; in process_status()
400 dev_info(&card->dev->dev, "Port %d: %s @%d/%d kb/s%s%s%s%s\n", in process_status()
404 card->atmdev[port]->link_rate = rate_down / 424; in process_status()
405 atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_FOUND); in process_status()
417 if (skb->len < 7) in process_command()
420 if (skb->data[0] != 'L' || !isdigit(skb->data[1]) || in process_command()
421 !isdigit(skb->data[2]) || !isdigit(skb->data[3]) || in process_command()
422 !isdigit(skb->data[4]) || !isdigit(skb->data[5]) || in process_command()
423 skb->data[6] != '\n') in process_command()
426 err = kstrtoint(&skb->data[1], 10, &cmdpid); in process_command()
430 spin_lock_irqsave(&card->param_queue_lock, flags); in process_command()
431 list_for_each_entry(prm, &card->param_queue, list) { in process_command()
432 if (prm->port == port && prm->pid == cmdpid) { in process_command()
433 prm->response = skb; in process_command()
435 wake_up(&card->param_wq); in process_command()
440 spin_unlock_irqrestore(&card->param_queue_lock, flags); in process_command()
448 struct solos_card *card = atmdev->dev_data; in console_show()
452 spin_lock_bh(&card->cli_queue_lock); in console_show()
453 skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]); in console_show()
454 spin_unlock_bh(&card->cli_queue_lock); in console_show()
458 len = skb->len; in console_show()
459 memcpy(buf, skb->data, len); in console_show()
470 if (size > (BUF_SIZE - sizeof(*header))) { in send_command()
471 dev_dbg(&card->dev->dev, "Command is too big. Dropping request\n"); in send_command()
476 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in send_command()\n"); in send_command()
482 header->size = cpu_to_le16(size); in send_command()
483 header->vpi = cpu_to_le16(0); in send_command()
484 header->vci = cpu_to_le16(0); in send_command()
485 header->type = cpu_to_le16(PKT_COMMAND); in send_command()
495 const char *buf, size_t count) in console_store() argument
498 struct solos_card *card = atmdev->dev_data; in console_store()
501 err = send_command(card, SOLOS_CHAN(atmdev), buf, count); in console_store()
503 return err?:count; in console_store()
517 const char *buf, size_t count) in geos_gpio_store() argument
523 if (count != 1 && (count != 2 || buf[1] != '\n')) in geos_gpio_store()
524 return -EINVAL; in geos_gpio_store()
526 spin_lock_irq(&card->param_queue_lock); in geos_gpio_store()
527 data32 = ioread32(card->config_regs + GPIO_STATUS); in geos_gpio_store()
529 data32 |= 1 << gattr->offset; in geos_gpio_store()
530 iowrite32(data32, card->config_regs + GPIO_STATUS); in geos_gpio_store()
532 data32 &= ~(1 << gattr->offset); in geos_gpio_store()
533 iowrite32(data32, card->config_regs + GPIO_STATUS); in geos_gpio_store()
535 count = -EINVAL; in geos_gpio_store()
537 spin_unlock_irq(&card->param_queue_lock); in geos_gpio_store()
538 return count; in geos_gpio_store()
548 data32 = ioread32(card->config_regs + GPIO_STATUS); in geos_gpio_show()
549 data32 = (data32 >> gattr->offset) & 1; in geos_gpio_show()
561 data32 = ioread32(card->config_regs + GPIO_STATUS); in hardware_show()
562 switch (gattr->offset) { in hardware_show()
581 #include "solos-attrlist.c"
598 #include "solos-attrlist.c"
634 fw_name = "solos-FPGA.bin"; in flash_upgrade()
635 if (card->atmel_flash) in flash_upgrade()
641 fw_name = "solos-Firmware.bin"; in flash_upgrade()
642 if (card->atmel_flash) in flash_upgrade()
648 if (card->fpga_version > LEGACY_BUFFERS){ in flash_upgrade()
649 fw_name = "solos-db-FPGA.bin"; in flash_upgrade()
650 if (card->atmel_flash) in flash_upgrade()
655 dev_info(&card->dev->dev, "FPGA version doesn't support" in flash_upgrade()
657 return -EPERM; in flash_upgrade()
661 if (card->fpga_version > LEGACY_BUFFERS){ in flash_upgrade()
662 fw_name = "solos-Firmware.bin"; in flash_upgrade()
663 if (card->atmel_flash) in flash_upgrade()
668 dev_info(&card->dev->dev, "FPGA version doesn't support" in flash_upgrade()
670 return -EPERM; in flash_upgrade()
674 return -ENODEV; in flash_upgrade()
677 if (request_firmware(&fw, fw_name, &card->dev->dev)) in flash_upgrade()
678 return -ENOENT; in flash_upgrade()
680 dev_info(&card->dev->dev, "Flash upgrade starting\n"); in flash_upgrade()
683 iowrite32(DRIVER_VERSION, card->config_regs + DRIVER_VER); in flash_upgrade()
685 numblocks = fw->size / blocksize; in flash_upgrade()
686 dev_info(&card->dev->dev, "Firmware size: %zd\n", fw->size); in flash_upgrade()
687 dev_info(&card->dev->dev, "Number of blocks: %d\n", numblocks); in flash_upgrade()
689 dev_info(&card->dev->dev, "Changing FPGA to Update mode\n"); in flash_upgrade()
690 iowrite32(1, card->config_regs + FPGA_MODE); in flash_upgrade()
691 (void) ioread32(card->config_regs + FPGA_MODE); in flash_upgrade()
695 dev_info(&card->dev->dev, "Set FPGA Flash mode to FPGA Chip Erase\n"); in flash_upgrade()
697 dev_info(&card->dev->dev, "Set FPGA Flash mode to Solos Chip Erase\n"); in flash_upgrade()
698 iowrite32((chip * 2), card->config_regs + FLASH_MODE); in flash_upgrade()
701 iowrite32(1, card->config_regs + WRITE_FLASH); in flash_upgrade()
702 wait_event(card->fw_wq, !ioread32(card->config_regs + FLASH_BUSY)); in flash_upgrade()
704 for (offset = 0; offset < fw->size; offset += blocksize) { in flash_upgrade()
708 iowrite32(0, card->config_regs + WRITE_FLASH); in flash_upgrade()
710 /* Set mode to Block Write */ in flash_upgrade()
711 /* dev_info(&card->dev->dev, "Set FPGA Flash mode to Block Write\n"); */ in flash_upgrade()
712 iowrite32(((chip * 2) + 1), card->config_regs + FLASH_MODE); in flash_upgrade()
714 /* Copy block to buffer, swapping each 16 bits for Atmel flash */ in flash_upgrade()
717 if (card->atmel_flash) in flash_upgrade()
718 word = swahb32p((uint32_t *)(fw->data + offset + i)); in flash_upgrade()
720 word = *(uint32_t *)(fw->data + offset + i); in flash_upgrade()
721 if(card->fpga_version > LEGACY_BUFFERS) in flash_upgrade()
727 /* Specify block number and then trigger flash write */ in flash_upgrade()
728 iowrite32(offset / blocksize, card->config_regs + FLASH_BLOCK); in flash_upgrade()
729 iowrite32(1, card->config_regs + WRITE_FLASH); in flash_upgrade()
730 wait_event(card->fw_wq, !ioread32(card->config_regs + FLASH_BUSY)); in flash_upgrade()
734 iowrite32(0, card->config_regs + WRITE_FLASH); in flash_upgrade()
735 iowrite32(0, card->config_regs + FPGA_MODE); in flash_upgrade()
736 iowrite32(0, card->config_regs + FLASH_MODE); in flash_upgrade()
737 dev_info(&card->dev->dev, "Returning FPGA to Data mode\n"); in flash_upgrade()
746 iowrite32(0, card->config_regs + IRQ_CLEAR); in solos_irq()
749 if (card->atmdev[0]) in solos_irq()
750 tasklet_schedule(&card->tlet); in solos_irq()
752 wake_up(&card->fw_wq); in solos_irq()
771 for (port = 0; port < card->nr_ports; port++) { in solos_bh()
778 if (card->using_dma) { in solos_bh()
779 skb = card->rx_skb[port]; in solos_bh()
780 card->rx_skb[port] = NULL; in solos_bh()
782 dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr, in solos_bh()
785 header = (void *)skb->data; in solos_bh()
786 size = le16_to_cpu(header->size); in solos_bh()
796 size = le16_to_cpu(header->size); in solos_bh()
797 if (size > (card->buffer_size - sizeof(*header))){ in solos_bh()
798 dev_warn(&card->dev->dev, "Invalid buffer size\n"); in solos_bh()
810 dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n"); in solos_bh()
819 dev_info(&card->dev->dev, "Received: port %d\n", port); in solos_bh()
820 dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n", in solos_bh()
821 size, le16_to_cpu(header->vpi), in solos_bh()
822 le16_to_cpu(header->vci)); in solos_bh()
826 switch (le16_to_cpu(header->type)) { in solos_bh()
828 vcc = find_vcc(card->atmdev[port], le16_to_cpu(header->vpi), in solos_bh()
829 le16_to_cpu(header->vci)); in solos_bh()
832 dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n", in solos_bh()
833 le16_to_cpu(header->vpi), le16_to_cpu(header->vci), in solos_bh()
838 atm_charge(vcc, skb->truesize); in solos_bh()
839 vcc->push(vcc, skb); in solos_bh()
840 atomic_inc(&vcc->stats->rx); in solos_bh()
846 dev_warn(&card->dev->dev, "Bad status packet of %d bytes on port %d:\n", skb->len, port); in solos_bh()
856 spin_lock(&card->cli_queue_lock); in solos_bh()
857 if (skb_queue_len(&card->cli_queue[port]) > 10) { in solos_bh()
859 dev_warn(&card->dev->dev, "Dropping console response on port %d\n", in solos_bh()
863 skb_queue_tail(&card->cli_queue[port], skb); in solos_bh()
864 spin_unlock(&card->cli_queue_lock); in solos_bh()
868 /* Allocate RX skbs for any ports which need them */ in solos_bh()
869 if (card->using_dma && card->atmdev[port] && in solos_bh()
870 !card->rx_skb[port]) { in solos_bh()
876 SKB_CB(skb)->dma_addr = in solos_bh()
877 dma_map_single(&card->dev->dev, skb->data, in solos_bh()
879 iowrite32(SKB_CB(skb)->dma_addr, in solos_bh()
880 card->config_regs + RX_DMA_ADDR(port)); in solos_bh()
881 card->rx_skb[port] = skb; in solos_bh()
884 dev_warn(&card->dev->dev, "Failed to allocate RX skb"); in solos_bh()
887 tasklet_schedule(&card->tlet); in solos_bh()
892 iowrite32(rx_done, card->config_regs + FLAGS_ADDR); in solos_bh()
904 head = &vcc_hash[vci & (VCC_HTABLE_SIZE -1)]; in find_vcc()
907 if (vcc->dev == dev && vcc->vci == vci && in find_vcc()
908 vcc->vpi == vpi && vcc->qos.rxtp.traffic_class != ATM_NONE && in find_vcc()
909 test_bit(ATM_VF_READY, &vcc->flags)) in find_vcc()
920 struct solos_card *card = vcc->dev->dev_data; in popen()
924 if (vcc->qos.aal != ATM_AAL5) { in popen()
925 dev_warn(&card->dev->dev, "Unsupported ATM type %d\n", in popen()
926 vcc->qos.aal); in popen()
927 return -EINVAL; in popen()
933 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n"); in popen()
934 return -ENOMEM; in popen()
938 header->size = cpu_to_le16(0); in popen()
939 header->vpi = cpu_to_le16(vcc->vpi); in popen()
940 header->vci = cpu_to_le16(vcc->vci); in popen()
941 header->type = cpu_to_le16(PKT_POPEN); in popen()
943 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); in popen()
945 set_bit(ATM_VF_ADDR, &vcc->flags); in popen()
946 set_bit(ATM_VF_READY, &vcc->flags); in popen()
953 struct solos_card *card = vcc->dev->dev_data; in pclose()
954 unsigned char port = SOLOS_CHAN(vcc->dev); in pclose()
958 /* Remove any yet-to-be-transmitted packets from the pending queue */ in pclose()
959 spin_lock_bh(&card->tx_queue_lock); in pclose()
960 skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) { in pclose()
961 if (SKB_CB(skb)->vcc == vcc) { in pclose()
962 skb_unlink(skb, &card->tx_queue[port]); in pclose()
966 spin_unlock_bh(&card->tx_queue_lock); in pclose()
970 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n"); in pclose()
975 header->size = cpu_to_le16(0); in pclose()
976 header->vpi = cpu_to_le16(vcc->vpi); in pclose()
977 header->vci = cpu_to_le16(vcc->vci); in pclose()
978 header->type = cpu_to_le16(PKT_PCLOSE); in pclose()
983 if (!wait_event_timeout(card->param_wq, !skb_shared(skb), 5 * HZ)) in pclose()
984 dev_warn(&card->dev->dev, in pclose()
992 tasklet_unlock_wait(&card->tlet); in pclose()
994 clear_bit(ATM_VF_ADDR, &vcc->flags); in pclose()
1005 len = buf->len; in print_buffer()
1010 sprintf(item,"%02X ",*(buf->data + i)); in print_buffer()
1034 SKB_CB(skb)->vcc = vcc; in fpga_queue()
1036 spin_lock_irqsave(&card->tx_queue_lock, flags); in fpga_queue()
1037 old_len = skb_queue_len(&card->tx_queue[port]); in fpga_queue()
1038 skb_queue_tail(&card->tx_queue[port], skb); in fpga_queue()
1040 card->tx_mask |= (1 << port); in fpga_queue()
1041 spin_unlock_irqrestore(&card->tx_queue_lock, flags); in fpga_queue()
1044 that introduces latency we don't want -- it's noticeable */ in fpga_queue()
1058 spin_lock_irqsave(&card->tx_lock, flags); in fpga_tx()
1060 card_flags = ioread32(card->config_regs + FLAGS_ADDR); in fpga_tx()
1068 tx_pending = card->tx_mask & ~card_flags; in fpga_tx()
1072 struct sk_buff *oldskb = card->tx_skb[port]; in fpga_tx()
1074 dma_unmap_single(&card->dev->dev, SKB_CB(oldskb)->dma_addr, in fpga_tx()
1075 oldskb->len, DMA_TO_DEVICE); in fpga_tx()
1076 card->tx_skb[port] = NULL; in fpga_tx()
1078 spin_lock(&card->tx_queue_lock); in fpga_tx()
1079 skb = skb_dequeue(&card->tx_queue[port]); in fpga_tx()
1081 card->tx_mask &= ~(1 << port); in fpga_tx()
1082 spin_unlock(&card->tx_queue_lock); in fpga_tx()
1084 if (skb && !card->using_dma) { in fpga_tx()
1085 memcpy_toio(TX_BUF(card, port), skb->data, skb->len); in fpga_tx()
1088 } else if (skb && card->using_dma) { in fpga_tx()
1089 unsigned char *data = skb->data; in fpga_tx()
1090 if ((unsigned long)data & card->dma_alignment) { in fpga_tx()
1091 data = card->dma_bounce + (BUF_SIZE * port); in fpga_tx()
1092 memcpy(data, skb->data, skb->len); in fpga_tx()
1094 SKB_CB(skb)->dma_addr = dma_map_single(&card->dev->dev, data, in fpga_tx()
1095 skb->len, DMA_TO_DEVICE); in fpga_tx()
1096 card->tx_skb[port] = skb; in fpga_tx()
1097 iowrite32(SKB_CB(skb)->dma_addr, in fpga_tx()
1098 card->config_regs + TX_DMA_ADDR(port)); in fpga_tx()
1106 struct pkt_hdr *header = (void *)oldskb->data; in fpga_tx()
1107 int size = le16_to_cpu(header->size); in fpga_tx()
1110 dev_info(&card->dev->dev, "Transmitted: port %d\n", in fpga_tx()
1112 dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n", in fpga_tx()
1113 size, le16_to_cpu(header->vpi), in fpga_tx()
1114 le16_to_cpu(header->vci)); in fpga_tx()
1118 vcc = SKB_CB(oldskb)->vcc; in fpga_tx()
1121 atomic_inc(&vcc->stats->tx); in fpga_tx()
1125 wake_up(&card->param_wq); in fpga_tx()
1129 /* For non-DMA TX, write the 'TX start' bit for all four ports simultaneously */ in fpga_tx()
1131 iowrite32(tx_started, card->config_regs + FLAGS_ADDR); in fpga_tx()
1133 spin_unlock_irqrestore(&card->tx_lock, flags); in fpga_tx()
1139 struct solos_card *card = vcc->dev->dev_data; in psend()
1143 pktlen = skb->len; in psend()
1144 if (pktlen > (BUF_SIZE - sizeof(*header))) { in psend()
1145 dev_warn(&card->dev->dev, "Length of PDU is too large. Dropping PDU.\n"); in psend()
1155 expand_by = sizeof(*header) - skb_headroom(skb); in psend()
1159 dev_warn(&card->dev->dev, "pskb_expand_head failed.\n"); in psend()
1168 header->size = cpu_to_le16(pktlen); in psend()
1169 header->vpi = cpu_to_le16(vcc->vpi); in psend()
1170 header->vci = cpu_to_le16(vcc->vci); in psend()
1171 header->type = cpu_to_le16(PKT_DATA); in psend()
1173 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, vcc); in psend()
1201 return -ENOMEM; in fpga_probe()
1203 card->dev = dev; in fpga_probe()
1204 init_waitqueue_head(&card->fw_wq); in fpga_probe()
1205 init_waitqueue_head(&card->param_wq); in fpga_probe()
1209 dev_warn(&dev->dev, "Failed to enable PCI device\n"); in fpga_probe()
1213 err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); in fpga_probe()
1215 dev_warn(&dev->dev, "Failed to set 32-bit DMA mask\n"); in fpga_probe()
1221 dev_warn(&dev->dev, "Failed to request regions\n"); in fpga_probe()
1225 card->config_regs = pci_iomap(dev, 0, CONFIG_RAM_SIZE); in fpga_probe()
1226 if (!card->config_regs) { in fpga_probe()
1227 dev_warn(&dev->dev, "Failed to ioremap config registers\n"); in fpga_probe()
1228 err = -ENOMEM; in fpga_probe()
1231 card->buffers = pci_iomap(dev, 1, DATA_RAM_SIZE); in fpga_probe()
1232 if (!card->buffers) { in fpga_probe()
1233 dev_warn(&dev->dev, "Failed to ioremap data buffers\n"); in fpga_probe()
1234 err = -ENOMEM; in fpga_probe()
1239 iowrite32(1, card->config_regs + FPGA_MODE); in fpga_probe()
1240 ioread32(card->config_regs + FPGA_MODE); in fpga_probe()
1242 iowrite32(0, card->config_regs + FPGA_MODE); in fpga_probe()
1243 ioread32(card->config_regs + FPGA_MODE); in fpga_probe()
1246 data32 = ioread32(card->config_regs + FPGA_VER); in fpga_probe()
1250 card->fpga_version = FPGA_VERSION(major_ver,minor_ver); in fpga_probe()
1251 if (card->fpga_version > LEGACY_BUFFERS) in fpga_probe()
1252 card->buffer_size = BUF_SIZE; in fpga_probe()
1254 card->buffer_size = OLD_BUF_SIZE; in fpga_probe()
1255 dev_info(&dev->dev, "Solos FPGA Version %d.%02d svn-%d\n", in fpga_probe()
1260 dev_warn(&dev->dev, in fpga_probe()
1266 /* Stopped using Atmel flash after 0.03-38 */ in fpga_probe()
1268 card->atmel_flash = 1; in fpga_probe()
1270 card->atmel_flash = 0; in fpga_probe()
1272 data32 = ioread32(card->config_regs + PORTS); in fpga_probe()
1273 card->nr_ports = (data32 & 0x000000FF); in fpga_probe()
1275 if (card->fpga_version >= DMA_SUPPORTED) { in fpga_probe()
1277 card->using_dma = 1; in fpga_probe()
1279 card->dma_alignment = 3; in fpga_probe()
1280 card->dma_bounce = kmalloc_array(card->nr_ports, in fpga_probe()
1282 if (!card->dma_bounce) { in fpga_probe()
1283 dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n"); in fpga_probe()
1284 err = -ENOMEM; in fpga_probe()
1290 card->using_dma = 0; in fpga_probe()
1291 /* Set RX empty flag for all ports */ in fpga_probe()
1292 iowrite32(0xF0, card->config_regs + FLAGS_ADDR); in fpga_probe()
1297 tasklet_init(&card->tlet, solos_bh, (unsigned long)card); in fpga_probe()
1298 spin_lock_init(&card->tx_lock); in fpga_probe()
1299 spin_lock_init(&card->tx_queue_lock); in fpga_probe()
1300 spin_lock_init(&card->cli_queue_lock); in fpga_probe()
1301 spin_lock_init(&card->param_queue_lock); in fpga_probe()
1302 INIT_LIST_HEAD(&card->param_queue); in fpga_probe()
1304 err = request_irq(dev->irq, solos_irq, IRQF_SHARED, in fpga_probe()
1305 "solos-pci", card); in fpga_probe()
1307 dev_dbg(&card->dev->dev, "Failed to request interrupt IRQ: %d\n", dev->irq); in fpga_probe()
1311 iowrite32(1, card->config_regs + IRQ_EN_ADDR); in fpga_probe()
1325 err = atm_init(card, &dev->dev); in fpga_probe()
1329 if (card->fpga_version >= DMA_SUPPORTED && in fpga_probe()
1330 sysfs_create_group(&card->dev->dev.kobj, &gpio_attr_group)) in fpga_probe()
1331 dev_err(&card->dev->dev, "Could not register parameter group for GPIOs\n"); in fpga_probe()
1336 iowrite32(0, card->config_regs + IRQ_EN_ADDR); in fpga_probe()
1337 free_irq(dev->irq, card); in fpga_probe()
1338 tasklet_kill(&card->tlet); in fpga_probe()
1341 kfree(card->dma_bounce); in fpga_probe()
1342 pci_iounmap(dev, card->buffers); in fpga_probe()
1344 pci_iounmap(dev, card->config_regs); in fpga_probe()
1356 for (i = 0; i < card->nr_ports; i++) { in atm_init()
1360 skb_queue_head_init(&card->tx_queue[i]); in atm_init()
1361 skb_queue_head_init(&card->cli_queue[i]); in atm_init()
1363 card->atmdev[i] = atm_dev_register("solos-pci", parent, &fpga_ops, -1, NULL); in atm_init()
1364 if (!card->atmdev[i]) { in atm_init()
1365 dev_err(&card->dev->dev, "Could not register ATM device %d\n", i); in atm_init()
1367 return -ENODEV; in atm_init()
1369 if (device_create_file(&card->atmdev[i]->class_dev, &dev_attr_console)) in atm_init()
1370 dev_err(&card->dev->dev, "Could not register console for ATM device %d\n", i); in atm_init()
1371 if (sysfs_create_group(&card->atmdev[i]->class_dev.kobj, &solos_attr_group)) in atm_init()
1372 dev_err(&card->dev->dev, "Could not register parameter group for ATM device %d\n", i); in atm_init()
1374 dev_info(&card->dev->dev, "Registered ATM device %d\n", card->atmdev[i]->number); in atm_init()
1376 card->atmdev[i]->ci_range.vpi_bits = 8; in atm_init()
1377 card->atmdev[i]->ci_range.vci_bits = 16; in atm_init()
1378 card->atmdev[i]->dev_data = card; in atm_init()
1379 card->atmdev[i]->phy_data = (void *)(unsigned long)i; in atm_init()
1380 atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND); in atm_init()
1384 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n"); in atm_init()
1390 header->size = cpu_to_le16(0); in atm_init()
1391 header->vpi = cpu_to_le16(0); in atm_init()
1392 header->vci = cpu_to_le16(0); in atm_init()
1393 header->type = cpu_to_le16(PKT_STATUS); in atm_init()
1404 for (i = 0; i < card->nr_ports; i++) { in atm_remove()
1405 if (card->atmdev[i]) { in atm_remove()
1408 dev_info(&card->dev->dev, "Unregistering ATM device %d\n", card->atmdev[i]->number); in atm_remove()
1410 sysfs_remove_group(&card->atmdev[i]->class_dev.kobj, &solos_attr_group); in atm_remove()
1411 atm_dev_deregister(card->atmdev[i]); in atm_remove()
1413 skb = card->rx_skb[i]; in atm_remove()
1415 dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr, in atm_remove()
1419 skb = card->tx_skb[i]; in atm_remove()
1421 dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr, in atm_remove()
1422 skb->len, DMA_TO_DEVICE); in atm_remove()
1425 while ((skb = skb_dequeue(&card->tx_queue[i]))) in atm_remove()
1437 iowrite32(0, card->config_regs + IRQ_EN_ADDR); in fpga_remove()
1440 iowrite32(1, card->config_regs + FPGA_MODE); in fpga_remove()
1441 (void)ioread32(card->config_regs + FPGA_MODE); in fpga_remove()
1443 if (card->fpga_version >= DMA_SUPPORTED) in fpga_remove()
1444 sysfs_remove_group(&card->dev->dev.kobj, &gpio_attr_group); in fpga_remove()
1448 free_irq(dev->irq, card); in fpga_remove()
1449 tasklet_kill(&card->tlet); in fpga_remove()
1451 kfree(card->dma_bounce); in fpga_remove()
1454 iowrite32(0, card->config_regs + FPGA_MODE); in fpga_remove()
1455 (void)ioread32(card->config_regs + FPGA_MODE); in fpga_remove()
1457 pci_iounmap(dev, card->buffers); in fpga_remove()
1458 pci_iounmap(dev, card->config_regs); in fpga_remove()
1483 BUILD_BUG_ON(sizeof(struct solos_skb_cb) > sizeof(((struct sk_buff *)0)->cb)); in solos_pci_init()