blob: 9f12ebc0624fea97533213c9ed4d13a20a1f1a3a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jean-Jacques Hiblot3b63db32017-07-24 15:18:15 +02002/*
3 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
4 * Written by Jean-Jacques Hiblot <jjhiblot@ti.com>
Jean-Jacques Hiblot3b63db32017-07-24 15:18:15 +02005 */
6
Peng Fan62ee9572020-10-15 18:05:58 +08007#include <clk.h>
Jean-Jacques Hiblot3b63db32017-07-24 15:18:15 +02008#include <common.h>
9#include <dm.h>
10#include <dm/device.h>
Peng Fan62ee9572020-10-15 18:05:58 +080011#include <dm/device_compat.h>
Jean-Jacques Hiblot3b63db32017-07-24 15:18:15 +020012#include <generic-phy.h>
13
Peng Fan62ee9572020-10-15 18:05:58 +080014struct nop_phy_priv {
15 struct clk_bulk bulk;
16};
17
18static 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
28static 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 Hiblot3b63db32017-07-24 15:18:15 +020044static const struct udevice_id nop_phy_ids[] = {
45 { .compatible = "nop-phy" },
Marek Vasut1220aa92021-03-31 11:21:07 +020046 { .compatible = "usb-nop-xceiv" },
Jean-Jacques Hiblot3b63db32017-07-24 15:18:15 +020047 { }
48};
49
50static struct phy_ops nop_phy_ops = {
Peng Fan62ee9572020-10-15 18:05:58 +080051 .init = nop_phy_init,
Jean-Jacques Hiblot3b63db32017-07-24 15:18:15 +020052};
53
54U_BOOT_DRIVER(nop_phy) = {
55 .name = "nop_phy",
56 .id = UCLASS_PHY,
57 .of_match = nop_phy_ids,
58 .ops = &nop_phy_ops,
Peng Fan62ee9572020-10-15 18:05:58 +080059 .probe = nop_phy_probe,
Simon Glass41575d82020-12-03 16:55:17 -070060 .priv_auto = sizeof(struct nop_phy_priv),
Jean-Jacques Hiblot3b63db32017-07-24 15:18:15 +020061};