Lines Matching +full:cdr +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
28 MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
43 return ioread8(priv->reg_base + reg); in sp_read_reg8()
48 iowrite8(val, priv->reg_base + reg); in sp_write_reg8()
53 return ioread8(priv->reg_base + reg * 2); in sp_read_reg16()
58 iowrite8(val, priv->reg_base + reg * 2); in sp_write_reg16()
63 return ioread8(priv->reg_base + reg * 4); in sp_read_reg32()
68 iowrite8(val, priv->reg_base + reg * 4); in sp_write_reg32()
73 struct technologic_priv *tp = priv->priv; in sp_technologic_read_reg16()
77 spin_lock_irqsave(&tp->io_lock, flags); in sp_technologic_read_reg16()
78 iowrite16(reg, priv->reg_base + 0); in sp_technologic_read_reg16()
79 val = ioread16(priv->reg_base + 2); in sp_technologic_read_reg16()
80 spin_unlock_irqrestore(&tp->io_lock, flags); in sp_technologic_read_reg16()
88 struct technologic_priv *tp = priv->priv; in sp_technologic_write_reg16()
91 spin_lock_irqsave(&tp->io_lock, flags); in sp_technologic_write_reg16()
92 iowrite16(reg, priv->reg_base + 0); in sp_technologic_write_reg16()
93 iowrite16(val, priv->reg_base + 2); in sp_technologic_write_reg16()
94 spin_unlock_irqrestore(&tp->io_lock, flags); in sp_technologic_write_reg16()
99 struct technologic_priv *tp = priv->priv; in sp_technologic_init()
101 priv->read_reg = sp_technologic_read_reg16; in sp_technologic_init()
102 priv->write_reg = sp_technologic_write_reg16; in sp_technologic_init()
103 spin_lock_init(&tp->io_lock); in sp_technologic_init()
108 priv->flags = SJA1000_QUIRK_NO_CDR_REG | SJA1000_QUIRK_RESET_ON_OVERRUN; in sp_rzn1_init()
116 priv->can.clock.freq = pdata->osc_freq / 2; in sp_populate()
117 priv->ocr = pdata->ocr; in sp_populate()
118 priv->cdr = pdata->cdr; in sp_populate()
122 priv->read_reg = sp_read_reg32; in sp_populate()
123 priv->write_reg = sp_write_reg32; in sp_populate()
126 priv->read_reg = sp_read_reg16; in sp_populate()
127 priv->write_reg = sp_write_reg16; in sp_populate()
131 priv->read_reg = sp_read_reg8; in sp_populate()
132 priv->write_reg = sp_write_reg8; in sp_populate()
142 err = of_property_read_u32(of, "reg-io-width", &prop); in sp_populate_of()
148 priv->read_reg = sp_read_reg32; in sp_populate_of()
149 priv->write_reg = sp_write_reg32; in sp_populate_of()
152 priv->read_reg = sp_read_reg16; in sp_populate_of()
153 priv->write_reg = sp_write_reg16; in sp_populate_of()
157 priv->read_reg = sp_read_reg8; in sp_populate_of()
158 priv->write_reg = sp_write_reg8; in sp_populate_of()
161 if (!priv->can.clock.freq) { in sp_populate_of()
162 err = of_property_read_u32(of, "nxp,external-clock-frequency", &prop); in sp_populate_of()
164 priv->can.clock.freq = prop / 2; in sp_populate_of()
166 priv->can.clock.freq = SP_CAN_CLOCK; /* default */ in sp_populate_of()
169 err = of_property_read_u32(of, "nxp,tx-output-mode", &prop); in sp_populate_of()
171 priv->ocr |= prop & OCR_MODE_MASK; in sp_populate_of()
173 priv->ocr |= OCR_MODE_NORMAL; /* default */ in sp_populate_of()
175 err = of_property_read_u32(of, "nxp,tx-output-config", &prop); in sp_populate_of()
177 priv->ocr |= (prop << OCR_TX_SHIFT) & OCR_TX_MASK; in sp_populate_of()
179 priv->ocr |= OCR_TX0_PULLDOWN; /* default */ in sp_populate_of()
181 err = of_property_read_u32(of, "nxp,clock-out-frequency", &prop); in sp_populate_of()
183 u32 divider = priv->can.clock.freq * 2 / prop; in sp_populate_of()
186 priv->cdr |= divider / 2 - 1; in sp_populate_of()
188 priv->cdr |= CDR_CLKOUT_MASK; in sp_populate_of()
190 priv->cdr |= CDR_CLK_OFF; /* default */ in sp_populate_of()
193 if (!of_property_read_bool(of, "nxp,no-comparator-bypass")) in sp_populate_of()
194 priv->cdr |= CDR_CBP; /* default */ in sp_populate_of()
208 { .compatible = "renesas,rzn1-sja1000", .data = &renesas_data, },
222 struct device_node *of = pdev->dev.of_node; in sp_probe()
227 pdata = dev_get_platdata(&pdev->dev); in sp_probe()
229 dev_err(&pdev->dev, "No platform data provided!\n"); in sp_probe()
230 return -ENODEV; in sp_probe()
235 return -ENODEV; in sp_probe()
237 if (!devm_request_mem_region(&pdev->dev, res_mem->start, in sp_probe()
239 return -EBUSY; in sp_probe()
241 addr = devm_ioremap(&pdev->dev, res_mem->start, in sp_probe()
244 return -ENOMEM; in sp_probe()
251 clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); in sp_probe()
253 return dev_err_probe(&pdev->dev, PTR_ERR(clk), in sp_probe()
258 return -ENODEV; in sp_probe()
261 of_data = device_get_match_data(&pdev->dev); in sp_probe()
263 priv_sz = of_data->priv_sz; in sp_probe()
267 return -ENOMEM; in sp_probe()
271 irq = res_irq->start; in sp_probe()
272 priv->irq_flags = res_irq->flags & IRQF_TRIGGER_MASK; in sp_probe()
273 if (res_irq->flags & IORESOURCE_IRQ_SHAREABLE) in sp_probe()
274 priv->irq_flags |= IRQF_SHARED; in sp_probe()
276 priv->irq_flags = IRQF_SHARED; in sp_probe()
279 if (priv->flags & SJA1000_QUIRK_RESET_ON_OVERRUN) in sp_probe()
280 priv->irq_flags |= IRQF_ONESHOT; in sp_probe()
282 dev->irq = irq; in sp_probe()
283 priv->reg_base = addr; in sp_probe()
287 priv->can.clock.freq = clk_get_rate(clk) / 2; in sp_probe()
288 if (!priv->can.clock.freq) { in sp_probe()
289 err = -EINVAL; in sp_probe()
290 dev_err(&pdev->dev, "Zero CAN clk rate"); in sp_probe()
297 if (of_data && of_data->init) in sp_probe()
298 of_data->init(priv, of); in sp_probe()
300 sp_populate(priv, pdata, res_mem->flags); in sp_probe()
304 SET_NETDEV_DEV(dev, &pdev->dev); in sp_probe()
308 dev_err(&pdev->dev, "registering %s failed (err=%d)\n", in sp_probe()
313 dev_info(&pdev->dev, "%s device registered (reg_base=%p, irq=%d)\n", in sp_probe()
314 DRV_NAME, priv->reg_base, dev->irq); in sp_probe()