1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2017 Texas Instruments Incorporated - https://www.ti.com/
10 #include <dm/device.h>
11 #include <dm/device_compat.h>
12 #include <generic-phy.h>
13 #include <asm-generic/gpio.h>
17 #if CONFIG_IS_ENABLED(DM_GPIO)
18 struct gpio_desc reset_gpio;
22 #if CONFIG_IS_ENABLED(DM_GPIO)
23 static int nop_phy_reset(struct phy *phy)
25 struct nop_phy_priv *priv = dev_get_priv(phy->dev);
27 /* Return if there is no gpio since it's optional */
28 if (!dm_gpio_is_valid(&priv->reset_gpio))
31 return dm_gpio_set_value(&priv->reset_gpio, true);
35 static int nop_phy_init(struct phy *phy)
37 struct nop_phy_priv *priv = dev_get_priv(phy->dev);
40 if (CONFIG_IS_ENABLED(CLK)) {
41 ret = clk_enable_bulk(&priv->bulk);
46 #if CONFIG_IS_ENABLED(DM_GPIO)
47 /* Take phy out of reset */
48 if (dm_gpio_is_valid(&priv->reset_gpio)) {
49 ret = dm_gpio_set_value(&priv->reset_gpio, false);
51 if (CONFIG_IS_ENABLED(CLK))
52 clk_disable_bulk(&priv->bulk);
60 static int nop_phy_probe(struct udevice *dev)
62 struct nop_phy_priv *priv = dev_get_priv(dev);
65 if (CONFIG_IS_ENABLED(CLK)) {
66 ret = clk_get_bulk(dev, &priv->bulk);
68 dev_err(dev, "Failed to get clk: %d\n", ret);
72 #if CONFIG_IS_ENABLED(DM_GPIO)
73 ret = gpio_request_by_name(dev, "reset-gpios", 0,
83 static const struct udevice_id nop_phy_ids[] = {
84 { .compatible = "nop-phy" },
85 { .compatible = "usb-nop-xceiv" },
89 static struct phy_ops nop_phy_ops = {
91 #if CONFIG_IS_ENABLED(DM_GPIO)
92 .reset = nop_phy_reset,
96 U_BOOT_DRIVER(nop_phy) = {
99 .of_match = nop_phy_ids,
101 .probe = nop_phy_probe,
102 .priv_auto = sizeof(struct nop_phy_priv),