12 #include <linux/module.h>
13 #include <linux/kernel.h>
15 #include <linux/device.h>
20 #include <linux/slab.h>
22 #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
24 #define TDO24M_SPI_BUFF_SIZE (4)
44 #define CMD0(x) ((0 << 30) | (x))
45 #define CMD1(x, x1) ((1 << 30) | ((x) << 9) | 0x100 | (x1))
46 #define CMD2(x, x1, x2) ((2 << 30) | ((x) << 18) | 0x20000 |\
47 ((x1) << 9) | 0x100 | (x2))
50 static uint32_t lcd_panel_reset[] = {
60 CMD2(0xB8, 0xFF, 0xF9),
68 CMD2(0xB8, 0x80, 0x02),
74 static uint32_t lcd_vga_pass_through_tdo24m[] = {
83 static uint32_t lcd_qvga_pass_through_tdo24m[] = {
92 static uint32_t lcd_vga_transfer_tdo24m[] = {
94 CMD2(0xd0, 0x08, 0x04),
96 CMD2(0xd2, 0x14, 0x00),
97 CMD2(0xd3, 0x1a, 0x0f),
98 CMD2(0xd4, 0x1f, 0xaf),
105 static uint32_t lcd_qvga_transfer[] = {
107 CMD2(0xd7, 0x08, 0x04),
109 CMD2(0xd9, 0x00, 0x08),
110 CMD2(0xde, 0x05, 0x0a),
111 CMD2(0xdf, 0x0a, 0x19),
118 static uint32_t lcd_vga_pass_through_tdo35s[] = {
126 static uint32_t lcd_qvga_pass_through_tdo35s[] = {
134 static uint32_t lcd_vga_transfer_tdo35s[] = {
136 CMD2(0xd0, 0x08, 0x04),
138 CMD2(0xd2, 0x00, 0x1e),
139 CMD2(0xd3, 0x14, 0x28),
140 CMD2(0xd4, 0x28, 0x64),
147 static uint32_t lcd_panel_config[] = {
148 CMD2(0xb8, 0xff, 0xf9),
166 CMD2(0xc3, 0x20, 0x40),
167 CMD2(0xc4, 0x60, 0xc0),
168 CMD2(0xc5, 0x10, 0x20),
170 CMD2(0xc7, 0x33, 0x43),
174 CMD2(0xec, 0x01, 0xf0),
182 int nparams,
err = 0;
188 nparams = (*p >> 30) & 0x3;
190 data = *p << (7 - nparams);
193 lcd->
buf[0] = (data >> 8) & 0xff;
194 lcd->
buf[1] = data & 0xff;
197 lcd->
buf[0] = (data >> 16) & 0xff;
198 lcd->
buf[1] = (data >> 8) & 0xff;
199 lcd->
buf[2] = data & 0xff;
202 lcd->
buf[0] = (data >> 24) & 0xff;
203 lcd->
buf[1] = (data >> 16) & 0xff;
204 lcd->
buf[2] = (data >> 8) & 0xff;
205 lcd->
buf[3] = data & 0xff;
210 x->
len = nparams + 2;
219 static int tdo24m_adj_mode(
struct tdo24m *lcd,
int mode)
223 tdo24m_writes(lcd, lcd_vga_pass_through_tdo24m);
224 tdo24m_writes(lcd, lcd_panel_config);
225 tdo24m_writes(lcd, lcd_vga_transfer_tdo24m);
228 tdo24m_writes(lcd, lcd_qvga_pass_through_tdo24m);
229 tdo24m_writes(lcd, lcd_panel_config);
230 tdo24m_writes(lcd, lcd_qvga_transfer);
240 static int tdo35s_adj_mode(
struct tdo24m *lcd,
int mode)
244 tdo24m_writes(lcd, lcd_vga_pass_through_tdo35s);
245 tdo24m_writes(lcd, lcd_panel_config);
246 tdo24m_writes(lcd, lcd_vga_transfer_tdo35s);
249 tdo24m_writes(lcd, lcd_qvga_pass_through_tdo35s);
250 tdo24m_writes(lcd, lcd_panel_config);
251 tdo24m_writes(lcd, lcd_qvga_transfer);
261 static int tdo24m_power_on(
struct tdo24m *lcd)
265 err = tdo24m_writes(lcd, lcd_panel_on);
269 err = tdo24m_writes(lcd, lcd_panel_reset);
278 static int tdo24m_power_off(
struct tdo24m *lcd)
280 return tdo24m_writes(lcd, lcd_panel_off);
283 static int tdo24m_power(
struct tdo24m *lcd,
int power)
288 ret = tdo24m_power_on(lcd);
290 ret = tdo24m_power_off(lcd);
299 static int tdo24m_set_power(
struct lcd_device *
ld,
int power)
301 struct tdo24m *lcd = lcd_get_data(ld);
302 return tdo24m_power(lcd, power);
307 struct tdo24m *lcd = lcd_get_data(ld);
313 struct tdo24m *lcd = lcd_get_data(ld);
316 if (m->
xres == 640 || m->
xres == 480)
319 if (lcd->
mode == mode)
325 static struct lcd_ops tdo24m_ops = {
326 .get_power = tdo24m_get_power,
327 .set_power = tdo24m_set_power,
328 .set_mode = tdo24m_set_mode,
340 pdata = spi->
dev.platform_data;
342 model = pdata->
model;
371 spi_message_add_tail(x, m);
429 #define tdo24m_suspend NULL
430 #define tdo24m_resume NULL
434 static void tdo24m_shutdown(
struct spi_device *spi)
446 .probe = tdo24m_probe,
448 .shutdown = tdo24m_shutdown,