Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ |
| 4 | * Written by Jean-Jacques Hiblot <jjhiblot@ti.com> |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
Peng Fan | 259029f | 2020-10-15 18:05:58 +0800 | [diff] [blame] | 7 | #include <clk.h> |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 8 | #include <common.h> |
| 9 | #include <dm.h> |
| 10 | #include <dm/device.h> |
Peng Fan | 259029f | 2020-10-15 18:05:58 +0800 | [diff] [blame] | 11 | #include <dm/device_compat.h> |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 12 | #include <generic-phy.h> |
| 13 | |
Peng Fan | 259029f | 2020-10-15 18:05:58 +0800 | [diff] [blame] | 14 | struct nop_phy_priv { |
| 15 | struct clk_bulk bulk; |
| 16 | }; |
| 17 | |
| 18 | static int nop_phy_init(struct phy *phy) |
| 19 | { |
| 20 | struct nop_phy_priv *priv = dev_get_priv(phy->dev); |
| 21 | |
| 22 | if (CONFIG_IS_ENABLED(CLK)) |
| 23 | return clk_enable_bulk(&priv->bulk); |
| 24 | |
| 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | static int nop_phy_probe(struct udevice *dev) |
| 29 | { |
| 30 | struct nop_phy_priv *priv = dev_get_priv(dev); |
| 31 | int ret; |
| 32 | |
| 33 | if (CONFIG_IS_ENABLED(CLK)) { |
| 34 | ret = clk_get_bulk(dev, &priv->bulk); |
| 35 | if (ret < 0) { |
| 36 | dev_err(dev, "Failed to get clk: %d\n", ret); |
| 37 | return ret; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 44 | static const struct udevice_id nop_phy_ids[] = { |
| 45 | { .compatible = "nop-phy" }, |
Marek Vasut | a4a1cb4 | 2021-03-31 11:21:07 +0200 | [diff] [blame] | 46 | { .compatible = "usb-nop-xceiv" }, |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 47 | { } |
| 48 | }; |
| 49 | |
| 50 | static struct phy_ops nop_phy_ops = { |
Peng Fan | 259029f | 2020-10-15 18:05:58 +0800 | [diff] [blame] | 51 | .init = nop_phy_init, |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | U_BOOT_DRIVER(nop_phy) = { |
| 55 | .name = "nop_phy", |
| 56 | .id = UCLASS_PHY, |
| 57 | .of_match = nop_phy_ids, |
| 58 | .ops = &nop_phy_ops, |
Peng Fan | 259029f | 2020-10-15 18:05:58 +0800 | [diff] [blame] | 59 | .probe = nop_phy_probe, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 60 | .priv_auto = sizeof(struct nop_phy_priv), |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 61 | }; |