Lines Matching +full:cdr +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2010-2012 Stephane Grosjean <s.grosjean@peak-system.com>
5 * CAN driver for PEAK-System PCAN-PC Card
7 * Copyright (C) 2006-2010 PEAK System-Technik GmbH
22 MODULE_AUTHOR("Stephane Grosjean <s.grosjean@peak-system.com>");
23 MODULE_DESCRIPTION("CAN driver for PEAK-System PCAN-PC Cards");
26 /* PEAK-System PCMCIA driver name */
117 * This means normal output mode, push-pull and the correct polarity.
122 * In the CDR register, you should set CBP to 1.
135 /* PCAN-PC Card private structure */
161 if (!timer_pending(&card->led_timer)) in pcan_start_led_timer()
162 mod_timer(&card->led_timer, jiffies + HZ); in pcan_start_led_timer()
170 del_timer_sync(&card->led_timer); in pcan_stop_led_timer()
178 return ioread8(priv->reg_base + port); in pcan_read_canreg()
186 struct pcan_pccard *card = priv->priv; in pcan_write_canreg()
187 int c = (priv->reg_base - card->ioport_addr) / PCC_CHAN_SIZE; in pcan_write_canreg()
193 /* Reset Mode: set led on */ in pcan_write_canreg()
197 /* Normal Mode: led slow blinking and start led timer */ in pcan_write_canreg()
205 iowrite8(v, priv->reg_base + port); in pcan_write_canreg()
213 return ioread8(card->ioport_addr + PCC_COMN_OFF + port); in pcan_read_reg()
223 if (card->ccr == v) in pcan_write_reg()
225 card->ccr = v; in pcan_write_reg()
228 iowrite8(v, card->ioport_addr + PCC_COMN_OFF + port); in pcan_write_reg()
237 return ((pcan_read_reg(card, PCC_FW_MAJOR) == card->fw_major) && in pcan_pccard_present()
238 (pcan_read_reg(card, PCC_FW_MINOR) == card->fw_minor)); in pcan_pccard_present()
252 return -EBUSY; in pcan_wait_spi_busy()
288 dev_err(&card->pdev->dev, in pcan_write_eeprom()
290 return -EIO; in pcan_write_eeprom()
321 dev_err(&card->pdev->dev, in pcan_write_eeprom()
323 return -EIO; in pcan_write_eeprom()
335 dev_err(&card->pdev->dev, in pcan_write_eeprom()
343 u8 ccr = card->ccr; in pcan_set_leds()
346 for (i = 0; i < card->chan_count; i++) in pcan_set_leds()
367 dev_err(&card->pdev->dev, in pcan_set_can_power()
382 ccr = card->ccr; in pcan_led_timer()
383 for (i = 0; i < card->chan_count; i++) { in pcan_led_timer()
388 netdev = card->channel[i].netdev; in pcan_led_timer()
389 if (!netdev || !(netdev->flags & IFF_UP)) in pcan_led_timer()
399 if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) { in pcan_led_timer()
400 card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes; in pcan_led_timer()
404 if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) { in pcan_led_timer()
405 card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes; in pcan_led_timer()
416 mod_timer(&card->led_timer, jiffies + HZ); in pcan_led_timer()
434 for (i = 0; i < card->chan_count; i++) { in pcan_isr()
450 netdev = card->channel[i].netdev; in pcan_isr()
471 for (i = 0; i < card->chan_count; i++) { in pcan_free_channels()
477 netdev = card->channel[i].netdev; in pcan_free_channels()
481 strscpy(name, netdev->name, IFNAMSIZ); in pcan_free_channels()
487 dev_info(&card->pdev->dev, "%s removed\n", name); in pcan_free_channels()
502 /* make sure SJA1000 is in reset mode */ in pcan_channel_present()
506 /* read reset-values */ in pcan_channel_present()
515 struct pcmcia_device *pdev = card->pdev; in pcan_add_channels()
520 card->ccr = ~ccr; in pcan_add_channels()
530 for (i = 0; i < ARRAY_SIZE(card->channel); i++) { in pcan_add_channels()
536 err = -ENOMEM; in pcan_add_channels()
542 priv->priv = card; in pcan_add_channels()
543 SET_NETDEV_DEV(netdev, &pdev->dev); in pcan_add_channels()
544 netdev->dev_id = i; in pcan_add_channels()
546 priv->irq_flags = IRQF_SHARED; in pcan_add_channels()
547 netdev->irq = pdev->irq; in pcan_add_channels()
548 priv->reg_base = card->ioport_addr + PCC_CHAN_OFF(i); in pcan_add_channels()
552 dev_err(&pdev->dev, "channel %d not present\n", i); in pcan_add_channels()
557 priv->read_reg = pcan_read_canreg; in pcan_add_channels()
558 priv->write_reg = pcan_write_canreg; in pcan_add_channels()
559 priv->can.clock.freq = PCC_CAN_CLOCK; in pcan_add_channels()
560 priv->ocr = PCC_OCR; in pcan_add_channels()
561 priv->cdr = PCC_CDR; in pcan_add_channels()
565 priv->cdr |= CDR_CLK_OFF; in pcan_add_channels()
567 priv->flags |= SJA1000_CUSTOM_IRQ_HANDLER; in pcan_add_channels()
576 card->channel[i].netdev = netdev; in pcan_add_channels()
577 card->chan_count++; in pcan_add_channels()
582 dev_info(&pdev->dev, in pcan_add_channels()
584 netdev->name, i, priv->reg_base, pdev->irq); in pcan_add_channels()
595 pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; in pcan_conf_check()
596 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; /* only */ in pcan_conf_check()
597 pdev->io_lines = 10; in pcan_conf_check()
608 struct pcan_pccard *card = pdev->priv; in pcan_free()
613 free_irq(pdev->irq, card); in pcan_free()
618 ioport_unmap(card->ioport_addr); in pcan_free()
621 pdev->priv = NULL; in pcan_free()
625 * setup PCMCIA socket and probe for PEAK-System PC-CARD
632 pdev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; in pcan_probe()
636 dev_err(&pdev->dev, "pcmcia_loop_config() error %d\n", err); in pcan_probe()
640 if (!pdev->irq) { in pcan_probe()
641 dev_err(&pdev->dev, "no irq assigned\n"); in pcan_probe()
642 err = -ENODEV; in pcan_probe()
648 dev_err(&pdev->dev, "pcmcia_enable_device failed err=%d\n", in pcan_probe()
655 err = -ENOMEM; in pcan_probe()
659 card->pdev = pdev; in pcan_probe()
660 pdev->priv = card; in pcan_probe()
663 card->ioport_addr = ioport_map(pdev->resource[0]->start, in pcan_probe()
664 resource_size(pdev->resource[0])); in pcan_probe()
665 if (!card->ioport_addr) { in pcan_probe()
666 dev_err(&pdev->dev, "couldn't map io port into io memory\n"); in pcan_probe()
667 err = -ENOMEM; in pcan_probe()
670 card->fw_major = pcan_read_reg(card, PCC_FW_MAJOR); in pcan_probe()
671 card->fw_minor = pcan_read_reg(card, PCC_FW_MINOR); in pcan_probe()
674 dev_info(&pdev->dev, "PEAK-System pcmcia card %s fw %d.%d\n", in pcan_probe()
675 pdev->prod_id[1] ? pdev->prod_id[1] : "PCAN-PC Card", in pcan_probe()
676 card->fw_major, card->fw_minor); in pcan_probe()
680 if (!card->chan_count) { in pcan_probe()
681 err = -ENOMEM; in pcan_probe()
686 timer_setup(&card->led_timer, pcan_led_timer, 0); in pcan_probe()
689 err = request_irq(pdev->irq, &pcan_isr, IRQF_SHARED, PCC_NAME, card); in pcan_probe()
691 dev_err(&pdev->dev, "couldn't request irq%d\n", pdev->irq); in pcan_probe()
705 ioport_unmap(card->ioport_addr); in pcan_probe()
709 pdev->priv = NULL; in pcan_probe()