2 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
3 * Written by Jean-Jacques Hiblot <jjhiblot@ti.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <generic-phy.h>
12 struct sandbox_phy_priv {
18 static int sandbox_phy_power_on(struct phy *phy)
20 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
22 if (!priv->initialized)
33 static int sandbox_phy_power_off(struct phy *phy)
35 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
37 if (!priv->initialized)
44 * for validation purpose, let's says that power off
45 * works only for PHY 0
55 static int sandbox_phy_init(struct phy *phy)
57 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
59 priv->initialized = true;
65 static int sandbox_phy_exit(struct phy *phy)
67 struct sandbox_phy_priv *priv = dev_get_priv(phy->dev);
69 priv->initialized = false;
75 static int sandbox_phy_probe(struct udevice *dev)
77 struct sandbox_phy_priv *priv = dev_get_priv(dev);
79 priv->initialized = false;
81 priv->broken = dev_read_bool(dev, "broken");
86 static struct phy_ops sandbox_phy_ops = {
87 .power_on = sandbox_phy_power_on,
88 .power_off = sandbox_phy_power_off,
89 .init = sandbox_phy_init,
90 .exit = sandbox_phy_exit,
93 static const struct udevice_id sandbox_phy_ids[] = {
94 { .compatible = "sandbox,phy" },
98 U_BOOT_DRIVER(phy_sandbox) = {
99 .name = "phy_sandbox",
101 .of_match = sandbox_phy_ids,
102 .ops = &sandbox_phy_ops,
103 .probe = sandbox_phy_probe,
104 .priv_auto_alloc_size = sizeof(struct sandbox_phy_priv),