1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
From nobody Mon Sep 17 00:00:00 2001
From: Håvard Skinnemoen <hskinnemoen@atmel.com>
Date: Wed Dec 21 14:52:09 2005 +0100
Subject: [PATCH] LTV350QV LCD driver
This patch adds support for powering on and off the Samsung LTV350QV
LCD panel via SPI. The driver responds to framebuffer power management,
it powers off the panel on reboot/halt/poweroff, and it can also be
controlled through sysfs. The panel is powered up when the module is
loaded and off when the module is unloaded.
---
drivers/video/backlight/Kconfig | 12 +
drivers/video/backlight/Makefile | 1
drivers/video/backlight/ltv350qv.c | 301 +++++++++++++++++++++++++++++++++++++
3 files changed, 314 insertions(+)
Index: linux-2.6.18-avr32/drivers/video/backlight/Kconfig
===================================================================
--- linux-2.6.18-avr32.orig/drivers/video/backlight/Kconfig 2006-09-11 20:30:16.000000000 +0200
+++ linux-2.6.18-avr32/drivers/video/backlight/Kconfig 2006-09-11 20:31:24.000000000 +0200
@@ -42,6 +42,18 @@ config LCD_DEVICE
depends on LCD_CLASS_DEVICE
default y
+config LCD_LTV350QV
+ tristate "Samsung LTV350QV LCD Panel"
+ depends on LCD_DEVICE && SPI
+ default n
+ help
+ If you have a Samsung LTV350QV LCD panel, say y to include a
+ power control driver for it. The panel starts up in power
+ off state, so you need this driver in order to see any
+ output.
+
+ The LTV350QV panel is present on most ATSTK1000 boards.
+
config BACKLIGHT_CORGI
tristate "Sharp Corgi Backlight Driver (SL Series)"
depends on BACKLIGHT_DEVICE && PXA_SHARPSL
Index: linux-2.6.18-avr32/drivers/video/backlight/Makefile
===================================================================
--- linux-2.6.18-avr32.orig/drivers/video/backlight/Makefile 2006-09-11 20:30:23.000000000 +0200
+++ linux-2.6.18-avr32/drivers/video/backlight/Makefile 2006-09-11 20:31:24.000000000 +0200
@@ -5,3 +5,4 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) +=
obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o
obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
+obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o
Index: linux-2.6.18-avr32/drivers/video/backlight/ltv350qv.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.18-avr32/drivers/video/backlight/ltv350qv.c 2006-09-11 20:31:24.000000000 +0200
@@ -0,0 +1,301 @@
+/*
+ * Power control for Samsung LTV350QV Quarter VGA LCD Panel
+ *
+ * Copyright (C) 2006 Atmel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/config.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/fb.h>
+#include <linux/init.h>
+#include <linux/lcd.h>
+#include <linux/module.h>
+#include <linux/reboot.h>
+#include <linux/spi/spi.h>
+
+#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
+
+struct ltv350qv {
+ struct spi_device *spi;
+ u8 *buffer;
+ int power;
+ struct semaphore lock;
+ struct lcd_device *ld;
+ struct list_head list;
+ int halt_done;
+};
+
+static LIST_HEAD(lcd_list);
+
+static int ltv350qv_write_reg(struct ltv350qv *lcd, u8 reg, u16 val)
+{
+ struct spi_message msg;
+ struct spi_transfer index_xfer = {
+ .len = 3,
+ .cs_change = 1,
+ };
+ struct spi_transfer value_xfer = {
+ .len = 3,
+ .cs_change = 1,
+ };
+
+ spi_message_init(&msg);
+
+ /* register index */
+ lcd->buffer[0] = 0x74;
+ lcd->buffer[1] = 0x00;
+ lcd->buffer[2] = reg & 0x7f;
+ index_xfer.tx_buf = lcd->buffer;
+ spi_message_add_tail(&index_xfer, &msg);
+
+ /* register value */
+ lcd->buffer[4] = 0x76;
+ lcd->buffer[5] = val >> 8;
+ lcd->buffer[6] = val;
+ value_xfer.tx_buf = lcd->buffer + 4;
+ spi_message_add_tail(&value_xfer, &msg);
+
+ return spi_sync(lcd->spi, &msg);
+}
+
+#define write_reg(_spi, reg, val) \
+ do { \
+ ret = ltv350qv_write_reg(_spi, reg, val); \
+ if (ret) \
+ goto out; \
+ } while (0)
+
+static int ltv350qv_power_on(struct ltv350qv *lcd)
+{
+ int ret;
+
+ write_reg(lcd, 9, 0x0000);
+ msleep(15);
+ write_reg(lcd, 9, 0x4000);
+ write_reg(lcd, 10, 0x2000);
+ write_reg(lcd, 9, 0x4055);
+ msleep(55);
+ write_reg(lcd, 1, 0x409d);
+ write_reg(lcd, 2, 0x0204);
+ write_reg(lcd, 3, 0x0100);
+ write_reg(lcd, 4, 0x3000);
+ write_reg(lcd, 5, 0x4003);
+ write_reg(lcd, 6, 0x000a);
+ write_reg(lcd, 7, 0x0021);
+ write_reg(lcd, 8, 0x0c00);
+ write_reg(lcd, 10, 0x0103);
+ write_reg(lcd, 11, 0x0301);
+ write_reg(lcd, 12, 0x1f0f);
+ write_reg(lcd, 13, 0x1f0f);
+ write_reg(lcd, 14, 0x0707);
+ write_reg(lcd, 15, 0x0307);
+ write_reg(lcd, 16, 0x0707);
+ write_reg(lcd, 17, 0x0000);
+ write_reg(lcd, 18, 0x0004);
+ write_reg(lcd, 19, 0x0000);
+
+ msleep(20);
+ write_reg(lcd, 9, 0x4a55);
+ write_reg(lcd, 5, 0x5003);
+
+out:
+ return ret;
+}
+
+static int ltv350qv_power_off(struct ltv350qv *lcd)
+{
+ int ret;
+
+ /* GON -> 0, POC -> 0 */
+ write_reg(lcd, 9, 0x4055);
+ /* DSC -> 0 */
+ write_reg(lcd, 5, 0x4003);
+ /* VCOMG -> 0 */
+ write_reg(lcd, 10, 0x2103);
+
+ msleep(1);
+
+ /* AP[2:0] -> 000 */
+ write_reg(lcd, 9, 0x4050);
+
+out:
+ return ret;
+}
+
+static int ltv350qv_power(struct ltv350qv *lcd, int power)
+{
+ int ret = 0;
+
+ down(&lcd->lock);
+
+ if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power))
+ ret = ltv350qv_power_on(lcd);
+ else if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power))
+ ret = ltv350qv_power_off(lcd);
+
+ if (!ret)
+ lcd->power = power;
+
+ up(&lcd->lock);
+
+ return ret;
+}
+
+static int ltv350qv_set_power(struct lcd_device *ld, int power)
+{
+ struct ltv350qv *lcd;
+
+ lcd = class_get_devdata(&ld->class_dev);
+ return ltv350qv_power(lcd, power);
+}
+
+static int ltv350qv_get_power(struct lcd_device *ld)
+{
+ struct ltv350qv *lcd;
+
+ lcd = class_get_devdata(&ld->class_dev);
+ return lcd->power;
+}
+
+static struct lcd_properties lcd_properties = {
+ .owner = THIS_MODULE,
+ .get_power = ltv350qv_get_power,
+ .set_power = ltv350qv_set_power,
+};
+
+static int __devinit ltv350qv_probe(struct spi_device *spi)
+{
+ struct ltv350qv *lcd;
+ struct lcd_device *ld;
+ int ret;
+
+ lcd = kzalloc(sizeof(struct ltv350qv), GFP_KERNEL);
+ if (!lcd)
+ return -ENOMEM;
+
+ lcd->spi = spi;
+ lcd->power = FB_BLANK_POWERDOWN;
+ init_MUTEX(&lcd->lock);
+ lcd->buffer = kzalloc(8, GFP_KERNEL);
+
+ spi->mode = SPI_MODE_3;
+ spi->bits_per_word = 8;
+ ret = spi_setup(spi);
+ if (ret)
+ goto out_free_lcd;
+
+ ld = lcd_device_register("ltv350qv", lcd, &lcd_properties);
+ if (IS_ERR(ld)) {
+ ret = PTR_ERR(ld);
+ goto out_free_lcd;
+ }
+ lcd->ld = ld;
+
+ list_add(&lcd->list, &lcd_list);
+
+ ret = ltv350qv_power(lcd, FB_BLANK_UNBLANK);
+ if (ret)
+ goto out_unregister;
+
+ dev_set_drvdata(&spi->dev, lcd);
+
+ return 0;
+
+out_unregister:
+ lcd_device_unregister(ld);
+out_free_lcd:
+ kfree(lcd);
+ return ret;
+}
+
+static int __devexit ltv350qv_remove(struct spi_device *spi)
+{
+ struct ltv350qv *lcd = dev_get_drvdata(&spi->dev);
+
+ ltv350qv_power(lcd, FB_BLANK_POWERDOWN);
+ list_del(&lcd->list);
+ lcd_device_unregister(lcd->ld);
+ kfree(lcd);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int ltv350qv_suspend(struct spi_device *spi,
+ pm_message_t state, u32 level)
+{
+ struct ltv350qv *lcd = dev_get_drvdata(&spi->dev);
+
+ if (level == SUSPEND_POWER_DOWN)
+ return ltv350qv_power(lcd, FB_BLANK_POWERDOWN);
+
+ return 0;
+}
+
+static int ltv350qv_resume(struct spi_device *spi, u32 level)
+{
+ struct ltv350qv *lcd = dev_get_drvdata(&spi->dev);
+
+ if (level == RESUME_POWER_ON)
+ return ltv350qv_power(lcd, FB_BLANK_UNBLANK);
+
+ return 0;
+}
+#else
+#define ltv350qv_suspend NULL
+#define ltv350qv_resume NULL
+#endif
+
+/* Power down all displays on reboot, poweroff or halt */
+static int ltv350qv_halt(struct notifier_block *nb, unsigned long event,
+ void *p)
+{
+ struct ltv350qv *lcd;
+
+ list_for_each_entry(lcd, &lcd_list, list) {
+ if (!lcd->halt_done)
+ ltv350qv_power(lcd, FB_BLANK_POWERDOWN);
+ lcd->halt_done = 1;
+ }
+
+ return NOTIFY_OK;
+}
+
+static struct spi_driver ltv350qv_driver = {
+ .driver = {
+ .name = "ltv350qv",
+ .bus = &spi_bus_type,
+ .owner = THIS_MODULE,
+ },
+
+ .probe = ltv350qv_probe,
+ .remove = __devexit_p(ltv350qv_remove),
+ .suspend = ltv350qv_suspend,
+ .resume = ltv350qv_resume,
+};
+
+static struct notifier_block ltv350qv_notifier = {
+ .notifier_call = ltv350qv_halt,
+};
+
+static int __init ltv350qv_init(void)
+{
+ register_reboot_notifier(<v350qv_notifier);
+ return spi_register_driver(<v350qv_driver);
+}
+
+static void __exit ltv350qv_exit(void)
+{
+ unregister_reboot_notifier(<v350qv_notifier);
+ spi_unregister_driver(<v350qv_driver);
+}
+module_init(ltv350qv_init);
+module_exit(ltv350qv_exit);
+
+MODULE_AUTHOR("Atmel Norway");
+MODULE_DESCRIPTION("Samsung LTV350QV LCD Driver");
+MODULE_LICENSE("GPL");
|