1 /* 2 * (C) Copyright 2008-2017 Fuzhou Rockchip Electronics Co., Ltd 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #ifndef _ROCKCHIP_CONNECTOR_H_ 8 #define _ROCKCHIP_CONNECTOR_H_ 9 10 #ifdef CONFIG_SPL_BUILD 11 struct rockchip_connector { 12 struct rockchip_phy *phy; 13 int id; 14 int type; 15 bool hpd; 16 17 const struct rockchip_connector_funcs *funcs; 18 void *data; 19 }; 20 #else 21 #include "rockchip_bridge.h" 22 #include "rockchip_panel.h" 23 24 struct rockchip_connector { 25 struct udevice *dev; 26 struct rockchip_bridge *bridge; 27 struct rockchip_panel *panel; 28 struct rockchip_phy *phy; 29 struct list_head head; 30 int id; 31 int type; 32 bool hpd; 33 bool split_mode; 34 bool dual_channel_mode; 35 36 const struct rockchip_connector_funcs *funcs; 37 void *data; 38 }; 39 #endif 40 41 /** 42 * enum drm_bus_flags - bus_flags info for &drm_display_info 43 * 44 * This enum defines signal polarities and clock edge information for signals on 45 * a bus as bitmask flags. 46 * 47 * The clock edge information is conveyed by two sets of symbols, 48 * DRM_BUS_FLAGS_*_DRIVE_\* and DRM_BUS_FLAGS_*_SAMPLE_\*. When this enum is 49 * used to describe a bus from the point of view of the transmitter, the 50 * \*_DRIVE_\* flags should be used. When used from the point of view of the 51 * receiver, the \*_SAMPLE_\* flags should be used. The \*_DRIVE_\* and 52 * \*_SAMPLE_\* flags alias each other, with the \*_SAMPLE_POSEDGE and 53 * \*_SAMPLE_NEGEDGE flags being equal to \*_DRIVE_NEGEDGE and \*_DRIVE_POSEDGE 54 * respectively. This simplifies code as signals are usually sampled on the 55 * opposite edge of the driving edge. Transmitters and receivers may however 56 * need to take other signal timings into account to convert between driving 57 * and sample edges. 58 */ 59 enum drm_bus_flags { 60 /** 61 * @DRM_BUS_FLAG_DE_LOW: 62 * 63 * The Data Enable signal is active low 64 */ 65 DRM_BUS_FLAG_DE_LOW = BIT(0), 66 67 /** 68 * @DRM_BUS_FLAG_DE_HIGH: 69 * 70 * The Data Enable signal is active high 71 */ 72 DRM_BUS_FLAG_DE_HIGH = BIT(1), 73 74 /** 75 * @DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE: 76 * 77 * Data is driven on the rising edge of the pixel clock 78 */ 79 DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE = BIT(2), 80 81 /** 82 * @DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE: 83 * 84 * Data is driven on the falling edge of the pixel clock 85 */ 86 DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE = BIT(3), 87 88 /** 89 * @DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE: 90 * 91 * Data is sampled on the rising edge of the pixel clock 92 */ 93 DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE, 94 95 /** 96 * @DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE: 97 * 98 * Data is sampled on the falling edge of the pixel clock 99 */ 100 DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE, 101 102 /** 103 * @DRM_BUS_FLAG_DATA_MSB_TO_LSB: 104 * 105 * Data is transmitted MSB to LSB on the bus 106 */ 107 DRM_BUS_FLAG_DATA_MSB_TO_LSB = BIT(4), 108 109 /** 110 * @DRM_BUS_FLAG_DATA_LSB_TO_MSB: 111 * 112 * Data is transmitted LSB to MSB on the bus 113 */ 114 DRM_BUS_FLAG_DATA_LSB_TO_MSB = BIT(5), 115 116 /** 117 * @DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE: 118 * 119 * Sync signals are driven on the rising edge of the pixel clock 120 */ 121 DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE = BIT(6), 122 123 /** 124 * @DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE: 125 * 126 * Sync signals are driven on the falling edge of the pixel clock 127 */ 128 DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE = BIT(7), 129 130 /** 131 * @DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE: 132 * 133 * Sync signals are sampled on the rising edge of the pixel clock 134 */ 135 DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE = DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE, 136 137 /** 138 * @DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE: 139 * 140 * Sync signals are sampled on the falling edge of the pixel clock 141 */ 142 DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE = DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE, 143 144 /** 145 * @DRM_BUS_FLAG_SHARP_SIGNALS: 146 * 147 * Set if the Sharp-specific signals (SPL, CLS, PS, REV) must be used 148 */ 149 DRM_BUS_FLAG_SHARP_SIGNALS = BIT(8), 150 }; 151 152 struct rockchip_connector_funcs { 153 /* 154 * pre init connector, prepare some parameter out_if, this will be 155 * used by rockchip_display.c and vop 156 */ 157 int (*pre_init)(struct rockchip_connector *connector, struct display_state *state); 158 159 /* 160 * init connector, prepare resource to ensure 161 * detect and get_timing can works 162 */ 163 int (*init)(struct rockchip_connector *connector, struct display_state *state); 164 165 void (*deinit)(struct rockchip_connector *connector, struct display_state *state); 166 /* 167 * Optional, if connector not support hotplug, 168 * Returns: 169 * 0 means disconnected, else means connected 170 */ 171 int (*detect)(struct rockchip_connector *connector, struct display_state *state); 172 /* 173 * Optional, if implement it, need fill the timing data: 174 * state->conn_state->mode 175 * you can refer to the rockchip_display: display_get_timing(), 176 * Returns: 177 * 0 means success, else means failed 178 */ 179 int (*get_timing)(struct rockchip_connector *connector, struct display_state *state); 180 /* 181 * Optional, if implement it, need fill the edid data: 182 * state->conn_state->edid 183 * Returns: 184 * 0 means success, else means failed 185 */ 186 int (*get_edid)(struct rockchip_connector *connector, struct display_state *state); 187 /* 188 * call before crtc enable. 189 */ 190 int (*prepare)(struct rockchip_connector *connector, struct display_state *state); 191 /* 192 * call after crtc enable 193 */ 194 int (*enable)(struct rockchip_connector *connector, struct display_state *state); 195 int (*disable)(struct rockchip_connector *connector, struct display_state *state); 196 void (*unprepare)(struct rockchip_connector *connector, struct display_state *state); 197 198 int (*check)(struct rockchip_connector *connector, struct display_state *state); 199 int (*mode_valid)(struct rockchip_connector *connector, struct display_state *state); 200 }; 201 202 const struct rockchip_connector * 203 rockchip_get_connector(const void *blob, int connector_node); 204 int rockchip_connector_bind(struct rockchip_connector *connector, struct udevice *dev, int id, 205 const struct rockchip_connector_funcs *funcs, void *data, int type); 206 struct rockchip_connector *get_rockchip_connector_by_device(struct udevice *dev); 207 int rockchip_connector_pre_init(struct display_state *state); 208 int rockchip_connector_init(struct display_state *state); 209 int rockchip_connector_deinit(struct display_state *state); 210 bool rockchip_connector_detect(struct display_state *state); 211 int rockchip_connector_get_timing(struct display_state *state); 212 int rockchip_connector_get_edid(struct display_state *state); 213 int rockchip_connector_pre_enable(struct display_state *state); 214 int rockchip_connector_enable(struct display_state *state); 215 int rockchip_connector_disable(struct display_state *state); 216 int rockchip_connector_post_disable(struct display_state *state); 217 218 #ifdef CONFIG_DRM_ROCKCHIP_ANALOGIX_DP 219 struct rockchip_dp_chip_data; 220 extern const struct rockchip_connector_funcs rockchip_analogix_dp_funcs; 221 extern const struct rockchip_dp_chip_data rk3399_analogix_edp_drv_data; 222 extern const struct rockchip_dp_chip_data rk3368_analogix_edp_drv_data; 223 extern const struct rockchip_dp_chip_data rk3288_analogix_dp_drv_data; 224 #endif 225 #endif 226