1186f8572SMark Yao /*
2186f8572SMark Yao * (C) Copyright 2008-2017 Fuzhou Rockchip Electronics Co., Ltd
3186f8572SMark Yao *
4186f8572SMark Yao * SPDX-License-Identifier: GPL-2.0+
5186f8572SMark Yao */
6186f8572SMark Yao
7186f8572SMark Yao #include <common.h>
8186f8572SMark Yao #include "rockchip_phy.h"
9186f8572SMark Yao
rockchip_phy_init(struct rockchip_phy * phy)1015081c50SWyon Bi int rockchip_phy_init(struct rockchip_phy *phy)
1115081c50SWyon Bi {
1215081c50SWyon Bi if (!phy)
1315081c50SWyon Bi return -ENODEV;
144b8c2ef1SMark Yao
157cacd0a8SWyon Bi if (phy->funcs && phy->funcs->init)
1615081c50SWyon Bi return phy->funcs->init(phy);
178e2bab3fSAlgea Cao
184b8c2ef1SMark Yao return 0;
19186f8572SMark Yao }
20186f8572SMark Yao
rockchip_phy_power_on(struct rockchip_phy * phy)2115081c50SWyon Bi int rockchip_phy_power_on(struct rockchip_phy *phy)
224b8c2ef1SMark Yao {
2315081c50SWyon Bi if (!phy)
2415081c50SWyon Bi return -ENODEV;
2515081c50SWyon Bi
267cacd0a8SWyon Bi if (phy->funcs && phy->funcs->power_on)
2715081c50SWyon Bi return phy->funcs->power_on(phy);
2815081c50SWyon Bi
294b8c2ef1SMark Yao return 0;
30186f8572SMark Yao }
31186f8572SMark Yao
rockchip_phy_power_off(struct rockchip_phy * phy)3215081c50SWyon Bi int rockchip_phy_power_off(struct rockchip_phy *phy)
33186f8572SMark Yao {
3415081c50SWyon Bi if (!phy)
35186f8572SMark Yao return -ENODEV;
3615081c50SWyon Bi
3715081c50SWyon Bi if (phy->funcs && phy->funcs->power_off)
3815081c50SWyon Bi return phy->funcs->power_off(phy);
3915081c50SWyon Bi
4015081c50SWyon Bi return 0;
41186f8572SMark Yao }
42186f8572SMark Yao
rockchip_phy_set_pll(struct rockchip_phy * phy,unsigned long rate)4315081c50SWyon Bi unsigned long rockchip_phy_set_pll(struct rockchip_phy *phy,
44186f8572SMark Yao unsigned long rate)
45186f8572SMark Yao {
4615081c50SWyon Bi if (!phy)
47186f8572SMark Yao return -ENODEV;
4815081c50SWyon Bi
4915081c50SWyon Bi if (phy->funcs && phy->funcs->set_pll)
5015081c50SWyon Bi return phy->funcs->set_pll(phy, rate);
5115081c50SWyon Bi
5215081c50SWyon Bi return 0;
53186f8572SMark Yao }
54186f8572SMark Yao
rockchip_phy_set_bus_width(struct rockchip_phy * phy,u32 bus_width)5515081c50SWyon Bi int rockchip_phy_set_bus_width(struct rockchip_phy *phy, u32 bus_width)
568e2bab3fSAlgea Cao {
5715081c50SWyon Bi if (!phy)
588e2bab3fSAlgea Cao return -ENODEV;
5915081c50SWyon Bi
6015081c50SWyon Bi if (phy->funcs && phy->funcs->set_bus_width)
6115081c50SWyon Bi return phy->funcs->set_bus_width(phy, bus_width);
6215081c50SWyon Bi
6315081c50SWyon Bi return 0;
648e2bab3fSAlgea Cao }
658e2bab3fSAlgea Cao
rockchip_phy_round_rate(struct rockchip_phy * phy,unsigned long rate)6615081c50SWyon Bi long rockchip_phy_round_rate(struct rockchip_phy *phy, unsigned long rate)
6715081c50SWyon Bi {
6815081c50SWyon Bi if (!phy)
6915081c50SWyon Bi return -ENODEV;
7015081c50SWyon Bi
7115081c50SWyon Bi if (phy->funcs && phy->funcs->round_rate)
7215081c50SWyon Bi return phy->funcs->round_rate(phy, rate);
7315081c50SWyon Bi
7415081c50SWyon Bi return 0;
758e2bab3fSAlgea Cao }
76*396701fdSWyon Bi
rockchip_phy_set_mode(struct rockchip_phy * phy,enum phy_mode mode)77*396701fdSWyon Bi int rockchip_phy_set_mode(struct rockchip_phy *phy, enum phy_mode mode)
78*396701fdSWyon Bi {
79*396701fdSWyon Bi if (!phy)
80*396701fdSWyon Bi return -ENODEV;
81*396701fdSWyon Bi
82*396701fdSWyon Bi if (phy->funcs && phy->funcs->set_mode)
83*396701fdSWyon Bi return phy->funcs->set_mode(phy, mode);
84*396701fdSWyon Bi
85*396701fdSWyon Bi return 0;
86*396701fdSWyon Bi }
87