xref: /openbmc/u-boot/drivers/video/s6e8ax0.c (revision 9c17a325)
1bba09e9fSDonghwa Lee /*
2bba09e9fSDonghwa Lee  * Copyright (C) 2012 Samsung Electronics
3bba09e9fSDonghwa Lee  *
4bba09e9fSDonghwa Lee  * Author: Donghwa Lee <dh09.lee@samsung.com>
5bba09e9fSDonghwa Lee  *
61a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
7bba09e9fSDonghwa Lee  */
8bba09e9fSDonghwa Lee 
9bba09e9fSDonghwa Lee #include <common.h>
10bba09e9fSDonghwa Lee #include <asm/arch/mipi_dsim.h>
11bba09e9fSDonghwa Lee 
12bba09e9fSDonghwa Lee #include "exynos_mipi_dsi_lowlevel.h"
13bba09e9fSDonghwa Lee #include "exynos_mipi_dsi_common.h"
14bba09e9fSDonghwa Lee 
15bba09e9fSDonghwa Lee static void s6e8ax0_panel_cond(struct mipi_dsim_device *dsim_dev)
16bba09e9fSDonghwa Lee {
17bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
183d024086SDonghwa Lee 	int reverse = dsim_dev->dsim_lcd_dev->reverse_panel;
19b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
20bba09e9fSDonghwa Lee 		0xf8, 0x3d, 0x35, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x4c,
21bba09e9fSDonghwa Lee 		0x6e, 0x10, 0x27, 0x7d, 0x3f, 0x10, 0x00, 0x00, 0x20,
22bba09e9fSDonghwa Lee 		0x04, 0x08, 0x6e, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08,
23bba09e9fSDonghwa Lee 		0x23, 0x23, 0xc0, 0xc8, 0x08, 0x48, 0xc1, 0x00, 0xc3,
24bba09e9fSDonghwa Lee 		0xff, 0xff, 0xc8
25bba09e9fSDonghwa Lee 	};
26bba09e9fSDonghwa Lee 
27b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send_reverse[] = {
283d024086SDonghwa Lee 		0xf8, 0x19, 0x35, 0x00, 0x00, 0x00, 0x93, 0x00, 0x3c,
293d024086SDonghwa Lee 		0x7d, 0x08, 0x27, 0x7d, 0x3f, 0x00, 0x00, 0x00, 0x20,
303d024086SDonghwa Lee 		0x04, 0x08, 0x6e, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08,
313d024086SDonghwa Lee 		0x23, 0x23, 0xc0, 0xc1, 0x01, 0x41, 0xc1, 0x00, 0xc1,
323d024086SDonghwa Lee 		0xf6, 0xf6, 0xc1
333d024086SDonghwa Lee 	};
343d024086SDonghwa Lee 
353d024086SDonghwa Lee 	if (reverse) {
363d024086SDonghwa Lee 		ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
37*9c17a325SDonghwa Lee 			data_to_send_reverse,
383d024086SDonghwa Lee 			ARRAY_SIZE(data_to_send_reverse));
393d024086SDonghwa Lee 	} else {
40bba09e9fSDonghwa Lee 		ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
41*9c17a325SDonghwa Lee 			data_to_send, ARRAY_SIZE(data_to_send));
42bba09e9fSDonghwa Lee 	}
433d024086SDonghwa Lee }
44bba09e9fSDonghwa Lee 
45bba09e9fSDonghwa Lee static void s6e8ax0_display_cond(struct mipi_dsim_device *dsim_dev)
46bba09e9fSDonghwa Lee {
47bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
48b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
49bba09e9fSDonghwa Lee 		0xf2, 0x80, 0x03, 0x0d
50bba09e9fSDonghwa Lee 	};
51bba09e9fSDonghwa Lee 
52bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
53*9c17a325SDonghwa Lee 			data_to_send, ARRAY_SIZE(data_to_send));
54bba09e9fSDonghwa Lee }
55bba09e9fSDonghwa Lee 
56bba09e9fSDonghwa Lee static void s6e8ax0_gamma_cond(struct mipi_dsim_device *dsim_dev)
57bba09e9fSDonghwa Lee {
58bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
598ecb4c64SDonghwa Lee 	/* 7500K 2.2 Set : 30cd */
60b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
618ecb4c64SDonghwa Lee 		0xfa, 0x01, 0x60, 0x10, 0x60, 0xf5, 0x00, 0xff, 0xad,
628ecb4c64SDonghwa Lee 		0xaf, 0xba, 0xc3, 0xd8, 0xc5, 0x9f, 0xc6, 0x9e, 0xc1,
638ecb4c64SDonghwa Lee 		0xdc, 0xc0, 0x00, 0x61, 0x00, 0x5a, 0x00, 0x74,
64bba09e9fSDonghwa Lee 	};
65bba09e9fSDonghwa Lee 
66bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
67*9c17a325SDonghwa Lee 			data_to_send, ARRAY_SIZE(data_to_send));
68bba09e9fSDonghwa Lee }
69bba09e9fSDonghwa Lee 
70bba09e9fSDonghwa Lee static void s6e8ax0_gamma_update(struct mipi_dsim_device *dsim_dev)
71bba09e9fSDonghwa Lee {
72bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
73*9c17a325SDonghwa Lee 	static const unsigned char data_to_send[] = {
74*9c17a325SDonghwa Lee 		0xf7, 0x03
75*9c17a325SDonghwa Lee 	};
76bba09e9fSDonghwa Lee 
77*9c17a325SDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, data_to_send,
78*9c17a325SDonghwa Lee 			ARRAY_SIZE(data_to_send));
79bba09e9fSDonghwa Lee }
80bba09e9fSDonghwa Lee 
81bba09e9fSDonghwa Lee static void s6e8ax0_etc_source_control(struct mipi_dsim_device *dsim_dev)
82bba09e9fSDonghwa Lee {
83bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
84b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
85bba09e9fSDonghwa Lee 		0xf6, 0x00, 0x02, 0x00
86bba09e9fSDonghwa Lee 	};
87bba09e9fSDonghwa Lee 
88bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
89*9c17a325SDonghwa Lee 			data_to_send, ARRAY_SIZE(data_to_send));
90bba09e9fSDonghwa Lee }
91bba09e9fSDonghwa Lee 
92bba09e9fSDonghwa Lee static void s6e8ax0_etc_pentile_control(struct mipi_dsim_device *dsim_dev)
93bba09e9fSDonghwa Lee {
94bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
95b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
96bba09e9fSDonghwa Lee 		0xb6, 0x0c, 0x02, 0x03, 0x32, 0xff, 0x44, 0x44, 0xc0,
97bba09e9fSDonghwa Lee 		0x00
98bba09e9fSDonghwa Lee 	};
99bba09e9fSDonghwa Lee 
100bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
101*9c17a325SDonghwa Lee 			data_to_send, ARRAY_SIZE(data_to_send));
102bba09e9fSDonghwa Lee }
103bba09e9fSDonghwa Lee 
104bba09e9fSDonghwa Lee static void s6e8ax0_etc_mipi_control1(struct mipi_dsim_device *dsim_dev)
105bba09e9fSDonghwa Lee {
106bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
107b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
108bba09e9fSDonghwa Lee 		0xe1, 0x10, 0x1c, 0x17, 0x08, 0x1d
109bba09e9fSDonghwa Lee 	};
110bba09e9fSDonghwa Lee 
111bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
112*9c17a325SDonghwa Lee 			data_to_send, ARRAY_SIZE(data_to_send));
113bba09e9fSDonghwa Lee }
114bba09e9fSDonghwa Lee 
115bba09e9fSDonghwa Lee static void s6e8ax0_etc_mipi_control2(struct mipi_dsim_device *dsim_dev)
116bba09e9fSDonghwa Lee {
117bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
118b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
119bba09e9fSDonghwa Lee 		0xe2, 0xed, 0x07, 0xc3, 0x13, 0x0d, 0x03
120bba09e9fSDonghwa Lee 	};
121bba09e9fSDonghwa Lee 
122bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
123*9c17a325SDonghwa Lee 			data_to_send, ARRAY_SIZE(data_to_send));
124bba09e9fSDonghwa Lee }
125bba09e9fSDonghwa Lee 
126bba09e9fSDonghwa Lee static void s6e8ax0_etc_power_control(struct mipi_dsim_device *dsim_dev)
127bba09e9fSDonghwa Lee {
128bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
129b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
130bba09e9fSDonghwa Lee 		0xf4, 0xcf, 0x0a, 0x12, 0x10, 0x19, 0x33, 0x02
131bba09e9fSDonghwa Lee 	};
132bba09e9fSDonghwa Lee 
133bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
134*9c17a325SDonghwa Lee 		data_to_send, ARRAY_SIZE(data_to_send));
135bba09e9fSDonghwa Lee }
136bba09e9fSDonghwa Lee 
137bba09e9fSDonghwa Lee static void s6e8ax0_etc_mipi_control3(struct mipi_dsim_device *dsim_dev)
138bba09e9fSDonghwa Lee {
139bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
140*9c17a325SDonghwa Lee 	static const unsigned char data_to_send[] = {
141*9c17a325SDonghwa Lee 		0xe3, 0x40
142*9c17a325SDonghwa Lee 	};
143bba09e9fSDonghwa Lee 
144*9c17a325SDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, data_to_send,
145*9c17a325SDonghwa Lee 		       ARRAY_SIZE(data_to_send));
146bba09e9fSDonghwa Lee }
147bba09e9fSDonghwa Lee 
148bba09e9fSDonghwa Lee static void s6e8ax0_etc_mipi_control4(struct mipi_dsim_device *dsim_dev)
149bba09e9fSDonghwa Lee {
150bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
151b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
152bba09e9fSDonghwa Lee 		0xe4, 0x00, 0x00, 0x14, 0x80, 0x00, 0x00, 0x00
153bba09e9fSDonghwa Lee 	};
154bba09e9fSDonghwa Lee 
155bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
156*9c17a325SDonghwa Lee 		data_to_send, ARRAY_SIZE(data_to_send));
157bba09e9fSDonghwa Lee }
158bba09e9fSDonghwa Lee 
159bba09e9fSDonghwa Lee static void s6e8ax0_elvss_set(struct mipi_dsim_device *dsim_dev)
160bba09e9fSDonghwa Lee {
161bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
162b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
163bba09e9fSDonghwa Lee 		0xb1, 0x04, 0x00
164bba09e9fSDonghwa Lee 	};
165bba09e9fSDonghwa Lee 
166bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
167*9c17a325SDonghwa Lee 			data_to_send, ARRAY_SIZE(data_to_send));
168bba09e9fSDonghwa Lee }
169bba09e9fSDonghwa Lee 
170bba09e9fSDonghwa Lee static void s6e8ax0_display_on(struct mipi_dsim_device *dsim_dev)
171bba09e9fSDonghwa Lee {
172bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
173*9c17a325SDonghwa Lee 	static const unsigned char data_to_send[] = {
174*9c17a325SDonghwa Lee 		0x29, 0x00
175*9c17a325SDonghwa Lee 	};
176bba09e9fSDonghwa Lee 
177*9c17a325SDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_SHORT_WRITE, data_to_send,
178*9c17a325SDonghwa Lee 		       ARRAY_SIZE(data_to_send));
179bba09e9fSDonghwa Lee }
180bba09e9fSDonghwa Lee 
181bba09e9fSDonghwa Lee static void s6e8ax0_sleep_out(struct mipi_dsim_device *dsim_dev)
182bba09e9fSDonghwa Lee {
183bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
184*9c17a325SDonghwa Lee 	static const unsigned char data_to_send[] = {
185*9c17a325SDonghwa Lee 		0x11, 0x00
186*9c17a325SDonghwa Lee 	};
187bba09e9fSDonghwa Lee 
188*9c17a325SDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_SHORT_WRITE, data_to_send,
189*9c17a325SDonghwa Lee 		       ARRAY_SIZE(data_to_send));
190bba09e9fSDonghwa Lee }
191bba09e9fSDonghwa Lee 
192bba09e9fSDonghwa Lee static void s6e8ax0_apply_level1_key(struct mipi_dsim_device *dsim_dev)
193bba09e9fSDonghwa Lee {
194bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
195b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
196bba09e9fSDonghwa Lee 		0xf0, 0x5a, 0x5a
197bba09e9fSDonghwa Lee 	};
198bba09e9fSDonghwa Lee 
199bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
200*9c17a325SDonghwa Lee 		data_to_send, ARRAY_SIZE(data_to_send));
201bba09e9fSDonghwa Lee }
202bba09e9fSDonghwa Lee 
203bba09e9fSDonghwa Lee static void s6e8ax0_apply_mtp_key(struct mipi_dsim_device *dsim_dev)
204bba09e9fSDonghwa Lee {
205bba09e9fSDonghwa Lee 	struct mipi_dsim_master_ops *ops = dsim_dev->master_ops;
206b1d8654bSPiotr Wilczek 	static const unsigned char data_to_send[] = {
207bba09e9fSDonghwa Lee 		0xf1, 0x5a, 0x5a
208bba09e9fSDonghwa Lee 	};
209bba09e9fSDonghwa Lee 
210bba09e9fSDonghwa Lee 	ops->cmd_write(dsim_dev, MIPI_DSI_DCS_LONG_WRITE,
211*9c17a325SDonghwa Lee 		data_to_send, ARRAY_SIZE(data_to_send));
212bba09e9fSDonghwa Lee }
213bba09e9fSDonghwa Lee 
214bba09e9fSDonghwa Lee static void s6e8ax0_panel_init(struct mipi_dsim_device *dsim_dev)
215bba09e9fSDonghwa Lee {
216bba09e9fSDonghwa Lee 	/*
217bba09e9fSDonghwa Lee 	 * in case of setting gamma and panel condition at first,
218bba09e9fSDonghwa Lee 	 * it shuold be setting like below.
219bba09e9fSDonghwa Lee 	 * set_gamma() -> set_panel_condition()
220bba09e9fSDonghwa Lee 	 */
221bba09e9fSDonghwa Lee 
222bba09e9fSDonghwa Lee 	s6e8ax0_apply_level1_key(dsim_dev);
223bba09e9fSDonghwa Lee 	s6e8ax0_apply_mtp_key(dsim_dev);
224bba09e9fSDonghwa Lee 
225bba09e9fSDonghwa Lee 	s6e8ax0_sleep_out(dsim_dev);
226bba09e9fSDonghwa Lee 	mdelay(5);
227bba09e9fSDonghwa Lee 	s6e8ax0_panel_cond(dsim_dev);
228bba09e9fSDonghwa Lee 	s6e8ax0_display_cond(dsim_dev);
229bba09e9fSDonghwa Lee 	s6e8ax0_gamma_cond(dsim_dev);
230bba09e9fSDonghwa Lee 	s6e8ax0_gamma_update(dsim_dev);
231bba09e9fSDonghwa Lee 
232bba09e9fSDonghwa Lee 	s6e8ax0_etc_source_control(dsim_dev);
233bba09e9fSDonghwa Lee 	s6e8ax0_elvss_set(dsim_dev);
234bba09e9fSDonghwa Lee 	s6e8ax0_etc_pentile_control(dsim_dev);
235bba09e9fSDonghwa Lee 	s6e8ax0_etc_mipi_control1(dsim_dev);
236bba09e9fSDonghwa Lee 	s6e8ax0_etc_mipi_control2(dsim_dev);
237bba09e9fSDonghwa Lee 	s6e8ax0_etc_power_control(dsim_dev);
238bba09e9fSDonghwa Lee 	s6e8ax0_etc_mipi_control3(dsim_dev);
239bba09e9fSDonghwa Lee 	s6e8ax0_etc_mipi_control4(dsim_dev);
240bba09e9fSDonghwa Lee }
241bba09e9fSDonghwa Lee 
242bba09e9fSDonghwa Lee static int s6e8ax0_panel_set(struct mipi_dsim_device *dsim_dev)
243bba09e9fSDonghwa Lee {
244bba09e9fSDonghwa Lee 	s6e8ax0_panel_init(dsim_dev);
245bba09e9fSDonghwa Lee 
246bba09e9fSDonghwa Lee 	return 0;
247bba09e9fSDonghwa Lee }
248bba09e9fSDonghwa Lee 
249bba09e9fSDonghwa Lee static void s6e8ax0_display_enable(struct mipi_dsim_device *dsim_dev)
250bba09e9fSDonghwa Lee {
251bba09e9fSDonghwa Lee 	s6e8ax0_display_on(dsim_dev);
252bba09e9fSDonghwa Lee }
253bba09e9fSDonghwa Lee 
254bba09e9fSDonghwa Lee static struct mipi_dsim_lcd_driver s6e8ax0_dsim_ddi_driver = {
255bba09e9fSDonghwa Lee 	.name = "s6e8ax0",
256bba09e9fSDonghwa Lee 	.id = -1,
257bba09e9fSDonghwa Lee 
258bba09e9fSDonghwa Lee 	.mipi_panel_init = s6e8ax0_panel_set,
259bba09e9fSDonghwa Lee 	.mipi_display_on = s6e8ax0_display_enable,
260bba09e9fSDonghwa Lee };
261bba09e9fSDonghwa Lee 
262bba09e9fSDonghwa Lee void s6e8ax0_init(void)
263bba09e9fSDonghwa Lee {
264bba09e9fSDonghwa Lee 	exynos_mipi_dsi_register_lcd_driver(&s6e8ax0_dsim_ddi_driver);
265bba09e9fSDonghwa Lee }
266