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 DECLARE_GLOBAL_DATA_PTR
;
14 struct sandbox_phy_priv
{
20 static int sandbox_phy_power_on(struct phy
*phy
)
22 struct sandbox_phy_priv
*priv
= dev_get_priv(phy
->dev
);
24 if (!priv
->initialized
)
35 static int sandbox_phy_power_off(struct phy
*phy
)
37 struct sandbox_phy_priv
*priv
= dev_get_priv(phy
->dev
);
39 if (!priv
->initialized
)
46 * for validation purpose, let's says that power off
47 * works only for PHY 0
57 static int sandbox_phy_init(struct phy
*phy
)
59 struct sandbox_phy_priv
*priv
= dev_get_priv(phy
->dev
);
61 priv
->initialized
= true;
67 static int sandbox_phy_exit(struct phy
*phy
)
69 struct sandbox_phy_priv
*priv
= dev_get_priv(phy
->dev
);
71 priv
->initialized
= false;
77 static int sandbox_phy_probe(struct udevice
*dev
)
79 struct sandbox_phy_priv
*priv
= dev_get_priv(dev
);
81 priv
->initialized
= false;
83 priv
->broken
= dev_read_bool(dev
, "broken");
88 static struct phy_ops sandbox_phy_ops
= {
89 .power_on
= sandbox_phy_power_on
,
90 .power_off
= sandbox_phy_power_off
,
91 .init
= sandbox_phy_init
,
92 .exit
= sandbox_phy_exit
,
95 static const struct udevice_id sandbox_phy_ids
[] = {
96 { .compatible
= "sandbox,phy" },
100 U_BOOT_DRIVER(phy_sandbox
) = {
101 .name
= "phy_sandbox",
103 .of_match
= sandbox_phy_ids
,
104 .ops
= &sandbox_phy_ops
,
105 .probe
= sandbox_phy_probe
,
106 .priv_auto_alloc_size
= sizeof(struct sandbox_phy_priv
),