Lines Matching +full:0 +full:- +full:mdio
1 // SPDX-License-Identifier: GPL-2.0-only
3 * OF helpers for the MDIO (Ethernet PHY) API
30 * ethernet-phy-idAAAA.BBBB */
36 int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, in of_mdiobus_phy_device_register() argument
39 return fwnode_mdiobus_phy_device_register(mdio, phy, in of_mdiobus_phy_device_register()
45 static int of_mdiobus_register_phy(struct mii_bus *mdio, in of_mdiobus_register_phy() argument
48 return fwnode_mdiobus_register_phy(mdio, of_fwnode_handle(child), addr); in of_mdiobus_register_phy()
51 static int of_mdiobus_register_device(struct mii_bus *mdio, in of_mdiobus_register_device() argument
58 mdiodev = mdio_device_create(mdio, addr); in of_mdiobus_register_device()
66 device_set_node(&mdiodev->dev, fwnode); in of_mdiobus_register_device()
71 device_set_node(&mdiodev->dev, NULL); in of_mdiobus_register_device()
77 dev_dbg(&mdio->dev, "registered mdio device %pOFn at address %i\n", in of_mdiobus_register_device()
79 return 0; in of_mdiobus_register_device()
85 * to have a compatible string, so they can be matched to an MDIO
89 { .compatible = "brcm,40nm-ephy" },
99 { .compatible = "moxa,moxart-rtl8201cp", },
105 * o Compatible string of "ethernet-phy-idX.X"
106 * o Compatible string of "ethernet-phy-ieee802.3-c45"
107 * o Compatible string of "ethernet-phy-ieee802.3-c22"
118 if (of_get_phy_id(child, &phy_id) != -EINVAL) in of_mdiobus_child_is_phy()
121 if (of_device_is_compatible(child, "ethernet-phy-ieee802.3-c45")) in of_mdiobus_child_is_phy()
124 if (of_device_is_compatible(child, "ethernet-phy-ieee802.3-c22")) in of_mdiobus_child_is_phy()
142 * __of_mdiobus_register - Register mii_bus and create PHYs from the device tree
143 * @mdio: pointer to mii_bus structure
144 * @np: pointer to device_node of MDIO bus.
145 * @owner: module owning the @mdio object.
150 int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np, in __of_mdiobus_register() argument
158 return __mdiobus_register(mdio, owner); in __of_mdiobus_register()
162 return -ENODEV; in __of_mdiobus_register()
166 mdio->phy_mask = ~0; in __of_mdiobus_register()
168 device_set_node(&mdio->dev, of_fwnode_handle(np)); in __of_mdiobus_register()
171 mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY; in __of_mdiobus_register()
172 of_property_read_u32(np, "reset-delay-us", &mdio->reset_delay_us); in __of_mdiobus_register()
173 mdio->reset_post_delay_us = 0; in __of_mdiobus_register()
174 of_property_read_u32(np, "reset-post-delay-us", &mdio->reset_post_delay_us); in __of_mdiobus_register()
176 /* Register the MDIO bus */ in __of_mdiobus_register()
177 rc = __mdiobus_register(mdio, owner); in __of_mdiobus_register()
183 addr = of_mdio_parse_addr(&mdio->dev, child); in __of_mdiobus_register()
184 if (addr < 0) { in __of_mdiobus_register()
190 rc = of_mdiobus_register_phy(mdio, child, addr); in __of_mdiobus_register()
192 rc = of_mdiobus_register_device(mdio, child, addr); in __of_mdiobus_register()
194 if (rc == -ENODEV) in __of_mdiobus_register()
195 dev_err(&mdio->dev, in __of_mdiobus_register()
196 "MDIO device at address %d is missing.\n", in __of_mdiobus_register()
203 return 0; in __of_mdiobus_register()
211 for (addr = 0; addr < PHY_MAX_ADDR; addr++) { in __of_mdiobus_register()
213 if (mdiobus_is_registered_device(mdio, addr)) in __of_mdiobus_register()
217 dev_info(&mdio->dev, "scan phy %pOFn at address %i\n", in __of_mdiobus_register()
221 /* -ENODEV is the return code that PHYLIB has in __of_mdiobus_register()
225 rc = of_mdiobus_register_phy(mdio, child, addr); in __of_mdiobus_register()
228 if (rc != -ENODEV) in __of_mdiobus_register()
234 return 0; in __of_mdiobus_register()
238 mdiobus_unregister(mdio); in __of_mdiobus_register()
244 * of_mdio_find_device - Given a device tree node, find the mdio_device
258 * of_phy_find_device - Give a PHY node, find the phy_device
271 * of_phy_connect - Connect to the phy described in the device tree
293 phy->dev_flags |= flags; in of_phy_connect()
298 put_device(&phy->mdio.dev); in of_phy_connect()
306 * - Get phy node and connect to the phy described in the device tree
329 if (ret < 0) { in of_phy_get_and_connect()
330 netdev_err(dev, "broken fixed-link specification\n"); in of_phy_get_and_connect()
335 phy_np = of_parse_phandle(np, "phy-handle", 0); in of_phy_get_and_connect()
340 phy = of_phy_connect(dev, phy_np, hndlr, 0, iface); in of_phy_get_and_connect()
351 * - the old DT binding, where 'fixed-link' was a property with 5
353 * - the new DT binding, where 'fixed-link' is a sub-node of the
363 dn = of_get_child_by_name(np, "fixed-link"); in of_phy_is_fixed_link()
370 if (err == 0 && strcmp(managed, "auto") != 0) in of_phy_is_fixed_link()
374 if (of_get_property(np, "fixed-link", &len) && in of_phy_is_fixed_link()
389 if (of_property_read_string(np, "managed", &managed) == 0 && in of_phy_register_fixed_link()
390 strcmp(managed, "in-band-status") == 0) { in of_phy_register_fixed_link()
396 fixed_link_node = of_get_child_by_name(np, "fixed-link"); in of_phy_register_fixed_link()
400 "full-duplex"); in of_phy_register_fixed_link()
404 return -EINVAL; in of_phy_register_fixed_link()
408 "asym-pause"); in of_phy_register_fixed_link()
415 if (of_property_read_u32_array(np, "fixed-link", fixed_link_prop, in of_phy_register_fixed_link()
416 ARRAY_SIZE(fixed_link_prop)) == 0) { in of_phy_register_fixed_link()
425 return -ENODEV; in of_phy_register_fixed_link()
442 put_device(&phydev->mdio.dev); /* of_phy_find_device() */ in of_phy_deregister_fixed_link()