1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
4 * Written by Jean-Jacques Hiblot <jjhiblot@ti.com>
9 #include <generic-phy.h>
11 #define DRIVER_DATA 0x12345678
13 struct sandbox_phy_priv {
19 static int sandbox_phy_power_on(struct phy *phy)
21 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
23 if (!priv->initialized)
34 static int sandbox_phy_power_off(struct phy *phy)
36 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
38 if (!priv->initialized)
45 * for validation purpose, let's says that power off
46 * works only for PHY 0
56 static int sandbox_phy_init(struct phy *phy)
58 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
60 priv->initialized = true;
66 static int sandbox_phy_exit(struct phy *phy)
68 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
70 priv->initialized = false;
76 static int sandbox_phy_bind(struct udevice *dev)
78 if (dev_get_driver_data(dev) != DRIVER_DATA)
84 static int sandbox_phy_probe(struct udevice *dev)
86 struct sandbox_phy_priv *priv = dev_get_priv(dev);
88 priv->initialized = false;
90 priv->broken = dev_read_bool(dev, "broken");
95 static struct phy_ops sandbox_phy_ops = {
96 .power_on = sandbox_phy_power_on,
97 .power_off = sandbox_phy_power_off,
98 .init = sandbox_phy_init,
99 .exit = sandbox_phy_exit,
102 static const struct udevice_id sandbox_phy_ids[] = {
103 { .compatible = "sandbox,phy_no_driver_data",
106 { .compatible = "sandbox,phy",
112 U_BOOT_DRIVER(phy_sandbox) = {
113 .name = "phy_sandbox",
115 .bind = sandbox_phy_bind,
116 .of_match = sandbox_phy_ids,
117 .ops = &sandbox_phy_ops,
118 .probe = sandbox_phy_probe,
119 .priv_auto = sizeof(struct sandbox_phy_priv),