1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. 4 */ 5 6 #ifndef _DP_PARSER_H_ 7 #define _DP_PARSER_H_ 8 9 #include <linux/platform_device.h> 10 #include <linux/phy/phy.h> 11 #include <linux/phy/phy-dp.h> 12 13 #include "msm_drv.h" 14 15 #define DP_LABEL "MDSS DP DISPLAY" 16 #define DP_MAX_PIXEL_CLK_KHZ 675000 17 #define DP_MAX_NUM_DP_LANES 4 18 19 enum dp_pm_type { 20 DP_CORE_PM, 21 DP_CTRL_PM, 22 DP_STREAM_PM, 23 DP_PHY_PM, 24 DP_MAX_PM 25 }; 26 27 struct dss_io_region { 28 size_t len; 29 void __iomem *base; 30 }; 31 32 struct dss_io_data { 33 struct dss_io_region ahb; 34 struct dss_io_region aux; 35 struct dss_io_region link; 36 struct dss_io_region p0; 37 }; 38 39 static inline const char *dp_parser_pm_name(enum dp_pm_type module) 40 { 41 switch (module) { 42 case DP_CORE_PM: return "DP_CORE_PM"; 43 case DP_CTRL_PM: return "DP_CTRL_PM"; 44 case DP_STREAM_PM: return "DP_STREAM_PM"; 45 case DP_PHY_PM: return "DP_PHY_PM"; 46 default: return "???"; 47 } 48 } 49 50 /** 51 * struct dp_display_data - display related device tree data. 52 * 53 * @ctrl_node: referece to controller device 54 * @phy_node: reference to phy device 55 * @is_active: is the controller currently active 56 * @name: name of the display 57 * @display_type: type of the display 58 */ 59 struct dp_display_data { 60 struct device_node *ctrl_node; 61 struct device_node *phy_node; 62 bool is_active; 63 const char *name; 64 const char *display_type; 65 }; 66 67 /** 68 * struct dp_ctrl_resource - controller's IO related data 69 * 70 * @dp_controller: Display Port controller mapped memory address 71 * @phy_io: phy's mapped memory address 72 */ 73 struct dp_io { 74 struct dss_io_data dp_controller; 75 struct phy *phy; 76 union phy_configure_opts phy_opts; 77 }; 78 79 /** 80 * struct dp_pinctrl - DP's pin control 81 * 82 * @pin: pin-controller's instance 83 * @state_active: active state pin control 84 * @state_hpd_active: hpd active state pin control 85 * @state_suspend: suspend state pin control 86 */ 87 struct dp_pinctrl { 88 struct pinctrl *pin; 89 struct pinctrl_state *state_active; 90 struct pinctrl_state *state_hpd_active; 91 struct pinctrl_state *state_suspend; 92 }; 93 94 #define DP_DEV_REGULATOR_MAX 4 95 96 /* Regulators for DP devices */ 97 struct dp_reg_entry { 98 char name[32]; 99 int enable_load; 100 int disable_load; 101 }; 102 103 struct dp_regulator_cfg { 104 int num; 105 struct dp_reg_entry regs[DP_DEV_REGULATOR_MAX]; 106 }; 107 108 struct dss_module_power { 109 unsigned int num_clk; 110 struct clk_bulk_data *clocks; 111 }; 112 113 /** 114 * struct dp_parser - DP parser's data exposed to clients 115 * 116 * @pdev: platform data of the client 117 * @mp: gpio, regulator and clock related data 118 * @pinctrl: pin-control related data 119 * @disp_data: controller's display related data 120 * @parse: function to be called by client to parse device tree. 121 */ 122 struct dp_parser { 123 struct platform_device *pdev; 124 struct dss_module_power mp[DP_MAX_PM]; 125 struct dp_pinctrl pinctrl; 126 struct dp_io io; 127 struct dp_display_data disp_data; 128 const struct dp_regulator_cfg *regulator_cfg; 129 u32 max_dp_lanes; 130 struct drm_bridge *next_bridge; 131 132 int (*parse)(struct dp_parser *parser); 133 }; 134 135 /** 136 * dp_parser_get() - get the DP's device tree parser module 137 * 138 * @pdev: platform data of the client 139 * return: pointer to dp_parser structure. 140 * 141 * This function provides client capability to parse the 142 * device tree and populate the data structures. The data 143 * related to clock, regulators, pin-control and other 144 * can be parsed using this module. 145 */ 146 struct dp_parser *dp_parser_get(struct platform_device *pdev); 147 148 /** 149 * dp_parser_find_next_bridge() - find an additional bridge to DP 150 * 151 * @parser: dp_parser data from client 152 * 153 * This function is used to find any additional bridge attached to 154 * the DP controller. The eDP interface requires a panel bridge. 155 * 156 * Return: 0 if able to get the bridge, otherwise negative errno for failure. 157 */ 158 int dp_parser_find_next_bridge(struct dp_parser *parser); 159 160 #endif 161