Merge tag 'v2021.01-rc5' into next
[platform/kernel/u-boot.git] / drivers / phy / nop-phy.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
4  * Written by Jean-Jacques Hiblot  <jjhiblot@ti.com>
5  */
6
7 #include <clk.h>
8 #include <common.h>
9 #include <dm.h>
10 #include <dm/device.h>
11 #include <dm/device_compat.h>
12 #include <generic-phy.h>
13
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
44 static const struct udevice_id nop_phy_ids[] = {
45         { .compatible = "nop-phy" },
46         { }
47 };
48
49 static struct phy_ops nop_phy_ops = {
50         .init = nop_phy_init,
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,
58         .probe = nop_phy_probe,
59         .priv_auto      = sizeof(struct nop_phy_priv),
60 };