Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * LCD panel driver for Sharp LS037V7DW01 |
| 3 | * |
| 4 | * Copyright (C) 2008 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 | #include <linux/module.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/device.h> |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 23 | #include <linux/err.h> |
| 24 | |
| 25 | #include <plat/display.h> |
| 26 | |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 27 | static struct omap_video_timings sharp_ls_timings = { |
| 28 | .x_res = 480, |
| 29 | .y_res = 640, |
| 30 | |
| 31 | .pixel_clock = 19200, |
| 32 | |
| 33 | .hsw = 2, |
| 34 | .hfp = 1, |
| 35 | .hbp = 28, |
| 36 | |
| 37 | .vsw = 1, |
| 38 | .vfp = 1, |
| 39 | .vbp = 1, |
| 40 | }; |
| 41 | |
| 42 | static int sharp_ls_panel_probe(struct omap_dss_device *dssdev) |
| 43 | { |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 44 | dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS | |
| 45 | OMAP_DSS_LCD_IHS; |
| 46 | dssdev->panel.acb = 0x28; |
| 47 | dssdev->panel.timings = sharp_ls_timings; |
| 48 | |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | static void sharp_ls_panel_remove(struct omap_dss_device *dssdev) |
| 53 | { |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 54 | } |
| 55 | |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 56 | static int sharp_ls_power_on(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 57 | { |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 58 | int r = 0; |
| 59 | |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 60 | r = omapdss_dpi_display_enable(dssdev); |
| 61 | if (r) |
| 62 | goto err0; |
| 63 | |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 64 | /* wait couple of vsyncs until enabling the LCD */ |
| 65 | msleep(50); |
| 66 | |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 67 | if (dssdev->platform_enable) { |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 68 | r = dssdev->platform_enable(dssdev); |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 69 | if (r) |
| 70 | goto err1; |
| 71 | } |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 72 | |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 73 | return 0; |
| 74 | err1: |
| 75 | omapdss_dpi_display_disable(dssdev); |
| 76 | err0: |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 77 | return r; |
| 78 | } |
| 79 | |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 80 | static void sharp_ls_power_off(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 81 | { |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 82 | if (dssdev->platform_disable) |
| 83 | dssdev->platform_disable(dssdev); |
| 84 | |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 85 | /* wait at least 5 vsyncs after disabling the LCD */ |
| 86 | |
| 87 | msleep(100); |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 88 | |
| 89 | omapdss_dpi_display_disable(dssdev); |
| 90 | } |
| 91 | |
| 92 | static int sharp_ls_panel_enable(struct omap_dss_device *dssdev) |
| 93 | { |
| 94 | int r; |
| 95 | r = sharp_ls_power_on(dssdev); |
| 96 | dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; |
| 97 | return r; |
| 98 | } |
| 99 | |
| 100 | static void sharp_ls_panel_disable(struct omap_dss_device *dssdev) |
| 101 | { |
| 102 | sharp_ls_power_off(dssdev); |
| 103 | dssdev->state = OMAP_DSS_DISPLAY_DISABLED; |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | static int sharp_ls_panel_suspend(struct omap_dss_device *dssdev) |
| 107 | { |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 108 | sharp_ls_power_off(dssdev); |
| 109 | dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED; |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | static int sharp_ls_panel_resume(struct omap_dss_device *dssdev) |
| 114 | { |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 115 | int r; |
| 116 | r = sharp_ls_power_on(dssdev); |
| 117 | dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; |
| 118 | return r; |
Tomi Valkeinen | 3b8f29b | 2009-12-09 18:19:42 +0200 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static struct omap_dss_driver sharp_ls_driver = { |
| 122 | .probe = sharp_ls_panel_probe, |
| 123 | .remove = sharp_ls_panel_remove, |
| 124 | |
| 125 | .enable = sharp_ls_panel_enable, |
| 126 | .disable = sharp_ls_panel_disable, |
| 127 | .suspend = sharp_ls_panel_suspend, |
| 128 | .resume = sharp_ls_panel_resume, |
| 129 | |
| 130 | .driver = { |
| 131 | .name = "sharp_ls_panel", |
| 132 | .owner = THIS_MODULE, |
| 133 | }, |
| 134 | }; |
| 135 | |
| 136 | static int __init sharp_ls_panel_drv_init(void) |
| 137 | { |
| 138 | return omap_dss_register_driver(&sharp_ls_driver); |
| 139 | } |
| 140 | |
| 141 | static void __exit sharp_ls_panel_drv_exit(void) |
| 142 | { |
| 143 | omap_dss_unregister_driver(&sharp_ls_driver); |
| 144 | } |
| 145 | |
| 146 | module_init(sharp_ls_panel_drv_init); |
| 147 | module_exit(sharp_ls_panel_drv_exit); |
| 148 | MODULE_LICENSE("GPL"); |