aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndrzej Zaborowski <balrogg@gmail.com>2008-01-13 18:15:43 -0500
committerRichard Purdie <rpurdie@rpsys.net>2008-02-07 04:31:52 -0500
commitec072b0f8bc8e885a8572418ad4b6802c027ca01 (patch)
tree4b37407fcd9515e9b7330159c26587797094b0e8 /drivers
parent515524537999c1f107a0a7c7f74c034979c2c86d (diff)
backlight: Add OMAP1 PWL backlight driver
This adds the OMAP1 PWL-based LCD backlight driver. It's been in the OMAP tree for some time. Note that OMAP2 can do similar things with the generic timers which have PWM outputs. Such timers are more generic than the PWL found on OMAP1 chips, but have a different EMI profile because they aren't driven by a pseudorandom number generator. [akpm@linux-foundation.org: cleanups] Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrzej Zaborowski <balrogg@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/backlight/Kconfig9
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/omap1_bl.c210
3 files changed, 220 insertions, 0 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 924e2551044a..dcd8073c2369 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -80,6 +80,15 @@ config BACKLIGHT_LOCOMO
80 If you have a Sharp Zaurus SL-5500 (Collie) or SL-5600 (Poodle) say y to 80 If you have a Sharp Zaurus SL-5500 (Collie) or SL-5600 (Poodle) say y to
81 enable the LCD/backlight driver. 81 enable the LCD/backlight driver.
82 82
83config BACKLIGHT_OMAP1
84 tristate "OMAP1 PWL-based LCD Backlight"
85 depends on BACKLIGHT_CLASS_DEVICE && ARCH_OMAP1
86 default y
87 help
88 This driver controls the LCD backlight level and power for
89 the PWL module of OMAP1 processors. Say Y if your board
90 uses this hardware.
91
83config BACKLIGHT_HP680 92config BACKLIGHT_HP680
84 tristate "HP Jornada 680 Backlight Driver" 93 tristate "HP Jornada 680 Backlight Driver"
85 depends on BACKLIGHT_CLASS_DEVICE && SH_HP6XX 94 depends on BACKLIGHT_CLASS_DEVICE && SH_HP6XX
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 965a78b18118..33f6c7cecc73 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -7,5 +7,6 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
7obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o 7obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o
8obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o 8obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
9obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o 9obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
10obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
10obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o 11obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
11obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o 12obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c
new file mode 100644
index 000000000000..891875d53a49
--- /dev/null
+++ b/drivers/video/backlight/omap1_bl.c
@@ -0,0 +1,210 @@
1/*
2 * Backlight driver for OMAP based boards.
3 *
4 * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
5 *
6 * This package is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This package is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this package; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/platform_device.h>
25#include <linux/fb.h>
26#include <linux/backlight.h>
27
28#include <asm/arch/hardware.h>
29#include <asm/arch/board.h>
30#include <asm/arch/mux.h>
31
32#define OMAPBL_MAX_INTENSITY 0xff
33
34struct omap_backlight {
35 int powermode;
36 int current_intensity;
37
38 struct device *dev;
39 struct omap_backlight_config *pdata;
40};
41
42static void inline omapbl_send_intensity(int intensity)
43{
44 omap_writeb(intensity, OMAP_PWL_ENABLE);
45}
46
47static void inline omapbl_send_enable(int enable)
48{
49 omap_writeb(enable, OMAP_PWL_CLK_ENABLE);
50}
51
52static void omapbl_blank(struct omap_backlight *bl, int mode)
53{
54 if (bl->pdata->set_power)
55 bl->pdata->set_power(bl->dev, mode);
56
57 switch (mode) {
58 case FB_BLANK_NORMAL:
59 case FB_BLANK_VSYNC_SUSPEND:
60 case FB_BLANK_HSYNC_SUSPEND:
61 case FB_BLANK_POWERDOWN:
62 omapbl_send_intensity(0);
63 omapbl_send_enable(0);
64 break;
65
66 case FB_BLANK_UNBLANK:
67 omapbl_send_intensity(bl->current_intensity);
68 omapbl_send_enable(1);
69 break;
70 }
71}
72
73#ifdef CONFIG_PM
74static int omapbl_suspend(struct platform_device *pdev, pm_message_t state)
75{
76 struct backlight_device *dev = platform_get_drvdata(pdev);
77 struct omap_backlight *bl = dev_get_drvdata(&dev->dev);
78
79 omapbl_blank(bl, FB_BLANK_POWERDOWN);
80 return 0;
81}
82
83static int omapbl_resume(struct platform_device *pdev)
84{
85 struct backlight_device *dev = platform_get_drvdata(pdev);
86 struct omap_backlight *bl = dev_get_drvdata(&dev->dev);
87
88 omapbl_blank(bl, bl->powermode);
89 return 0;
90}
91#else
92#define omapbl_suspend NULL
93#define omapbl_resume NULL
94#endif
95
96static int omapbl_set_power(struct backlight_device *dev, int state)
97{
98 struct omap_backlight *bl = dev_get_drvdata(&dev->dev);
99
100 omapbl_blank(bl, state);
101 bl->powermode = state;
102
103 return 0;
104}
105
106static int omapbl_update_status(struct backlight_device *dev)
107{
108 struct omap_backlight *bl = dev_get_drvdata(&dev->dev);
109
110 if (bl->current_intensity != dev->props.brightness) {
111 if (bl->powermode == FB_BLANK_UNBLANK)
112 omapbl_send_intensity(dev->props.brightness);
113 bl->current_intensity = dev->props.brightness;
114 }
115
116 if (dev->props.fb_blank != bl->powermode)
117 omapbl_set_power(dev, dev->props.fb_blank);
118
119 return 0;
120}
121
122static int omapbl_get_intensity(struct backlight_device *dev)
123{
124 struct omap_backlight *bl = dev_get_drvdata(&dev->dev);
125 return bl->current_intensity;
126}
127
128static struct backlight_ops omapbl_ops = {
129 .get_brightness = omapbl_get_intensity,
130 .update_status = omapbl_update_status,
131};
132
133static int omapbl_probe(struct platform_device *pdev)
134{
135 struct backlight_device *dev;
136 struct omap_backlight *bl;
137 struct omap_backlight_config *pdata = pdev->dev.platform_data;
138
139 if (!pdata)
140 return -ENXIO;
141
142 omapbl_ops.check_fb = pdata->check_fb;
143
144 bl = kzalloc(sizeof(struct omap_backlight), GFP_KERNEL);
145 if (unlikely(!bl))
146 return -ENOMEM;
147
148 dev = backlight_device_register("omap-bl", &pdev->dev, bl, &omapbl_ops);
149 if (IS_ERR(dev)) {
150 kfree(bl);
151 return PTR_ERR(dev);
152 }
153
154 bl->powermode = FB_BLANK_POWERDOWN;
155 bl->current_intensity = 0;
156
157 bl->pdata = pdata;
158 bl->dev = &pdev->dev;
159
160 platform_set_drvdata(pdev, dev);
161
162 omap_cfg_reg(PWL); /* Conflicts with UART3 */
163
164 dev->props.fb_blank = FB_BLANK_UNBLANK;
165 dev->props.max_brightness = OMAPBL_MAX_INTENSITY;
166 dev->props.brightness = pdata->default_intensity;
167 omapbl_update_status(dev);
168
169 printk(KERN_INFO "OMAP LCD backlight initialised\n");
170
171 return 0;
172}
173
174static int omapbl_remove(struct platform_device *pdev)
175{
176 struct backlight_device *dev = platform_get_drvdata(pdev);
177 struct omap_backlight *bl = dev_get_drvdata(&dev->dev);
178
179 backlight_device_unregister(dev);
180 kfree(bl);
181
182 return 0;
183}
184
185static struct platform_driver omapbl_driver = {
186 .probe = omapbl_probe,
187 .remove = omapbl_remove,
188 .suspend = omapbl_suspend,
189 .resume = omapbl_resume,
190 .driver = {
191 .name = "omap-bl",
192 },
193};
194
195static int __init omapbl_init(void)
196{
197 return platform_driver_register(&omapbl_driver);
198}
199
200static void __exit omapbl_exit(void)
201{
202 platform_driver_unregister(&omapbl_driver);
203}
204
205module_init(omapbl_init);
206module_exit(omapbl_exit);
207
208MODULE_AUTHOR("Andrzej Zaborowski <balrog@zabor.org>");
209MODULE_DESCRIPTION("OMAP LCD Backlight driver");
210MODULE_LICENSE("GPL");