Lines Matching +full:cdr +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (C) 2008 Markus Plessing <plessing@ems-wuensche.com>
5 * Copyright (C) 2008 Sebastian Haas <haas@ems-wuensche.com>
23 MODULE_AUTHOR("Sebastian Haas <support@ems-wuensche.com>");
24 MODULE_AUTHOR("Gerhard Uttenthaler <uttenthaler@ems-wuensche.com>");
25 MODULE_DESCRIPTION("Socket-CAN driver for EMS CPC-PCI/PCIe/104P CAN cards");
48 * PSB4610 PITA-2 bridge control registers
80 * This means normal output mode, push-pull and the correct polarity.
84 /* In the CDR register, you should set CBP to 1.
114 /* CPC-PCI v1 */
116 /* CPC-PCI v2 */
118 /* CPC-104P v2 */
120 /* CPC-PCIe v3 */
130 return readb(card->base_addr + (port * 4)); in ems_pci_v1_readb()
135 return readb(priv->reg_base + (port * 4)); in ems_pci_v1_read_reg()
141 writeb(val, priv->reg_base + (port * 4)); in ems_pci_v1_write_reg()
146 struct ems_pci_card *card = priv->priv; in ems_pci_v1_post_irq()
150 card->conf_addr + PITA2_ICR); in ems_pci_v1_post_irq()
155 return readb(priv->reg_base + port); in ems_pci_v2_read_reg()
161 writeb(val, priv->reg_base + port); in ems_pci_v2_write_reg()
166 struct ems_pci_card *card = priv->priv; in ems_pci_v2_post_irq()
168 writel(PLX_ICSR_ENA_CLR, card->conf_addr + PLX_ICSR); in ems_pci_v2_post_irq()
173 return readb(priv->reg_base + port); in ems_pci_v3_read_reg()
179 writeb(val, priv->reg_base + port); in ems_pci_v3_write_reg()
184 struct ems_pci_card *card = priv->priv; in ems_pci_v3_post_irq()
186 writel(ASIX_LINTSR_INT0AC, card->conf_addr + ASIX_LINTSR); in ems_pci_v3_post_irq()
190 * by trying to set 'em into the PeliCAN mode
196 /* Make sure SJA1000 is in reset mode */ in ems_pci_check_chan()
197 priv->write_reg(priv, SJA1000_MOD, 1); in ems_pci_check_chan()
199 priv->write_reg(priv, SJA1000_CDR, CDR_PELICAN); in ems_pci_check_chan()
201 /* read reset-values */ in ems_pci_check_chan()
202 res = priv->read_reg(priv, SJA1000_CDR); in ems_pci_check_chan()
216 for (i = 0; i < card->channels; i++) { in ems_pci_del_card()
217 dev = card->net_dev[i]; in ems_pci_del_card()
222 dev_info(&pdev->dev, "Removing %s.\n", dev->name); in ems_pci_del_card()
227 if (card->base_addr) in ems_pci_del_card()
228 pci_iounmap(card->pci_dev, card->base_addr); in ems_pci_del_card()
230 if (card->conf_addr) in ems_pci_del_card()
231 pci_iounmap(card->pci_dev, card->conf_addr); in ems_pci_del_card()
241 writeb(0, card->base_addr); in ems_pci_card_reset()
245 * CAN channel to SJA1000 Socket-CAN subsystem.
258 dev_err(&pdev->dev, "Enabling PCI device failed\n"); in ems_pci_add_card()
259 return -ENODEV; in ems_pci_add_card()
266 return -ENOMEM; in ems_pci_add_card()
271 card->pci_dev = pdev; in ems_pci_add_card()
273 card->channels = 0; in ems_pci_add_card()
275 if (pdev->vendor == PCI_VENDOR_ID_ASIX) { in ems_pci_add_card()
276 card->version = 3; /* CPC-PCI v3 */ in ems_pci_add_card()
281 } else if (pdev->vendor == PCI_VENDOR_ID_PLX) { in ems_pci_add_card()
282 card->version = 2; /* CPC-PCI v2 */ in ems_pci_add_card()
288 card->version = 1; /* CPC-PCI v1 */ in ems_pci_add_card()
296 card->conf_addr = pci_iomap(pdev, conf_bar, conf_size); in ems_pci_add_card()
297 if (!card->conf_addr) { in ems_pci_add_card()
298 err = -ENOMEM; in ems_pci_add_card()
302 card->base_addr = pci_iomap(pdev, base_bar, EMS_PCI_BASE_SIZE); in ems_pci_add_card()
303 if (!card->base_addr) { in ems_pci_add_card()
304 err = -ENOMEM; in ems_pci_add_card()
308 if (card->version == 1) { in ems_pci_add_card()
309 /* Configure PITA-2 parallel interface (enable MUX) */ in ems_pci_add_card()
310 writel(PITA2_MISC_CONFIG, card->conf_addr + PITA2_MISC); in ems_pci_add_card()
318 dev_err(&pdev->dev, in ems_pci_add_card()
320 err = -ENODEV; in ems_pci_add_card()
325 if (card->version == 3) { in ems_pci_add_card()
329 writel(readl(card->conf_addr + ASIX_LIEMR) & ~ASIX_LIEMR_LRST, in ems_pci_add_card()
330 card->conf_addr + ASIX_LIEMR); in ems_pci_add_card()
339 err = -ENOMEM; in ems_pci_add_card()
343 card->net_dev[i] = dev; in ems_pci_add_card()
345 priv->priv = card; in ems_pci_add_card()
346 priv->irq_flags = IRQF_SHARED; in ems_pci_add_card()
348 dev->irq = pdev->irq; in ems_pci_add_card()
350 if (card->version == 1) { in ems_pci_add_card()
351 priv->read_reg = ems_pci_v1_read_reg; in ems_pci_add_card()
352 priv->write_reg = ems_pci_v1_write_reg; in ems_pci_add_card()
353 priv->post_irq = ems_pci_v1_post_irq; in ems_pci_add_card()
354 priv->reg_base = card->base_addr + EMS_PCI_V1_CAN_BASE_OFFSET in ems_pci_add_card()
356 } else if (card->version == 2) { in ems_pci_add_card()
357 priv->read_reg = ems_pci_v2_read_reg; in ems_pci_add_card()
358 priv->write_reg = ems_pci_v2_write_reg; in ems_pci_add_card()
359 priv->post_irq = ems_pci_v2_post_irq; in ems_pci_add_card()
360 priv->reg_base = card->base_addr + EMS_PCI_V2_CAN_BASE_OFFSET in ems_pci_add_card()
363 priv->read_reg = ems_pci_v3_read_reg; in ems_pci_add_card()
364 priv->write_reg = ems_pci_v3_write_reg; in ems_pci_add_card()
365 priv->post_irq = ems_pci_v3_post_irq; in ems_pci_add_card()
366 priv->reg_base = card->base_addr + EMS_PCI_V3_CAN_BASE_OFFSET in ems_pci_add_card()
372 priv->can.clock.freq = EMS_PCI_CAN_CLOCK; in ems_pci_add_card()
373 priv->ocr = EMS_PCI_OCR; in ems_pci_add_card()
374 priv->cdr = EMS_PCI_CDR; in ems_pci_add_card()
376 SET_NETDEV_DEV(dev, &pdev->dev); in ems_pci_add_card()
377 dev->dev_id = i; in ems_pci_add_card()
379 if (card->version == 1) { in ems_pci_add_card()
382 card->conf_addr + PITA2_ICR); in ems_pci_add_card()
383 } else if (card->version == 2) { in ems_pci_add_card()
386 card->conf_addr + PLX_ICSR); in ems_pci_add_card()
389 writel(ASIX_LINTSR_INT0AC, card->conf_addr + ASIX_LINTSR); in ems_pci_add_card()
391 writel(readl(card->conf_addr + ASIX_LIEMR) | ASIX_LIEMR_L0EINTEN, in ems_pci_add_card()
392 card->conf_addr + ASIX_LIEMR); in ems_pci_add_card()
398 dev_err(&pdev->dev, in ems_pci_add_card()
405 card->channels++; in ems_pci_add_card()
407 dev_info(&pdev->dev, "Channel #%d at 0x%p, irq %d\n", in ems_pci_add_card()
408 i + 1, priv->reg_base, dev->irq); in ems_pci_add_card()
417 dev_err(&pdev->dev, "Error: %d. Cleaning Up.\n", err); in ems_pci_add_card()