]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/video/omap2/displays/panel-taal.c
788104c9998acc878d5ff1ffcf14457de64cd13e
[mv-sheeva.git] / drivers / video / omap2 / displays / panel-taal.c
1 /*
2  * Taal DSI command mode panel
3  *
4  * Copyright (C) 2009 Nokia Corporation
5  * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published by
9  * the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 /*#define DEBUG*/
21
22 #include <linux/module.h>
23 #include <linux/delay.h>
24 #include <linux/err.h>
25 #include <linux/jiffies.h>
26 #include <linux/sched.h>
27 #include <linux/backlight.h>
28 #include <linux/fb.h>
29 #include <linux/interrupt.h>
30 #include <linux/gpio.h>
31 #include <linux/workqueue.h>
32 #include <linux/slab.h>
33 #include <linux/regulator/consumer.h>
34 #include <linux/mutex.h>
35
36 #include <video/omapdss.h>
37 #include <video/omap-panel-nokia-dsi.h>
38
39 /* DSI Virtual channel. Hardcoded for now. */
40 #define TCH 0
41
42 #define DCS_READ_NUM_ERRORS     0x05
43 #define DCS_READ_POWER_MODE     0x0a
44 #define DCS_READ_MADCTL         0x0b
45 #define DCS_READ_PIXEL_FORMAT   0x0c
46 #define DCS_RDDSDR              0x0f
47 #define DCS_SLEEP_IN            0x10
48 #define DCS_SLEEP_OUT           0x11
49 #define DCS_DISPLAY_OFF         0x28
50 #define DCS_DISPLAY_ON          0x29
51 #define DCS_COLUMN_ADDR         0x2a
52 #define DCS_PAGE_ADDR           0x2b
53 #define DCS_MEMORY_WRITE        0x2c
54 #define DCS_TEAR_OFF            0x34
55 #define DCS_TEAR_ON             0x35
56 #define DCS_MEM_ACC_CTRL        0x36
57 #define DCS_PIXEL_FORMAT        0x3a
58 #define DCS_BRIGHTNESS          0x51
59 #define DCS_CTRL_DISPLAY        0x53
60 #define DCS_WRITE_CABC          0x55
61 #define DCS_READ_CABC           0x56
62 #define DCS_GET_ID1             0xda
63 #define DCS_GET_ID2             0xdb
64 #define DCS_GET_ID3             0xdc
65
66 static irqreturn_t taal_te_isr(int irq, void *data);
67 static void taal_te_timeout_work_callback(struct work_struct *work);
68 static int _taal_enable_te(struct omap_dss_device *dssdev, bool enable);
69
70 struct panel_regulator {
71         struct regulator *regulator;
72         const char *name;
73         int min_uV;
74         int max_uV;
75 };
76
77 static void free_regulators(struct panel_regulator *regulators, int n)
78 {
79         int i;
80
81         for (i = 0; i < n; i++) {
82                 /* disable/put in reverse order */
83                 regulator_disable(regulators[n - i - 1].regulator);
84                 regulator_put(regulators[n - i - 1].regulator);
85         }
86 }
87
88 static int init_regulators(struct omap_dss_device *dssdev,
89                         struct panel_regulator *regulators, int n)
90 {
91         int r, i, v;
92
93         for (i = 0; i < n; i++) {
94                 struct regulator *reg;
95
96                 reg = regulator_get(&dssdev->dev, regulators[i].name);
97                 if (IS_ERR(reg)) {
98                         dev_err(&dssdev->dev, "failed to get regulator %s\n",
99                                 regulators[i].name);
100                         r = PTR_ERR(reg);
101                         goto err;
102                 }
103
104                 /* FIXME: better handling of fixed vs. variable regulators */
105                 v = regulator_get_voltage(reg);
106                 if (v < regulators[i].min_uV || v > regulators[i].max_uV) {
107                         r = regulator_set_voltage(reg, regulators[i].min_uV,
108                                                 regulators[i].max_uV);
109                         if (r) {
110                                 dev_err(&dssdev->dev,
111                                         "failed to set regulator %s voltage\n",
112                                         regulators[i].name);
113                                 regulator_put(reg);
114                                 goto err;
115                         }
116                 }
117
118                 r = regulator_enable(reg);
119                 if (r) {
120                         dev_err(&dssdev->dev, "failed to enable regulator %s\n",
121                                 regulators[i].name);
122                         regulator_put(reg);
123                         goto err;
124                 }
125
126                 regulators[i].regulator = reg;
127         }
128
129         return 0;
130
131 err:
132         free_regulators(regulators, i);
133
134         return r;
135 }
136
137 /**
138  * struct panel_config - panel configuration
139  * @name: panel name
140  * @type: panel type
141  * @timings: panel resolution
142  * @sleep: various panel specific delays, passed to msleep() if non-zero
143  * @reset_sequence: reset sequence timings, passed to udelay() if non-zero
144  * @regulators: array of panel regulators
145  * @num_regulators: number of regulators in the array
146  */
147 struct panel_config {
148         const char *name;
149         int type;
150
151         struct omap_video_timings timings;
152
153         struct {
154                 unsigned int sleep_in;
155                 unsigned int sleep_out;
156                 unsigned int hw_reset;
157                 unsigned int enable_te;
158         } sleep;
159
160         struct {
161                 unsigned int high;
162                 unsigned int low;
163         } reset_sequence;
164
165         struct panel_regulator *regulators;
166         int num_regulators;
167 };
168
169 enum {
170         PANEL_TAAL,
171 };
172
173 static struct panel_config panel_configs[] = {
174         {
175                 .name           = "taal",
176                 .type           = PANEL_TAAL,
177                 .timings        = {
178                         .x_res          = 864,
179                         .y_res          = 480,
180                 },
181                 .sleep          = {
182                         .sleep_in       = 5,
183                         .sleep_out      = 5,
184                         .hw_reset       = 5,
185                         .enable_te      = 100, /* possible panel bug */
186                 },
187                 .reset_sequence = {
188                         .high           = 10,
189                         .low            = 10,
190                 },
191         },
192 };
193
194 struct taal_data {
195         struct mutex lock;
196
197         struct backlight_device *bldev;
198
199         unsigned long   hw_guard_end;   /* next value of jiffies when we can
200                                          * issue the next sleep in/out command
201                                          */
202         unsigned long   hw_guard_wait;  /* max guard time in jiffies */
203
204         struct omap_dss_device *dssdev;
205
206         bool enabled;
207         u8 rotate;
208         bool mirror;
209
210         bool te_enabled;
211
212         atomic_t do_update;
213         struct {
214                 u16 x;
215                 u16 y;
216                 u16 w;
217                 u16 h;
218         } update_region;
219         int channel;
220
221         struct delayed_work te_timeout_work;
222
223         bool use_dsi_bl;
224
225         bool cabc_broken;
226         unsigned cabc_mode;
227
228         bool intro_printed;
229
230         struct workqueue_struct *esd_wq;
231         struct delayed_work esd_work;
232         unsigned esd_interval;
233
234         struct panel_config *panel_config;
235 };
236
237 static inline struct nokia_dsi_panel_data
238 *get_panel_data(const struct omap_dss_device *dssdev)
239 {
240         return (struct nokia_dsi_panel_data *) dssdev->data;
241 }
242
243 static void taal_esd_work(struct work_struct *work);
244
245 static void hw_guard_start(struct taal_data *td, int guard_msec)
246 {
247         td->hw_guard_wait = msecs_to_jiffies(guard_msec);
248         td->hw_guard_end = jiffies + td->hw_guard_wait;
249 }
250
251 static void hw_guard_wait(struct taal_data *td)
252 {
253         unsigned long wait = td->hw_guard_end - jiffies;
254
255         if ((long)wait > 0 && wait <= td->hw_guard_wait) {
256                 set_current_state(TASK_UNINTERRUPTIBLE);
257                 schedule_timeout(wait);
258         }
259 }
260
261 static int taal_dcs_read_1(struct taal_data *td, u8 dcs_cmd, u8 *data)
262 {
263         int r;
264         u8 buf[1];
265
266         r = dsi_vc_dcs_read(td->channel, dcs_cmd, buf, 1);
267
268         if (r < 0)
269                 return r;
270
271         *data = buf[0];
272
273         return 0;
274 }
275
276 static int taal_dcs_write_0(struct taal_data *td, u8 dcs_cmd)
277 {
278         return dsi_vc_dcs_write(td->channel, &dcs_cmd, 1);
279 }
280
281 static int taal_dcs_write_1(struct taal_data *td, u8 dcs_cmd, u8 param)
282 {
283         u8 buf[2];
284         buf[0] = dcs_cmd;
285         buf[1] = param;
286         return dsi_vc_dcs_write(td->channel, buf, 2);
287 }
288
289 static int taal_sleep_in(struct taal_data *td)
290
291 {
292         u8 cmd;
293         int r;
294
295         hw_guard_wait(td);
296
297         cmd = DCS_SLEEP_IN;
298         r = dsi_vc_dcs_write_nosync(td->channel, &cmd, 1);
299         if (r)
300                 return r;
301
302         hw_guard_start(td, 120);
303
304         if (td->panel_config->sleep.sleep_in)
305                 msleep(td->panel_config->sleep.sleep_in);
306
307         return 0;
308 }
309
310 static int taal_sleep_out(struct taal_data *td)
311 {
312         int r;
313
314         hw_guard_wait(td);
315
316         r = taal_dcs_write_0(td, DCS_SLEEP_OUT);
317         if (r)
318                 return r;
319
320         hw_guard_start(td, 120);
321
322         if (td->panel_config->sleep.sleep_out)
323                 msleep(td->panel_config->sleep.sleep_out);
324
325         return 0;
326 }
327
328 static int taal_get_id(struct taal_data *td, u8 *id1, u8 *id2, u8 *id3)
329 {
330         int r;
331
332         r = taal_dcs_read_1(td, DCS_GET_ID1, id1);
333         if (r)
334                 return r;
335         r = taal_dcs_read_1(td, DCS_GET_ID2, id2);
336         if (r)
337                 return r;
338         r = taal_dcs_read_1(td, DCS_GET_ID3, id3);
339         if (r)
340                 return r;
341
342         return 0;
343 }
344
345 static int taal_set_addr_mode(struct taal_data *td, u8 rotate, bool mirror)
346 {
347         int r;
348         u8 mode;
349         int b5, b6, b7;
350
351         r = taal_dcs_read_1(td, DCS_READ_MADCTL, &mode);
352         if (r)
353                 return r;
354
355         switch (rotate) {
356         default:
357         case 0:
358                 b7 = 0;
359                 b6 = 0;
360                 b5 = 0;
361                 break;
362         case 1:
363                 b7 = 0;
364                 b6 = 1;
365                 b5 = 1;
366                 break;
367         case 2:
368                 b7 = 1;
369                 b6 = 1;
370                 b5 = 0;
371                 break;
372         case 3:
373                 b7 = 1;
374                 b6 = 0;
375                 b5 = 1;
376                 break;
377         }
378
379         if (mirror)
380                 b6 = !b6;
381
382         mode &= ~((1<<7) | (1<<6) | (1<<5));
383         mode |= (b7 << 7) | (b6 << 6) | (b5 << 5);
384
385         return taal_dcs_write_1(td, DCS_MEM_ACC_CTRL, mode);
386 }
387
388 static int taal_set_update_window(struct taal_data *td,
389                 u16 x, u16 y, u16 w, u16 h)
390 {
391         int r;
392         u16 x1 = x;
393         u16 x2 = x + w - 1;
394         u16 y1 = y;
395         u16 y2 = y + h - 1;
396
397         u8 buf[5];
398         buf[0] = DCS_COLUMN_ADDR;
399         buf[1] = (x1 >> 8) & 0xff;
400         buf[2] = (x1 >> 0) & 0xff;
401         buf[3] = (x2 >> 8) & 0xff;
402         buf[4] = (x2 >> 0) & 0xff;
403
404         r = dsi_vc_dcs_write_nosync(td->channel, buf, sizeof(buf));
405         if (r)
406                 return r;
407
408         buf[0] = DCS_PAGE_ADDR;
409         buf[1] = (y1 >> 8) & 0xff;
410         buf[2] = (y1 >> 0) & 0xff;
411         buf[3] = (y2 >> 8) & 0xff;
412         buf[4] = (y2 >> 0) & 0xff;
413
414         r = dsi_vc_dcs_write_nosync(td->channel, buf, sizeof(buf));
415         if (r)
416                 return r;
417
418         dsi_vc_send_bta_sync(td->channel);
419
420         return r;
421 }
422
423 static int taal_bl_update_status(struct backlight_device *dev)
424 {
425         struct omap_dss_device *dssdev = dev_get_drvdata(&dev->dev);
426         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
427         struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
428         int r;
429         int level;
430
431         if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
432                         dev->props.power == FB_BLANK_UNBLANK)
433                 level = dev->props.brightness;
434         else
435                 level = 0;
436
437         dev_dbg(&dssdev->dev, "update brightness to %d\n", level);
438
439         mutex_lock(&td->lock);
440
441         if (td->use_dsi_bl) {
442                 if (td->enabled) {
443                         dsi_bus_lock();
444                         r = taal_dcs_write_1(td, DCS_BRIGHTNESS, level);
445                         dsi_bus_unlock();
446                 } else {
447                         r = 0;
448                 }
449         } else {
450                 if (!panel_data->set_backlight)
451                         r = -EINVAL;
452                 else
453                         r = panel_data->set_backlight(dssdev, level);
454         }
455
456         mutex_unlock(&td->lock);
457
458         return r;
459 }
460
461 static int taal_bl_get_intensity(struct backlight_device *dev)
462 {
463         if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
464                         dev->props.power == FB_BLANK_UNBLANK)
465                 return dev->props.brightness;
466
467         return 0;
468 }
469
470 static const struct backlight_ops taal_bl_ops = {
471         .get_brightness = taal_bl_get_intensity,
472         .update_status  = taal_bl_update_status,
473 };
474
475 static void taal_get_timings(struct omap_dss_device *dssdev,
476                         struct omap_video_timings *timings)
477 {
478         *timings = dssdev->panel.timings;
479 }
480
481 static void taal_get_resolution(struct omap_dss_device *dssdev,
482                 u16 *xres, u16 *yres)
483 {
484         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
485
486         if (td->rotate == 0 || td->rotate == 2) {
487                 *xres = dssdev->panel.timings.x_res;
488                 *yres = dssdev->panel.timings.y_res;
489         } else {
490                 *yres = dssdev->panel.timings.x_res;
491                 *xres = dssdev->panel.timings.y_res;
492         }
493 }
494
495 static ssize_t taal_num_errors_show(struct device *dev,
496                 struct device_attribute *attr, char *buf)
497 {
498         struct omap_dss_device *dssdev = to_dss_device(dev);
499         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
500         u8 errors;
501         int r;
502
503         mutex_lock(&td->lock);
504
505         if (td->enabled) {
506                 dsi_bus_lock();
507                 r = taal_dcs_read_1(td, DCS_READ_NUM_ERRORS, &errors);
508                 dsi_bus_unlock();
509         } else {
510                 r = -ENODEV;
511         }
512
513         mutex_unlock(&td->lock);
514
515         if (r)
516                 return r;
517
518         return snprintf(buf, PAGE_SIZE, "%d\n", errors);
519 }
520
521 static ssize_t taal_hw_revision_show(struct device *dev,
522                 struct device_attribute *attr, char *buf)
523 {
524         struct omap_dss_device *dssdev = to_dss_device(dev);
525         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
526         u8 id1, id2, id3;
527         int r;
528
529         mutex_lock(&td->lock);
530
531         if (td->enabled) {
532                 dsi_bus_lock();
533                 r = taal_get_id(td, &id1, &id2, &id3);
534                 dsi_bus_unlock();
535         } else {
536                 r = -ENODEV;
537         }
538
539         mutex_unlock(&td->lock);
540
541         if (r)
542                 return r;
543
544         return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3);
545 }
546
547 static const char *cabc_modes[] = {
548         "off",          /* used also always when CABC is not supported */
549         "ui",
550         "still-image",
551         "moving-image",
552 };
553
554 static ssize_t show_cabc_mode(struct device *dev,
555                 struct device_attribute *attr,
556                 char *buf)
557 {
558         struct omap_dss_device *dssdev = to_dss_device(dev);
559         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
560         const char *mode_str;
561         int mode;
562         int len;
563
564         mode = td->cabc_mode;
565
566         mode_str = "unknown";
567         if (mode >= 0 && mode < ARRAY_SIZE(cabc_modes))
568                 mode_str = cabc_modes[mode];
569         len = snprintf(buf, PAGE_SIZE, "%s\n", mode_str);
570
571         return len < PAGE_SIZE - 1 ? len : PAGE_SIZE - 1;
572 }
573
574 static ssize_t store_cabc_mode(struct device *dev,
575                 struct device_attribute *attr,
576                 const char *buf, size_t count)
577 {
578         struct omap_dss_device *dssdev = to_dss_device(dev);
579         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
580         int i;
581
582         for (i = 0; i < ARRAY_SIZE(cabc_modes); i++) {
583                 if (sysfs_streq(cabc_modes[i], buf))
584                         break;
585         }
586
587         if (i == ARRAY_SIZE(cabc_modes))
588                 return -EINVAL;
589
590         mutex_lock(&td->lock);
591
592         if (td->enabled) {
593                 dsi_bus_lock();
594                 if (!td->cabc_broken)
595                         taal_dcs_write_1(td, DCS_WRITE_CABC, i);
596                 dsi_bus_unlock();
597         }
598
599         td->cabc_mode = i;
600
601         mutex_unlock(&td->lock);
602
603         return count;
604 }
605
606 static ssize_t show_cabc_available_modes(struct device *dev,
607                 struct device_attribute *attr,
608                 char *buf)
609 {
610         int len;
611         int i;
612
613         for (i = 0, len = 0;
614              len < PAGE_SIZE && i < ARRAY_SIZE(cabc_modes); i++)
615                 len += snprintf(&buf[len], PAGE_SIZE - len, "%s%s%s",
616                         i ? " " : "", cabc_modes[i],
617                         i == ARRAY_SIZE(cabc_modes) - 1 ? "\n" : "");
618
619         return len < PAGE_SIZE ? len : PAGE_SIZE - 1;
620 }
621
622 static DEVICE_ATTR(num_dsi_errors, S_IRUGO, taal_num_errors_show, NULL);
623 static DEVICE_ATTR(hw_revision, S_IRUGO, taal_hw_revision_show, NULL);
624 static DEVICE_ATTR(cabc_mode, S_IRUGO | S_IWUSR,
625                 show_cabc_mode, store_cabc_mode);
626 static DEVICE_ATTR(cabc_available_modes, S_IRUGO,
627                 show_cabc_available_modes, NULL);
628
629 static struct attribute *taal_attrs[] = {
630         &dev_attr_num_dsi_errors.attr,
631         &dev_attr_hw_revision.attr,
632         &dev_attr_cabc_mode.attr,
633         &dev_attr_cabc_available_modes.attr,
634         NULL,
635 };
636
637 static struct attribute_group taal_attr_group = {
638         .attrs = taal_attrs,
639 };
640
641 static void taal_hw_reset(struct omap_dss_device *dssdev)
642 {
643         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
644         struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
645
646         if (panel_data->reset_gpio == -1)
647                 return;
648
649         gpio_set_value(panel_data->reset_gpio, 1);
650         if (td->panel_config->reset_sequence.high)
651                 udelay(td->panel_config->reset_sequence.high);
652         /* reset the panel */
653         gpio_set_value(panel_data->reset_gpio, 0);
654         /* assert reset */
655         if (td->panel_config->reset_sequence.low)
656                 udelay(td->panel_config->reset_sequence.low);
657         gpio_set_value(panel_data->reset_gpio, 1);
658         /* wait after releasing reset */
659         if (td->panel_config->sleep.hw_reset)
660                 msleep(td->panel_config->sleep.hw_reset);
661 }
662
663 static int taal_probe(struct omap_dss_device *dssdev)
664 {
665         struct backlight_properties props;
666         struct taal_data *td;
667         struct backlight_device *bldev;
668         struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
669         struct panel_config *panel_config = NULL;
670         int r, i;
671
672         dev_dbg(&dssdev->dev, "probe\n");
673
674         if (!panel_data || !panel_data->name) {
675                 r = -EINVAL;
676                 goto err;
677         }
678
679         for (i = 0; i < ARRAY_SIZE(panel_configs); i++) {
680                 if (strcmp(panel_data->name, panel_configs[i].name) == 0) {
681                         panel_config = &panel_configs[i];
682                         break;
683                 }
684         }
685
686         if (!panel_config) {
687                 r = -EINVAL;
688                 goto err;
689         }
690
691         dssdev->panel.config = OMAP_DSS_LCD_TFT;
692         dssdev->panel.timings = panel_config->timings;
693         dssdev->ctrl.pixel_size = 24;
694
695         td = kzalloc(sizeof(*td), GFP_KERNEL);
696         if (!td) {
697                 r = -ENOMEM;
698                 goto err;
699         }
700         td->dssdev = dssdev;
701         td->panel_config = panel_config;
702         td->esd_interval = panel_data->esd_interval;
703
704         mutex_init(&td->lock);
705
706         atomic_set(&td->do_update, 0);
707
708         r = init_regulators(dssdev, panel_config->regulators,
709                         panel_config->num_regulators);
710         if (r)
711                 goto err_reg;
712
713         td->esd_wq = create_singlethread_workqueue("taal_esd");
714         if (td->esd_wq == NULL) {
715                 dev_err(&dssdev->dev, "can't create ESD workqueue\n");
716                 r = -ENOMEM;
717                 goto err_wq;
718         }
719         INIT_DELAYED_WORK_DEFERRABLE(&td->esd_work, taal_esd_work);
720
721         dev_set_drvdata(&dssdev->dev, td);
722
723         taal_hw_reset(dssdev);
724
725         /* if no platform set_backlight() defined, presume DSI backlight
726          * control */
727         memset(&props, 0, sizeof(struct backlight_properties));
728         if (!panel_data->set_backlight)
729                 td->use_dsi_bl = true;
730
731         if (td->use_dsi_bl)
732                 props.max_brightness = 255;
733         else
734                 props.max_brightness = 127;
735
736         props.type = BACKLIGHT_RAW;
737         bldev = backlight_device_register("taal", &dssdev->dev, dssdev,
738                                           &taal_bl_ops, &props);
739         if (IS_ERR(bldev)) {
740                 r = PTR_ERR(bldev);
741                 goto err_bl;
742         }
743
744         td->bldev = bldev;
745
746         bldev->props.fb_blank = FB_BLANK_UNBLANK;
747         bldev->props.power = FB_BLANK_UNBLANK;
748         if (td->use_dsi_bl)
749                 bldev->props.brightness = 255;
750         else
751                 bldev->props.brightness = 127;
752
753         taal_bl_update_status(bldev);
754
755         if (panel_data->use_ext_te) {
756                 int gpio = panel_data->ext_te_gpio;
757
758                 r = gpio_request(gpio, "taal irq");
759                 if (r) {
760                         dev_err(&dssdev->dev, "GPIO request failed\n");
761                         goto err_gpio;
762                 }
763
764                 gpio_direction_input(gpio);
765
766                 r = request_irq(gpio_to_irq(gpio), taal_te_isr,
767                                 IRQF_DISABLED | IRQF_TRIGGER_RISING,
768                                 "taal vsync", dssdev);
769
770                 if (r) {
771                         dev_err(&dssdev->dev, "IRQ request failed\n");
772                         gpio_free(gpio);
773                         goto err_irq;
774                 }
775
776                 INIT_DELAYED_WORK_DEFERRABLE(&td->te_timeout_work,
777                                         taal_te_timeout_work_callback);
778
779                 dev_dbg(&dssdev->dev, "Using GPIO TE\n");
780         }
781
782         r = omap_dsi_request_vc(dssdev, &td->channel);
783         if (r) {
784                 dev_err(&dssdev->dev, "failed to get virtual channel\n");
785                 goto err_req_vc;
786         }
787
788         r = omap_dsi_set_vc_id(dssdev, td->channel, TCH);
789         if (r) {
790                 dev_err(&dssdev->dev, "failed to set VC_ID\n");
791                 goto err_vc_id;
792         }
793
794         r = sysfs_create_group(&dssdev->dev.kobj, &taal_attr_group);
795         if (r) {
796                 dev_err(&dssdev->dev, "failed to create sysfs files\n");
797                 goto err_vc_id;
798         }
799
800         return 0;
801
802 err_vc_id:
803         omap_dsi_release_vc(dssdev, td->channel);
804 err_req_vc:
805         if (panel_data->use_ext_te)
806                 free_irq(gpio_to_irq(panel_data->ext_te_gpio), dssdev);
807 err_irq:
808         if (panel_data->use_ext_te)
809                 gpio_free(panel_data->ext_te_gpio);
810 err_gpio:
811         backlight_device_unregister(bldev);
812 err_bl:
813         destroy_workqueue(td->esd_wq);
814 err_wq:
815         free_regulators(panel_config->regulators, panel_config->num_regulators);
816 err_reg:
817         kfree(td);
818 err:
819         return r;
820 }
821
822 static void __exit taal_remove(struct omap_dss_device *dssdev)
823 {
824         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
825         struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
826         struct backlight_device *bldev;
827
828         dev_dbg(&dssdev->dev, "remove\n");
829
830         sysfs_remove_group(&dssdev->dev.kobj, &taal_attr_group);
831         omap_dsi_release_vc(dssdev, td->channel);
832
833         if (panel_data->use_ext_te) {
834                 int gpio = panel_data->ext_te_gpio;
835                 free_irq(gpio_to_irq(gpio), dssdev);
836                 gpio_free(gpio);
837         }
838
839         bldev = td->bldev;
840         bldev->props.power = FB_BLANK_POWERDOWN;
841         taal_bl_update_status(bldev);
842         backlight_device_unregister(bldev);
843
844         cancel_delayed_work(&td->esd_work);
845         destroy_workqueue(td->esd_wq);
846
847         /* reset, to be sure that the panel is in a valid state */
848         taal_hw_reset(dssdev);
849
850         free_regulators(td->panel_config->regulators,
851                         td->panel_config->num_regulators);
852
853         kfree(td);
854 }
855
856 static int taal_power_on(struct omap_dss_device *dssdev)
857 {
858         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
859         u8 id1, id2, id3;
860         int r;
861
862         r = omapdss_dsi_display_enable(dssdev);
863         if (r) {
864                 dev_err(&dssdev->dev, "failed to enable DSI\n");
865                 goto err0;
866         }
867
868         taal_hw_reset(dssdev);
869
870         omapdss_dsi_vc_enable_hs(td->channel, false);
871
872         r = taal_sleep_out(td);
873         if (r)
874                 goto err;
875
876         r = taal_get_id(td, &id1, &id2, &id3);
877         if (r)
878                 goto err;
879
880         /* on early Taal revisions CABC is broken */
881         if (td->panel_config->type == PANEL_TAAL &&
882                 (id2 == 0x00 || id2 == 0xff || id2 == 0x81))
883                 td->cabc_broken = true;
884
885         r = taal_dcs_write_1(td, DCS_BRIGHTNESS, 0xff);
886         if (r)
887                 goto err;
888
889         r = taal_dcs_write_1(td, DCS_CTRL_DISPLAY,
890                         (1<<2) | (1<<5));       /* BL | BCTRL */
891         if (r)
892                 goto err;
893
894         r = taal_dcs_write_1(td, DCS_PIXEL_FORMAT, 0x7); /* 24bit/pixel */
895         if (r)
896                 goto err;
897
898         r = taal_set_addr_mode(td, td->rotate, td->mirror);
899         if (r)
900                 goto err;
901
902         if (!td->cabc_broken) {
903                 r = taal_dcs_write_1(td, DCS_WRITE_CABC, td->cabc_mode);
904                 if (r)
905                         goto err;
906         }
907
908         r = taal_dcs_write_0(td, DCS_DISPLAY_ON);
909         if (r)
910                 goto err;
911
912         r = _taal_enable_te(dssdev, td->te_enabled);
913         if (r)
914                 goto err;
915
916         td->enabled = 1;
917
918         if (!td->intro_printed) {
919                 dev_info(&dssdev->dev, "%s panel revision %02x.%02x.%02x\n",
920                         td->panel_config->name, id1, id2, id3);
921                 if (td->cabc_broken)
922                         dev_info(&dssdev->dev,
923                                         "old Taal version, CABC disabled\n");
924                 td->intro_printed = true;
925         }
926
927         omapdss_dsi_vc_enable_hs(td->channel, true);
928
929         return 0;
930 err:
931         dev_err(&dssdev->dev, "error while enabling panel, issuing HW reset\n");
932
933         taal_hw_reset(dssdev);
934
935         omapdss_dsi_display_disable(dssdev, true, false);
936 err0:
937         return r;
938 }
939
940 static void taal_power_off(struct omap_dss_device *dssdev)
941 {
942         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
943         int r;
944
945         r = taal_dcs_write_0(td, DCS_DISPLAY_OFF);
946         if (!r) {
947                 r = taal_sleep_in(td);
948                 /* HACK: wait a bit so that the message goes through */
949                 msleep(10);
950         }
951
952         if (r) {
953                 dev_err(&dssdev->dev,
954                                 "error disabling panel, issuing HW reset\n");
955                 taal_hw_reset(dssdev);
956         }
957
958         omapdss_dsi_display_disable(dssdev, true, false);
959
960         td->enabled = 0;
961 }
962
963 static int taal_enable(struct omap_dss_device *dssdev)
964 {
965         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
966         int r;
967
968         dev_dbg(&dssdev->dev, "enable\n");
969
970         mutex_lock(&td->lock);
971
972         if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) {
973                 r = -EINVAL;
974                 goto err;
975         }
976
977         dsi_bus_lock();
978
979         r = taal_power_on(dssdev);
980
981         dsi_bus_unlock();
982
983         if (r)
984                 goto err;
985
986         if (td->esd_interval > 0)
987                 queue_delayed_work(td->esd_wq, &td->esd_work,
988                                 msecs_to_jiffies(td->esd_interval));
989
990         dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
991
992         mutex_unlock(&td->lock);
993
994         return 0;
995 err:
996         dev_dbg(&dssdev->dev, "enable failed\n");
997         mutex_unlock(&td->lock);
998         return r;
999 }
1000
1001 static void taal_disable(struct omap_dss_device *dssdev)
1002 {
1003         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1004
1005         dev_dbg(&dssdev->dev, "disable\n");
1006
1007         mutex_lock(&td->lock);
1008
1009         cancel_delayed_work(&td->esd_work);
1010
1011         dsi_bus_lock();
1012
1013         if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
1014                 taal_power_off(dssdev);
1015
1016         dsi_bus_unlock();
1017
1018         dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
1019
1020         mutex_unlock(&td->lock);
1021 }
1022
1023 static int taal_suspend(struct omap_dss_device *dssdev)
1024 {
1025         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1026         int r;
1027
1028         dev_dbg(&dssdev->dev, "suspend\n");
1029
1030         mutex_lock(&td->lock);
1031
1032         if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) {
1033                 r = -EINVAL;
1034                 goto err;
1035         }
1036
1037         cancel_delayed_work(&td->esd_work);
1038
1039         dsi_bus_lock();
1040
1041         taal_power_off(dssdev);
1042
1043         dsi_bus_unlock();
1044
1045         dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
1046
1047         mutex_unlock(&td->lock);
1048
1049         return 0;
1050 err:
1051         mutex_unlock(&td->lock);
1052         return r;
1053 }
1054
1055 static int taal_resume(struct omap_dss_device *dssdev)
1056 {
1057         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1058         int r;
1059
1060         dev_dbg(&dssdev->dev, "resume\n");
1061
1062         mutex_lock(&td->lock);
1063
1064         if (dssdev->state != OMAP_DSS_DISPLAY_SUSPENDED) {
1065                 r = -EINVAL;
1066                 goto err;
1067         }
1068
1069         dsi_bus_lock();
1070
1071         r = taal_power_on(dssdev);
1072
1073         dsi_bus_unlock();
1074
1075         if (r) {
1076                 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
1077         } else {
1078                 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
1079                 if (td->esd_interval > 0)
1080                         queue_delayed_work(td->esd_wq, &td->esd_work,
1081                                         msecs_to_jiffies(td->esd_interval));
1082         }
1083
1084         mutex_unlock(&td->lock);
1085
1086         return r;
1087 err:
1088         mutex_unlock(&td->lock);
1089         return r;
1090 }
1091
1092 static void taal_framedone_cb(int err, void *data)
1093 {
1094         struct omap_dss_device *dssdev = data;
1095         dev_dbg(&dssdev->dev, "framedone, err %d\n", err);
1096         dsi_bus_unlock();
1097 }
1098
1099 static irqreturn_t taal_te_isr(int irq, void *data)
1100 {
1101         struct omap_dss_device *dssdev = data;
1102         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1103         int old;
1104         int r;
1105
1106         old = atomic_cmpxchg(&td->do_update, 1, 0);
1107
1108         if (old) {
1109                 cancel_delayed_work(&td->te_timeout_work);
1110
1111                 r = omap_dsi_update(dssdev, td->channel,
1112                                 td->update_region.x,
1113                                 td->update_region.y,
1114                                 td->update_region.w,
1115                                 td->update_region.h,
1116                                 taal_framedone_cb, dssdev);
1117                 if (r)
1118                         goto err;
1119         }
1120
1121         return IRQ_HANDLED;
1122 err:
1123         dev_err(&dssdev->dev, "start update failed\n");
1124         dsi_bus_unlock();
1125         return IRQ_HANDLED;
1126 }
1127
1128 static void taal_te_timeout_work_callback(struct work_struct *work)
1129 {
1130         struct taal_data *td = container_of(work, struct taal_data,
1131                                         te_timeout_work.work);
1132         struct omap_dss_device *dssdev = td->dssdev;
1133
1134         dev_err(&dssdev->dev, "TE not received for 250ms!\n");
1135
1136         atomic_set(&td->do_update, 0);
1137         dsi_bus_unlock();
1138 }
1139
1140 static int taal_update(struct omap_dss_device *dssdev,
1141                                     u16 x, u16 y, u16 w, u16 h)
1142 {
1143         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1144         struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
1145         int r;
1146
1147         dev_dbg(&dssdev->dev, "update %d, %d, %d x %d\n", x, y, w, h);
1148
1149         mutex_lock(&td->lock);
1150         dsi_bus_lock();
1151
1152         if (!td->enabled) {
1153                 r = 0;
1154                 goto err;
1155         }
1156
1157         r = omap_dsi_prepare_update(dssdev, &x, &y, &w, &h, true);
1158         if (r)
1159                 goto err;
1160
1161         r = taal_set_update_window(td, x, y, w, h);
1162         if (r)
1163                 goto err;
1164
1165         if (td->te_enabled && panel_data->use_ext_te) {
1166                 td->update_region.x = x;
1167                 td->update_region.y = y;
1168                 td->update_region.w = w;
1169                 td->update_region.h = h;
1170                 barrier();
1171                 schedule_delayed_work(&td->te_timeout_work,
1172                                 msecs_to_jiffies(250));
1173                 atomic_set(&td->do_update, 1);
1174         } else {
1175                 r = omap_dsi_update(dssdev, td->channel, x, y, w, h,
1176                                 taal_framedone_cb, dssdev);
1177                 if (r)
1178                         goto err;
1179         }
1180
1181         /* note: no bus_unlock here. unlock is in framedone_cb */
1182         mutex_unlock(&td->lock);
1183         return 0;
1184 err:
1185         dsi_bus_unlock();
1186         mutex_unlock(&td->lock);
1187         return r;
1188 }
1189
1190 static int taal_sync(struct omap_dss_device *dssdev)
1191 {
1192         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1193
1194         dev_dbg(&dssdev->dev, "sync\n");
1195
1196         mutex_lock(&td->lock);
1197         dsi_bus_lock();
1198         dsi_bus_unlock();
1199         mutex_unlock(&td->lock);
1200
1201         dev_dbg(&dssdev->dev, "sync done\n");
1202
1203         return 0;
1204 }
1205
1206 static int _taal_enable_te(struct omap_dss_device *dssdev, bool enable)
1207 {
1208         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1209         struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
1210         int r;
1211
1212         if (enable)
1213                 r = taal_dcs_write_1(td, DCS_TEAR_ON, 0);
1214         else
1215                 r = taal_dcs_write_0(td, DCS_TEAR_OFF);
1216
1217         if (!panel_data->use_ext_te)
1218                 omapdss_dsi_enable_te(dssdev, enable);
1219
1220         if (td->panel_config->sleep.enable_te)
1221                 msleep(td->panel_config->sleep.enable_te);
1222
1223         return r;
1224 }
1225
1226 static int taal_enable_te(struct omap_dss_device *dssdev, bool enable)
1227 {
1228         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1229         int r;
1230
1231         mutex_lock(&td->lock);
1232
1233         if (td->te_enabled == enable)
1234                 goto end;
1235
1236         dsi_bus_lock();
1237
1238         if (td->enabled) {
1239                 r = _taal_enable_te(dssdev, enable);
1240                 if (r)
1241                         goto err;
1242         }
1243
1244         td->te_enabled = enable;
1245
1246         dsi_bus_unlock();
1247 end:
1248         mutex_unlock(&td->lock);
1249
1250         return 0;
1251 err:
1252         dsi_bus_unlock();
1253         mutex_unlock(&td->lock);
1254
1255         return r;
1256 }
1257
1258 static int taal_get_te(struct omap_dss_device *dssdev)
1259 {
1260         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1261         int r;
1262
1263         mutex_lock(&td->lock);
1264         r = td->te_enabled;
1265         mutex_unlock(&td->lock);
1266
1267         return r;
1268 }
1269
1270 static int taal_rotate(struct omap_dss_device *dssdev, u8 rotate)
1271 {
1272         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1273         int r;
1274
1275         dev_dbg(&dssdev->dev, "rotate %d\n", rotate);
1276
1277         mutex_lock(&td->lock);
1278
1279         if (td->rotate == rotate)
1280                 goto end;
1281
1282         dsi_bus_lock();
1283
1284         if (td->enabled) {
1285                 r = taal_set_addr_mode(td, rotate, td->mirror);
1286                 if (r)
1287                         goto err;
1288         }
1289
1290         td->rotate = rotate;
1291
1292         dsi_bus_unlock();
1293 end:
1294         mutex_unlock(&td->lock);
1295         return 0;
1296 err:
1297         dsi_bus_unlock();
1298         mutex_unlock(&td->lock);
1299         return r;
1300 }
1301
1302 static u8 taal_get_rotate(struct omap_dss_device *dssdev)
1303 {
1304         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1305         int r;
1306
1307         mutex_lock(&td->lock);
1308         r = td->rotate;
1309         mutex_unlock(&td->lock);
1310
1311         return r;
1312 }
1313
1314 static int taal_mirror(struct omap_dss_device *dssdev, bool enable)
1315 {
1316         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1317         int r;
1318
1319         dev_dbg(&dssdev->dev, "mirror %d\n", enable);
1320
1321         mutex_lock(&td->lock);
1322
1323         if (td->mirror == enable)
1324                 goto end;
1325
1326         dsi_bus_lock();
1327         if (td->enabled) {
1328                 r = taal_set_addr_mode(td, td->rotate, enable);
1329                 if (r)
1330                         goto err;
1331         }
1332
1333         td->mirror = enable;
1334
1335         dsi_bus_unlock();
1336 end:
1337         mutex_unlock(&td->lock);
1338         return 0;
1339 err:
1340         dsi_bus_unlock();
1341         mutex_unlock(&td->lock);
1342         return r;
1343 }
1344
1345 static bool taal_get_mirror(struct omap_dss_device *dssdev)
1346 {
1347         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1348         int r;
1349
1350         mutex_lock(&td->lock);
1351         r = td->mirror;
1352         mutex_unlock(&td->lock);
1353
1354         return r;
1355 }
1356
1357 static int taal_run_test(struct omap_dss_device *dssdev, int test_num)
1358 {
1359         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1360         u8 id1, id2, id3;
1361         int r;
1362
1363         mutex_lock(&td->lock);
1364
1365         if (!td->enabled) {
1366                 r = -ENODEV;
1367                 goto err1;
1368         }
1369
1370         dsi_bus_lock();
1371
1372         r = taal_dcs_read_1(td, DCS_GET_ID1, &id1);
1373         if (r)
1374                 goto err2;
1375         r = taal_dcs_read_1(td, DCS_GET_ID2, &id2);
1376         if (r)
1377                 goto err2;
1378         r = taal_dcs_read_1(td, DCS_GET_ID3, &id3);
1379         if (r)
1380                 goto err2;
1381
1382         dsi_bus_unlock();
1383         mutex_unlock(&td->lock);
1384         return 0;
1385 err2:
1386         dsi_bus_unlock();
1387 err1:
1388         mutex_unlock(&td->lock);
1389         return r;
1390 }
1391
1392 static int taal_memory_read(struct omap_dss_device *dssdev,
1393                 void *buf, size_t size,
1394                 u16 x, u16 y, u16 w, u16 h)
1395 {
1396         int r;
1397         int first = 1;
1398         int plen;
1399         unsigned buf_used = 0;
1400         struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1401
1402         if (size < w * h * 3)
1403                 return -ENOMEM;
1404
1405         mutex_lock(&td->lock);
1406
1407         if (!td->enabled) {
1408                 r = -ENODEV;
1409                 goto err1;
1410         }
1411
1412         size = min(w * h * 3,
1413                         dssdev->panel.timings.x_res *
1414                         dssdev->panel.timings.y_res * 3);
1415
1416         dsi_bus_lock();
1417
1418         /* plen 1 or 2 goes into short packet. until checksum error is fixed,
1419          * use short packets. plen 32 works, but bigger packets seem to cause
1420          * an error. */
1421         if (size % 2)
1422                 plen = 1;
1423         else
1424                 plen = 2;
1425
1426         taal_set_update_window(td, x, y, w, h);
1427
1428         r = dsi_vc_set_max_rx_packet_size(td->channel, plen);
1429         if (r)
1430                 goto err2;
1431
1432         while (buf_used < size) {
1433                 u8 dcs_cmd = first ? 0x2e : 0x3e;
1434                 first = 0;
1435
1436                 r = dsi_vc_dcs_read(td->channel, dcs_cmd,
1437                                 buf + buf_used, size - buf_used);
1438
1439                 if (r < 0) {
1440                         dev_err(&dssdev->dev, "read error\n");
1441                         goto err3;
1442                 }
1443
1444                 buf_used += r;
1445
1446                 if (r < plen) {
1447                         dev_err(&dssdev->dev, "short read\n");
1448                         break;
1449                 }
1450
1451                 if (signal_pending(current)) {
1452                         dev_err(&dssdev->dev, "signal pending, "
1453                                         "aborting memory read\n");
1454                         r = -ERESTARTSYS;
1455                         goto err3;
1456                 }
1457         }
1458
1459         r = buf_used;
1460
1461 err3:
1462         dsi_vc_set_max_rx_packet_size(td->channel, 1);
1463 err2:
1464         dsi_bus_unlock();
1465 err1:
1466         mutex_unlock(&td->lock);
1467         return r;
1468 }
1469
1470 static void taal_esd_work(struct work_struct *work)
1471 {
1472         struct taal_data *td = container_of(work, struct taal_data,
1473                         esd_work.work);
1474         struct omap_dss_device *dssdev = td->dssdev;
1475         struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
1476         u8 state1, state2;
1477         int r;
1478
1479         mutex_lock(&td->lock);
1480
1481         if (!td->enabled) {
1482                 mutex_unlock(&td->lock);
1483                 return;
1484         }
1485
1486         dsi_bus_lock();
1487
1488         r = taal_dcs_read_1(td, DCS_RDDSDR, &state1);
1489         if (r) {
1490                 dev_err(&dssdev->dev, "failed to read Taal status\n");
1491                 goto err;
1492         }
1493
1494         /* Run self diagnostics */
1495         r = taal_sleep_out(td);
1496         if (r) {
1497                 dev_err(&dssdev->dev, "failed to run Taal self-diagnostics\n");
1498                 goto err;
1499         }
1500
1501         r = taal_dcs_read_1(td, DCS_RDDSDR, &state2);
1502         if (r) {
1503                 dev_err(&dssdev->dev, "failed to read Taal status\n");
1504                 goto err;
1505         }
1506
1507         /* Each sleep out command will trigger a self diagnostic and flip
1508          * Bit6 if the test passes.
1509          */
1510         if (!((state1 ^ state2) & (1 << 6))) {
1511                 dev_err(&dssdev->dev, "LCD self diagnostics failed\n");
1512                 goto err;
1513         }
1514         /* Self-diagnostics result is also shown on TE GPIO line. We need
1515          * to re-enable TE after self diagnostics */
1516         if (td->te_enabled && panel_data->use_ext_te) {
1517                 r = taal_dcs_write_1(td, DCS_TEAR_ON, 0);
1518                 if (r)
1519                         goto err;
1520         }
1521
1522         dsi_bus_unlock();
1523
1524         queue_delayed_work(td->esd_wq, &td->esd_work,
1525                        msecs_to_jiffies(td->esd_interval));
1526
1527         mutex_unlock(&td->lock);
1528         return;
1529 err:
1530         dev_err(&dssdev->dev, "performing LCD reset\n");
1531
1532         taal_power_off(dssdev);
1533         taal_hw_reset(dssdev);
1534         taal_power_on(dssdev);
1535
1536         dsi_bus_unlock();
1537
1538         queue_delayed_work(td->esd_wq, &td->esd_work,
1539                        msecs_to_jiffies(td->esd_interval));
1540
1541         mutex_unlock(&td->lock);
1542 }
1543
1544 static int taal_set_update_mode(struct omap_dss_device *dssdev,
1545                 enum omap_dss_update_mode mode)
1546 {
1547         if (mode != OMAP_DSS_UPDATE_MANUAL)
1548                 return -EINVAL;
1549         return 0;
1550 }
1551
1552 static enum omap_dss_update_mode taal_get_update_mode(
1553                 struct omap_dss_device *dssdev)
1554 {
1555         return OMAP_DSS_UPDATE_MANUAL;
1556 }
1557
1558 static struct omap_dss_driver taal_driver = {
1559         .probe          = taal_probe,
1560         .remove         = __exit_p(taal_remove),
1561
1562         .enable         = taal_enable,
1563         .disable        = taal_disable,
1564         .suspend        = taal_suspend,
1565         .resume         = taal_resume,
1566
1567         .set_update_mode = taal_set_update_mode,
1568         .get_update_mode = taal_get_update_mode,
1569
1570         .update         = taal_update,
1571         .sync           = taal_sync,
1572
1573         .get_resolution = taal_get_resolution,
1574         .get_recommended_bpp = omapdss_default_get_recommended_bpp,
1575
1576         .enable_te      = taal_enable_te,
1577         .get_te         = taal_get_te,
1578
1579         .set_rotate     = taal_rotate,
1580         .get_rotate     = taal_get_rotate,
1581         .set_mirror     = taal_mirror,
1582         .get_mirror     = taal_get_mirror,
1583         .run_test       = taal_run_test,
1584         .memory_read    = taal_memory_read,
1585
1586         .get_timings    = taal_get_timings,
1587
1588         .driver         = {
1589                 .name   = "taal",
1590                 .owner  = THIS_MODULE,
1591         },
1592 };
1593
1594 static int __init taal_init(void)
1595 {
1596         omap_dss_register_driver(&taal_driver);
1597
1598         return 0;
1599 }
1600
1601 static void __exit taal_exit(void)
1602 {
1603         omap_dss_unregister_driver(&taal_driver);
1604 }
1605
1606 module_init(taal_init);
1607 module_exit(taal_exit);
1608
1609 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>");
1610 MODULE_DESCRIPTION("Taal Driver");
1611 MODULE_LICENSE("GPL");