Lines Matching +full:data +full:- +full:bus
1 // SPDX-License-Identifier: GPL-2.0+
3 * Hisilicon Fast Ethernet MDIO Bus Driver
28 static int hisi_femac_mdio_wait_ready(struct hisi_femac_mdio_data *data) in hisi_femac_mdio_wait_ready() argument
32 return readl_poll_timeout(data->membase + MDIO_RWCTRL, in hisi_femac_mdio_wait_ready()
36 static int hisi_femac_mdio_read(struct mii_bus *bus, int mii_id, int regnum) in hisi_femac_mdio_read() argument
38 struct hisi_femac_mdio_data *data = bus->priv; in hisi_femac_mdio_read() local
41 ret = hisi_femac_mdio_wait_ready(data); in hisi_femac_mdio_read()
46 data->membase + MDIO_RWCTRL); in hisi_femac_mdio_read()
48 ret = hisi_femac_mdio_wait_ready(data); in hisi_femac_mdio_read()
52 return readl(data->membase + MDIO_RO_DATA) & 0xFFFF; in hisi_femac_mdio_read()
55 static int hisi_femac_mdio_write(struct mii_bus *bus, int mii_id, int regnum, in hisi_femac_mdio_write() argument
58 struct hisi_femac_mdio_data *data = bus->priv; in hisi_femac_mdio_write() local
61 ret = hisi_femac_mdio_wait_ready(data); in hisi_femac_mdio_write()
67 data->membase + MDIO_RWCTRL); in hisi_femac_mdio_write()
69 return hisi_femac_mdio_wait_ready(data); in hisi_femac_mdio_write()
74 struct device_node *np = pdev->dev.of_node; in hisi_femac_mdio_probe()
75 struct mii_bus *bus; in hisi_femac_mdio_probe() local
76 struct hisi_femac_mdio_data *data; in hisi_femac_mdio_probe() local
79 bus = mdiobus_alloc_size(sizeof(*data)); in hisi_femac_mdio_probe()
80 if (!bus) in hisi_femac_mdio_probe()
81 return -ENOMEM; in hisi_femac_mdio_probe()
83 bus->name = "hisi_femac_mii_bus"; in hisi_femac_mdio_probe()
84 bus->read = &hisi_femac_mdio_read; in hisi_femac_mdio_probe()
85 bus->write = &hisi_femac_mdio_write; in hisi_femac_mdio_probe()
86 snprintf(bus->id, MII_BUS_ID_SIZE, "%s", pdev->name); in hisi_femac_mdio_probe()
87 bus->parent = &pdev->dev; in hisi_femac_mdio_probe()
89 data = bus->priv; in hisi_femac_mdio_probe()
90 data->membase = devm_platform_ioremap_resource(pdev, 0); in hisi_femac_mdio_probe()
91 if (IS_ERR(data->membase)) { in hisi_femac_mdio_probe()
92 ret = PTR_ERR(data->membase); in hisi_femac_mdio_probe()
96 data->clk = devm_clk_get(&pdev->dev, NULL); in hisi_femac_mdio_probe()
97 if (IS_ERR(data->clk)) { in hisi_femac_mdio_probe()
98 ret = PTR_ERR(data->clk); in hisi_femac_mdio_probe()
102 ret = clk_prepare_enable(data->clk); in hisi_femac_mdio_probe()
106 ret = of_mdiobus_register(bus, np); in hisi_femac_mdio_probe()
110 platform_set_drvdata(pdev, bus); in hisi_femac_mdio_probe()
115 clk_disable_unprepare(data->clk); in hisi_femac_mdio_probe()
117 mdiobus_free(bus); in hisi_femac_mdio_probe()
123 struct mii_bus *bus = platform_get_drvdata(pdev); in hisi_femac_mdio_remove() local
124 struct hisi_femac_mdio_data *data = bus->priv; in hisi_femac_mdio_remove() local
126 mdiobus_unregister(bus); in hisi_femac_mdio_remove()
127 clk_disable_unprepare(data->clk); in hisi_femac_mdio_remove()
128 mdiobus_free(bus); in hisi_femac_mdio_remove()
132 { .compatible = "hisilicon,hisi-femac-mdio" },
141 .name = "hisi-femac-mdio",