2 * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
3 * Hyungwon Hwang <human.hwang@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/arch/mipi_dsim.h>
11 #define SCAN_FROM_LEFT_TO_RIGHT 0
12 #define SCAN_FROM_RIGHT_TO_LEFT 1
13 #define SCAN_FROM_TOP_TO_BOTTOM 0
14 #define SCAN_FROM_BOTTOM_TO_TOP 1
16 static void l5f31188_sleep_in(struct mipi_dsim_device *dev,
17 struct mipi_dsim_master_ops *ops)
19 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE, 0x10, 0x00);
22 static void l5f31188_sleep_out(struct mipi_dsim_device *dev,
23 struct mipi_dsim_master_ops *ops)
25 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE, 0x11, 0x00);
28 static void l5f31188_set_gamma(struct mipi_dsim_device *dev,
29 struct mipi_dsim_master_ops *ops)
31 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE, 0x26, 0x00);
34 static void l5f31188_display_off(struct mipi_dsim_device *dev,
35 struct mipi_dsim_master_ops *ops)
37 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE, 0x28, 0x00);
40 static void l5f31188_display_on(struct mipi_dsim_device *dev,
41 struct mipi_dsim_master_ops *ops)
43 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE, 0x29, 0x00);
46 static void l5f31188_ctl_memory_access(struct mipi_dsim_device *dev,
47 struct mipi_dsim_master_ops *ops,
48 int h_direction, int v_direction)
50 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0x36,
51 (((h_direction & 0x1) << 1) | (v_direction & 0x1)));
54 static void l5f31188_set_pixel_format(struct mipi_dsim_device *dev,
55 struct mipi_dsim_master_ops *ops)
57 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0x3A, 0x70);
60 static void l5f31188_write_disbv(struct mipi_dsim_device *dev,
61 struct mipi_dsim_master_ops *ops, unsigned int brightness)
63 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0x51, brightness);
66 static void l5f31188_write_ctrld(struct mipi_dsim_device *dev,
67 struct mipi_dsim_master_ops *ops)
69 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0x53, 0x2C);
72 static void l5f31188_write_cabc(struct mipi_dsim_device *dev,
73 struct mipi_dsim_master_ops *ops,
76 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0x55, wm_mode);
79 static void l5f31188_write_cabcmb(struct mipi_dsim_device *dev,
80 struct mipi_dsim_master_ops *ops, unsigned int min_brightness)
82 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0x5E,
86 static void l5f31188_set_extension(struct mipi_dsim_device *dev,
87 struct mipi_dsim_master_ops *ops)
89 const unsigned char data_to_send[] = {
90 0xB9, 0xFF, 0x83, 0x94
93 ops->cmd_write(dev, MIPI_DSI_DCS_LONG_WRITE,
94 (unsigned int)data_to_send, ARRAY_SIZE(data_to_send));
97 static void l5f31188_set_dgc_lut(struct mipi_dsim_device *dev,
98 struct mipi_dsim_master_ops *ops)
100 const unsigned char data_to_send[] = {
101 0xC1, 0x01, 0x00, 0x04, 0x0E, 0x18, 0x1E, 0x26,
102 0x2F, 0x36, 0x3E, 0x47, 0x4E, 0x56, 0x5D, 0x65,
103 0x6D, 0x75, 0x7D, 0x84, 0x8C, 0x94, 0x9C, 0xA4,
104 0xAD, 0xB5, 0xBD, 0xC5, 0xCC, 0xD4, 0xDE, 0xE5,
105 0xEE, 0xF7, 0xFF, 0x3F, 0x9A, 0xCE, 0xD4, 0x21,
106 0xA1, 0x26, 0x54, 0x00, 0x00, 0x04, 0x0E, 0x19,
107 0x1F, 0x27, 0x30, 0x37, 0x40, 0x48, 0x50, 0x58,
108 0x60, 0x67, 0x6F, 0x77, 0x7F, 0x87, 0x8F, 0x97,
109 0x9F, 0xA7, 0xB0, 0xB8, 0xC0, 0xC8, 0xCE, 0xD8,
110 0xE0, 0xE7, 0xF0, 0xF7, 0xFF, 0x3C, 0xEB, 0xFD,
111 0x2F, 0x66, 0xA8, 0x2C, 0x46, 0x00, 0x00, 0x04,
112 0x0E, 0x18, 0x1E, 0x26, 0x30, 0x38, 0x41, 0x4A,
113 0x52, 0x5A, 0x62, 0x6B, 0x73, 0x7B, 0x83, 0x8C,
114 0x94, 0x9C, 0xA5, 0xAD, 0xB6, 0xBD, 0xC5, 0xCC,
115 0xD4, 0xDD, 0xE3, 0xEB, 0xF2, 0xF9, 0xFF, 0x3F,
116 0xA4, 0x8A, 0x8F, 0xC7, 0x33, 0xF5, 0xE9, 0x00
118 ops->cmd_write(dev, MIPI_DSI_DCS_LONG_WRITE,
119 (unsigned int)data_to_send, ARRAY_SIZE(data_to_send));
122 static void l5f31188_set_tcon(struct mipi_dsim_device *dev,
123 struct mipi_dsim_master_ops *ops)
125 const unsigned char data_to_send[] = {
128 ops->cmd_write(dev, MIPI_DSI_DCS_LONG_WRITE,
129 (unsigned int)data_to_send, ARRAY_SIZE(data_to_send));
132 static void l5f31188_set_ptba(struct mipi_dsim_device *dev,
133 struct mipi_dsim_master_ops *ops)
135 const unsigned char data_to_send[] = {
138 ops->cmd_write(dev, MIPI_DSI_DCS_LONG_WRITE,
139 (unsigned int)data_to_send, ARRAY_SIZE(data_to_send));
142 static void l5f31188_set_eco(struct mipi_dsim_device *dev,
143 struct mipi_dsim_master_ops *ops)
145 ops->cmd_write(dev, MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0xC6, 0x0C);
148 static int l5f31188_panel_init(struct mipi_dsim_device *dev)
150 struct mipi_dsim_master_ops *ops = dev->master_ops;
152 l5f31188_set_extension(dev, ops);
153 l5f31188_set_dgc_lut(dev, ops);
155 l5f31188_set_eco(dev, ops);
156 l5f31188_set_tcon(dev, ops);
157 l5f31188_set_ptba(dev, ops);
158 l5f31188_set_gamma(dev, ops);
159 l5f31188_ctl_memory_access(dev, ops,
160 SCAN_FROM_LEFT_TO_RIGHT, SCAN_FROM_TOP_TO_BOTTOM);
161 l5f31188_set_pixel_format(dev, ops);
162 l5f31188_write_disbv(dev, ops, 0xFF);
163 l5f31188_write_ctrld(dev, ops);
164 l5f31188_write_cabc(dev, ops, 0x0);
165 l5f31188_write_cabcmb(dev, ops, 0x0);
167 l5f31188_sleep_out(dev, ops);
175 static void l5f31188_display_enable(struct mipi_dsim_device *dev)
177 struct mipi_dsim_master_ops *ops = dev->master_ops;
178 l5f31188_display_on(dev, ops);
181 static struct mipi_dsim_lcd_driver l5f31188_dsim_ddi_driver = {
185 .mipi_panel_init = l5f31188_panel_init,
186 .mipi_display_on = l5f31188_display_enable,
189 void l5f31188_init(void)
191 exynos_mipi_dsi_register_lcd_driver(&l5f31188_dsim_ddi_driver);