33 #include <linux/kernel.h>
34 #include <linux/module.h>
36 #include <linux/netdevice.h>
38 #include <linux/pci.h>
44 #define DRV_NAME "kvaser_pci"
51 #define MAX_NO_OF_CHANNELS 4
63 #define KVASER_PCI_CAN_CLOCK (16000000 / 2)
73 #define KVASER_PCI_OCR (OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL)
81 #define KVASER_PCI_CDR (CDR_CBP | CDR_CLKOUT_MASK)
86 #define XILINX_VERINT 7
89 #define XILINX_PRESUMED_VERSION 14
94 #define S5920_INTCSR 0x38
95 #define S5920_PTCR 0x60
96 #define INTCSR_ADDON_INTENABLE_M 0x2000
99 #define KVASER_PCI_PORT_BYTES 0x20
101 #define PCI_CONFIG_PORT_SIZE 0x80
102 #define PCI_PORT_SIZE 0x80
103 #define PCI_PORT_XILINX_SIZE 0x08
105 #define KVASER_PCI_VENDOR_ID1 0x10e8
106 #define KVASER_PCI_DEVICE_ID1 0x8406
108 #define KVASER_PCI_VENDOR_ID2 0x1a07
109 #define KVASER_PCI_DEVICE_ID2 0x0008
154 static int number_of_sja1000_chip(
void __iomem *base_addr)
181 priv = netdev_priv(dev);
190 kvaser_pci_disable_irq(dev);
224 priv = netdev_priv(dev);
246 kvaser_pci_enable_irq(dev);
248 struct sja1000_priv *master_priv = netdev_priv(*master_dev);
257 priv->
read_reg = kvaser_pci_read_reg;
270 dev_info(&pdev->
dev,
"reg_base=%p conf_addr=%p irq=%d\n",
278 dev_err(&pdev->
dev,
"Registering device failed (err=%d)\n",
289 kvaser_pci_del_chan(dev);
306 dev_info(&pdev->
dev,
"initializing device %04x:%04x\n",
315 goto failure_release_pci;
319 if (conf_addr ==
NULL) {
321 goto failure_release_regions;
326 if (res_addr ==
NULL) {
328 goto failure_iounmap;
332 if (base_addr ==
NULL) {
334 goto failure_iounmap;
337 no_channels = number_of_sja1000_chip(base_addr);
338 if (no_channels == 0) {
340 goto failure_iounmap;
344 err = kvaser_pci_add_chan(pdev, i, &master_dev,
348 goto failure_cleanup;
351 priv = netdev_priv(master_dev);
354 dev_info(&pdev->
dev,
"xilinx version=%d number of channels=%d\n",
357 pci_set_drvdata(pdev, master_dev);
361 kvaser_pci_del_chan(master_dev);
364 if (conf_addr !=
NULL)
366 if (res_addr !=
NULL)
368 if (base_addr !=
NULL)
371 failure_release_regions:
384 struct net_device *dev = pci_get_drvdata(pdev);
386 kvaser_pci_del_chan(dev);
390 pci_set_drvdata(pdev,
NULL);
393 static struct pci_driver kvaser_pci_driver = {
395 .id_table = kvaser_pci_tbl,
396 .probe = kvaser_pci_init_one,