Lines Matching +full:card +full:- +full:detect +full:- +full:delay
1 // SPDX-License-Identifier: GPL-2.0
12 #include <linux/delay.h>
58 return readb(priv->reg_base + port); in f81601_pci_read_reg()
64 struct f81601_pci_card *card = priv->priv; in f81601_pci_write_reg() local
67 spin_lock_irqsave(&card->lock, flags); in f81601_pci_write_reg()
68 writeb(val, priv->reg_base + port); in f81601_pci_write_reg()
69 readb(priv->reg_base); in f81601_pci_write_reg()
70 spin_unlock_irqrestore(&card->lock, flags); in f81601_pci_write_reg()
75 struct f81601_pci_card *card = pci_get_drvdata(pdev); in f81601_pci_remove() local
79 for (i = 0; i < ARRAY_SIZE(card->net_dev); i++) { in f81601_pci_remove()
80 dev = card->net_dev[i]; in f81601_pci_remove()
84 dev_info(&pdev->dev, "%s: Removing %s\n", __func__, dev->name); in f81601_pci_remove()
92 * available CAN channel to SJA1000 Socket-CAN subsystem.
99 struct f81601_pci_card *card; in f81601_pci_probe() local
104 dev_err(&pdev->dev, "Failed to enable PCI device\n"); in f81601_pci_probe()
105 return -ENODEV; in f81601_pci_probe()
108 dev_info(&pdev->dev, "Detected card at slot #%i\n", in f81601_pci_probe()
109 PCI_SLOT(pdev->devfn)); in f81601_pci_probe()
111 card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); in f81601_pci_probe()
112 if (!card) in f81601_pci_probe()
113 return -ENOMEM; in f81601_pci_probe()
115 card->dev = pdev; in f81601_pci_probe()
116 spin_lock_init(&card->lock); in f81601_pci_probe()
118 pci_set_drvdata(pdev, card); in f81601_pci_probe()
126 dev_info(&pdev->dev, in f81601_pci_probe()
129 dev_info(&pdev->dev, in f81601_pci_probe()
136 card->addr = pcim_iomap(pdev, 0, pci_resource_len(pdev, 0)); in f81601_pci_probe()
138 if (!card->addr) { in f81601_pci_probe()
139 err = -ENOMEM; in f81601_pci_probe()
140 dev_err(&pdev->dev, "%s: Failed to remap BAR\n", __func__); in f81601_pci_probe()
144 /* read CAN2_HW_EN strap pin to detect how many CANBUS do we have */ in f81601_pci_probe()
145 count = ARRAY_SIZE(card->net_dev); in f81601_pci_probe()
153 err = -ENOMEM; in f81601_pci_probe()
158 priv->priv = card; in f81601_pci_probe()
159 priv->irq_flags = IRQF_SHARED; in f81601_pci_probe()
160 priv->reg_base = card->addr + 0x80 * i; in f81601_pci_probe()
161 priv->read_reg = f81601_pci_read_reg; in f81601_pci_probe()
162 priv->write_reg = f81601_pci_write_reg; in f81601_pci_probe()
165 priv->can.clock.freq = 24000000 / 2; in f81601_pci_probe()
167 priv->can.clock.freq = external_clk / 2; in f81601_pci_probe()
169 priv->ocr = OCR_TX0_PUSHPULL | OCR_TX1_PUSHPULL; in f81601_pci_probe()
170 priv->cdr = CDR_CBP; in f81601_pci_probe()
172 SET_NETDEV_DEV(dev, &pdev->dev); in f81601_pci_probe()
173 dev->dev_id = i; in f81601_pci_probe()
174 dev->irq = pdev->irq; in f81601_pci_probe()
179 dev_err(&pdev->dev, in f81601_pci_probe()
186 card->net_dev[i] = dev; in f81601_pci_probe()
187 dev_info(&pdev->dev, "Channel #%d, %s at 0x%p, irq %d\n", i, in f81601_pci_probe()
188 dev->name, priv->reg_base, dev->irq); in f81601_pci_probe()
194 dev_err(&pdev->dev, "%s: failed: %d. Cleaning Up.\n", __func__, err); in f81601_pci_probe()