4 * Copyright 2017 Bernecker & Rainer Industrieelektronik GmbH
6 * SPDX-License-Identifier: GPL-2.0+
13 #include <fdt_support.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 int fixedphy_probe(struct phy_device *phydev)
19 struct fixed_link *priv;
20 int ofnode = phydev->addr;
23 /* check for mandatory properties within fixed-link node */
24 val = fdt_getprop_u32_default_node(gd->fdt_blob,
25 ofnode, 0, "speed", 0);
26 if (val != SPEED_10 && val != SPEED_100 && val != SPEED_1000) {
27 printf("ERROR: no/invalid speed given in fixed-link node!");
31 priv = malloc(sizeof(*priv));
34 memset(priv, 0, sizeof(*priv));
39 priv->link_speed = val;
40 priv->duplex = fdtdec_get_bool(gd->fdt_blob, ofnode, "full-duplex");
41 priv->pause = fdtdec_get_bool(gd->fdt_blob, ofnode, "pause");
42 priv->asym_pause = fdtdec_get_bool(gd->fdt_blob, ofnode, "asym-pause");
44 /* fixed-link phy must not be reset by core phy code */
45 phydev->flags |= PHY_FLAG_BROKEN_RESET;
50 int fixedphy_startup(struct phy_device *phydev)
52 struct fixed_link *priv = phydev->priv;
54 phydev->asym_pause = priv->asym_pause;
55 phydev->pause = priv->pause;
56 phydev->duplex = priv->duplex;
57 phydev->speed = priv->link_speed;
63 int fixedphy_shutdown(struct phy_device *phydev)
68 static struct phy_driver fixedphy_driver = {
72 .features = PHY_GBIT_FEATURES | SUPPORTED_MII,
73 .probe = fixedphy_probe,
74 .startup = fixedphy_startup,
75 .shutdown = fixedphy_shutdown,
78 int phy_fixed_init(void)
80 phy_register(&fixedphy_driver);