xref: /OK3568_Linux_fs/u-boot/drivers/video/drm/rockchip_phy.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * (C) Copyright 2008-2017 Fuzhou Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include "rockchip_phy.h"
9 
rockchip_phy_init(struct rockchip_phy * phy)10 int rockchip_phy_init(struct rockchip_phy *phy)
11 {
12 	if (!phy)
13 		return -ENODEV;
14 
15 	if (phy->funcs && phy->funcs->init)
16 		return phy->funcs->init(phy);
17 
18 	return 0;
19 }
20 
rockchip_phy_power_on(struct rockchip_phy * phy)21 int rockchip_phy_power_on(struct rockchip_phy *phy)
22 {
23 	if (!phy)
24 		return -ENODEV;
25 
26 	if (phy->funcs && phy->funcs->power_on)
27 		return phy->funcs->power_on(phy);
28 
29 	return 0;
30 }
31 
rockchip_phy_power_off(struct rockchip_phy * phy)32 int rockchip_phy_power_off(struct rockchip_phy *phy)
33 {
34 	if (!phy)
35 		return -ENODEV;
36 
37 	if (phy->funcs && phy->funcs->power_off)
38 		return phy->funcs->power_off(phy);
39 
40 	return 0;
41 }
42 
rockchip_phy_set_pll(struct rockchip_phy * phy,unsigned long rate)43 unsigned long rockchip_phy_set_pll(struct rockchip_phy *phy,
44 				   unsigned long rate)
45 {
46 	if (!phy)
47 		return -ENODEV;
48 
49 	if (phy->funcs && phy->funcs->set_pll)
50 		return phy->funcs->set_pll(phy, rate);
51 
52 	return 0;
53 }
54 
rockchip_phy_set_bus_width(struct rockchip_phy * phy,u32 bus_width)55 int rockchip_phy_set_bus_width(struct rockchip_phy *phy, u32 bus_width)
56 {
57 	if (!phy)
58 		return -ENODEV;
59 
60 	if (phy->funcs && phy->funcs->set_bus_width)
61 		return phy->funcs->set_bus_width(phy, bus_width);
62 
63 	return 0;
64 }
65 
rockchip_phy_round_rate(struct rockchip_phy * phy,unsigned long rate)66 long rockchip_phy_round_rate(struct rockchip_phy *phy, unsigned long rate)
67 {
68 	if (!phy)
69 		return -ENODEV;
70 
71 	if (phy->funcs && phy->funcs->round_rate)
72 		return phy->funcs->round_rate(phy, rate);
73 
74 	return 0;
75 }
76 
rockchip_phy_set_mode(struct rockchip_phy * phy,enum phy_mode mode)77 int rockchip_phy_set_mode(struct rockchip_phy *phy, enum phy_mode mode)
78 {
79 	if (!phy)
80 		return -ENODEV;
81 
82 	if (phy->funcs && phy->funcs->set_mode)
83 		return phy->funcs->set_mode(phy, mode);
84 
85 	return 0;
86 }
87