[PATCH] net: macb: Add support for fixed link
Dan Carpenter
dan.carpenter at linaro.org
Mon Feb 5 08:40:20 CET 2024
On Sat, Feb 03, 2024 at 07:06:52PM +0100, belouargamohamed at gmail.com wrote:
> @@ -1276,6 +1297,30 @@ int __weak macb_late_eth_of_to_plat(struct udevice *dev)
> static int macb_eth_of_to_plat(struct udevice *dev)
> {
> struct eth_pdata *pdata = dev_get_plat(dev);
> + struct macb_device *macb = dev_get_priv(dev);
> + void *blob = (void *)gd->fdt_blob;
> + int node = dev_of_offset(dev);
> + int fl_node, speed_fdt;
> +
> + /* fetch 'fixed-link' property */
> + fl_node = fdt_subnode_offset(blob, node, "fixed-link");
> + if (fl_node != -FDT_ERR_NOTFOUND) {
Why not check for if (fl_node >= 0)? The fdt_subnode_offset() function
can return a variety of error codes.
regards,
dan carpenter
> + /* set phy_addr to invalid value for fixed link */
> + macb->phy_addr = PHY_MAX_ADDR + 1;
> + macb->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex");
> + speed_fdt = fdtdec_get_int(blob, fl_node, "speed", 0);
> + if (speed_fdt == 100) {
> + macb->speed = 1;
> + }
> + else if (speed_fdt == 10) {
> + macb->speed = 0;
> + }
> + else {
> + printf("%s: The given speed %d of ethernet in the DT is not supported\n",
> + __func__, speed_fdt);
> + return -EINVAL;
> + }
> + }
>
More information about the U-Boot
mailing list