Skip to content

Commit f4f6bda

Browse files
Mike Rapoportrpurdie
authored andcommitted
backlight: add support for Toppoly TDO35S series to tdo24m lcd driver
Signed-off-by: Mike Rapoport <mike@compulab.co.il> Acked-by: Eric Miao <eric.miao@marvell.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
1 parent c835ee7 commit f4f6bda

3 files changed

Lines changed: 101 additions & 10 deletions

File tree

‎drivers/video/backlight/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ config LCD_ILI9320
5252
then say y to include a power driver for it.
5353

5454
config LCD_TDO24M
55-
tristate "Toppoly TDO24M LCD Panels support"
55+
tristate "Toppoly TDO24M and TDO35S LCD Panels support"
5656
depends on LCD_CLASS_DEVICE && SPI_MASTER
5757
default n
5858
help
59-
If you have a Toppoly TDO24M series LCD panel, say y here to
59+
If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to
6060
include the support for it.
6161

6262
config LCD_VGG2432A4

‎drivers/video/backlight/tdo24m.c‎

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/init.h>
1515
#include <linux/device.h>
1616
#include <linux/spi/spi.h>
17+
#include <linux/spi/tdo24m.h>
1718
#include <linux/fb.h>
1819
#include <linux/lcd.h>
1920

@@ -31,6 +32,9 @@ struct tdo24m {
3132
struct spi_transfer xfer;
3233
uint8_t *buf;
3334

35+
int (*adj_mode)(struct tdo24m *lcd, int mode);
36+
int color_invert;
37+
3438
int power;
3539
int mode;
3640
};
@@ -66,7 +70,7 @@ static uint32_t lcd_panel_off[] = {
6670
CMD_NULL,
6771
};
6872

69-
static uint32_t lcd_vga_pass_through[] = {
73+
static uint32_t lcd_vga_pass_through_tdo24m[] = {
7074
CMD1(0xB0, 0x16),
7175
CMD1(0xBC, 0x80),
7276
CMD1(0xE1, 0x00),
@@ -75,7 +79,7 @@ static uint32_t lcd_vga_pass_through[] = {
7579
CMD_NULL,
7680
};
7781

78-
static uint32_t lcd_qvga_pass_through[] = {
82+
static uint32_t lcd_qvga_pass_through_tdo24m[] = {
7983
CMD1(0xB0, 0x16),
8084
CMD1(0xBC, 0x81),
8185
CMD1(0xE1, 0x00),
@@ -84,7 +88,7 @@ static uint32_t lcd_qvga_pass_through[] = {
8488
CMD_NULL,
8589
};
8690

87-
static uint32_t lcd_vga_transfer[] = {
91+
static uint32_t lcd_vga_transfer_tdo24m[] = {
8892
CMD1(0xcf, 0x02), /* Blanking period control (1) */
8993
CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
9094
CMD1(0xd1, 0x01), /* CKV timing control on/off */
@@ -110,6 +114,35 @@ static uint32_t lcd_qvga_transfer[] = {
110114
CMD_NULL,
111115
};
112116

117+
static uint32_t lcd_vga_pass_through_tdo35s[] = {
118+
CMD1(0xB0, 0x16),
119+
CMD1(0xBC, 0x80),
120+
CMD1(0xE1, 0x00),
121+
CMD1(0x3B, 0x00),
122+
CMD_NULL,
123+
};
124+
125+
static uint32_t lcd_qvga_pass_through_tdo35s[] = {
126+
CMD1(0xB0, 0x16),
127+
CMD1(0xBC, 0x81),
128+
CMD1(0xE1, 0x00),
129+
CMD1(0x3B, 0x22),
130+
CMD_NULL,
131+
};
132+
133+
static uint32_t lcd_vga_transfer_tdo35s[] = {
134+
CMD1(0xcf, 0x02), /* Blanking period control (1) */
135+
CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
136+
CMD1(0xd1, 0x01), /* CKV timing control on/off */
137+
CMD2(0xd2, 0x00, 0x1e), /* CKV 1,2 timing control */
138+
CMD2(0xd3, 0x14, 0x28), /* OEV timing control */
139+
CMD2(0xd4, 0x28, 0x64), /* ASW timing control (1) */
140+
CMD1(0xd5, 0x28), /* ASW timing control (2) */
141+
CMD0(0x21), /* Invert for normally black display */
142+
CMD0(0x29), /* Display on */
143+
CMD_NULL,
144+
};
145+
113146
static uint32_t lcd_panel_config[] = {
114147
CMD2(0xb8, 0xff, 0xf9), /* Output control */
115148
CMD0(0x11), /* sleep out */
@@ -148,6 +181,8 @@ static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array)
148181
int nparams, err = 0;
149182

150183
for (; *p != CMD_NULL; p++) {
184+
if (!lcd->color_invert && *p == CMD0(0x21))
185+
continue;
151186

152187
nparams = (*p >> 30) & 0x3;
153188

@@ -184,12 +219,33 @@ static int tdo24m_adj_mode(struct tdo24m *lcd, int mode)
184219
{
185220
switch (mode) {
186221
case MODE_VGA:
187-
tdo24m_writes(lcd, lcd_vga_pass_through);
222+
tdo24m_writes(lcd, lcd_vga_pass_through_tdo24m);
188223
tdo24m_writes(lcd, lcd_panel_config);
189-
tdo24m_writes(lcd, lcd_vga_transfer);
224+
tdo24m_writes(lcd, lcd_vga_transfer_tdo24m);
190225
break;
191226
case MODE_QVGA:
192-
tdo24m_writes(lcd, lcd_qvga_pass_through);
227+
tdo24m_writes(lcd, lcd_qvga_pass_through_tdo24m);
228+
tdo24m_writes(lcd, lcd_panel_config);
229+
tdo24m_writes(lcd, lcd_qvga_transfer);
230+
break;
231+
default:
232+
return -EINVAL;
233+
}
234+
235+
lcd->mode = mode;
236+
return 0;
237+
}
238+
239+
static int tdo35s_adj_mode(struct tdo24m *lcd, int mode)
240+
{
241+
switch (mode) {
242+
case MODE_VGA:
243+
tdo24m_writes(lcd, lcd_vga_pass_through_tdo35s);
244+
tdo24m_writes(lcd, lcd_panel_config);
245+
tdo24m_writes(lcd, lcd_vga_transfer_tdo35s);
246+
break;
247+
case MODE_QVGA:
248+
tdo24m_writes(lcd, lcd_qvga_pass_through_tdo35s);
193249
tdo24m_writes(lcd, lcd_panel_config);
194250
tdo24m_writes(lcd, lcd_qvga_transfer);
195251
break;
@@ -213,7 +269,7 @@ static int tdo24m_power_on(struct tdo24m *lcd)
213269
if (err)
214270
goto out;
215271

216-
err = tdo24m_adj_mode(lcd, lcd->mode);
272+
err = lcd->adj_mode(lcd, lcd->mode);
217273
out:
218274
return err;
219275
}
@@ -262,7 +318,7 @@ static int tdo24m_set_mode(struct lcd_device *ld, struct fb_videomode *m)
262318
if (lcd->mode == mode)
263319
return 0;
264320

265-
return tdo24m_adj_mode(lcd, mode);
321+
return lcd->adj_mode(lcd, mode);
266322
}
267323

268324
static struct lcd_ops tdo24m_ops = {
@@ -276,8 +332,16 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
276332
struct tdo24m *lcd;
277333
struct spi_message *m;
278334
struct spi_transfer *x;
335+
struct tdo24m_platform_data *pdata;
336+
enum tdo24m_model model;
279337
int err;
280338

339+
pdata = spi->dev.platform_data;
340+
if (pdata)
341+
model = pdata->model;
342+
else
343+
model = TDO24M;
344+
281345
spi->bits_per_word = 8;
282346
spi->mode = SPI_MODE_3;
283347
err = spi_setup(spi);
@@ -306,6 +370,20 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
306370
x->tx_buf = &lcd->buf[0];
307371
spi_message_add_tail(x, m);
308372

373+
switch (model) {
374+
case TDO24M:
375+
lcd->color_invert = 1;
376+
lcd->adj_mode = tdo24m_adj_mode;
377+
break;
378+
case TDO35S:
379+
lcd->adj_mode = tdo35s_adj_mode;
380+
lcd->color_invert = 0;
381+
break;
382+
default:
383+
dev_err(&spi->dev, "Unsupported model");
384+
goto out_free;
385+
}
386+
309387
lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev,
310388
lcd, &tdo24m_ops);
311389
if (IS_ERR(lcd->lcd_dev)) {

‎include/linux/spi/tdo24m.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef __TDO24M_H__
2+
#define __TDO24M_H__
3+
4+
enum tdo24m_model {
5+
TDO24M,
6+
TDO35S,
7+
};
8+
9+
struct tdo24m_platform_data {
10+
enum tdo24m_model model;
11+
};
12+
13+
#endif /* __TDO24M_H__ */

0 commit comments

Comments
 (0)