1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright 2017 Bernecker & Rainer Industrieelektronik GmbH
13 #include <fdt_support.h>
14 #include <asm/global_data.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 static int fixedphy_probe(struct phy_device *phydev)
20 /* fixed-link phy must not be reset by core phy code */
21 phydev->flags |= PHY_FLAG_BROKEN_RESET;
26 static int fixedphy_config(struct phy_device *phydev)
28 ofnode node = phy_get_ofnode(phydev);
29 struct fixed_link *priv;
30 bool old_binding = false;
34 if (!ofnode_valid(node))
37 /* check for mandatory properties within fixed-link node */
38 val = ofnode_read_u32_default(node, "speed", 0);
43 if (ofnode_read_u32_array(node, "fixed-link", old_val,
44 ARRAY_SIZE(old_val))) {
45 printf("ERROR: no/invalid <fixed-link> property!\n");
51 if (val != SPEED_10 && val != SPEED_100 && val != SPEED_1000 &&
52 val != SPEED_2500 && val != SPEED_10000) {
53 printf("ERROR: no/invalid speed given in fixed-link node!\n");
57 priv = malloc(sizeof(*priv));
60 memset(priv, 0, sizeof(*priv));
64 priv->link_speed = val;
66 priv->duplex = ofnode_read_bool(node, "full-duplex");
67 priv->pause = ofnode_read_bool(node, "pause");
68 priv->asym_pause = ofnode_read_bool(node, "asym-pause");
70 priv->duplex = old_val[1];
71 priv->pause = old_val[3];
72 priv->asym_pause = old_val[4];
78 static int fixedphy_startup(struct phy_device *phydev)
80 struct fixed_link *priv = phydev->priv;
82 phydev->asym_pause = priv->asym_pause;
83 phydev->pause = priv->pause;
84 phydev->duplex = priv->duplex;
85 phydev->speed = priv->link_speed;
91 static int fixedphy_shutdown(struct phy_device *phydev)
96 static struct phy_driver fixedphy_driver = {
100 .features = PHY_GBIT_FEATURES | SUPPORTED_MII,
101 .probe = fixedphy_probe,
102 .config = fixedphy_config,
103 .startup = fixedphy_startup,
104 .shutdown = fixedphy_shutdown,
107 int phy_fixed_init(void)
109 phy_register(&fixedphy_driver);