1 /*
2  * Allwinner SoCs display driver.
3  *
4  * Copyright (C) 2016 Allwinner.
5  *
6  * This file is licensed under the terms of the GNU General Public
7  * License version 2.  This program is licensed "as is" without any
8  * warranty of any kind, whether express or implied.
9  */
10 
11 #include "panels.h"
12 
13 extern struct sunxi_lcd_drv g_lcd_drv;
14 
15 /**
16  * sunxi_lcd_delay_ms.
17  * @ms: Delay time, unit: millisecond.
18  */
19 s32 sunxi_lcd_delay_ms(u32 ms);
20 
21 /**
22  * sunxi_lcd_delay_us.
23  * @us: Delay time, unit: microsecond.
24  */
25 s32 sunxi_lcd_delay_us(u32 us);
26 
27 /**
28  * sunxi_lcd_tcon_enable - enable timing controller.
29  * @screen_id: The index of screen.
30  */
31 void sunxi_lcd_tcon_enable(u32 screen_id);
32 
33 /**
34  * sunxi_lcd_dsi_mode_switch
35  * @screen_id: The index of screen.
36  * @cmd_en : enable command mode
37  * @lp_en : enable low power mode for video mode
38  */
39 void sunxi_lcd_dsi_mode_switch(u32 screen_id, u32 cmd_en, u32 lp_en);
40 
41 /**
42  * sunxi_lcd_tcon_disable - disable timing controller.
43  * @screen_id: The index of screen.
44  */
45 void sunxi_lcd_tcon_disable(u32 screen_id);
46 
47 /**
48  * sunxi_lcd_backlight_enable - enable the backlight of panel.
49  * @screen_id: The index of screen.
50  */
51 void sunxi_lcd_backlight_enable(u32 screen_id);
52 
53 /**
54  * sunxi_lcd_backlight_disable - disable the backlight of panel.
55  * @screen_id: The index of screen.
56  */
57 void sunxi_lcd_backlight_disable(u32 screen_id);
58 
59 /**
60  * sunxi_lcd_power_enable - enable the power of panel.
61  * @screen_id: The index of screen.
62  * @pwr_id:     The index of power
63  */
64 void sunxi_lcd_power_enable(u32 screen_id, u32 pwr_id);
65 
66 /**
67  * sunxi_lcd_power_disable - disable the power of panel.
68  * @screen_id: The index of screen.
69  * @pwr_id:     The index of power
70  */
71 void sunxi_lcd_power_disable(u32 screen_id, u32 pwr_id);
72 
73 /**
74  * sunxi_pwm_enable - enable pwm modules, start output pwm wave.
75  * @pwm_channel: The index of pwm channel.
76  *
77  * need to conifg gpio for pwm function
78  */
79 s32 sunxi_lcd_pwm_enable(u32 pwm_channel);
80 
81 /**
82  * sunxi_pwm_disable - disable pwm modules, stop output pwm wave.
83  * @pwm_channel: The index of pwm channel.
84  */
85 s32 sunxi_lcd_pwm_disable(u32 pwm_channel);
86 
87 /**
88 *
89 * sunxi_lcd_cpu_set_auto_mode
90 * @screen_id: The index of screen.
91  */
92 s32 sunxi_lcd_cpu_set_auto_mode(u32 screen_id);
93 
94 /**
95  * sunxi_lcd_cpu_write - write command and para to cpu panel.
96  * @scree_id: The index of screen.
97  * @command: Command to be transfer.
98  * @para: The pointer to para
99  * @para_num: The number of para
100  */
101 s32 sunxi_lcd_cpu_write(u32 screen_id, u32 index, u32 data);
102 
103 /**
104  * sunxi_lcd_cpu_write_index - write command to cpu panel.
105  * @scree_id: The index of screen.
106  * @index: Command or index to be transfer.
107  */
108 s32 sunxi_lcd_cpu_write_index(u32 scree_id, u32 index);
109 
110 /**
111  * sunxi_lcd_cpu_write_data - write data to cpu panel.
112  * @scree_id: The index of screen.
113  * @data: Data to be transfer.
114  */
115 s32 sunxi_lcd_cpu_write_data(u32 scree_id, u32 data);
116 
117 /**
118  * sunxi_lcd_dsi_dcs_write - write command and para to mipi panel(DCS type).
119  * @scree_id: The index of screen.
120  * @command: Command to be transfer.
121  * @para: The pointer to para.
122  * @para_num: The number of para
123  */
124 s32 sunxi_lcd_dsi_dcs_write(u32 scree_id, u8 command, u8 *para, u32 para_num);
125 
126 /**
127  * sunxi_lcd_dsi_dcs_write - write command and para to mipi panel.
128  * @scree_id: The index of screen.
129  * @command: Command to be transfer.
130  * @paran: Para to be transfer.
131  */
132 s32 sunxi_lcd_dsi_dcs_write_0para(u32 scree_id, u8 command);
133 s32 sunxi_lcd_dsi_dcs_write_1para(u32 scree_id, u8 command, u8 para1);
134 s32 sunxi_lcd_dsi_dcs_write_2para(u32 scree_id, u8 command, u8 para1, u8 para2);
135 s32 sunxi_lcd_dsi_dcs_write_3para(u32 scree_id, u8 command, u8 para1, u8 para2,
136                   u8 para3);
137 s32 sunxi_lcd_dsi_dcs_write_4para(u32 scree_id, u8 command, u8 para1, u8 para2,
138                   u8 para3, u8 para4);
139 s32 sunxi_lcd_dsi_dcs_write_5para(u32 scree_id, u8 command, u8 para1, u8 para2,
140                   u8 para3, u8 para4, u8 para5);
141 
142 s32 sunxi_lcd_dsi_gen_short_read0p(u32 screen_id, u8 *result);
143 s32 sunxi_lcd_dsi_gen_short_read1p(u32 screen_id, u8 para0, u8 *result);
144 s32 sunxi_lcd_dsi_gen_short_read2p(u32 screen_id, u8 para0, u8 para1,
145                    u8 *result);
146 /**
147  * @name       :sunxi_lcd_dsi_dcs_read
148  * @brief      :dcs read
149  * @param[IN]  :sel:index of dsi
150  * @param[IN]  :cmd: dcs command
151  * @param[OUT] :result: pointer of read result,larger then max ret size
152  * @param[OUT] :num_p: number of bytes have been readed
153  * @return     :number of bytes have been readed
154  */
155 s32 sunxi_lcd_dsi_dcs_read(u32 sel, u8 cmd, u8 *result, u32 *num_p);
156 /**
157  * sunxi_lcd_dsi_gen_write - write command and para to mipi panel(GEN type).
158  * @scree_id: The index of screen.
159  * @command: Command to be transfer.
160  * @para: The pointer to para.
161  * @para_num: The number of para
162  */
163 s32 sunxi_lcd_dsi_gen_write(u32 scree_id, u8 command, u8 *para, u32 para_num);
164 
165 /**
166  * @name       :sunxi_lcd_dsi_set_max_ret_size
167  * @brief      :set max ret size of dsi read
168  * @param[IN]  :sel:index of dsi
169  * @param[IN]  :size:number of byte of max size
170  * @return     :0
171  */
172 s32 sunxi_lcd_dsi_set_max_ret_size(u32 sel, u32 size);
173 
174 /**
175  * sunxi_lcd_dsi_gen_write - write command and para to mipi panel.
176  * @scree_id: The index of screen.
177  * @command: Command to be transfer.
178  * @paran: Para to be transfer.
179  */
180 s32 sunxi_lcd_dsi_gen_write_0para(u32 scree_id, u8 command);
181 s32 sunxi_lcd_dsi_gen_write_1para(u32 scree_id, u8 command, u8 para1);
182 s32 sunxi_lcd_dsi_gen_write_2para(u32 scree_id, u8 command, u8 para1, u8 para2);
183 s32 sunxi_lcd_dsi_gen_write_3para(u32 scree_id, u8 command, u8 para1, u8 para2,
184                   u8 para3);
185 s32 sunxi_lcd_dsi_gen_write_4para(u32 scree_id, u8 command, u8 para1, u8 para2,
186                   u8 para3, u8 para4);
187 s32 sunxi_lcd_dsi_gen_write_5para(u32 scree_id, u8 command, u8 para1, u8 para2,
188                   u8 para3, u8 para4, u8 para5);
189 s32 sunxi_lcd_dsi_dcs_write_6para(u32 screen_id, u8 command, u8 para1, u8 para2,
190                   u8 para3, u8 para4, u8 para5, u8 para6);
191 /**
192  * sunxi_lcd_dsi_clk_enable - enable dsi clk.
193  * @scree_id: The index of screen.
194  */
195 s32 sunxi_lcd_dsi_clk_enable(u32 scree_id);
196 
197 /**
198  * sunxi_lcd_dsi_clk_disable - disable dsi clk.
199  * @scree_id: The index of screen.
200  */
201 s32 sunxi_lcd_dsi_clk_disable(u32 scree_id);
202 
203 /**
204  * sunxi_lcd_pin_cfg - config pin panel used
205  * @screen_id: The index of screen.
206  * @bon:     1: config pin according to sys_config, 0: set disable state
207  */
208 s32 sunxi_lcd_pin_cfg(u32 screen_id, u32 bon);
209 
210 /**
211  * sunxi_lcd_set_panel_funs -  set panel functions.
212  * @name: The panel driver name.
213  * @lcd_cfg: The functions.
214  */
215 s32 sunxi_lcd_set_panel_funs(char *name, struct disp_lcd_panel_fun *lcd_cfg);
216 
217 /**
218  * sunxi_lcd_gpio_set_value
219  * @screen_id: The index of screen.
220  * @io_index:  the index of gpio
221  * @value: value of gpio to be set
222  */
223 s32 sunxi_lcd_gpio_set_value(u32 screen_id, u32 io_index, u32 value);
224 
225 /**
226  * sunxi_lcd_gpio_set_direction
227  * @screen_id: The index of screen.
228  * @io_index:  the index of gpio
229  * @direction: value of gpio to be set
230  */
231 s32 sunxi_lcd_gpio_set_direction(u32 screen_id, u32 io_index, u32 direction);
232 
233 extern struct sunxi_lcd_drv g_lcd_drv;
234