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 #endif 44 {} 45 }; 46 47 static int rockchip_phy_probe(struct udevice *dev) 48 { 49 return 0; 50 } 51 52 static int rockchip_phy_bind(struct udevice *dev) 53 { 54 return 0; 55 } 56 57 U_BOOT_DRIVER(rockchip_phy) = { 58 .name = "rockchip_phy", 59 .id = UCLASS_PHY, 60 .of_match = rockchip_phy_ids, 61 .bind = rockchip_phy_bind, 62 .probe = rockchip_phy_probe, 63 }; 64 65 int rockchip_phy_power_on(struct display_state *state) 66 { 67 struct connector_state *conn_state = &state->conn_state; 68 const struct rockchip_phy *phy = conn_state->phy; 69 70 if (!phy || !phy->funcs || !phy->funcs->power_on) { 71 printf("%s: failed to find phy power on funcs\n", __func__); 72 return -ENODEV; 73 } 74 75 return phy->funcs->power_on(state); 76 } 77 78 int rockchip_phy_power_off(struct display_state *state) 79 { 80 struct connector_state *conn_state = &state->conn_state; 81 const struct rockchip_phy *phy = conn_state->phy; 82 83 if (!phy || !phy->funcs || !phy->funcs->power_off) { 84 printf("%s: failed to find phy power_off funcs\n", __func__); 85 return -ENODEV; 86 } 87 88 return phy->funcs->power_off(state); 89 } 90 91 unsigned long rockchip_phy_set_pll(struct display_state *state, 92 unsigned long rate) 93 { 94 struct connector_state *conn_state = &state->conn_state; 95 const struct rockchip_phy *phy = conn_state->phy; 96 97 if (!phy || !phy->funcs || !phy->funcs->set_pll) { 98 printf("%s: failed to find phy set_pll funcs\n", __func__); 99 return -ENODEV; 100 } 101 102 return phy->funcs->set_pll(state, rate); 103 } 104