1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2017 Texas Instruments Incorporated - https://www.ti.com/
8 #include <generic-phy.h>
10 #define DRIVER_DATA 0x12345678
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;
76 sandbox_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
81 if (mode != PHY_MODE_USB_HOST)
87 static int sandbox_phy_bind(struct udevice *dev)
89 if (dev_get_driver_data(dev) != DRIVER_DATA)
95 static int sandbox_phy_probe(struct udevice *dev)
97 struct sandbox_phy_priv *priv = dev_get_priv(dev);
99 priv->initialized = false;
101 priv->broken = dev_read_bool(dev, "broken");
106 static struct phy_ops sandbox_phy_ops = {
107 .power_on = sandbox_phy_power_on,
108 .power_off = sandbox_phy_power_off,
109 .init = sandbox_phy_init,
110 .exit = sandbox_phy_exit,
111 .set_mode = sandbox_phy_set_mode,
114 static const struct udevice_id sandbox_phy_ids[] = {
115 { .compatible = "sandbox,phy_no_driver_data",
118 { .compatible = "sandbox,phy",
124 U_BOOT_DRIVER(phy_sandbox) = {
125 .name = "phy_sandbox",
127 .bind = sandbox_phy_bind,
128 .of_match = sandbox_phy_ids,
129 .ops = &sandbox_phy_ops,
130 .probe = sandbox_phy_probe,
131 .priv_auto = sizeof(struct sandbox_phy_priv),