Lines Matching +full:child +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0-only
29 * ethernet-phy-idAAAA.BBBB */
37 if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) == 2) { in of_get_phy_id()
42 return -EINVAL; in of_get_phy_id()
45 static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) in of_find_mii_timestamper() argument
50 err = of_parse_phandle_with_fixed_args(node, "timestamper", 1, 0, &arg); in of_find_mii_timestamper()
52 if (err == -ENOENT) in of_find_mii_timestamper()
58 return ERR_PTR(-EINVAL); in of_find_mii_timestamper()
64 struct device_node *child, u32 addr) in of_mdiobus_phy_device_register() argument
68 rc = of_irq_get(child, 0); in of_mdiobus_phy_device_register()
69 if (rc == -EPROBE_DEFER) in of_mdiobus_phy_device_register()
73 phy->irq = rc; in of_mdiobus_phy_device_register()
74 mdio->irq[addr] = rc; in of_mdiobus_phy_device_register()
76 phy->irq = mdio->irq[addr]; in of_mdiobus_phy_device_register()
79 if (of_property_read_bool(child, "broken-turn-around")) in of_mdiobus_phy_device_register()
80 mdio->phy_ignore_ta_mask |= 1 << addr; in of_mdiobus_phy_device_register()
82 of_property_read_u32(child, "reset-assert-us", in of_mdiobus_phy_device_register()
83 &phy->mdio.reset_assert_delay); in of_mdiobus_phy_device_register()
84 of_property_read_u32(child, "reset-deassert-us", in of_mdiobus_phy_device_register()
85 &phy->mdio.reset_deassert_delay); in of_mdiobus_phy_device_register()
87 /* Associate the OF node with the device structure so it in of_mdiobus_phy_device_register()
89 of_node_get(child); in of_mdiobus_phy_device_register()
90 phy->mdio.dev.of_node = child; in of_mdiobus_phy_device_register()
91 phy->mdio.dev.fwnode = of_fwnode_handle(child); in of_mdiobus_phy_device_register()
97 of_node_put(child); in of_mdiobus_phy_device_register()
101 dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n", in of_mdiobus_phy_device_register()
102 child, addr); in of_mdiobus_phy_device_register()
108 struct device_node *child, u32 addr) in of_mdiobus_register_phy() argument
116 mii_ts = of_find_mii_timestamper(child); in of_mdiobus_register_phy()
120 is_c45 = of_device_is_compatible(child, in of_mdiobus_register_phy()
121 "ethernet-phy-ieee802.3-c45"); in of_mdiobus_register_phy()
123 if (!is_c45 && !of_get_phy_id(child, &phy_id)) in of_mdiobus_register_phy()
133 rc = of_mdiobus_phy_device_register(mdio, phy, child, addr); in of_mdiobus_register_phy()
141 /* phy->mii_ts may already be defined by the PHY driver. A in of_mdiobus_register_phy()
146 phy->mii_ts = mii_ts; in of_mdiobus_register_phy()
152 struct device_node *child, u32 addr) in of_mdiobus_register_device() argument
161 /* Associate the OF node with the device structure so it in of_mdiobus_register_device()
164 of_node_get(child); in of_mdiobus_register_device()
165 mdiodev->dev.of_node = child; in of_mdiobus_register_device()
166 mdiodev->dev.fwnode = of_fwnode_handle(child); in of_mdiobus_register_device()
172 of_node_put(child); in of_mdiobus_register_device()
176 dev_dbg(&mdio->dev, "registered mdio device %pOFn at address %i\n", in of_mdiobus_register_device()
177 child, addr); in of_mdiobus_register_device()
188 { .compatible = "brcm,40nm-ephy" },
198 { .compatible = "moxa,moxart-rtl8201cp", },
203 * Return true if the child node is for a phy. It must either:
204 * o Compatible string of "ethernet-phy-idX.X"
205 * o Compatible string of "ethernet-phy-ieee802.3-c45"
206 * o Compatible string of "ethernet-phy-ieee802.3-c22"
213 bool of_mdiobus_child_is_phy(struct device_node *child) in of_mdiobus_child_is_phy() argument
217 if (of_get_phy_id(child, &phy_id) != -EINVAL) in of_mdiobus_child_is_phy()
220 if (of_device_is_compatible(child, "ethernet-phy-ieee802.3-c45")) in of_mdiobus_child_is_phy()
223 if (of_device_is_compatible(child, "ethernet-phy-ieee802.3-c22")) in of_mdiobus_child_is_phy()
226 if (of_match_node(whitelist_phys, child)) { in of_mdiobus_child_is_phy()
229 child); in of_mdiobus_child_is_phy()
233 if (!of_find_property(child, "compatible", NULL)) in of_mdiobus_child_is_phy()
241 * of_mdiobus_register - Register mii_bus and create PHYs from the device tree
246 * for each child node of @np.
250 struct device_node *child; in of_mdiobus_register() local
257 /* Do not continue if the node is disabled */ in of_mdiobus_register()
259 return -ENODEV; in of_mdiobus_register()
263 mdio->phy_mask = ~0; in of_mdiobus_register()
265 mdio->dev.of_node = np; in of_mdiobus_register()
266 mdio->dev.fwnode = of_fwnode_handle(np); in of_mdiobus_register()
269 mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY; in of_mdiobus_register()
270 of_property_read_u32(np, "reset-delay-us", &mdio->reset_delay_us); in of_mdiobus_register()
271 mdio->reset_post_delay_us = 0; in of_mdiobus_register()
272 of_property_read_u32(np, "reset-post-delay-us", &mdio->reset_post_delay_us); in of_mdiobus_register()
279 /* Loop over the child nodes and register a phy_device for each phy */ in of_mdiobus_register()
280 for_each_available_child_of_node(np, child) { in of_mdiobus_register()
281 addr = of_mdio_parse_addr(&mdio->dev, child); in of_mdiobus_register()
287 if (of_mdiobus_child_is_phy(child)) in of_mdiobus_register()
288 rc = of_mdiobus_register_phy(mdio, child, addr); in of_mdiobus_register()
290 rc = of_mdiobus_register_device(mdio, child, addr); in of_mdiobus_register()
292 if (rc == -ENODEV) in of_mdiobus_register()
293 dev_err(&mdio->dev, in of_mdiobus_register()
304 for_each_available_child_of_node(np, child) { in of_mdiobus_register()
306 if (of_find_property(child, "reg", NULL)) in of_mdiobus_register()
315 dev_info(&mdio->dev, "scan phy %pOFn at address %i\n", in of_mdiobus_register()
316 child, addr); in of_mdiobus_register()
318 if (of_mdiobus_child_is_phy(child)) { in of_mdiobus_register()
319 /* -ENODEV is the return code that PHYLIB has in of_mdiobus_register()
323 rc = of_mdiobus_register_phy(mdio, child, addr); in of_mdiobus_register()
326 if (rc != -ENODEV) in of_mdiobus_register()
341 * of_mdio_find_device - Given a device tree node, find the mdio_device
342 * @np: pointer to the mdio_device's device tree node
364 * of_phy_find_device - Give a PHY node, find the phy_device
365 * @phy_np: Pointer to the phy's device tree node
378 if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) in of_phy_find_device()
379 return to_phy_device(&mdiodev->dev); in of_phy_find_device()
381 put_device(&mdiodev->dev); in of_phy_find_device()
388 * of_phy_connect - Connect to the phy described in the device tree
390 * @phy_np: Pointer to device tree node for the PHY
410 phy->dev_flags |= flags; in of_phy_connect()
415 put_device(&phy->mdio.dev); in of_phy_connect()
423 * - Get phy node and connect to the phy described in the device tree
425 * @np: Pointer to device tree node for the net_device claiming the phy
447 netdev_err(dev, "broken fixed-link specification\n"); in of_phy_get_and_connect()
452 phy_np = of_parse_phandle(np, "phy-handle", 0); in of_phy_get_and_connect()
466 * of_phy_attach - Attach to a PHY without starting the state machine
468 * @phy_np: Node pointer for the PHY
489 put_device(&phy->mdio.dev); in of_phy_attach()
498 * - the old DT binding, where 'fixed-link' was a property with 5
500 * - the new DT binding, where 'fixed-link' is a sub-node of the
510 dn = of_get_child_by_name(np, "fixed-link"); in of_phy_is_fixed_link()
521 if (of_get_property(np, "fixed-link", &len) && in of_phy_is_fixed_link()
537 strcmp(managed, "in-band-status") == 0) { in of_phy_register_fixed_link()
543 fixed_link_node = of_get_child_by_name(np, "fixed-link"); in of_phy_register_fixed_link()
547 "full-duplex"); in of_phy_register_fixed_link()
551 return -EINVAL; in of_phy_register_fixed_link()
555 "asym-pause"); in of_phy_register_fixed_link()
562 if (of_property_read_u32_array(np, "fixed-link", fixed_link_prop, in of_phy_register_fixed_link()
572 return -ENODEV; in of_phy_register_fixed_link()
589 put_device(&phydev->mdio.dev); /* of_phy_find_device() */ in of_phy_deregister_fixed_link()