Lines Matching +full:cdr +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.
79 * In the CDR register, you should set CBP to 1.
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*/
149 u32 size; /* 0x00 - auto, e.g. length of entire bar */
157 u8 cdr; /* clock divider register */ member
165 /* Pointer to device-dependent reset function */
170 "Adlink PCI-7841/cPCI-7841", 2,
178 "Adlink PCI-7841/cPCI-7841 SE", 2,
186 "esd CAN-PCI/CPCI/PCI104/200", 2,
194 "esd CAN-PCI/PMC/266", 2,
202 "esd CAN-PCIe/2000", 2,
210 "IXXAT PC-I 04/PCI", 2,
218 "Marathon CAN-bus-PCI", 2,
226 "Marathon CAN-bus-PCIe", 2,
242 "Connect Tech Inc. CANpro/104-Plus Opto (CRG001)", 2,
250 "Eclus CAN-200-PCI", 2,
275 /* Adlink PCI-7841/cPCI-7841 */
282 /* Adlink PCI-7841/cPCI-7841 SE */
289 /* esd CAN-PCI/200 */
296 /* esd CAN-CPCI/200 */
303 /* esd CAN-PCI104/200 */
310 /* esd CAN-PCI/266 */
317 /* esd CAN-PMC/266 */
324 /* esd CAN-PCIE/2000 */
331 /* IXXAT PC-I 04/PCI card */
338 /* Marathon CAN-bus-PCI card */
345 /* Marathon CAN-bus-PCIe card */
359 /* Connect Tech Inc. CANpro/104-Plus Opto (CRG001) card */
366 /* Elcus CAN-200-PCI */
387 /* ASEM Dual CAN raw -new model */
399 return ioread8(priv->reg_base + port); in plx_pci_read_reg()
404 iowrite8(val, priv->reg_base + port); in plx_pci_write_reg()
409 * by trying to switch 'em from the Basic mode into the PeliCAN mode.
410 * Also check states of some registers in reset mode.
417 * Check registers after hardware reset (the Basic mode) in plx_pci_check_sja1000()
420 if ((priv->read_reg(priv, REG_CR) & REG_CR_BASICCAN_INITIAL_MASK) == in plx_pci_check_sja1000()
422 (priv->read_reg(priv, SJA1000_SR) == REG_SR_BASICCAN_INITIAL) && in plx_pci_check_sja1000()
423 (priv->read_reg(priv, SJA1000_IR) == REG_IR_BASICCAN_INITIAL)) in plx_pci_check_sja1000()
426 /* Bring the SJA1000 into the PeliCAN mode*/ in plx_pci_check_sja1000()
427 priv->write_reg(priv, SJA1000_CDR, CDR_PELICAN); in plx_pci_check_sja1000()
430 * Check registers after reset in the PeliCAN mode. in plx_pci_check_sja1000()
433 if (priv->read_reg(priv, SJA1000_MOD) == REG_MOD_PELICAN_INITIAL && in plx_pci_check_sja1000()
434 priv->read_reg(priv, SJA1000_SR) == REG_SR_PELICAN_INITIAL && in plx_pci_check_sja1000()
435 priv->read_reg(priv, SJA1000_IR) == REG_IR_PELICAN_INITIAL) in plx_pci_check_sja1000()
451 cntrl = ioread32(card->conf_addr + PLX_CNTRL); in plx_pci_reset_common()
453 iowrite32(cntrl, card->conf_addr + PLX_CNTRL); in plx_pci_reset_common()
456 iowrite32(cntrl, card->conf_addr + PLX_CNTRL); in plx_pci_reset_common()
469 cntrl = ioread32(card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
471 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
474 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
478 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
488 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); in plx9056_pci_reset_common()
491 /* Special reset function for Marathon CAN-bus-PCI card */
503 dev_err(&pdev->dev, "Failed to remap reset " in plx_pci_reset_marathon_pci()
514 /* Special reset function for Marathon CAN-bus-PCIe card */
526 addr = pci_iomap(pdev, chan_map->bar, chan_map->size); in plx_pci_reset_marathon_pcie()
528 dev_err(&pdev->dev, "Failed to remap reset " in plx_pci_reset_marathon_pcie()
529 "space %d (BAR%d)\n", i, chan_map->bar); in plx_pci_reset_marathon_pcie()
533 reset_addr = addr + chan_map->offset + in plx_pci_reset_marathon_pcie()
552 dev_err(&pdev->dev, "Failed to remap reset space 0 (BAR0)\n"); in plx_pci_reset_asem_dual_can_raw()
575 dev = card->net_dev[i]; in plx_pci_del_card()
579 dev_info(&pdev->dev, "Removing %s\n", dev->name); in plx_pci_del_card()
582 if (priv->reg_base) in plx_pci_del_card()
583 pci_iounmap(pdev, priv->reg_base); in plx_pci_del_card()
587 card->reset_func(pdev); in plx_pci_del_card()
590 * Disable interrupts from PCI-card and disable local in plx_pci_del_card()
593 if (pdev->device != PCI_DEVICE_ID_PLX_9056 && in plx_pci_del_card()
594 pdev->device != MARATHON_PCIE_DEVICE_ID) in plx_pci_del_card()
595 iowrite32(0x0, card->conf_addr + PLX_INTCSR); in plx_pci_del_card()
597 iowrite32(0x0, card->conf_addr + PLX9056_INTCSR); in plx_pci_del_card()
599 if (card->conf_addr) in plx_pci_del_card()
600 pci_iounmap(pdev, card->conf_addr); in plx_pci_del_card()
609 * available CAN channel to SJA1000 Socket-CAN subsystem.
622 ci = (struct plx_pci_card_info *)ent->driver_data; in plx_pci_add_card()
625 dev_err(&pdev->dev, "Failed to enable PCI device\n"); in plx_pci_add_card()
626 return -ENODEV; in plx_pci_add_card()
629 dev_info(&pdev->dev, "Detected \"%s\" card at slot #%i\n", in plx_pci_add_card()
630 ci->name, PCI_SLOT(pdev->devfn)); in plx_pci_add_card()
636 return -ENOMEM; in plx_pci_add_card()
641 card->channels = 0; in plx_pci_add_card()
644 addr = pci_iomap(pdev, ci->conf_map.bar, ci->conf_map.size); in plx_pci_add_card()
646 err = -ENOMEM; in plx_pci_add_card()
647 dev_err(&pdev->dev, "Failed to remap configuration space " in plx_pci_add_card()
648 "(BAR%d)\n", ci->conf_map.bar); in plx_pci_add_card()
651 card->conf_addr = addr + ci->conf_map.offset; in plx_pci_add_card()
653 ci->reset_func(pdev); in plx_pci_add_card()
654 card->reset_func = ci->reset_func; in plx_pci_add_card()
657 for (i = 0; i < ci->channel_count; i++) { in plx_pci_add_card()
658 struct plx_pci_channel_map *cm = &ci->chan_map_tbl[i]; in plx_pci_add_card()
662 err = -ENOMEM; in plx_pci_add_card()
666 card->net_dev[i] = dev; in plx_pci_add_card()
668 priv->priv = card; in plx_pci_add_card()
669 priv->irq_flags = IRQF_SHARED; in plx_pci_add_card()
671 dev->irq = pdev->irq; in plx_pci_add_card()
675 * This is device-dependent mapping in plx_pci_add_card()
677 addr = pci_iomap(pdev, cm->bar, cm->size); in plx_pci_add_card()
679 err = -ENOMEM; in plx_pci_add_card()
680 dev_err(&pdev->dev, "Failed to remap BAR%d\n", cm->bar); in plx_pci_add_card()
684 priv->reg_base = addr + cm->offset; in plx_pci_add_card()
685 priv->read_reg = plx_pci_read_reg; in plx_pci_add_card()
686 priv->write_reg = plx_pci_write_reg; in plx_pci_add_card()
690 priv->can.clock.freq = ci->can_clock; in plx_pci_add_card()
691 priv->ocr = ci->ocr; in plx_pci_add_card()
692 priv->cdr = ci->cdr; in plx_pci_add_card()
694 SET_NETDEV_DEV(dev, &pdev->dev); in plx_pci_add_card()
695 dev->dev_id = i; in plx_pci_add_card()
700 dev_err(&pdev->dev, "Registering device failed " in plx_pci_add_card()
705 card->channels++; in plx_pci_add_card()
707 dev_info(&pdev->dev, "Channel #%d at 0x%p, irq %d " in plx_pci_add_card()
708 "registered as %s\n", i + 1, priv->reg_base, in plx_pci_add_card()
709 dev->irq, dev->name); in plx_pci_add_card()
711 dev_err(&pdev->dev, "Channel #%d not detected\n", in plx_pci_add_card()
714 card->net_dev[i] = NULL; in plx_pci_add_card()
718 if (!card->channels) { in plx_pci_add_card()
719 err = -ENODEV; in plx_pci_add_card()
724 * Enable interrupts from PCI-card (PLX90xx) and enable Local_1, in plx_pci_add_card()
727 if (pdev->device != PCI_DEVICE_ID_PLX_9056 && in plx_pci_add_card()
728 pdev->device != MARATHON_PCIE_DEVICE_ID) { in plx_pci_add_card()
729 val = ioread32(card->conf_addr + PLX_INTCSR); in plx_pci_add_card()
730 if (pdev->subsystem_vendor == PCI_VENDOR_ID_ESDGMBH) in plx_pci_add_card()
734 iowrite32(val, card->conf_addr + PLX_INTCSR); in plx_pci_add_card()
737 card->conf_addr + PLX9056_INTCSR); in plx_pci_add_card()
742 dev_err(&pdev->dev, "Error: %d. Cleaning Up.\n", err); in plx_pci_add_card()