Lines Matching refs:dev

90 	struct orion_mdio_dev *dev = bus->priv;  in orion_mdio_wait_ready()  local
94 if (dev->err_interrupt <= 0) { in orion_mdio_wait_ready()
96 MVMDIO_SMI_TIMEOUT, false, dev)) in orion_mdio_wait_ready()
105 if (wait_event_timeout(dev->smi_busy_wait, in orion_mdio_wait_ready()
106 ops->is_done(dev), timeout)) in orion_mdio_wait_ready()
114 static int orion_mdio_smi_is_done(struct orion_mdio_dev *dev) in orion_mdio_smi_is_done() argument
116 return !(readl(dev->regs) & MVMDIO_SMI_BUSY); in orion_mdio_smi_is_done()
126 struct orion_mdio_dev *dev = bus->priv; in orion_mdio_smi_read() local
137 dev->regs); in orion_mdio_smi_read()
143 val = readl(dev->regs); in orion_mdio_smi_read()
155 struct orion_mdio_dev *dev = bus->priv; in orion_mdio_smi_write() local
166 dev->regs); in orion_mdio_smi_write()
171 static int orion_mdio_xsmi_is_done(struct orion_mdio_dev *dev) in orion_mdio_xsmi_is_done() argument
173 return !(readl(dev->regs + MVMDIO_XSMI_MGNT_REG) & MVMDIO_XSMI_BUSY); in orion_mdio_xsmi_is_done()
183 struct orion_mdio_dev *dev = bus->priv; in orion_mdio_xsmi_read_c45() local
190 writel(regnum, dev->regs + MVMDIO_XSMI_ADDR_REG); in orion_mdio_xsmi_read_c45()
194 dev->regs + MVMDIO_XSMI_MGNT_REG); in orion_mdio_xsmi_read_c45()
200 if (!(readl(dev->regs + MVMDIO_XSMI_MGNT_REG) & in orion_mdio_xsmi_read_c45()
206 return readl(dev->regs + MVMDIO_XSMI_MGNT_REG) & GENMASK(15, 0); in orion_mdio_xsmi_read_c45()
212 struct orion_mdio_dev *dev = bus->priv; in orion_mdio_xsmi_write_c45() local
219 writel(regnum, dev->regs + MVMDIO_XSMI_ADDR_REG); in orion_mdio_xsmi_write_c45()
223 dev->regs + MVMDIO_XSMI_MGNT_REG); in orion_mdio_xsmi_write_c45()
230 struct orion_mdio_dev *dev = dev_id; in orion_mdio_err_irq() local
232 if (readl(dev->regs + MVMDIO_ERR_INT_CAUSE) & in orion_mdio_err_irq()
235 dev->regs + MVMDIO_ERR_INT_CAUSE); in orion_mdio_err_irq()
236 wake_up(&dev->smi_busy_wait); in orion_mdio_err_irq()
248 struct orion_mdio_dev *dev; in orion_mdio_probe() local
251 type = (uintptr_t)device_get_match_data(&pdev->dev); in orion_mdio_probe()
255 dev_err(&pdev->dev, "No SMI register address given\n"); in orion_mdio_probe()
259 bus = devm_mdiobus_alloc_size(&pdev->dev, in orion_mdio_probe()
277 dev_name(&pdev->dev)); in orion_mdio_probe()
278 bus->parent = &pdev->dev; in orion_mdio_probe()
280 dev = bus->priv; in orion_mdio_probe()
281 dev->regs = devm_ioremap(&pdev->dev, r->start, resource_size(r)); in orion_mdio_probe()
282 if (!dev->regs) { in orion_mdio_probe()
283 dev_err(&pdev->dev, "Unable to remap SMI register\n"); in orion_mdio_probe()
287 init_waitqueue_head(&dev->smi_busy_wait); in orion_mdio_probe()
289 if (pdev->dev.of_node) { in orion_mdio_probe()
290 for (i = 0; i < ARRAY_SIZE(dev->clk); i++) { in orion_mdio_probe()
291 dev->clk[i] = of_clk_get(pdev->dev.of_node, i); in orion_mdio_probe()
292 if (PTR_ERR(dev->clk[i]) == -EPROBE_DEFER) { in orion_mdio_probe()
296 if (IS_ERR(dev->clk[i])) in orion_mdio_probe()
298 clk_prepare_enable(dev->clk[i]); in orion_mdio_probe()
301 if (!IS_ERR(of_clk_get(pdev->dev.of_node, in orion_mdio_probe()
302 ARRAY_SIZE(dev->clk)))) in orion_mdio_probe()
303 dev_warn(&pdev->dev, in orion_mdio_probe()
305 __stringify(ARRAY_SIZE(dev->clk)) "\n"); in orion_mdio_probe()
307 dev->clk[0] = clk_get(&pdev->dev, NULL); in orion_mdio_probe()
308 if (PTR_ERR(dev->clk[0]) == -EPROBE_DEFER) { in orion_mdio_probe()
312 if (!IS_ERR(dev->clk[0])) in orion_mdio_probe()
313 clk_prepare_enable(dev->clk[0]); in orion_mdio_probe()
317 dev->err_interrupt = platform_get_irq_optional(pdev, 0); in orion_mdio_probe()
318 if (dev->err_interrupt > 0 && in orion_mdio_probe()
320 dev_err(&pdev->dev, in orion_mdio_probe()
322 dev->err_interrupt = 0; in orion_mdio_probe()
324 if (dev->err_interrupt > 0) { in orion_mdio_probe()
325 ret = devm_request_irq(&pdev->dev, dev->err_interrupt, in orion_mdio_probe()
327 IRQF_SHARED, pdev->name, dev); in orion_mdio_probe()
332 dev->regs + MVMDIO_ERR_INT_MASK); in orion_mdio_probe()
334 } else if (dev->err_interrupt == -EPROBE_DEFER) { in orion_mdio_probe()
342 if (is_acpi_node(pdev->dev.fwnode)) in orion_mdio_probe()
343 ret = acpi_mdiobus_register(bus, pdev->dev.fwnode); in orion_mdio_probe()
345 ret = of_mdiobus_register(bus, pdev->dev.of_node); in orion_mdio_probe()
347 dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret); in orion_mdio_probe()
356 if (dev->err_interrupt > 0) in orion_mdio_probe()
357 writel(0, dev->regs + MVMDIO_ERR_INT_MASK); in orion_mdio_probe()
360 for (i = 0; i < ARRAY_SIZE(dev->clk); i++) { in orion_mdio_probe()
361 if (IS_ERR(dev->clk[i])) in orion_mdio_probe()
363 clk_disable_unprepare(dev->clk[i]); in orion_mdio_probe()
364 clk_put(dev->clk[i]); in orion_mdio_probe()
373 struct orion_mdio_dev *dev = bus->priv; in orion_mdio_remove() local
376 if (dev->err_interrupt > 0) in orion_mdio_remove()
377 writel(0, dev->regs + MVMDIO_ERR_INT_MASK); in orion_mdio_remove()
380 for (i = 0; i < ARRAY_SIZE(dev->clk); i++) { in orion_mdio_remove()
381 if (IS_ERR(dev->clk[i])) in orion_mdio_remove()
383 clk_disable_unprepare(dev->clk[i]); in orion_mdio_remove()
384 clk_put(dev->clk[i]); in orion_mdio_remove()