Lines Matching +full:asp +full:- +full:v2
1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2014-2017 Broadcom
17 #include <linux/platform_data/mdio-bcm-unimac.h>
50 * peripheral registers for CPU-native byte order. in unimac_mdio_readl()
53 return __raw_readl(priv->base + offset); in unimac_mdio_readl()
55 return readl_relaxed(priv->base + offset); in unimac_mdio_readl()
62 __raw_writel(val, priv->base + offset); in unimac_mdio_writel()
64 writel_relaxed(val, priv->base + offset); in unimac_mdio_writel()
93 struct unimac_mdio_priv *priv = bus->priv; in unimac_mdio_read()
97 ret = clk_prepare_enable(priv->clk); in unimac_mdio_read()
108 ret = priv->wait_func(priv->wait_func_data); in unimac_mdio_read()
115 * turn-around, e.g: Broadcom BCM53125 external switches, so check for in unimac_mdio_read()
119 if (!(bus->phy_ignore_ta_mask & 1 << phy_id) && (cmd & MDIO_READ_FAIL)) { in unimac_mdio_read()
120 ret = -EIO; in unimac_mdio_read()
126 clk_disable_unprepare(priv->clk); in unimac_mdio_read()
133 struct unimac_mdio_priv *priv = bus->priv; in unimac_mdio_write()
137 ret = clk_prepare_enable(priv->clk); in unimac_mdio_write()
148 ret = priv->wait_func(priv->wait_func_data); in unimac_mdio_write()
149 clk_disable_unprepare(priv->clk); in unimac_mdio_write()
162 * there (e.g: during system-wide power management).
164 * bus->reset is invoked before mdiobus_scan during mdiobus_register and is
166 * to read from non-existing PHYs, we either use bus->phy_mask or do a manual
171 struct device_node *np = bus->dev.of_node; in unimac_mdio_reset()
177 read_mask = ~bus->phy_mask; in unimac_mdio_reset()
180 addr = of_mdio_parse_addr(&bus->dev, child); in unimac_mdio_reset()
190 dev_dbg(&bus->dev, "Workaround for PHY @ %d\n", addr); in unimac_mdio_reset()
205 if (!priv->clk_freq) in unimac_mdio_clk_set()
208 ret = clk_prepare_enable(priv->clk); in unimac_mdio_clk_set()
212 if (!priv->clk) in unimac_mdio_clk_set()
215 rate = clk_get_rate(priv->clk); in unimac_mdio_clk_set()
217 div = (rate / (2 * priv->clk_freq)) - 1; in unimac_mdio_clk_set()
232 clk_disable_unprepare(priv->clk); in unimac_mdio_clk_set()
238 struct unimac_mdio_pdata *pdata = pdev->dev.platform_data; in unimac_mdio_probe()
245 np = pdev->dev.of_node; in unimac_mdio_probe()
247 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in unimac_mdio_probe()
249 return -ENOMEM; in unimac_mdio_probe()
253 return -EINVAL; in unimac_mdio_probe()
258 priv->base = devm_ioremap(&pdev->dev, r->start, resource_size(r)); in unimac_mdio_probe()
259 if (!priv->base) { in unimac_mdio_probe()
260 dev_err(&pdev->dev, "failed to remap register\n"); in unimac_mdio_probe()
261 return -ENOMEM; in unimac_mdio_probe()
264 if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq)) in unimac_mdio_probe()
265 priv->clk_freq = 0; in unimac_mdio_probe()
267 priv->mii_bus = mdiobus_alloc(); in unimac_mdio_probe()
268 if (!priv->mii_bus) in unimac_mdio_probe()
269 return -ENOMEM; in unimac_mdio_probe()
271 bus = priv->mii_bus; in unimac_mdio_probe()
272 bus->priv = priv; in unimac_mdio_probe()
274 bus->name = pdata->bus_name; in unimac_mdio_probe()
275 priv->wait_func = pdata->wait_func; in unimac_mdio_probe()
276 priv->wait_func_data = pdata->wait_func_data; in unimac_mdio_probe()
277 bus->phy_mask = ~pdata->phy_mask; in unimac_mdio_probe()
278 priv->clk = pdata->clk; in unimac_mdio_probe()
280 bus->name = "unimac MII bus"; in unimac_mdio_probe()
281 priv->wait_func_data = priv; in unimac_mdio_probe()
282 priv->wait_func = unimac_mdio_poll; in unimac_mdio_probe()
283 priv->clk = devm_clk_get_optional(&pdev->dev, NULL); in unimac_mdio_probe()
286 if (IS_ERR(priv->clk)) { in unimac_mdio_probe()
287 ret = PTR_ERR(priv->clk); in unimac_mdio_probe()
291 bus->parent = &pdev->dev; in unimac_mdio_probe()
292 bus->read = unimac_mdio_read; in unimac_mdio_probe()
293 bus->write = unimac_mdio_write; in unimac_mdio_probe()
294 bus->reset = unimac_mdio_reset; in unimac_mdio_probe()
295 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-%d", pdev->name, pdev->id); in unimac_mdio_probe()
303 dev_err(&pdev->dev, "MDIO bus registration failed\n"); in unimac_mdio_probe()
309 dev_info(&pdev->dev, "Broadcom UniMAC MDIO bus\n"); in unimac_mdio_probe()
322 mdiobus_unregister(priv->mii_bus); in unimac_mdio_remove()
323 mdiobus_free(priv->mii_bus); in unimac_mdio_remove()
337 { .compatible = "brcm,asp-v2.2-mdio", },
338 { .compatible = "brcm,asp-v2.1-mdio", },
339 { .compatible = "brcm,asp-v2.0-mdio", },
340 { .compatible = "brcm,bcm6846-mdio", },
341 { .compatible = "brcm,genet-mdio-v5", },
342 { .compatible = "brcm,genet-mdio-v4", },
343 { .compatible = "brcm,genet-mdio-v3", },
344 { .compatible = "brcm,genet-mdio-v2", },
345 { .compatible = "brcm,genet-mdio-v1", },
346 { .compatible = "brcm,unimac-mdio", },