diff options
Diffstat (limited to 'drivers/video/omap')
-rw-r--r-- | drivers/video/omap/lcd_ams_delta.c | 93 |
1 files changed, 89 insertions, 4 deletions
diff --git a/drivers/video/omap/lcd_ams_delta.c b/drivers/video/omap/lcd_ams_delta.c index 567db6ac32c8..6978ae4ef83a 100644 --- a/drivers/video/omap/lcd_ams_delta.c +++ b/drivers/video/omap/lcd_ams_delta.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/lcd.h> | ||
27 | 28 | ||
28 | #include <plat/board-ams-delta.h> | 29 | #include <plat/board-ams-delta.h> |
29 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
@@ -32,6 +33,71 @@ | |||
32 | 33 | ||
33 | #define AMS_DELTA_DEFAULT_CONTRAST 112 | 34 | #define AMS_DELTA_DEFAULT_CONTRAST 112 |
34 | 35 | ||
36 | #define AMS_DELTA_MAX_CONTRAST 0x00FF | ||
37 | #define AMS_DELTA_LCD_POWER 0x0100 | ||
38 | |||
39 | |||
40 | /* LCD class device section */ | ||
41 | |||
42 | static int ams_delta_lcd; | ||
43 | |||
44 | static int ams_delta_lcd_set_power(struct lcd_device *dev, int power) | ||
45 | { | ||
46 | if (power == FB_BLANK_UNBLANK) { | ||
47 | if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER)) { | ||
48 | omap_writeb(ams_delta_lcd & AMS_DELTA_MAX_CONTRAST, | ||
49 | OMAP_PWL_ENABLE); | ||
50 | omap_writeb(1, OMAP_PWL_CLK_ENABLE); | ||
51 | ams_delta_lcd |= AMS_DELTA_LCD_POWER; | ||
52 | } | ||
53 | } else { | ||
54 | if (ams_delta_lcd & AMS_DELTA_LCD_POWER) { | ||
55 | omap_writeb(0, OMAP_PWL_ENABLE); | ||
56 | omap_writeb(0, OMAP_PWL_CLK_ENABLE); | ||
57 | ams_delta_lcd &= ~AMS_DELTA_LCD_POWER; | ||
58 | } | ||
59 | } | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static int ams_delta_lcd_set_contrast(struct lcd_device *dev, int value) | ||
64 | { | ||
65 | if ((value >= 0) && (value <= AMS_DELTA_MAX_CONTRAST)) { | ||
66 | omap_writeb(value, OMAP_PWL_ENABLE); | ||
67 | ams_delta_lcd &= ~AMS_DELTA_MAX_CONTRAST; | ||
68 | ams_delta_lcd |= value; | ||
69 | } | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | #ifdef CONFIG_LCD_CLASS_DEVICE | ||
74 | static int ams_delta_lcd_get_power(struct lcd_device *dev) | ||
75 | { | ||
76 | if (ams_delta_lcd & AMS_DELTA_LCD_POWER) | ||
77 | return FB_BLANK_UNBLANK; | ||
78 | else | ||
79 | return FB_BLANK_POWERDOWN; | ||
80 | } | ||
81 | |||
82 | static int ams_delta_lcd_get_contrast(struct lcd_device *dev) | ||
83 | { | ||
84 | if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER)) | ||
85 | return 0; | ||
86 | |||
87 | return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST; | ||
88 | } | ||
89 | |||
90 | static struct lcd_ops ams_delta_lcd_ops = { | ||
91 | .get_power = ams_delta_lcd_get_power, | ||
92 | .set_power = ams_delta_lcd_set_power, | ||
93 | .get_contrast = ams_delta_lcd_get_contrast, | ||
94 | .set_contrast = ams_delta_lcd_set_contrast, | ||
95 | }; | ||
96 | #endif | ||
97 | |||
98 | |||
99 | /* omapfb panel section */ | ||
100 | |||
35 | static int ams_delta_panel_init(struct lcd_panel *panel, | 101 | static int ams_delta_panel_init(struct lcd_panel *panel, |
36 | struct omapfb_device *fbdev) | 102 | struct omapfb_device *fbdev) |
37 | { | 103 | { |
@@ -48,10 +114,6 @@ static int ams_delta_panel_enable(struct lcd_panel *panel) | |||
48 | AMS_DELTA_LATCH2_LCD_NDISP); | 114 | AMS_DELTA_LATCH2_LCD_NDISP); |
49 | ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN, | 115 | ams_delta_latch2_write(AMS_DELTA_LATCH2_LCD_VBLEN, |
50 | AMS_DELTA_LATCH2_LCD_VBLEN); | 116 | AMS_DELTA_LATCH2_LCD_VBLEN); |
51 | |||
52 | omap_writeb(1, OMAP_PWL_CLK_ENABLE); | ||
53 | omap_writeb(AMS_DELTA_DEFAULT_CONTRAST, OMAP_PWL_ENABLE); | ||
54 | |||
55 | return 0; | 117 | return 0; |
56 | } | 118 | } |
57 | 119 | ||
@@ -91,8 +153,31 @@ static struct lcd_panel ams_delta_panel = { | |||
91 | .get_caps = ams_delta_panel_get_caps, | 153 | .get_caps = ams_delta_panel_get_caps, |
92 | }; | 154 | }; |
93 | 155 | ||
156 | |||
157 | /* platform driver section */ | ||
158 | |||
94 | static int ams_delta_panel_probe(struct platform_device *pdev) | 159 | static int ams_delta_panel_probe(struct platform_device *pdev) |
95 | { | 160 | { |
161 | struct lcd_device *lcd_device = NULL; | ||
162 | #ifdef CONFIG_LCD_CLASS_DEVICE | ||
163 | int ret; | ||
164 | |||
165 | lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL, | ||
166 | &ams_delta_lcd_ops); | ||
167 | |||
168 | if (IS_ERR(lcd_device)) { | ||
169 | ret = PTR_ERR(lcd_device); | ||
170 | dev_err(&pdev->dev, "failed to register device\n"); | ||
171 | return ret; | ||
172 | } | ||
173 | |||
174 | platform_set_drvdata(pdev, lcd_device); | ||
175 | lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST; | ||
176 | #endif | ||
177 | |||
178 | ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST); | ||
179 | ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK); | ||
180 | |||
96 | omapfb_register_panel(&ams_delta_panel); | 181 | omapfb_register_panel(&ams_delta_panel); |
97 | return 0; | 182 | return 0; |
98 | } | 183 | } |