Lines Matching +full:fixed +full:- +full:link
2 * Fixed MDIO bus (MDIO bus emulation with fixed PHYs)
7 * Copyright (c) 2006-2007 MontaVista Software, Inc.
53 if (gpio_is_valid(fp->link_gpio)) in fixed_phy_update()
54 fp->status.link = !!gpio_get_value_cansleep(fp->link_gpio); in fixed_phy_update()
59 struct fixed_mdio_bus *fmb = bus->priv; in fixed_mdio_read()
62 list_for_each_entry(fp, &fmb->phys, node) { in fixed_mdio_read()
63 if (fp->addr == phy_addr) { in fixed_mdio_read()
68 s = read_seqcount_begin(&fp->seqcount); in fixed_mdio_read()
70 if (fp->link_update) in fixed_mdio_read()
71 fp->link_update(fp->phydev->attached_dev, in fixed_mdio_read()
72 &fp->status); in fixed_mdio_read()
75 state = fp->status; in fixed_mdio_read()
76 } while (read_seqcount_retry(&fp->seqcount, s)); in fixed_mdio_read()
92 * If something weird is required to be done with link/speed,
94 * May be useful for PHY's that need to be software-driven.
103 if (!phydev || !phydev->mdio.bus) in fixed_phy_set_link_update()
104 return -EINVAL; in fixed_phy_set_link_update()
106 list_for_each_entry(fp, &fmb->phys, node) { in fixed_phy_set_link_update()
107 if (fp->addr == phydev->mdio.addr) { in fixed_phy_set_link_update()
108 fp->link_update = link_update; in fixed_phy_set_link_update()
109 fp->phydev = phydev; in fixed_phy_set_link_update()
114 return -ENOENT; in fixed_phy_set_link_update()
132 return -ENOMEM; in fixed_phy_add()
134 seqcount_init(&fp->seqcount); in fixed_phy_add()
137 fmb->mii_bus->irq[phy_addr] = irq; in fixed_phy_add()
139 fp->addr = phy_addr; in fixed_phy_add()
140 fp->status = *status; in fixed_phy_add()
141 fp->link_gpio = link_gpio; in fixed_phy_add()
143 if (gpio_is_valid(fp->link_gpio)) { in fixed_phy_add()
144 ret = gpio_request_one(fp->link_gpio, GPIOF_DIR_IN, in fixed_phy_add()
145 "fixed-link-gpio-link"); in fixed_phy_add()
152 list_add_tail(&fp->node, &fmb->phys); in fixed_phy_add()
169 list_for_each_entry_safe(fp, tmp, &fmb->phys, node) { in fixed_phy_del()
170 if (fp->addr == phy_addr) { in fixed_phy_del()
171 list_del(&fp->node); in fixed_phy_del()
172 if (gpio_is_valid(fp->link_gpio)) in fixed_phy_del()
173 gpio_free(fp->link_gpio); in fixed_phy_del()
191 if (!fmb->mii_bus || fmb->mii_bus->state != MDIOBUS_REGISTERED) in fixed_phy_register()
192 return ERR_PTR(-EPROBE_DEFER); in fixed_phy_register()
205 phy = get_phy_device(fmb->mii_bus, phy_addr, false); in fixed_phy_register()
208 return ERR_PTR(-EINVAL); in fixed_phy_register()
211 /* propagate the fixed link values to struct phy_device */ in fixed_phy_register()
212 phy->link = status->link; in fixed_phy_register()
213 if (status->link) { in fixed_phy_register()
214 phy->speed = status->speed; in fixed_phy_register()
215 phy->duplex = status->duplex; in fixed_phy_register()
216 phy->pause = status->pause; in fixed_phy_register()
217 phy->asym_pause = status->asym_pause; in fixed_phy_register()
221 phy->mdio.dev.of_node = np; in fixed_phy_register()
222 phy->is_pseudo_fixed_link = true; in fixed_phy_register()
224 switch (status->speed) { in fixed_phy_register()
226 phy->supported = PHY_1000BT_FEATURES; in fixed_phy_register()
229 phy->supported = PHY_100BT_FEATURES; in fixed_phy_register()
233 phy->supported = PHY_10BT_FEATURES; in fixed_phy_register()
251 of_node_put(phy->mdio.dev.of_node); in fixed_phy_unregister()
252 fixed_phy_del(phy->mdio.addr); in fixed_phy_unregister()
261 pdev = platform_device_register_simple("Fixed MDIO bus", 0, NULL, 0); in fixed_mdio_bus_init()
265 fmb->mii_bus = mdiobus_alloc(); in fixed_mdio_bus_init()
266 if (fmb->mii_bus == NULL) { in fixed_mdio_bus_init()
267 ret = -ENOMEM; in fixed_mdio_bus_init()
271 snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "fixed-0"); in fixed_mdio_bus_init()
272 fmb->mii_bus->name = "Fixed MDIO Bus"; in fixed_mdio_bus_init()
273 fmb->mii_bus->priv = fmb; in fixed_mdio_bus_init()
274 fmb->mii_bus->parent = &pdev->dev; in fixed_mdio_bus_init()
275 fmb->mii_bus->read = &fixed_mdio_read; in fixed_mdio_bus_init()
276 fmb->mii_bus->write = &fixed_mdio_write; in fixed_mdio_bus_init()
278 ret = mdiobus_register(fmb->mii_bus); in fixed_mdio_bus_init()
285 mdiobus_free(fmb->mii_bus); in fixed_mdio_bus_init()
297 mdiobus_unregister(fmb->mii_bus); in fixed_mdio_bus_exit()
298 mdiobus_free(fmb->mii_bus); in fixed_mdio_bus_exit()
301 list_for_each_entry_safe(fp, tmp, &fmb->phys, node) { in fixed_mdio_bus_exit()
302 list_del(&fp->node); in fixed_mdio_bus_exit()
309 MODULE_DESCRIPTION("Fixed MDIO bus (MDIO bus emulation with fixed PHYs)");