diff options
author | Thierry Reding <thierry.reding@avionic-design.de> | 2009-08-14 09:58:56 -0400 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-09-07 10:14:44 -0400 |
commit | 3b96ea9ef837c010f2187e0618d823fbdd8eeb54 (patch) | |
tree | 162680ddf1bbe6f67d1b4c5b2348e7d874953685 /drivers/video | |
parent | 5036cc41e07d6614350e329666ee8a79cea6f793 (diff) |
backlight: Add support for the Avionic Design Xanthos backlight device.
This patch adds support for the backlight device found on Avionic Design
Xanthos-based boards.
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/Kconfig | 8 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 2 | ||||
-rw-r--r-- | drivers/video/backlight/adx_bl.c | 178 |
3 files changed, 187 insertions, 1 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index c0d4a536ea87..22a49944d98d 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -243,3 +243,11 @@ config BACKLIGHT_WM831X | |||
243 | help | 243 | help |
244 | If you have a backlight driven by the ISINK and DCDC of a | 244 | If you have a backlight driven by the ISINK and DCDC of a |
245 | WM831x PMIC say y to enable the backlight driver for it. | 245 | WM831x PMIC say y to enable the backlight driver for it. |
246 | |||
247 | config BACKLIGHT_ADX | ||
248 | tristate "Avionic Design Xanthos Backlight Driver" | ||
249 | depends on BACKLIGHT_CLASS_DEVICE && ARCH_PXA_ADX | ||
250 | default y | ||
251 | help | ||
252 | Say Y to enable the backlight driver on Avionic Design Xanthos-based | ||
253 | boards. | ||
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 0abc014215ba..a483709205ac 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -26,4 +26,4 @@ obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o | |||
26 | obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o | 26 | obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o |
27 | obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o | 27 | obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o |
28 | obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o | 28 | obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o |
29 | 29 | obj-$(CONFIG_BACKLIGHT_ADX) += adx_bl.o | |
diff --git a/drivers/video/backlight/adx_bl.c b/drivers/video/backlight/adx_bl.c new file mode 100644 index 000000000000..2c3bdfc620b7 --- /dev/null +++ b/drivers/video/backlight/adx_bl.c | |||
@@ -0,0 +1,178 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/backlight/adx.c | ||
3 | * | ||
4 | * Copyright (C) 2009 Avionic Design GmbH | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * Written by Thierry Reding <thierry.reding@avionic-design.de> | ||
11 | */ | ||
12 | |||
13 | #include <linux/backlight.h> | ||
14 | #include <linux/fb.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | |||
19 | /* register definitions */ | ||
20 | #define ADX_BACKLIGHT_CONTROL 0x00 | ||
21 | #define ADX_BACKLIGHT_CONTROL_ENABLE (1 << 0) | ||
22 | #define ADX_BACKLIGHT_BRIGHTNESS 0x08 | ||
23 | #define ADX_BACKLIGHT_STATUS 0x10 | ||
24 | #define ADX_BACKLIGHT_ERROR 0x18 | ||
25 | |||
26 | struct adxbl { | ||
27 | void __iomem *base; | ||
28 | }; | ||
29 | |||
30 | static int adx_backlight_update_status(struct backlight_device *bldev) | ||
31 | { | ||
32 | struct adxbl *bl = bl_get_data(bldev); | ||
33 | u32 value; | ||
34 | |||
35 | value = bldev->props.brightness; | ||
36 | writel(value, bl->base + ADX_BACKLIGHT_BRIGHTNESS); | ||
37 | |||
38 | value = readl(bl->base + ADX_BACKLIGHT_CONTROL); | ||
39 | |||
40 | if (bldev->props.state & BL_CORE_FBBLANK) | ||
41 | value &= ~ADX_BACKLIGHT_CONTROL_ENABLE; | ||
42 | else | ||
43 | value |= ADX_BACKLIGHT_CONTROL_ENABLE; | ||
44 | |||
45 | writel(value, bl->base + ADX_BACKLIGHT_CONTROL); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static int adx_backlight_get_brightness(struct backlight_device *bldev) | ||
51 | { | ||
52 | struct adxbl *bl = bl_get_data(bldev); | ||
53 | u32 brightness; | ||
54 | |||
55 | brightness = readl(bl->base + ADX_BACKLIGHT_BRIGHTNESS); | ||
56 | return brightness & 0xff; | ||
57 | } | ||
58 | |||
59 | static int adx_backlight_check_fb(struct fb_info *fb) | ||
60 | { | ||
61 | return 1; | ||
62 | } | ||
63 | |||
64 | static struct backlight_ops adx_backlight_ops = { | ||
65 | .options = 0, | ||
66 | .update_status = adx_backlight_update_status, | ||
67 | .get_brightness = adx_backlight_get_brightness, | ||
68 | .check_fb = adx_backlight_check_fb, | ||
69 | }; | ||
70 | |||
71 | static int __devinit adx_backlight_probe(struct platform_device *pdev) | ||
72 | { | ||
73 | struct backlight_device *bldev; | ||
74 | struct resource *res; | ||
75 | struct adxbl *bl; | ||
76 | int ret = 0; | ||
77 | |||
78 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
79 | if (!res) { | ||
80 | ret = -ENXIO; | ||
81 | goto out; | ||
82 | } | ||
83 | |||
84 | res = devm_request_mem_region(&pdev->dev, res->start, | ||
85 | resource_size(res), res->name); | ||
86 | if (!res) { | ||
87 | ret = -ENXIO; | ||
88 | goto out; | ||
89 | } | ||
90 | |||
91 | bl = devm_kzalloc(&pdev->dev, sizeof(*bl), GFP_KERNEL); | ||
92 | if (!bl) { | ||
93 | ret = -ENOMEM; | ||
94 | goto out; | ||
95 | } | ||
96 | |||
97 | bl->base = devm_ioremap_nocache(&pdev->dev, res->start, | ||
98 | resource_size(res)); | ||
99 | if (!bl->base) { | ||
100 | ret = -ENXIO; | ||
101 | goto out; | ||
102 | } | ||
103 | |||
104 | bldev = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, bl, | ||
105 | &adx_backlight_ops); | ||
106 | if (!bldev) { | ||
107 | ret = -ENOMEM; | ||
108 | goto out; | ||
109 | } | ||
110 | |||
111 | bldev->props.max_brightness = 0xff; | ||
112 | bldev->props.brightness = 0xff; | ||
113 | bldev->props.power = FB_BLANK_UNBLANK; | ||
114 | |||
115 | platform_set_drvdata(pdev, bldev); | ||
116 | |||
117 | out: | ||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | static int __devexit adx_backlight_remove(struct platform_device *pdev) | ||
122 | { | ||
123 | struct backlight_device *bldev; | ||
124 | int ret = 0; | ||
125 | |||
126 | bldev = platform_get_drvdata(pdev); | ||
127 | bldev->props.power = FB_BLANK_UNBLANK; | ||
128 | bldev->props.brightness = 0xff; | ||
129 | backlight_update_status(bldev); | ||
130 | backlight_device_unregister(bldev); | ||
131 | platform_set_drvdata(pdev, NULL); | ||
132 | |||
133 | return ret; | ||
134 | } | ||
135 | |||
136 | #ifdef CONFIG_PM | ||
137 | static int adx_backlight_suspend(struct platform_device *pdev, | ||
138 | pm_message_t state) | ||
139 | { | ||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static int adx_backlight_resume(struct platform_device *pdev) | ||
144 | { | ||
145 | return 0; | ||
146 | } | ||
147 | #else | ||
148 | #define adx_backlight_suspend NULL | ||
149 | #define adx_backlight_resume NULL | ||
150 | #endif | ||
151 | |||
152 | static struct platform_driver adx_backlight_driver = { | ||
153 | .probe = adx_backlight_probe, | ||
154 | .remove = __devexit_p(adx_backlight_remove), | ||
155 | .suspend = adx_backlight_suspend, | ||
156 | .resume = adx_backlight_resume, | ||
157 | .driver = { | ||
158 | .name = "adx-backlight", | ||
159 | .owner = THIS_MODULE, | ||
160 | }, | ||
161 | }; | ||
162 | |||
163 | static int __init adx_backlight_init(void) | ||
164 | { | ||
165 | return platform_driver_register(&adx_backlight_driver); | ||
166 | } | ||
167 | |||
168 | static void __exit adx_backlight_exit(void) | ||
169 | { | ||
170 | platform_driver_unregister(&adx_backlight_driver); | ||
171 | } | ||
172 | |||
173 | module_init(adx_backlight_init); | ||
174 | module_exit(adx_backlight_exit); | ||
175 | |||
176 | MODULE_AUTHOR("Thierry Reding <thierry.reding@avionic-design.de>"); | ||
177 | MODULE_DESCRIPTION("Avionic Design Xanthos Backlight Driver"); | ||
178 | MODULE_LICENSE("GPL v2"); | ||