1 /* 2 * (C) Copyright 2008-2017 Fuzhou Rockchip Electronics Co., Ltd 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #include <config.h> 8 #include <common.h> 9 #include <dm/device.h> 10 #include <errno.h> 11 #include <asm/unaligned.h> 12 #include <linux/list.h> 13 14 #include "rockchip_display.h" 15 #include "rockchip_crtc.h" 16 #include "rockchip_connector.h" 17 #include "rockchip_phy.h" 18 19 #ifdef CONFIG_DRM_ROCKCHIP_DW_MIPI_DSI 20 static const struct rockchip_phy rockchip_inno_mipi_dphy_data = { 21 .funcs = &inno_mipi_dphy_funcs, 22 }; 23 #endif 24 25 static const struct udevice_id rockchip_phy_ids[] = { 26 #ifdef CONFIG_DRM_ROCKCHIP_DW_MIPI_DSI 27 { 28 .compatible = "rockchip,px30-mipi-dphy", 29 .data = (ulong)&rockchip_inno_mipi_dphy_data, 30 }, 31 { 32 .compatible = "rockchip,rk3128-mipi-dphy", 33 .data = (ulong)&rockchip_inno_mipi_dphy_data, 34 }, 35 { 36 .compatible = "rockchip,rk3366-mipi-dphy", 37 .data = (ulong)&rockchip_inno_mipi_dphy_data, 38 }, 39 { 40 .compatible = "rockchip,rk3368-mipi-dphy", 41 .data = (ulong)&rockchip_inno_mipi_dphy_data, 42 }, 43 { 44 .compatible = "rockchip,rv1108-mipi-dphy", 45 .data = (ulong)&rockchip_inno_mipi_dphy_data, 46 }, 47 #endif 48 {} 49 }; 50 51 static int rockchip_phy_probe(struct udevice *dev) 52 { 53 return 0; 54 } 55 56 static int rockchip_phy_bind(struct udevice *dev) 57 { 58 return 0; 59 } 60 61 U_BOOT_DRIVER(rockchip_phy) = { 62 .name = "rockchip_phy", 63 .id = UCLASS_PHY, 64 .of_match = rockchip_phy_ids, 65 .bind = rockchip_phy_bind, 66 .probe = rockchip_phy_probe, 67 }; 68 69 int rockchip_phy_power_on(struct display_state *state) 70 { 71 struct connector_state *conn_state = &state->conn_state; 72 const struct rockchip_phy *phy = conn_state->phy; 73 74 if (!phy || !phy->funcs || !phy->funcs->power_on) { 75 printf("%s: failed to find phy power on funcs\n", __func__); 76 return -ENODEV; 77 } 78 79 return phy->funcs->power_on(state); 80 } 81 82 int rockchip_phy_power_off(struct display_state *state) 83 { 84 struct connector_state *conn_state = &state->conn_state; 85 const struct rockchip_phy *phy = conn_state->phy; 86 87 if (!phy || !phy->funcs || !phy->funcs->power_off) { 88 printf("%s: failed to find phy power_off funcs\n", __func__); 89 return -ENODEV; 90 } 91 92 return phy->funcs->power_off(state); 93 } 94 95 unsigned long rockchip_phy_set_pll(struct display_state *state, 96 unsigned long rate) 97 { 98 struct connector_state *conn_state = &state->conn_state; 99 const struct rockchip_phy *phy = conn_state->phy; 100 101 if (!phy || !phy->funcs || !phy->funcs->set_pll) { 102 printf("%s: failed to find phy set_pll funcs\n", __func__); 103 return -ENODEV; 104 } 105 106 return phy->funcs->set_pll(state, rate); 107 } 108