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