Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: sja1000: plx_pci: Add support for Marathon CAN-bus-PCIe card

This patch adds support for the Marathon CAN-bus-PCIe card to the
sja1000 driver. For more information see:

http://can.marathon.ru/page/devices/can-bus-pcie

Signed-off-by: Nikita Edward Baruzdin <nebaruzdin@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Nikita Edward Baruzdin and committed by
Marc Kleine-Budde
056a7201 3e51a335

+56 -8
+56 -8
drivers/net/can/sja1000/plx_pci.c
··· 39 39 MODULE_SUPPORTED_DEVICE("Adlink PCI-7841/cPCI-7841, " 40 40 "Adlink PCI-7841/cPCI-7841 SE, " 41 41 "Marathon CAN-bus-PCI, " 42 + "Marathon CAN-bus-PCIe, " 42 43 "TEWS TECHNOLOGIES TPMC810, " 43 44 "esd CAN-PCI/CPCI/PCI104/200, " 44 45 "esd CAN-PCI/PMC/266, " ··· 134 133 #define IXXAT_PCI_SUB_SYS_ID 0x2540 135 134 136 135 #define MARATHON_PCI_DEVICE_ID 0x2715 136 + #define MARATHON_PCIE_DEVICE_ID 0x3432 137 137 138 138 #define TEWS_PCI_VENDOR_ID 0x1498 139 139 #define TEWS_PCI_DEVICE_ID_TMPC810 0x032A ··· 143 141 #define CTI_PCI_DEVICE_ID_CRG001 0x0900 144 142 145 143 static void plx_pci_reset_common(struct pci_dev *pdev); 146 - static void plx_pci_reset_marathon(struct pci_dev *pdev); 147 144 static void plx9056_pci_reset_common(struct pci_dev *pdev); 145 + static void plx_pci_reset_marathon_pci(struct pci_dev *pdev); 146 + static void plx_pci_reset_marathon_pcie(struct pci_dev *pdev); 148 147 149 148 struct plx_pci_channel_map { 150 149 u32 bar; ··· 218 215 /* based on PLX9050 */ 219 216 }; 220 217 221 - static struct plx_pci_card_info plx_pci_card_info_marathon = { 218 + static struct plx_pci_card_info plx_pci_card_info_marathon_pci = { 222 219 "Marathon CAN-bus-PCI", 2, 223 220 PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR, 224 221 {0, 0x00, 0x00}, { {2, 0x00, 0x00}, {4, 0x00, 0x00} }, 225 - &plx_pci_reset_marathon 222 + &plx_pci_reset_marathon_pci 226 223 /* based on PLX9052 */ 224 + }; 225 + 226 + static struct plx_pci_card_info plx_pci_card_info_marathon_pcie = { 227 + "Marathon CAN-bus-PCIe", 2, 228 + PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR, 229 + {0, 0x00, 0x00}, { {2, 0x00, 0x00}, {3, 0x80, 0x00} }, 230 + &plx_pci_reset_marathon_pcie 231 + /* based on PEX8311 */ 227 232 }; 228 233 229 234 static struct plx_pci_card_info plx_pci_card_info_tews = { ··· 327 316 PCI_VENDOR_ID_PLX, MARATHON_PCI_DEVICE_ID, 328 317 PCI_ANY_ID, PCI_ANY_ID, 329 318 0, 0, 330 - (kernel_ulong_t)&plx_pci_card_info_marathon 319 + (kernel_ulong_t)&plx_pci_card_info_marathon_pci 320 + }, 321 + { 322 + /* Marathon CAN-bus-PCIe card */ 323 + PCI_VENDOR_ID_PLX, MARATHON_PCIE_DEVICE_ID, 324 + PCI_ANY_ID, PCI_ANY_ID, 325 + 0, 0, 326 + (kernel_ulong_t)&plx_pci_card_info_marathon_pcie 331 327 }, 332 328 { 333 329 /* TEWS TECHNOLOGIES TPMC810 card */ ··· 455 437 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); 456 438 }; 457 439 458 - /* Special reset function for Marathon card */ 459 - static void plx_pci_reset_marathon(struct pci_dev *pdev) 440 + /* Special reset function for Marathon CAN-bus-PCI card */ 441 + static void plx_pci_reset_marathon_pci(struct pci_dev *pdev) 460 442 { 461 443 void __iomem *reset_addr; 462 444 int i; ··· 474 456 iowrite8(0x1, reset_addr); 475 457 udelay(100); 476 458 pci_iounmap(pdev, reset_addr); 459 + } 460 + } 461 + } 462 + 463 + /* Special reset function for Marathon CAN-bus-PCIe card */ 464 + static void plx_pci_reset_marathon_pcie(struct pci_dev *pdev) 465 + { 466 + void __iomem *addr; 467 + void __iomem *reset_addr; 468 + int i; 469 + 470 + plx9056_pci_reset_common(pdev); 471 + 472 + for (i = 0; i < 2; i++) { 473 + struct plx_pci_channel_map *chan_map = 474 + &plx_pci_card_info_marathon_pcie.chan_map_tbl[i]; 475 + addr = pci_iomap(pdev, chan_map->bar, chan_map->size); 476 + if (!addr) { 477 + dev_err(&pdev->dev, "Failed to remap reset " 478 + "space %d (BAR%d)\n", i, chan_map->bar); 479 + } else { 480 + /* reset the SJA1000 chip */ 481 + #define MARATHON_PCIE_RESET_OFFSET 32 482 + reset_addr = addr + chan_map->offset + 483 + MARATHON_PCIE_RESET_OFFSET; 484 + iowrite8(0x1, reset_addr); 485 + udelay(100); 486 + pci_iounmap(pdev, addr); 477 487 } 478 488 } 479 489 } ··· 532 486 * Disable interrupts from PCI-card and disable local 533 487 * interrupts 534 488 */ 535 - if (pdev->device != PCI_DEVICE_ID_PLX_9056) 489 + if (pdev->device != PCI_DEVICE_ID_PLX_9056 && 490 + pdev->device != MARATHON_PCIE_DEVICE_ID) 536 491 iowrite32(0x0, card->conf_addr + PLX_INTCSR); 537 492 else 538 493 iowrite32(0x0, card->conf_addr + PLX9056_INTCSR); ··· 666 619 * Enable interrupts from PCI-card (PLX90xx) and enable Local_1, 667 620 * Local_2 interrupts from the SJA1000 chips 668 621 */ 669 - if (pdev->device != PCI_DEVICE_ID_PLX_9056) { 622 + if (pdev->device != PCI_DEVICE_ID_PLX_9056 && 623 + pdev->device != MARATHON_PCIE_DEVICE_ID) { 670 624 val = ioread32(card->conf_addr + PLX_INTCSR); 671 625 if (pdev->subsystem_vendor == PCI_VENDOR_ID_ESDGMBH) 672 626 val |= PLX_LINT1_EN | PLX_PCI_INT_EN;