Lines Matching +full:cm +full:- +full:poll +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2008-2010 Pavel Cheblakov <P.B.Cheblakov@inp.nsk.su>
7 * Copyright (C) 2008 Markus Plessing <plessing@ems-wuensche.com>
8 * Copyright (C) 2008 Sebastian Haas <haas@ems-wuensche.com>
26 MODULE_DESCRIPTION("Socket-CAN driver for PLX90xx PCI-bridge cards with "
37 /* Pointer to device-dependent reset function */
71 * This means normal output mode, push-pull and the correct polarity.
86 /* SJA1000 Control Register in the BasicCAN Mode */
89 /* States of some SJA1000 registers after hardware reset in the BasicCAN mode*/
95 /* States of some SJA1000 registers after hardware reset in the PeliCAN mode*/
148 u32 size; /* 0x00 - auto, e.g. length of entire bar */
164 /* Pointer to device-dependent reset function */
169 "Adlink PCI-7841/cPCI-7841", 2,
177 "Adlink PCI-7841/cPCI-7841 SE", 2,
185 "esd CAN-PCI/CPCI/PCI104/200", 2,
193 "esd CAN-PCI/PMC/266", 2,
201 "esd CAN-PCIe/2000", 2,
209 "IXXAT PC-I 04/PCI", 2,
217 "Marathon CAN-bus-PCI", 2,
225 "Marathon CAN-bus-PCIe", 2,
241 "Connect Tech Inc. CANpro/104-Plus Opto (CRG001)", 2,
249 "Eclus CAN-200-PCI", 2,
274 /* Adlink PCI-7841/cPCI-7841 */
281 /* Adlink PCI-7841/cPCI-7841 SE */
288 /* esd CAN-PCI/200 */
295 /* esd CAN-CPCI/200 */
302 /* esd CAN-PCI104/200 */
309 /* esd CAN-PCI/266 */
316 /* esd CAN-PMC/266 */
323 /* esd CAN-PCIE/2000 */
330 /* IXXAT PC-I 04/PCI card */
337 /* Marathon CAN-bus-PCI card */
344 /* Marathon CAN-bus-PCIe card */
358 /* Connect Tech Inc. CANpro/104-Plus Opto (CRG001) card */
365 /* Elcus CAN-200-PCI */
386 /* ASEM Dual CAN raw -new model */
398 return ioread8(priv->reg_base + port); in plx_pci_read_reg()
403 iowrite8(val, priv->reg_base + port); in plx_pci_write_reg()
408 * by trying to switch 'em from the Basic mode into the PeliCAN mode.
409 * Also check states of some registers in reset mode.
416 * Check registers after hardware reset (the Basic mode) in plx_pci_check_sja1000()
419 if ((priv->read_reg(priv, REG_CR) & REG_CR_BASICCAN_INITIAL_MASK) == in plx_pci_check_sja1000()
421 (priv->read_reg(priv, SJA1000_SR) == REG_SR_BASICCAN_INITIAL) && in plx_pci_check_sja1000()
422 (priv->read_reg(priv, SJA1000_IR) == REG_IR_BASICCAN_INITIAL)) in plx_pci_check_sja1000()
425 /* Bring the SJA1000 into the PeliCAN mode*/ in plx_pci_check_sja1000()
426 priv->write_reg(priv, SJA1000_CDR, CDR_PELICAN); in plx_pci_check_sja1000()
429 * Check registers after reset in the PeliCAN mode. in plx_pci_check_sja1000()
432 if (priv->read_reg(priv, SJA1000_MOD) == REG_MOD_PELICAN_INITIAL && in plx_pci_check_sja1000()
433 priv->read_reg(priv, SJA1000_SR) == REG_SR_PELICAN_INITIAL && in plx_pci_check_sja1000()
434 priv->read_reg(priv, SJA1000_IR) == REG_IR_PELICAN_INITIAL) in plx_pci_check_sja1000()
450 cntrl = ioread32(card->conf_addr + PLX_CNTRL); in plx_pci_reset_common()
452 iowrite32(cntrl, card->conf_addr + PLX_CNTRL); in plx_pci_reset_common()
455 iowrite32(cntrl, card->conf_addr + PLX_CNTRL); in plx_pci_reset_common()
468 cntrl = ioread32(card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
470 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
473 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
477 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
480 * There is no safe way to poll for the end in plx9056_pci_reset_common()
487 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
490 /* Special reset function for Marathon CAN-bus-PCI card */
502 dev_err(&pdev->dev, "Failed to remap reset " in plx_pci_reset_marathon_pci()
513 /* Special reset function for Marathon CAN-bus-PCIe card */
525 addr = pci_iomap(pdev, chan_map->bar, chan_map->size); in plx_pci_reset_marathon_pcie()
527 dev_err(&pdev->dev, "Failed to remap reset " in plx_pci_reset_marathon_pcie()
528 "space %d (BAR%d)\n", i, chan_map->bar); in plx_pci_reset_marathon_pcie()
532 reset_addr = addr + chan_map->offset + in plx_pci_reset_marathon_pcie()
551 dev_err(&pdev->dev, "Failed to remap reset space 0 (BAR0)\n"); in plx_pci_reset_asem_dual_can_raw()
574 dev = card->net_dev[i]; in plx_pci_del_card()
578 dev_info(&pdev->dev, "Removing %s\n", dev->name); in plx_pci_del_card()
581 if (priv->reg_base) in plx_pci_del_card()
582 pci_iounmap(pdev, priv->reg_base); in plx_pci_del_card()
586 card->reset_func(pdev); in plx_pci_del_card()
589 * Disable interrupts from PCI-card and disable local in plx_pci_del_card()
592 if (pdev->device != PCI_DEVICE_ID_PLX_9056 && in plx_pci_del_card()
593 pdev->device != MARATHON_PCIE_DEVICE_ID) in plx_pci_del_card()
594 iowrite32(0x0, card->conf_addr + PLX_INTCSR); in plx_pci_del_card()
596 iowrite32(0x0, card->conf_addr + PLX9056_INTCSR); in plx_pci_del_card()
598 if (card->conf_addr) in plx_pci_del_card()
599 pci_iounmap(pdev, card->conf_addr); in plx_pci_del_card()
608 * available CAN channel to SJA1000 Socket-CAN subsystem.
621 ci = (struct plx_pci_card_info *)ent->driver_data; in plx_pci_add_card()
624 dev_err(&pdev->dev, "Failed to enable PCI device\n"); in plx_pci_add_card()
625 return -ENODEV; in plx_pci_add_card()
628 dev_info(&pdev->dev, "Detected \"%s\" card at slot #%i\n", in plx_pci_add_card()
629 ci->name, PCI_SLOT(pdev->devfn)); in plx_pci_add_card()
635 return -ENOMEM; in plx_pci_add_card()
640 card->channels = 0; in plx_pci_add_card()
643 addr = pci_iomap(pdev, ci->conf_map.bar, ci->conf_map.size); in plx_pci_add_card()
645 err = -ENOMEM; in plx_pci_add_card()
646 dev_err(&pdev->dev, "Failed to remap configuration space " in plx_pci_add_card()
647 "(BAR%d)\n", ci->conf_map.bar); in plx_pci_add_card()
650 card->conf_addr = addr + ci->conf_map.offset; in plx_pci_add_card()
652 ci->reset_func(pdev); in plx_pci_add_card()
653 card->reset_func = ci->reset_func; in plx_pci_add_card()
656 for (i = 0; i < ci->channel_count; i++) { in plx_pci_add_card()
657 struct plx_pci_channel_map *cm = &ci->chan_map_tbl[i]; in plx_pci_add_card() local
661 err = -ENOMEM; in plx_pci_add_card()
665 card->net_dev[i] = dev; in plx_pci_add_card()
667 priv->priv = card; in plx_pci_add_card()
668 priv->irq_flags = IRQF_SHARED; in plx_pci_add_card()
670 dev->irq = pdev->irq; in plx_pci_add_card()
674 * This is device-dependent mapping in plx_pci_add_card()
676 addr = pci_iomap(pdev, cm->bar, cm->size); in plx_pci_add_card()
678 err = -ENOMEM; in plx_pci_add_card()
679 dev_err(&pdev->dev, "Failed to remap BAR%d\n", cm->bar); in plx_pci_add_card()
683 priv->reg_base = addr + cm->offset; in plx_pci_add_card()
684 priv->read_reg = plx_pci_read_reg; in plx_pci_add_card()
685 priv->write_reg = plx_pci_write_reg; in plx_pci_add_card()
689 priv->can.clock.freq = ci->can_clock; in plx_pci_add_card()
690 priv->ocr = ci->ocr; in plx_pci_add_card()
691 priv->cdr = ci->cdr; in plx_pci_add_card()
693 SET_NETDEV_DEV(dev, &pdev->dev); in plx_pci_add_card()
694 dev->dev_id = i; in plx_pci_add_card()
699 dev_err(&pdev->dev, "Registering device failed " in plx_pci_add_card()
704 card->channels++; in plx_pci_add_card()
706 dev_info(&pdev->dev, "Channel #%d at 0x%p, irq %d " in plx_pci_add_card()
707 "registered as %s\n", i + 1, priv->reg_base, in plx_pci_add_card()
708 dev->irq, dev->name); in plx_pci_add_card()
710 dev_err(&pdev->dev, "Channel #%d not detected\n", in plx_pci_add_card()
713 card->net_dev[i] = NULL; in plx_pci_add_card()
717 if (!card->channels) { in plx_pci_add_card()
718 err = -ENODEV; in plx_pci_add_card()
723 * Enable interrupts from PCI-card (PLX90xx) and enable Local_1, in plx_pci_add_card()
726 if (pdev->device != PCI_DEVICE_ID_PLX_9056 && in plx_pci_add_card()
727 pdev->device != MARATHON_PCIE_DEVICE_ID) { in plx_pci_add_card()
728 val = ioread32(card->conf_addr + PLX_INTCSR); in plx_pci_add_card()
729 if (pdev->subsystem_vendor == PCI_VENDOR_ID_ESDGMBH) in plx_pci_add_card()
733 iowrite32(val, card->conf_addr + PLX_INTCSR); in plx_pci_add_card()
736 card->conf_addr + PLX9056_INTCSR); in plx_pci_add_card()
741 dev_err(&pdev->dev, "Error: %d. Cleaning Up.\n", err); in plx_pci_add_card()