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" }, |
| 46 | { } |
| 47 | }; |
| 48 | |
| 49 | static struct phy_ops nop_phy_ops = { |
Peng Fan | 259029f | 2020-10-15 18:05:58 +0800 | [diff] [blame] | 50 | .init = nop_phy_init, |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | U_BOOT_DRIVER(nop_phy) = { |
| 54 | .name = "nop_phy", |
| 55 | .id = UCLASS_PHY, |
| 56 | .of_match = nop_phy_ids, |
| 57 | .ops = &nop_phy_ops, |
Peng Fan | 259029f | 2020-10-15 18:05:58 +0800 | [diff] [blame] | 58 | .probe = nop_phy_probe, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 59 | .priv_auto = sizeof(struct nop_phy_priv), |
Jean-Jacques Hiblot | c2da3e3 | 2017-07-24 15:18:15 +0200 | [diff] [blame] | 60 | }; |