Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property
1 // SPDX-License-Identifier: GPL-2.0-only
30 * ethernet-phy-idAAAA.BBBB */
37 struct device_node *child, u32 addr) in of_mdiobus_phy_device_register() argument
40 of_fwnode_handle(child), in of_mdiobus_phy_device_register()
46 struct device_node *child, u32 addr) in of_mdiobus_register_phy() argument
48 return fwnode_mdiobus_register_phy(mdio, of_fwnode_handle(child), addr); in of_mdiobus_register_phy()
52 struct device_node *child, u32 addr) in of_mdiobus_register_device() argument
54 struct fwnode_handle *fwnode = of_fwnode_handle(child); in of_mdiobus_register_device()
62 /* Associate the OF node with the device structure so it in of_mdiobus_register_device()
66 device_set_node(&mdiodev->dev, fwnode); in of_mdiobus_register_device()
72 of_node_put(child); in of_mdiobus_register_device()
76 dev_dbg(&mdio->dev, "registered mdio device %pOFn at address %i\n", in of_mdiobus_register_device()
77 child, addr); in of_mdiobus_register_device()
81 /* The following is a list of PHY compatible strings which appear in
82 * some DTBs. The compatible string is never matched against a PHY
84 * to have a compatible string, so they can be matched to an MDIO
88 { .compatible = "brcm,40nm-ephy" },
98 { .compatible = "moxa,moxart-rtl8201cp", },
103 * Return true if the child node is for a phy. It must either:
104 * o Compatible string of "ethernet-phy-idX.X"
105 * o Compatible string of "ethernet-phy-ieee802.3-c45"
106 * o Compatible string of "ethernet-phy-ieee802.3-c22"
107 * o In the white list above (and issue a warning)
110 * A device which is not a phy is expected to have a compatible string
113 bool of_mdiobus_child_is_phy(struct device_node *child) in of_mdiobus_child_is_phy() argument
117 if (of_get_phy_id(child, &phy_id) != -EINVAL) in of_mdiobus_child_is_phy()
120 if (of_device_is_compatible(child, "ethernet-phy-ieee802.3-c45")) in of_mdiobus_child_is_phy()
123 if (of_device_is_compatible(child, "ethernet-phy-ieee802.3-c22")) in of_mdiobus_child_is_phy()
126 if (of_match_node(whitelist_phys, child)) { in of_mdiobus_child_is_phy()
129 child); in of_mdiobus_child_is_phy()
133 if (!of_find_property(child, "compatible", NULL)) in of_mdiobus_child_is_phy()
141 * of_mdiobus_register - Register mii_bus and create PHYs from the device tree
145 * This function registers the mii_bus structure and registers a phy_device
146 * for each child node of @np.
150 struct device_node *child; in of_mdiobus_register() local
157 /* Do not continue if the node is disabled */ in of_mdiobus_register()
159 return -ENODEV; in of_mdiobus_register()
163 mdio->phy_mask = ~0; in of_mdiobus_register()
165 device_set_node(&mdio->dev, of_fwnode_handle(np)); in of_mdiobus_register()
168 mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY; in of_mdiobus_register()
169 of_property_read_u32(np, "reset-delay-us", &mdio->reset_delay_us); in of_mdiobus_register()
170 mdio->reset_post_delay_us = 0; in of_mdiobus_register()
171 of_property_read_u32(np, "reset-post-delay-us", &mdio->reset_post_delay_us); in of_mdiobus_register()
178 /* Loop over the child nodes and register a phy_device for each phy */ in of_mdiobus_register()
179 for_each_available_child_of_node(np, child) { in of_mdiobus_register()
180 addr = of_mdio_parse_addr(&mdio->dev, child); in of_mdiobus_register()
186 if (of_mdiobus_child_is_phy(child)) in of_mdiobus_register()
187 rc = of_mdiobus_register_phy(mdio, child, addr); in of_mdiobus_register()
189 rc = of_mdiobus_register_device(mdio, child, addr); in of_mdiobus_register()
191 if (rc == -ENODEV) in of_mdiobus_register()
192 dev_err(&mdio->dev, in of_mdiobus_register()
202 /* auto scan for PHYs with empty reg property */ in of_mdiobus_register()
203 for_each_available_child_of_node(np, child) { in of_mdiobus_register()
204 /* Skip PHYs with reg property set */ in of_mdiobus_register()
205 if (of_find_property(child, "reg", NULL)) in of_mdiobus_register()
213 /* be noisy to encourage people to set reg property */ in of_mdiobus_register()
214 dev_info(&mdio->dev, "scan phy %pOFn at address %i\n", in of_mdiobus_register()
215 child, addr); in of_mdiobus_register()
217 if (of_mdiobus_child_is_phy(child)) { in of_mdiobus_register()
218 /* -ENODEV is the return code that PHYLIB has in of_mdiobus_register()
222 rc = of_mdiobus_register_phy(mdio, child, addr); in of_mdiobus_register()
225 if (rc != -ENODEV) in of_mdiobus_register()
240 * of_mdio_find_device - Given a device tree node, find the mdio_device
241 * @np: pointer to the mdio_device's device tree node
243 * If successful, returns a pointer to the mdio_device with the embedded
254 * of_phy_find_device - Give a PHY node, find the phy_device
255 * @phy_np: Pointer to the phy's device tree node
257 * If successful, returns a pointer to the phy_device with the embedded
267 * of_phy_connect - Connect to the phy described in the device tree
269 * @phy_np: Pointer to device tree node for the PHY
274 * If successful, returns a pointer to the phy_device with the embedded
289 phy->dev_flags |= flags; in of_phy_connect()
294 put_device(&phy->mdio.dev); in of_phy_connect()
302 * - Get phy node and connect to the phy described in the device tree
304 * @np: Pointer to device tree node for the net_device claiming the phy
307 * If successful, returns a pointer to the phy_device with the embedded
326 netdev_err(dev, "broken fixed-link specification\n"); in of_phy_get_and_connect()
331 phy_np = of_parse_phandle(np, "phy-handle", 0); in of_phy_get_and_connect()
347 * - the old DT binding, where 'fixed-link' was a property with 5
349 * - the new DT binding, where 'fixed-link' is a sub-node of the
359 dn = of_get_child_by_name(np, "fixed-link"); in of_phy_is_fixed_link()
370 if (of_get_property(np, "fixed-link", &len) && in of_phy_is_fixed_link()
386 strcmp(managed, "in-band-status") == 0) { in of_phy_register_fixed_link()
392 fixed_link_node = of_get_child_by_name(np, "fixed-link"); in of_phy_register_fixed_link()
396 "full-duplex"); in of_phy_register_fixed_link()
400 return -EINVAL; in of_phy_register_fixed_link()
404 "asym-pause"); in of_phy_register_fixed_link()
411 if (of_property_read_u32_array(np, "fixed-link", fixed_link_prop, in of_phy_register_fixed_link()
421 return -ENODEV; in of_phy_register_fixed_link()
438 put_device(&phydev->mdio.dev); /* of_phy_find_device() */ in of_phy_deregister_fixed_link()