1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright 2017 Bernecker & Rainer Industrieelektronik GmbH
12 #include <fdt_support.h>
14 DECLARE_GLOBAL_DATA_PTR;
16 int fixedphy_probe(struct phy_device *phydev)
18 struct fixed_link *priv;
19 int ofnode = phydev->addr;
22 /* check for mandatory properties within fixed-link node */
23 val = fdt_getprop_u32_default_node(gd->fdt_blob,
24 ofnode, 0, "speed", 0);
25 if (val != SPEED_10 && val != SPEED_100 && val != SPEED_1000) {
26 printf("ERROR: no/invalid speed given in fixed-link node!");
30 priv = malloc(sizeof(*priv));
33 memset(priv, 0, sizeof(*priv));
37 priv->link_speed = val;
38 priv->duplex = fdtdec_get_bool(gd->fdt_blob, ofnode, "full-duplex");
39 priv->pause = fdtdec_get_bool(gd->fdt_blob, ofnode, "pause");
40 priv->asym_pause = fdtdec_get_bool(gd->fdt_blob, ofnode, "asym-pause");
42 /* fixed-link phy must not be reset by core phy code */
43 phydev->flags |= PHY_FLAG_BROKEN_RESET;
48 int fixedphy_startup(struct phy_device *phydev)
50 struct fixed_link *priv = phydev->priv;
52 phydev->asym_pause = priv->asym_pause;
53 phydev->pause = priv->pause;
54 phydev->duplex = priv->duplex;
55 phydev->speed = priv->link_speed;
61 int fixedphy_shutdown(struct phy_device *phydev)
66 static struct phy_driver fixedphy_driver = {
70 .features = PHY_GBIT_FEATURES | SUPPORTED_MII,
71 .probe = fixedphy_probe,
72 .startup = fixedphy_startup,
73 .shutdown = fixedphy_shutdown,
76 int phy_fixed_init(void)
78 phy_register(&fixedphy_driver);