2 * Taal DSI command mode panel
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
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.
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
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/>.
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>
29 #include <linux/interrupt.h>
30 #include <linux/gpio.h>
31 #include <linux/completion.h>
32 #include <linux/workqueue.h>
33 #include <linux/slab.h>
35 #include <plat/display.h>
37 /* DSI Virtual channel. Hardcoded for now. */
40 #define DCS_READ_NUM_ERRORS 0x05
41 #define DCS_READ_POWER_MODE 0x0a
42 #define DCS_READ_MADCTL 0x0b
43 #define DCS_READ_PIXEL_FORMAT 0x0c
44 #define DCS_RDDSDR 0x0f
45 #define DCS_SLEEP_IN 0x10
46 #define DCS_SLEEP_OUT 0x11
47 #define DCS_DISPLAY_OFF 0x28
48 #define DCS_DISPLAY_ON 0x29
49 #define DCS_COLUMN_ADDR 0x2a
50 #define DCS_PAGE_ADDR 0x2b
51 #define DCS_MEMORY_WRITE 0x2c
52 #define DCS_TEAR_OFF 0x34
53 #define DCS_TEAR_ON 0x35
54 #define DCS_MEM_ACC_CTRL 0x36
55 #define DCS_PIXEL_FORMAT 0x3a
56 #define DCS_BRIGHTNESS 0x51
57 #define DCS_CTRL_DISPLAY 0x53
58 #define DCS_WRITE_CABC 0x55
59 #define DCS_READ_CABC 0x56
60 #define DCS_GET_ID1 0xda
61 #define DCS_GET_ID2 0xdb
62 #define DCS_GET_ID3 0xdc
64 /* #define TAAL_USE_ESD_CHECK */
65 #define TAAL_ESD_CHECK_PERIOD msecs_to_jiffies(5000)
67 static int _taal_enable_te(struct omap_dss_device
*dssdev
, bool enable
);
70 struct backlight_device
*bldev
;
72 unsigned long hw_guard_end
; /* next value of jiffies when we can
73 * issue the next sleep in/out command
75 unsigned long hw_guard_wait
; /* max guard time in jiffies */
77 struct omap_dss_device
*dssdev
;
85 struct completion te_completion
;
94 struct workqueue_struct
*esd_wq
;
95 struct delayed_work esd_work
;
98 static void taal_esd_work(struct work_struct
*work
);
100 static void hw_guard_start(struct taal_data
*td
, int guard_msec
)
102 td
->hw_guard_wait
= msecs_to_jiffies(guard_msec
);
103 td
->hw_guard_end
= jiffies
+ td
->hw_guard_wait
;
106 static void hw_guard_wait(struct taal_data
*td
)
108 unsigned long wait
= td
->hw_guard_end
- jiffies
;
110 if ((long)wait
> 0 && wait
<= td
->hw_guard_wait
) {
111 set_current_state(TASK_UNINTERRUPTIBLE
);
112 schedule_timeout(wait
);
116 static int taal_dcs_read_1(u8 dcs_cmd
, u8
*data
)
121 r
= dsi_vc_dcs_read(TCH
, dcs_cmd
, buf
, 1);
131 static int taal_dcs_write_0(u8 dcs_cmd
)
133 return dsi_vc_dcs_write(TCH
, &dcs_cmd
, 1);
136 static int taal_dcs_write_1(u8 dcs_cmd
, u8 param
)
141 return dsi_vc_dcs_write(TCH
, buf
, 2);
144 static int taal_sleep_in(struct taal_data
*td
)
153 r
= dsi_vc_dcs_write_nosync(TCH
, &cmd
, 1);
157 hw_guard_start(td
, 120);
164 static int taal_sleep_out(struct taal_data
*td
)
170 r
= taal_dcs_write_0(DCS_SLEEP_OUT
);
174 hw_guard_start(td
, 120);
181 static int taal_get_id(u8
*id1
, u8
*id2
, u8
*id3
)
185 r
= taal_dcs_read_1(DCS_GET_ID1
, id1
);
188 r
= taal_dcs_read_1(DCS_GET_ID2
, id2
);
191 r
= taal_dcs_read_1(DCS_GET_ID3
, id3
);
198 static int taal_set_addr_mode(u8 rotate
, bool mirror
)
204 r
= taal_dcs_read_1(DCS_READ_MADCTL
, &mode
);
235 mode
&= ~((1<<7) | (1<<6) | (1<<5));
236 mode
|= (b7
<< 7) | (b6
<< 6) | (b5
<< 5);
238 return taal_dcs_write_1(DCS_MEM_ACC_CTRL
, mode
);
241 static int taal_set_update_window(u16 x
, u16 y
, u16 w
, u16 h
)
250 buf
[0] = DCS_COLUMN_ADDR
;
251 buf
[1] = (x1
>> 8) & 0xff;
252 buf
[2] = (x1
>> 0) & 0xff;
253 buf
[3] = (x2
>> 8) & 0xff;
254 buf
[4] = (x2
>> 0) & 0xff;
256 r
= dsi_vc_dcs_write_nosync(TCH
, buf
, sizeof(buf
));
260 buf
[0] = DCS_PAGE_ADDR
;
261 buf
[1] = (y1
>> 8) & 0xff;
262 buf
[2] = (y1
>> 0) & 0xff;
263 buf
[3] = (y2
>> 8) & 0xff;
264 buf
[4] = (y2
>> 0) & 0xff;
266 r
= dsi_vc_dcs_write_nosync(TCH
, buf
, sizeof(buf
));
270 dsi_vc_send_bta_sync(TCH
);
275 static int taal_bl_update_status(struct backlight_device
*dev
)
277 struct omap_dss_device
*dssdev
= dev_get_drvdata(&dev
->dev
);
278 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
282 if (dev
->props
.fb_blank
== FB_BLANK_UNBLANK
&&
283 dev
->props
.power
== FB_BLANK_UNBLANK
)
284 level
= dev
->props
.brightness
;
288 dev_dbg(&dssdev
->dev
, "update brightness to %d\n", level
);
290 if (td
->use_dsi_bl
) {
293 r
= taal_dcs_write_1(DCS_BRIGHTNESS
, level
);
299 if (!dssdev
->set_backlight
)
302 r
= dssdev
->set_backlight(dssdev
, level
);
310 static int taal_bl_get_intensity(struct backlight_device
*dev
)
312 if (dev
->props
.fb_blank
== FB_BLANK_UNBLANK
&&
313 dev
->props
.power
== FB_BLANK_UNBLANK
)
314 return dev
->props
.brightness
;
319 static struct backlight_ops taal_bl_ops
= {
320 .get_brightness
= taal_bl_get_intensity
,
321 .update_status
= taal_bl_update_status
,
324 static void taal_get_timings(struct omap_dss_device
*dssdev
,
325 struct omap_video_timings
*timings
)
327 *timings
= dssdev
->panel
.timings
;
330 static void taal_get_resolution(struct omap_dss_device
*dssdev
,
331 u16
*xres
, u16
*yres
)
333 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
335 if (td
->rotate
== 0 || td
->rotate
== 2) {
336 *xres
= dssdev
->panel
.timings
.x_res
;
337 *yres
= dssdev
->panel
.timings
.y_res
;
339 *yres
= dssdev
->panel
.timings
.x_res
;
340 *xres
= dssdev
->panel
.timings
.y_res
;
344 static irqreturn_t
taal_te_isr(int irq
, void *data
)
346 struct omap_dss_device
*dssdev
= data
;
347 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
349 complete_all(&td
->te_completion
);
354 static ssize_t
taal_num_errors_show(struct device
*dev
,
355 struct device_attribute
*attr
, char *buf
)
357 struct omap_dss_device
*dssdev
= to_dss_device(dev
);
358 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
364 r
= taal_dcs_read_1(DCS_READ_NUM_ERRORS
, &errors
);
373 return snprintf(buf
, PAGE_SIZE
, "%d\n", errors
);
376 static ssize_t
taal_hw_revision_show(struct device
*dev
,
377 struct device_attribute
*attr
, char *buf
)
379 struct omap_dss_device
*dssdev
= to_dss_device(dev
);
380 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
386 r
= taal_get_id(&id1
, &id2
, &id3
);
395 return snprintf(buf
, PAGE_SIZE
, "%02x.%02x.%02x\n", id1
, id2
, id3
);
398 static const char *cabc_modes
[] = {
399 "off", /* used also always when CABC is not supported */
405 static ssize_t
show_cabc_mode(struct device
*dev
,
406 struct device_attribute
*attr
,
409 struct omap_dss_device
*dssdev
= to_dss_device(dev
);
410 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
411 const char *mode_str
;
415 mode
= td
->cabc_mode
;
417 mode_str
= "unknown";
418 if (mode
>= 0 && mode
< ARRAY_SIZE(cabc_modes
))
419 mode_str
= cabc_modes
[mode
];
420 len
= snprintf(buf
, PAGE_SIZE
, "%s\n", mode_str
);
422 return len
< PAGE_SIZE
- 1 ? len
: PAGE_SIZE
- 1;
425 static ssize_t
store_cabc_mode(struct device
*dev
,
426 struct device_attribute
*attr
,
427 const char *buf
, size_t count
)
429 struct omap_dss_device
*dssdev
= to_dss_device(dev
);
430 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
433 for (i
= 0; i
< ARRAY_SIZE(cabc_modes
); i
++) {
434 if (sysfs_streq(cabc_modes
[i
], buf
))
438 if (i
== ARRAY_SIZE(cabc_modes
))
443 if (!td
->cabc_broken
)
444 taal_dcs_write_1(DCS_WRITE_CABC
, i
);
453 static ssize_t
show_cabc_available_modes(struct device
*dev
,
454 struct device_attribute
*attr
,
461 len
< PAGE_SIZE
&& i
< ARRAY_SIZE(cabc_modes
); i
++)
462 len
+= snprintf(&buf
[len
], PAGE_SIZE
- len
, "%s%s%s",
463 i
? " " : "", cabc_modes
[i
],
464 i
== ARRAY_SIZE(cabc_modes
) - 1 ? "\n" : "");
466 return len
< PAGE_SIZE
? len
: PAGE_SIZE
- 1;
469 static DEVICE_ATTR(num_dsi_errors
, S_IRUGO
, taal_num_errors_show
, NULL
);
470 static DEVICE_ATTR(hw_revision
, S_IRUGO
, taal_hw_revision_show
, NULL
);
471 static DEVICE_ATTR(cabc_mode
, S_IRUGO
| S_IWUSR
,
472 show_cabc_mode
, store_cabc_mode
);
473 static DEVICE_ATTR(cabc_available_modes
, S_IRUGO
,
474 show_cabc_available_modes
, NULL
);
476 static struct attribute
*taal_attrs
[] = {
477 &dev_attr_num_dsi_errors
.attr
,
478 &dev_attr_hw_revision
.attr
,
479 &dev_attr_cabc_mode
.attr
,
480 &dev_attr_cabc_available_modes
.attr
,
484 static struct attribute_group taal_attr_group
= {
488 static int taal_probe(struct omap_dss_device
*dssdev
)
490 struct backlight_properties props
;
491 struct taal_data
*td
;
492 struct backlight_device
*bldev
;
495 const struct omap_video_timings taal_panel_timings
= {
500 dev_dbg(&dssdev
->dev
, "probe\n");
502 dssdev
->panel
.config
= OMAP_DSS_LCD_TFT
;
503 dssdev
->panel
.timings
= taal_panel_timings
;
504 dssdev
->ctrl
.pixel_size
= 24;
506 td
= kzalloc(sizeof(*td
), GFP_KERNEL
);
513 td
->esd_wq
= create_singlethread_workqueue("taal_esd");
514 if (td
->esd_wq
== NULL
) {
515 dev_err(&dssdev
->dev
, "can't create ESD workqueue\n");
519 INIT_DELAYED_WORK_DEFERRABLE(&td
->esd_work
, taal_esd_work
);
521 dev_set_drvdata(&dssdev
->dev
, td
);
523 /* if no platform set_backlight() defined, presume DSI backlight
525 memset(&props
, 0, sizeof(struct backlight_properties
));
526 if (!dssdev
->set_backlight
)
527 td
->use_dsi_bl
= true;
530 props
.max_brightness
= 255;
532 props
.max_brightness
= 127;
533 bldev
= backlight_device_register("taal", &dssdev
->dev
, dssdev
,
534 &taal_bl_ops
, &props
);
542 bldev
->props
.fb_blank
= FB_BLANK_UNBLANK
;
543 bldev
->props
.power
= FB_BLANK_UNBLANK
;
545 bldev
->props
.brightness
= 255;
547 bldev
->props
.brightness
= 127;
549 taal_bl_update_status(bldev
);
551 if (dssdev
->phy
.dsi
.ext_te
) {
552 int gpio
= dssdev
->phy
.dsi
.ext_te_gpio
;
554 r
= gpio_request(gpio
, "taal irq");
556 dev_err(&dssdev
->dev
, "GPIO request failed\n");
560 gpio_direction_input(gpio
);
562 r
= request_irq(gpio_to_irq(gpio
), taal_te_isr
,
563 IRQF_DISABLED
| IRQF_TRIGGER_RISING
,
564 "taal vsync", dssdev
);
567 dev_err(&dssdev
->dev
, "IRQ request failed\n");
572 init_completion(&td
->te_completion
);
574 td
->use_ext_te
= true;
577 r
= sysfs_create_group(&dssdev
->dev
.kobj
, &taal_attr_group
);
579 dev_err(&dssdev
->dev
, "failed to create sysfs files\n");
585 if (td
->use_ext_te
) {
586 int gpio
= dssdev
->phy
.dsi
.ext_te_gpio
;
587 free_irq(gpio_to_irq(gpio
), dssdev
);
591 backlight_device_unregister(bldev
);
593 cancel_delayed_work_sync(&td
->esd_work
);
594 destroy_workqueue(td
->esd_wq
);
601 static void taal_remove(struct omap_dss_device
*dssdev
)
603 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
604 struct backlight_device
*bldev
;
606 dev_dbg(&dssdev
->dev
, "remove\n");
608 sysfs_remove_group(&dssdev
->dev
.kobj
, &taal_attr_group
);
610 if (td
->use_ext_te
) {
611 int gpio
= dssdev
->phy
.dsi
.ext_te_gpio
;
612 free_irq(gpio_to_irq(gpio
), dssdev
);
617 bldev
->props
.power
= FB_BLANK_POWERDOWN
;
618 taal_bl_update_status(bldev
);
619 backlight_device_unregister(bldev
);
621 cancel_delayed_work_sync(&td
->esd_work
);
622 destroy_workqueue(td
->esd_wq
);
627 static int taal_power_on(struct omap_dss_device
*dssdev
)
629 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
633 if (dssdev
->platform_enable
) {
634 r
= dssdev
->platform_enable(dssdev
);
639 /* it seems we have to wait a bit until taal is ready */
644 r
= omapdss_dsi_display_enable(dssdev
);
646 dev_err(&dssdev
->dev
, "failed to enable DSI\n");
650 omapdss_dsi_vc_enable_hs(TCH
, false);
652 r
= taal_sleep_out(td
);
656 r
= taal_get_id(&id1
, &id2
, &id3
);
660 /* on early revisions CABC is broken */
661 if (id2
== 0x00 || id2
== 0xff || id2
== 0x81)
662 td
->cabc_broken
= true;
664 taal_dcs_write_1(DCS_BRIGHTNESS
, 0xff);
665 taal_dcs_write_1(DCS_CTRL_DISPLAY
, (1<<2) | (1<<5)); /* BL | BCTRL */
667 taal_dcs_write_1(DCS_PIXEL_FORMAT
, 0x7); /* 24bit/pixel */
669 taal_set_addr_mode(td
->rotate
, td
->mirror
);
670 if (!td
->cabc_broken
)
671 taal_dcs_write_1(DCS_WRITE_CABC
, td
->cabc_mode
);
673 taal_dcs_write_0(DCS_DISPLAY_ON
);
675 r
= _taal_enable_te(dssdev
, td
->te_enabled
);
679 #ifdef TAAL_USE_ESD_CHECK
680 queue_delayed_work(td
->esd_wq
, &td
->esd_work
, TAAL_ESD_CHECK_PERIOD
);
685 if (!td
->intro_printed
) {
686 dev_info(&dssdev
->dev
, "revision %02x.%02x.%02x\n",
689 dev_info(&dssdev
->dev
,
690 "old Taal version, CABC disabled\n");
691 td
->intro_printed
= true;
694 omapdss_dsi_vc_enable_hs(TCH
, true);
702 omapdss_dsi_display_disable(dssdev
);
704 if (dssdev
->platform_disable
)
705 dssdev
->platform_disable(dssdev
);
710 static void taal_power_off(struct omap_dss_device
*dssdev
)
712 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
716 cancel_delayed_work(&td
->esd_work
);
718 taal_dcs_write_0(DCS_DISPLAY_OFF
);
721 /* wait a bit so that the message goes through */
724 omapdss_dsi_display_disable(dssdev
);
726 if (dssdev
->platform_disable
)
727 dssdev
->platform_disable(dssdev
);
734 static int taal_enable(struct omap_dss_device
*dssdev
)
737 dev_dbg(&dssdev
->dev
, "enable\n");
739 if (dssdev
->state
!= OMAP_DSS_DISPLAY_DISABLED
)
742 r
= taal_power_on(dssdev
);
746 dssdev
->state
= OMAP_DSS_DISPLAY_ACTIVE
;
751 static void taal_disable(struct omap_dss_device
*dssdev
)
753 dev_dbg(&dssdev
->dev
, "disable\n");
755 if (dssdev
->state
== OMAP_DSS_DISPLAY_ACTIVE
)
756 taal_power_off(dssdev
);
758 dssdev
->state
= OMAP_DSS_DISPLAY_DISABLED
;
761 static int taal_suspend(struct omap_dss_device
*dssdev
)
763 dev_dbg(&dssdev
->dev
, "suspend\n");
765 if (dssdev
->state
!= OMAP_DSS_DISPLAY_ACTIVE
)
768 taal_power_off(dssdev
);
769 dssdev
->state
= OMAP_DSS_DISPLAY_SUSPENDED
;
774 static int taal_resume(struct omap_dss_device
*dssdev
)
777 dev_dbg(&dssdev
->dev
, "resume\n");
779 if (dssdev
->state
!= OMAP_DSS_DISPLAY_SUSPENDED
)
782 r
= taal_power_on(dssdev
);
783 dssdev
->state
= OMAP_DSS_DISPLAY_ACTIVE
;
787 static void taal_framedone_cb(int err
, void *data
)
789 struct omap_dss_device
*dssdev
= data
;
790 dev_dbg(&dssdev
->dev
, "framedone, err %d\n", err
);
794 static int taal_update(struct omap_dss_device
*dssdev
,
795 u16 x
, u16 y
, u16 w
, u16 h
)
797 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
800 dev_dbg(&dssdev
->dev
, "update %d, %d, %d x %d\n", x
, y
, w
, h
);
809 r
= omap_dsi_prepare_update(dssdev
, &x
, &y
, &w
, &h
);
813 r
= taal_set_update_window(x
, y
, w
, h
);
817 r
= omap_dsi_update(dssdev
, TCH
, x
, y
, w
, h
,
818 taal_framedone_cb
, dssdev
);
822 /* note: no bus_unlock here. unlock is in framedone_cb */
829 static int taal_sync(struct omap_dss_device
*dssdev
)
831 dev_dbg(&dssdev
->dev
, "sync\n");
836 dev_dbg(&dssdev
->dev
, "sync done\n");
841 static int _taal_enable_te(struct omap_dss_device
*dssdev
, bool enable
)
843 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
846 td
->te_enabled
= enable
;
849 r
= taal_dcs_write_1(DCS_TEAR_ON
, 0);
851 r
= taal_dcs_write_0(DCS_TEAR_OFF
);
853 omapdss_dsi_enable_te(dssdev
, enable
);
855 /* XXX for some reason, DSI TE breaks if we don't wait here.
856 * Panel bug? Needs more studying */
862 static int taal_enable_te(struct omap_dss_device
*dssdev
, bool enable
)
868 r
= _taal_enable_te(dssdev
, enable
);
875 static int taal_get_te(struct omap_dss_device
*dssdev
)
877 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
878 return td
->te_enabled
;
881 static int taal_rotate(struct omap_dss_device
*dssdev
, u8 rotate
)
883 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
886 dev_dbg(&dssdev
->dev
, "rotate %d\n", rotate
);
891 r
= taal_set_addr_mode(rotate
, td
->mirror
);
905 static u8
taal_get_rotate(struct omap_dss_device
*dssdev
)
907 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
911 static int taal_mirror(struct omap_dss_device
*dssdev
, bool enable
)
913 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
916 dev_dbg(&dssdev
->dev
, "mirror %d\n", enable
);
920 r
= taal_set_addr_mode(td
->rotate
, enable
);
934 static bool taal_get_mirror(struct omap_dss_device
*dssdev
)
936 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
940 static int taal_run_test(struct omap_dss_device
*dssdev
, int test_num
)
947 r
= taal_dcs_read_1(DCS_GET_ID1
, &id1
);
950 r
= taal_dcs_read_1(DCS_GET_ID2
, &id2
);
953 r
= taal_dcs_read_1(DCS_GET_ID3
, &id3
);
964 static int taal_memory_read(struct omap_dss_device
*dssdev
,
965 void *buf
, size_t size
,
966 u16 x
, u16 y
, u16 w
, u16 h
)
971 unsigned buf_used
= 0;
972 struct taal_data
*td
= dev_get_drvdata(&dssdev
->dev
);
977 if (size
< w
* h
* 3)
980 size
= min(w
* h
* 3,
981 dssdev
->panel
.timings
.x_res
*
982 dssdev
->panel
.timings
.y_res
* 3);
986 /* plen 1 or 2 goes into short packet. until checksum error is fixed,
987 * use short packets. plen 32 works, but bigger packets seem to cause
994 taal_set_update_window(x
, y
, w
, h
);
996 r
= dsi_vc_set_max_rx_packet_size(TCH
, plen
);
1000 while (buf_used
< size
) {
1001 u8 dcs_cmd
= first
? 0x2e : 0x3e;
1004 r
= dsi_vc_dcs_read(TCH
, dcs_cmd
,
1005 buf
+ buf_used
, size
- buf_used
);
1008 dev_err(&dssdev
->dev
, "read error\n");
1015 dev_err(&dssdev
->dev
, "short read\n");
1019 if (signal_pending(current
)) {
1020 dev_err(&dssdev
->dev
, "signal pending, "
1021 "aborting memory read\n");
1030 dsi_vc_set_max_rx_packet_size(TCH
, 1);
1036 static void taal_esd_work(struct work_struct
*work
)
1038 struct taal_data
*td
= container_of(work
, struct taal_data
,
1040 struct omap_dss_device
*dssdev
= td
->dssdev
;
1049 r
= taal_dcs_read_1(DCS_RDDSDR
, &state1
);
1051 dev_err(&dssdev
->dev
, "failed to read Taal status\n");
1055 /* Run self diagnostics */
1056 r
= taal_sleep_out(td
);
1058 dev_err(&dssdev
->dev
, "failed to run Taal self-diagnostics\n");
1062 r
= taal_dcs_read_1(DCS_RDDSDR
, &state2
);
1064 dev_err(&dssdev
->dev
, "failed to read Taal status\n");
1068 /* Each sleep out command will trigger a self diagnostic and flip
1069 * Bit6 if the test passes.
1071 if (!((state1
^ state2
) & (1 << 6))) {
1072 dev_err(&dssdev
->dev
, "LCD self diagnostics failed\n");
1075 /* Self-diagnostics result is also shown on TE GPIO line. We need
1076 * to re-enable TE after self diagnostics */
1077 if (td
->use_ext_te
&& td
->te_enabled
) {
1078 r
= taal_dcs_write_1(DCS_TEAR_ON
, 0);
1085 queue_delayed_work(td
->esd_wq
, &td
->esd_work
, TAAL_ESD_CHECK_PERIOD
);
1089 dev_err(&dssdev
->dev
, "performing LCD reset\n");
1091 taal_disable(dssdev
);
1092 taal_enable(dssdev
);
1096 queue_delayed_work(td
->esd_wq
, &td
->esd_work
, TAAL_ESD_CHECK_PERIOD
);
1099 static int taal_set_update_mode(struct omap_dss_device
*dssdev
,
1100 enum omap_dss_update_mode mode
)
1102 if (mode
!= OMAP_DSS_UPDATE_MANUAL
)
1107 static enum omap_dss_update_mode
taal_get_update_mode(
1108 struct omap_dss_device
*dssdev
)
1110 return OMAP_DSS_UPDATE_MANUAL
;
1113 static struct omap_dss_driver taal_driver
= {
1114 .probe
= taal_probe
,
1115 .remove
= taal_remove
,
1117 .enable
= taal_enable
,
1118 .disable
= taal_disable
,
1119 .suspend
= taal_suspend
,
1120 .resume
= taal_resume
,
1122 .set_update_mode
= taal_set_update_mode
,
1123 .get_update_mode
= taal_get_update_mode
,
1125 .update
= taal_update
,
1128 .get_resolution
= taal_get_resolution
,
1129 .get_recommended_bpp
= omapdss_default_get_recommended_bpp
,
1131 .enable_te
= taal_enable_te
,
1132 .get_te
= taal_get_te
,
1134 .set_rotate
= taal_rotate
,
1135 .get_rotate
= taal_get_rotate
,
1136 .set_mirror
= taal_mirror
,
1137 .get_mirror
= taal_get_mirror
,
1138 .run_test
= taal_run_test
,
1139 .memory_read
= taal_memory_read
,
1141 .get_timings
= taal_get_timings
,
1145 .owner
= THIS_MODULE
,
1149 static int __init
taal_init(void)
1151 omap_dss_register_driver(&taal_driver
);
1156 static void __exit
taal_exit(void)
1158 omap_dss_unregister_driver(&taal_driver
);
1161 module_init(taal_init
);
1162 module_exit(taal_exit
);
1164 MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>");
1165 MODULE_DESCRIPTION("Taal Driver");
1166 MODULE_LICENSE("GPL");