Lines Matching +full:data +full:- +full:bus
1 // SPDX-License-Identifier: GPL-2.0
33 static int moxart_mdio_read(struct mii_bus *bus, int mii_id, int regnum) in moxart_mdio_read() argument
35 struct moxart_mdio_data *data = bus->priv; in moxart_mdio_read() local
39 dev_dbg(&bus->dev, "%s\n", __func__); in moxart_mdio_read()
44 writel(ctrl, data->base + REG_PHY_CTRL); in moxart_mdio_read()
47 ctrl = readl(data->base + REG_PHY_CTRL); in moxart_mdio_read()
53 count--; in moxart_mdio_read()
56 dev_dbg(&bus->dev, "%s timed out\n", __func__); in moxart_mdio_read()
58 return -ETIMEDOUT; in moxart_mdio_read()
61 static int moxart_mdio_write(struct mii_bus *bus, int mii_id, in moxart_mdio_write() argument
64 struct moxart_mdio_data *data = bus->priv; in moxart_mdio_write() local
68 dev_dbg(&bus->dev, "%s\n", __func__); in moxart_mdio_write()
75 writel(value, data->base + REG_PHY_WRITE_DATA); in moxart_mdio_write()
76 writel(ctrl, data->base + REG_PHY_CTRL); in moxart_mdio_write()
79 ctrl = readl(data->base + REG_PHY_CTRL); in moxart_mdio_write()
85 count--; in moxart_mdio_write()
88 dev_dbg(&bus->dev, "%s timed out\n", __func__); in moxart_mdio_write()
90 return -ETIMEDOUT; in moxart_mdio_write()
93 static int moxart_mdio_reset(struct mii_bus *bus) in moxart_mdio_reset() argument
95 int data, i; in moxart_mdio_reset() local
98 data = moxart_mdio_read(bus, i, MII_BMCR); in moxart_mdio_reset()
99 if (data < 0) in moxart_mdio_reset()
102 data |= BMCR_RESET; in moxart_mdio_reset()
103 if (moxart_mdio_write(bus, i, MII_BMCR, data) < 0) in moxart_mdio_reset()
112 struct device_node *np = pdev->dev.of_node; in moxart_mdio_probe()
113 struct mii_bus *bus; in moxart_mdio_probe() local
114 struct moxart_mdio_data *data; in moxart_mdio_probe() local
117 bus = mdiobus_alloc_size(sizeof(*data)); in moxart_mdio_probe()
118 if (!bus) in moxart_mdio_probe()
119 return -ENOMEM; in moxart_mdio_probe()
121 bus->name = "MOXA ART Ethernet MII"; in moxart_mdio_probe()
122 bus->read = &moxart_mdio_read; in moxart_mdio_probe()
123 bus->write = &moxart_mdio_write; in moxart_mdio_probe()
124 bus->reset = &moxart_mdio_reset; in moxart_mdio_probe()
125 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-%d-mii", pdev->name, pdev->id); in moxart_mdio_probe()
126 bus->parent = &pdev->dev; in moxart_mdio_probe()
136 bus->irq[i] = PHY_MAC_INTERRUPT; in moxart_mdio_probe()
138 data = bus->priv; in moxart_mdio_probe()
139 data->base = devm_platform_ioremap_resource(pdev, 0); in moxart_mdio_probe()
140 if (IS_ERR(data->base)) { in moxart_mdio_probe()
141 ret = PTR_ERR(data->base); in moxart_mdio_probe()
145 ret = of_mdiobus_register(bus, np); in moxart_mdio_probe()
149 platform_set_drvdata(pdev, bus); in moxart_mdio_probe()
154 mdiobus_free(bus); in moxart_mdio_probe()
160 struct mii_bus *bus = platform_get_drvdata(pdev); in moxart_mdio_remove() local
162 mdiobus_unregister(bus); in moxart_mdio_remove()
163 mdiobus_free(bus); in moxart_mdio_remove()
167 { .compatible = "moxa,moxart-mdio" },
176 .name = "moxart-mdio",