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