blob: 741e9d7cec1141139142d1b0b8649aa5ffa1d15d [file] [log] [blame]
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +02001/*
2 * LCD panel driver for TPO TD043MTEA1
3 *
4 * Author: Gražvydas Ignotas <notasas@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/delay.h>
14#include <linux/spi/spi.h>
15#include <linux/regulator/consumer.h>
16#include <linux/gpio.h>
17#include <linux/err.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090018#include <linux/slab.h>
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +020019
Tomi Valkeinena0b38cc2011-05-11 14:05:07 +030020#include <video/omapdss.h>
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +020021
22#define TPO_R02_MODE(x) ((x) & 7)
23#define TPO_R02_MODE_800x480 7
24#define TPO_R02_NCLK_RISING BIT(3)
25#define TPO_R02_HSYNC_HIGH BIT(4)
26#define TPO_R02_VSYNC_HIGH BIT(5)
27
28#define TPO_R03_NSTANDBY BIT(0)
29#define TPO_R03_EN_CP_CLK BIT(1)
30#define TPO_R03_EN_VGL_PUMP BIT(2)
31#define TPO_R03_EN_PWM BIT(3)
32#define TPO_R03_DRIVING_CAP_100 BIT(4)
33#define TPO_R03_EN_PRE_CHARGE BIT(6)
34#define TPO_R03_SOFTWARE_CTL BIT(7)
35
36#define TPO_R04_NFLIP_H BIT(0)
37#define TPO_R04_NFLIP_V BIT(1)
38#define TPO_R04_CP_CLK_FREQ_1H BIT(2)
39#define TPO_R04_VGL_FREQ_1H BIT(4)
40
41#define TPO_R03_VAL_NORMAL (TPO_R03_NSTANDBY | TPO_R03_EN_CP_CLK | \
42 TPO_R03_EN_VGL_PUMP | TPO_R03_EN_PWM | \
43 TPO_R03_DRIVING_CAP_100 | TPO_R03_EN_PRE_CHARGE | \
44 TPO_R03_SOFTWARE_CTL)
45
46#define TPO_R03_VAL_STANDBY (TPO_R03_DRIVING_CAP_100 | \
47 TPO_R03_EN_PRE_CHARGE | TPO_R03_SOFTWARE_CTL)
48
49static const u16 tpo_td043_def_gamma[12] = {
50 106, 200, 289, 375, 460, 543, 625, 705, 785, 864, 942, 1020
51};
52
53struct tpo_td043_device {
54 struct spi_device *spi;
55 struct regulator *vcc_reg;
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +020056 int nreset_gpio;
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +020057 u16 gamma[12];
58 u32 mode;
59 u32 hmirror:1;
60 u32 vmirror:1;
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +020061 u32 powered_on:1;
62 u32 spi_suspended:1;
63 u32 power_on_resume:1;
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +020064};
65
66static int tpo_td043_write(struct spi_device *spi, u8 addr, u8 data)
67{
68 struct spi_message m;
69 struct spi_transfer xfer;
70 u16 w;
71 int r;
72
73 spi_message_init(&m);
74
75 memset(&xfer, 0, sizeof(xfer));
76
77 w = ((u16)addr << 10) | (1 << 8) | data;
78 xfer.tx_buf = &w;
79 xfer.bits_per_word = 16;
80 xfer.len = 2;
81 spi_message_add_tail(&xfer, &m);
82
83 r = spi_sync(spi, &m);
84 if (r < 0)
85 dev_warn(&spi->dev, "failed to write to LCD reg (%d)\n", r);
86 return r;
87}
88
89static void tpo_td043_write_gamma(struct spi_device *spi, u16 gamma[12])
90{
91 u8 i, val;
92
93 /* gamma bits [9:8] */
94 for (val = i = 0; i < 4; i++)
95 val |= (gamma[i] & 0x300) >> ((i + 1) * 2);
96 tpo_td043_write(spi, 0x11, val);
97
98 for (val = i = 0; i < 4; i++)
99 val |= (gamma[i+4] & 0x300) >> ((i + 1) * 2);
100 tpo_td043_write(spi, 0x12, val);
101
102 for (val = i = 0; i < 4; i++)
103 val |= (gamma[i+8] & 0x300) >> ((i + 1) * 2);
104 tpo_td043_write(spi, 0x13, val);
105
106 /* gamma bits [7:0] */
107 for (val = i = 0; i < 12; i++)
108 tpo_td043_write(spi, 0x14 + i, gamma[i] & 0xff);
109}
110
111static int tpo_td043_write_mirror(struct spi_device *spi, bool h, bool v)
112{
113 u8 reg4 = TPO_R04_NFLIP_H | TPO_R04_NFLIP_V | \
114 TPO_R04_CP_CLK_FREQ_1H | TPO_R04_VGL_FREQ_1H;
115 if (h)
116 reg4 &= ~TPO_R04_NFLIP_H;
117 if (v)
118 reg4 &= ~TPO_R04_NFLIP_V;
119
120 return tpo_td043_write(spi, 4, reg4);
121}
122
123static int tpo_td043_set_hmirror(struct omap_dss_device *dssdev, bool enable)
124{
125 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
126
127 tpo_td043->hmirror = enable;
128 return tpo_td043_write_mirror(tpo_td043->spi, tpo_td043->hmirror,
129 tpo_td043->vmirror);
130}
131
132static bool tpo_td043_get_hmirror(struct omap_dss_device *dssdev)
133{
134 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
135
136 return tpo_td043->hmirror;
137}
138
139static ssize_t tpo_td043_vmirror_show(struct device *dev,
140 struct device_attribute *attr, char *buf)
141{
142 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
143
144 return snprintf(buf, PAGE_SIZE, "%d\n", tpo_td043->vmirror);
145}
146
147static ssize_t tpo_td043_vmirror_store(struct device *dev,
148 struct device_attribute *attr, const char *buf, size_t count)
149{
150 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
Tomi Valkeinene3502ce2011-04-04 15:40:23 +0300151 int val;
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200152 int ret;
153
Tomi Valkeinene3502ce2011-04-04 15:40:23 +0300154 ret = kstrtoint(buf, 0, &val);
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200155 if (ret < 0)
156 return ret;
157
Tomi Valkeinene3502ce2011-04-04 15:40:23 +0300158 val = !!val;
159
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200160 ret = tpo_td043_write_mirror(tpo_td043->spi, tpo_td043->hmirror, val);
161 if (ret < 0)
162 return ret;
163
164 tpo_td043->vmirror = val;
165
166 return count;
167}
168
169static ssize_t tpo_td043_mode_show(struct device *dev,
170 struct device_attribute *attr, char *buf)
171{
172 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
173
174 return snprintf(buf, PAGE_SIZE, "%d\n", tpo_td043->mode);
175}
176
177static ssize_t tpo_td043_mode_store(struct device *dev,
178 struct device_attribute *attr, const char *buf, size_t count)
179{
180 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
181 long val;
182 int ret;
183
Tomi Valkeinene3502ce2011-04-04 15:40:23 +0300184 ret = kstrtol(buf, 0, &val);
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200185 if (ret != 0 || val & ~7)
186 return -EINVAL;
187
188 tpo_td043->mode = val;
189
190 val |= TPO_R02_NCLK_RISING;
191 tpo_td043_write(tpo_td043->spi, 2, val);
192
193 return count;
194}
195
196static ssize_t tpo_td043_gamma_show(struct device *dev,
197 struct device_attribute *attr, char *buf)
198{
199 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
200 ssize_t len = 0;
201 int ret;
202 int i;
203
204 for (i = 0; i < ARRAY_SIZE(tpo_td043->gamma); i++) {
205 ret = snprintf(buf + len, PAGE_SIZE - len, "%u ",
206 tpo_td043->gamma[i]);
207 if (ret < 0)
208 return ret;
209 len += ret;
210 }
211 buf[len - 1] = '\n';
212
213 return len;
214}
215
216static ssize_t tpo_td043_gamma_store(struct device *dev,
217 struct device_attribute *attr, const char *buf, size_t count)
218{
219 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
220 unsigned int g[12];
221 int ret;
222 int i;
223
224 ret = sscanf(buf, "%u %u %u %u %u %u %u %u %u %u %u %u",
225 &g[0], &g[1], &g[2], &g[3], &g[4], &g[5],
226 &g[6], &g[7], &g[8], &g[9], &g[10], &g[11]);
227
228 if (ret != 12)
229 return -EINVAL;
230
231 for (i = 0; i < 12; i++)
232 tpo_td043->gamma[i] = g[i];
233
234 tpo_td043_write_gamma(tpo_td043->spi, tpo_td043->gamma);
235
236 return count;
237}
238
239static DEVICE_ATTR(vmirror, S_IRUGO | S_IWUSR,
240 tpo_td043_vmirror_show, tpo_td043_vmirror_store);
241static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR,
242 tpo_td043_mode_show, tpo_td043_mode_store);
243static DEVICE_ATTR(gamma, S_IRUGO | S_IWUSR,
244 tpo_td043_gamma_show, tpo_td043_gamma_store);
245
246static struct attribute *tpo_td043_attrs[] = {
247 &dev_attr_vmirror.attr,
248 &dev_attr_mode.attr,
249 &dev_attr_gamma.attr,
250 NULL,
251};
252
253static struct attribute_group tpo_td043_attr_group = {
254 .attrs = tpo_td043_attrs,
255};
256
257static const struct omap_video_timings tpo_td043_timings = {
258 .x_res = 800,
259 .y_res = 480,
260
261 .pixel_clock = 36000,
262
263 .hsw = 1,
264 .hfp = 68,
265 .hbp = 214,
266
267 .vsw = 1,
268 .vfp = 39,
269 .vbp = 34,
270};
271
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200272static int tpo_td043_power_on(struct tpo_td043_device *tpo_td043)
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200273{
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200274 int nreset_gpio = tpo_td043->nreset_gpio;
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200275
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200276 if (tpo_td043->powered_on)
Stanley.Miao18016e32010-09-03 05:03:48 +0200277 return 0;
278
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200279 regulator_enable(tpo_td043->vcc_reg);
280
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200281 /* wait for regulator to stabilize */
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200282 msleep(160);
283
284 if (gpio_is_valid(nreset_gpio))
285 gpio_set_value(nreset_gpio, 1);
286
287 tpo_td043_write(tpo_td043->spi, 2,
288 TPO_R02_MODE(tpo_td043->mode) | TPO_R02_NCLK_RISING);
289 tpo_td043_write(tpo_td043->spi, 3, TPO_R03_VAL_NORMAL);
290 tpo_td043_write(tpo_td043->spi, 0x20, 0xf0);
291 tpo_td043_write(tpo_td043->spi, 0x21, 0xf0);
292 tpo_td043_write_mirror(tpo_td043->spi, tpo_td043->hmirror,
293 tpo_td043->vmirror);
294 tpo_td043_write_gamma(tpo_td043->spi, tpo_td043->gamma);
295
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200296 tpo_td043->powered_on = 1;
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200297 return 0;
298}
299
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200300static void tpo_td043_power_off(struct tpo_td043_device *tpo_td043)
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200301{
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200302 int nreset_gpio = tpo_td043->nreset_gpio;
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200303
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200304 if (!tpo_td043->powered_on)
Stanley.Miao18016e32010-09-03 05:03:48 +0200305 return;
306
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200307 tpo_td043_write(tpo_td043->spi, 3,
308 TPO_R03_VAL_STANDBY | TPO_R03_EN_PWM);
309
310 if (gpio_is_valid(nreset_gpio))
311 gpio_set_value(nreset_gpio, 0);
312
313 /* wait for at least 2 vsyncs before cutting off power */
314 msleep(50);
315
316 tpo_td043_write(tpo_td043->spi, 3, TPO_R03_VAL_STANDBY);
317
318 regulator_disable(tpo_td043->vcc_reg);
319
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200320 tpo_td043->powered_on = 0;
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200321}
322
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200323static int tpo_td043_enable_dss(struct omap_dss_device *dssdev)
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200324{
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200325 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
326 int r;
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200327
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200328 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
329 return 0;
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200330
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200331 r = omapdss_dpi_display_enable(dssdev);
332 if (r)
333 goto err0;
334
335 if (dssdev->platform_enable) {
336 r = dssdev->platform_enable(dssdev);
337 if (r)
338 goto err1;
339 }
340
341 /*
342 * If we are resuming from system suspend, SPI clocks might not be
343 * enabled yet, so we'll program the LCD from SPI PM resume callback.
344 */
345 if (!tpo_td043->spi_suspended) {
346 r = tpo_td043_power_on(tpo_td043);
347 if (r)
348 goto err1;
349 }
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200350
351 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
352
353 return 0;
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200354err1:
355 omapdss_dpi_display_disable(dssdev);
356err0:
357 return r;
358}
359
360static void tpo_td043_disable_dss(struct omap_dss_device *dssdev)
361{
362 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
363
364 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
365 return;
366
367 if (dssdev->platform_disable)
368 dssdev->platform_disable(dssdev);
369
370 omapdss_dpi_display_disable(dssdev);
371
372 if (!tpo_td043->spi_suspended)
373 tpo_td043_power_off(tpo_td043);
374}
375
376static int tpo_td043_enable(struct omap_dss_device *dssdev)
377{
378 dev_dbg(&dssdev->dev, "enable\n");
379
380 return tpo_td043_enable_dss(dssdev);
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200381}
382
383static void tpo_td043_disable(struct omap_dss_device *dssdev)
384{
385 dev_dbg(&dssdev->dev, "disable\n");
386
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200387 tpo_td043_disable_dss(dssdev);
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200388
389 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200390}
391
392static int tpo_td043_suspend(struct omap_dss_device *dssdev)
393{
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200394 dev_dbg(&dssdev->dev, "suspend\n");
395
396 tpo_td043_disable_dss(dssdev);
397
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200398 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200399
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200400 return 0;
401}
402
403static int tpo_td043_resume(struct omap_dss_device *dssdev)
404{
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200405 dev_dbg(&dssdev->dev, "resume\n");
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200406
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200407 return tpo_td043_enable_dss(dssdev);
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200408}
409
410static int tpo_td043_probe(struct omap_dss_device *dssdev)
411{
412 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
413 int nreset_gpio = dssdev->reset_gpio;
414 int ret = 0;
415
416 dev_dbg(&dssdev->dev, "probe\n");
417
418 if (tpo_td043 == NULL) {
419 dev_err(&dssdev->dev, "missing tpo_td043_device\n");
420 return -ENODEV;
421 }
422
423 dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IHS |
424 OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IPC;
425 dssdev->panel.timings = tpo_td043_timings;
426 dssdev->ctrl.pixel_size = 24;
427
428 tpo_td043->mode = TPO_R02_MODE_800x480;
429 memcpy(tpo_td043->gamma, tpo_td043_def_gamma, sizeof(tpo_td043->gamma));
430
431 tpo_td043->vcc_reg = regulator_get(&dssdev->dev, "vcc");
432 if (IS_ERR(tpo_td043->vcc_reg)) {
433 dev_err(&dssdev->dev, "failed to get LCD VCC regulator\n");
434 ret = PTR_ERR(tpo_td043->vcc_reg);
435 goto fail_regulator;
436 }
437
438 if (gpio_is_valid(nreset_gpio)) {
439 ret = gpio_request(nreset_gpio, "lcd reset");
440 if (ret < 0) {
441 dev_err(&dssdev->dev, "couldn't request reset GPIO\n");
442 goto fail_gpio_req;
443 }
444
445 ret = gpio_direction_output(nreset_gpio, 0);
446 if (ret < 0) {
447 dev_err(&dssdev->dev, "couldn't set GPIO direction\n");
448 goto fail_gpio_direction;
449 }
450 }
451
452 ret = sysfs_create_group(&dssdev->dev.kobj, &tpo_td043_attr_group);
453 if (ret)
454 dev_warn(&dssdev->dev, "failed to create sysfs files\n");
455
456 return 0;
457
458fail_gpio_direction:
459 gpio_free(nreset_gpio);
460fail_gpio_req:
461 regulator_put(tpo_td043->vcc_reg);
462fail_regulator:
463 kfree(tpo_td043);
464 return ret;
465}
466
467static void tpo_td043_remove(struct omap_dss_device *dssdev)
468{
469 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
470 int nreset_gpio = dssdev->reset_gpio;
471
472 dev_dbg(&dssdev->dev, "remove\n");
473
474 sysfs_remove_group(&dssdev->dev.kobj, &tpo_td043_attr_group);
475 regulator_put(tpo_td043->vcc_reg);
476 if (gpio_is_valid(nreset_gpio))
477 gpio_free(nreset_gpio);
478}
479
480static struct omap_dss_driver tpo_td043_driver = {
481 .probe = tpo_td043_probe,
482 .remove = tpo_td043_remove,
483
484 .enable = tpo_td043_enable,
485 .disable = tpo_td043_disable,
486 .suspend = tpo_td043_suspend,
487 .resume = tpo_td043_resume,
488 .set_mirror = tpo_td043_set_hmirror,
489 .get_mirror = tpo_td043_get_hmirror,
490
491 .driver = {
492 .name = "tpo_td043mtea1_panel",
493 .owner = THIS_MODULE,
494 },
495};
496
497static int tpo_td043_spi_probe(struct spi_device *spi)
498{
499 struct omap_dss_device *dssdev = spi->dev.platform_data;
500 struct tpo_td043_device *tpo_td043;
501 int ret;
502
503 if (dssdev == NULL) {
504 dev_err(&spi->dev, "missing dssdev\n");
505 return -ENODEV;
506 }
507
508 spi->bits_per_word = 16;
509 spi->mode = SPI_MODE_0;
510
511 ret = spi_setup(spi);
512 if (ret < 0) {
513 dev_err(&spi->dev, "spi_setup failed: %d\n", ret);
514 return ret;
515 }
516
517 tpo_td043 = kzalloc(sizeof(*tpo_td043), GFP_KERNEL);
518 if (tpo_td043 == NULL)
519 return -ENOMEM;
520
521 tpo_td043->spi = spi;
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200522 tpo_td043->nreset_gpio = dssdev->reset_gpio;
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200523 dev_set_drvdata(&spi->dev, tpo_td043);
524 dev_set_drvdata(&dssdev->dev, tpo_td043);
525
526 omap_dss_register_driver(&tpo_td043_driver);
527
528 return 0;
529}
530
531static int __devexit tpo_td043_spi_remove(struct spi_device *spi)
532{
533 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&spi->dev);
534
535 omap_dss_unregister_driver(&tpo_td043_driver);
536 kfree(tpo_td043);
537
538 return 0;
539}
540
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200541#ifdef CONFIG_PM_SLEEP
542static int tpo_td043_spi_suspend(struct device *dev)
543{
544 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
545
546 dev_dbg(dev, "tpo_td043_spi_suspend, tpo %p\n", tpo_td043);
547
548 tpo_td043->power_on_resume = tpo_td043->powered_on;
549 tpo_td043_power_off(tpo_td043);
550 tpo_td043->spi_suspended = 1;
551
552 return 0;
553}
554
555static int tpo_td043_spi_resume(struct device *dev)
556{
557 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(dev);
558 int ret;
559
560 dev_dbg(dev, "tpo_td043_spi_resume\n");
561
562 if (tpo_td043->power_on_resume) {
563 ret = tpo_td043_power_on(tpo_td043);
564 if (ret)
565 return ret;
566 }
567 tpo_td043->spi_suspended = 0;
568
569 return 0;
570}
571#endif
572
573static SIMPLE_DEV_PM_OPS(tpo_td043_spi_pm,
574 tpo_td043_spi_suspend, tpo_td043_spi_resume);
575
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200576static struct spi_driver tpo_td043_spi_driver = {
577 .driver = {
578 .name = "tpo_td043mtea1_panel_spi",
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200579 .owner = THIS_MODULE,
Grazvydas Ignotas8df4f5c2012-02-07 02:13:49 +0200580 .pm = &tpo_td043_spi_pm,
Grazvydas Ignotas9ce4ad02009-12-11 21:30:14 +0200581 },
582 .probe = tpo_td043_spi_probe,
583 .remove = __devexit_p(tpo_td043_spi_remove),
584};
585
586static int __init tpo_td043_init(void)
587{
588 return spi_register_driver(&tpo_td043_spi_driver);
589}
590
591static void __exit tpo_td043_exit(void)
592{
593 spi_unregister_driver(&tpo_td043_spi_driver);
594}
595
596module_init(tpo_td043_init);
597module_exit(tpo_td043_exit);
598
599MODULE_AUTHOR("Gražvydas Ignotas <notasas@gmail.com>");
600MODULE_DESCRIPTION("TPO TD043MTEA1 LCD Driver");
601MODULE_LICENSE("GPL");