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