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 struct sandbox_phy_priv {
17 static int sandbox_phy_power_on(struct phy *phy)
19 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
21 if (!priv->initialized)
32 static int sandbox_phy_power_off(struct phy *phy)
34 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
36 if (!priv->initialized)
43 * for validation purpose, let's says that power off
44 * works only for PHY 0
54 static int sandbox_phy_init(struct phy *phy)
56 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
58 priv->initialized = true;
64 static int sandbox_phy_exit(struct phy *phy)
66 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
68 priv->initialized = false;
74 static int sandbox_phy_probe(struct udevice *dev)
76 struct sandbox_phy_priv *priv = dev_get_priv(dev);
78 priv->initialized = false;
80 priv->broken = dev_read_bool(dev, "broken");
85 static struct phy_ops sandbox_phy_ops = {
86 .power_on = sandbox_phy_power_on,
87 .power_off = sandbox_phy_power_off,
88 .init = sandbox_phy_init,
89 .exit = sandbox_phy_exit,
92 static const struct udevice_id sandbox_phy_ids[] = {
93 { .compatible = "sandbox,phy" },
97 U_BOOT_DRIVER(phy_sandbox) = {
98 .name = "phy_sandbox",
100 .of_match = sandbox_phy_ids,
101 .ops = &sandbox_phy_ops,
102 .probe = sandbox_phy_probe,
103 .priv_auto_alloc_size = sizeof(struct sandbox_phy_priv),