Lines Matching +full:sun4i +full:- +full:a10 +full:- +full:mdio
1 // SPDX-License-Identifier: GPL-2.0
3 * Allwinner EMAC MDIO interface driver
5 * Copyright 2012-2013 Stefan Roese <sr@denx.de>
6 * Copyright 2013 Maxime Ripard <maxime.ripard@free-electrons.com>
38 struct sun4i_mdio_data *data = bus->priv; in sun4i_mdio_read()
43 writel((mii_id << 8) | regnum, data->membase + EMAC_MAC_MADR_REG); in sun4i_mdio_read()
45 writel(0x1, data->membase + EMAC_MAC_MCMD_REG); in sun4i_mdio_read()
49 while (readl(data->membase + EMAC_MAC_MIND_REG) & 0x1) { in sun4i_mdio_read()
51 return -ETIMEDOUT; in sun4i_mdio_read()
56 writel(0x0, data->membase + EMAC_MAC_MCMD_REG); in sun4i_mdio_read()
58 value = readl(data->membase + EMAC_MAC_MRDD_REG); in sun4i_mdio_read()
66 struct sun4i_mdio_data *data = bus->priv; in sun4i_mdio_write()
70 writel((mii_id << 8) | regnum, data->membase + EMAC_MAC_MADR_REG); in sun4i_mdio_write()
72 writel(0x1, data->membase + EMAC_MAC_MCMD_REG); in sun4i_mdio_write()
76 while (readl(data->membase + EMAC_MAC_MIND_REG) & 0x1) { in sun4i_mdio_write()
78 return -ETIMEDOUT; in sun4i_mdio_write()
83 writel(0x0, data->membase + EMAC_MAC_MCMD_REG); in sun4i_mdio_write()
85 writel(value, data->membase + EMAC_MAC_MWTD_REG); in sun4i_mdio_write()
92 struct device_node *np = pdev->dev.of_node; in sun4i_mdio_probe()
99 return -ENOMEM; in sun4i_mdio_probe()
101 bus->name = "sun4i_mii_bus"; in sun4i_mdio_probe()
102 bus->read = &sun4i_mdio_read; in sun4i_mdio_probe()
103 bus->write = &sun4i_mdio_write; in sun4i_mdio_probe()
104 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev)); in sun4i_mdio_probe()
105 bus->parent = &pdev->dev; in sun4i_mdio_probe()
107 data = bus->priv; in sun4i_mdio_probe()
108 data->membase = devm_platform_ioremap_resource(pdev, 0); in sun4i_mdio_probe()
109 if (IS_ERR(data->membase)) { in sun4i_mdio_probe()
110 ret = PTR_ERR(data->membase); in sun4i_mdio_probe()
114 data->regulator = devm_regulator_get(&pdev->dev, "phy"); in sun4i_mdio_probe()
115 if (IS_ERR(data->regulator)) { in sun4i_mdio_probe()
116 if (PTR_ERR(data->regulator) == -EPROBE_DEFER) { in sun4i_mdio_probe()
117 ret = -EPROBE_DEFER; in sun4i_mdio_probe()
121 dev_info(&pdev->dev, "no regulator found\n"); in sun4i_mdio_probe()
122 data->regulator = NULL; in sun4i_mdio_probe()
124 ret = regulator_enable(data->regulator); in sun4i_mdio_probe()
138 if (data->regulator) in sun4i_mdio_probe()
139 regulator_disable(data->regulator); in sun4i_mdio_probe()
148 struct sun4i_mdio_data *data = bus->priv; in sun4i_mdio_remove()
151 if (data->regulator) in sun4i_mdio_remove()
152 regulator_disable(data->regulator); in sun4i_mdio_remove()
157 { .compatible = "allwinner,sun4i-a10-mdio" },
160 { .compatible = "allwinner,sun4i-mdio" },
169 .name = "sun4i-mdio",
176 MODULE_DESCRIPTION("Allwinner EMAC MDIO interface driver");
177 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");