23 #include <linux/kernel.h>
24 #include <linux/module.h>
26 #include <linux/netdevice.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
35 #define DRV_NAME "sja1000_plx_pci"
41 "Adlink PCI-7841/cPCI-7841 SE, "
42 "Marathon CAN-bus-PCI, "
43 "TEWS TECHNOLOGIES TPMC810, "
44 "esd CAN-PCI/CPCI/PCI104/200, "
45 "esd CAN-PCI/PMC/266, "
50 #define PLX_PCI_MAX_CHAN 2
61 #define PLX_PCI_CAN_CLOCK (16000000 / 2)
64 #define PLX_INTCSR 0x4c
65 #define PLX_CNTRL 0x50
70 #define PLX_LINT1_EN 0x1
71 #define PLX_LINT2_EN (1 << 3)
72 #define PLX_PCI_INT_EN (1 << 6)
73 #define PLX_PCI_RESET (1 << 30)
76 #define PLX9056_INTCSR 0x68
77 #define PLX9056_CNTRL 0x6c
79 #define PLX9056_LINTI (1 << 11)
80 #define PLX9056_PCI_INT_EN (1 << 8)
81 #define PLX9056_PCI_RCR (1 << 29)
91 #define PLX_PCI_OCR (OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL)
99 #define PLX_PCI_CDR (CDR_CBP | CDR_CLKOUT_MASK)
105 #define REG_CR_BASICCAN_INITIAL 0x21
106 #define REG_CR_BASICCAN_INITIAL_MASK 0xa1
107 #define REG_SR_BASICCAN_INITIAL 0x0c
108 #define REG_IR_BASICCAN_INITIAL 0xe0
111 #define REG_MOD_PELICAN_INITIAL 0x01
112 #define REG_SR_PELICAN_INITIAL 0x3c
113 #define REG_IR_PELICAN_INITIAL 0x00
115 #define ADLINK_PCI_VENDOR_ID 0x144A
116 #define ADLINK_PCI_DEVICE_ID 0x7841
118 #define ESD_PCI_SUB_SYS_ID_PCI200 0x0004
119 #define ESD_PCI_SUB_SYS_ID_PCI266 0x0009
120 #define ESD_PCI_SUB_SYS_ID_PMC266 0x000e
121 #define ESD_PCI_SUB_SYS_ID_CPCI200 0x010b
122 #define ESD_PCI_SUB_SYS_ID_PCIE2000 0x0200
123 #define ESD_PCI_SUB_SYS_ID_PCI104200 0x0501
125 #define IXXAT_PCI_VENDOR_ID 0x10b5
126 #define IXXAT_PCI_DEVICE_ID 0x9050
127 #define IXXAT_PCI_SUB_SYS_ID 0x2540
129 #define MARATHON_PCI_DEVICE_ID 0x2715
131 #define TEWS_PCI_VENDOR_ID 0x1498
132 #define TEWS_PCI_DEVICE_ID_TMPC810 0x032A
134 static void plx_pci_reset_common(
struct pci_dev *pdev);
135 static void plx_pci_reset_marathon(
struct pci_dev *pdev);
136 static void plx9056_pci_reset_common(
struct pci_dev *pdev);
162 "Adlink PCI-7841/cPCI-7841", 2,
164 {1, 0x00, 0x00}, { {2, 0x00, 0x80}, {2, 0x80, 0x80} },
165 &plx_pci_reset_common
170 "Adlink PCI-7841/cPCI-7841 SE", 2,
172 {0, 0x00, 0x00}, { {2, 0x00, 0x80}, {2, 0x80, 0x80} },
173 &plx_pci_reset_common
178 "esd CAN-PCI/CPCI/PCI104/200", 2,
180 {0, 0x00, 0x00}, { {2, 0x00, 0x80}, {2, 0x100, 0x80} },
181 &plx_pci_reset_common
186 "esd CAN-PCI/PMC/266", 2,
188 {0, 0x00, 0x00}, { {2, 0x00, 0x80}, {2, 0x100, 0x80} },
189 &plx9056_pci_reset_common
194 "esd CAN-PCIe/2000", 2,
196 {0, 0x00, 0x00}, { {2, 0x00, 0x80}, {2, 0x100, 0x80} },
197 &plx9056_pci_reset_common
202 "IXXAT PC-I 04/PCI", 2,
204 {0, 0x00, 0x00}, { {2, 0x00, 0x80}, {2, 0x200, 0x80} },
205 &plx_pci_reset_common
210 "Marathon CAN-bus-PCI", 2,
212 {0, 0x00, 0x00}, { {2, 0x00, 0x00}, {4, 0x00, 0x00} },
213 &plx_pci_reset_marathon
218 "TEWS TECHNOLOGIES TPMC810", 2,
220 {0, 0x00, 0x00}, { {2, 0x000, 0x80}, {2, 0x100, 0x80} },
221 &plx_pci_reset_common
356 static void plx_pci_reset_common(
struct pci_dev *pdev)
373 static void plx9056_pci_reset_common(
struct pci_dev *pdev)
402 static void plx_pci_reset_marathon(
struct pci_dev *pdev)
406 static const int reset_bar[2] = {3, 5};
408 plx_pci_reset_common(pdev);
410 for (i = 0; i < 2; i++) {
411 reset_addr = pci_iomap(pdev, reset_bar[i], 0);
414 "space %d (BAR%d)\n", i, reset_bar[i]);
424 static void plx_pci_del_card(
struct pci_dev *pdev)
438 priv = netdev_priv(dev);
450 if (pdev->
device != PCI_DEVICE_ID_PLX_9056)
461 pci_set_drvdata(pdev,
NULL);
482 dev_err(&pdev->
dev,
"Failed to enable PCI device\n");
486 dev_info(&pdev->
dev,
"Detected \"%s\" card at slot #%i\n",
492 dev_err(&pdev->
dev,
"Unable to allocate memory\n");
497 pci_set_drvdata(pdev, card);
505 dev_err(&pdev->
dev,
"Failed to remap configuration space "
507 goto failure_cleanup;
521 goto failure_cleanup;
525 priv = netdev_priv(dev);
535 addr = pci_iomap(pdev, cm->
bar, cm->
size);
539 goto failure_cleanup;
547 if (plx_pci_check_sja1000(priv)) {
557 dev_err(&pdev->
dev,
"Registering device failed "
559 goto failure_cleanup;
564 dev_info(&pdev->
dev,
"Channel #%d at 0x%p, irq %d "
565 "registered as %s\n", i + 1, priv->
reg_base,
568 dev_err(&pdev->
dev,
"Channel #%d not detected\n",
577 goto failure_cleanup;
584 if (pdev->
device != PCI_DEVICE_ID_PLX_9056) {
598 dev_err(&pdev->
dev,
"Error: %d. Cleaning Up.\n", err);
600 plx_pci_del_card(pdev);
607 .id_table = plx_pci_tbl,
608 .probe = plx_pci_add_card,
609 .remove = plx_pci_del_card,