aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAshish Jangam <ashish.jangam@kpitcummins.com>2012-04-05 17:25:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-04-05 18:25:51 -0400
commit6ede3d832aaa038e7465e677569f7acc96b4dcdf (patch)
treefd07e865735078ba30c6c26d89917a6297875497 /drivers
parent6e61ee3b7a1e05a8c5b76095a1ea6c3711c922cb (diff)
backlight: add driver for DA9052/53 PMIC v1
DA9052/53 PMIC has capability to supply power for upto 3 banks of 6 white serial LEDS. It can also control intensity of independent banks and to drive these banks boost converter will provide up to 24V and forward current of max 50mA. This patch allows to control intensity of the individual WLEDs bank through DA9052/53 PMIC. This patch is functionally tested on Samsung SMDKV6410. Signed-off-by: David Dajun Chen <dchen@diasemi.com> Signed-off-by: Ashish Jangam <ashish.jangam@kpitcummins.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/backlight/Kconfig6
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/da9052_bl.c187
3 files changed, 194 insertions, 0 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 7ed9991fa747..af16884491ed 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -245,6 +245,12 @@ config BACKLIGHT_DA903X
245 If you have a LCD backlight connected to the WLED output of DA9030 245 If you have a LCD backlight connected to the WLED output of DA9030
246 or DA9034 WLED output, say Y here to enable this driver. 246 or DA9034 WLED output, say Y here to enable this driver.
247 247
248config BACKLIGHT_DA9052
249 tristate "Dialog DA9052/DA9053 WLED"
250 depends on PMIC_DA9052
251 help
252 Enable the Backlight Driver for DA9052-BC and DA9053-AA/Bx PMICs.
253
248config BACKLIGHT_MAX8925 254config BACKLIGHT_MAX8925
249 tristate "Backlight driver for MAX8925" 255 tristate "Backlight driver for MAX8925"
250 depends on MFD_MAX8925 256 depends on MFD_MAX8925
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 8071eb656147..36855ae887d6 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o
29obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o 29obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o
30obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o 30obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
31obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o 31obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o
32obj-$(CONFIG_BACKLIGHT_DA9052) += da9052_bl.o
32obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o 33obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o
33obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o 34obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o
34obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o 35obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o
diff --git a/drivers/video/backlight/da9052_bl.c b/drivers/video/backlight/da9052_bl.c
new file mode 100644
index 000000000000..b628d68f5162
--- /dev/null
+++ b/drivers/video/backlight/da9052_bl.c
@@ -0,0 +1,187 @@
1/*
2 * Backlight Driver for Dialog DA9052 PMICs
3 *
4 * Copyright(c) 2012 Dialog Semiconductor Ltd.
5 *
6 * Author: David Dajun Chen <dchen@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */
14
15#include <linux/backlight.h>
16#include <linux/delay.h>
17#include <linux/fb.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20
21#include <linux/mfd/da9052/da9052.h>
22#include <linux/mfd/da9052/reg.h>
23
24#define DA9052_MAX_BRIGHTNESS 0xFF
25
26enum {
27 DA9052_WLEDS_OFF,
28 DA9052_WLEDS_ON,
29};
30
31enum {
32 DA9052_TYPE_WLED1,
33 DA9052_TYPE_WLED2,
34 DA9052_TYPE_WLED3,
35};
36
37static unsigned char wled_bank[] = {
38 DA9052_LED1_CONF_REG,
39 DA9052_LED2_CONF_REG,
40 DA9052_LED3_CONF_REG,
41};
42
43struct da9052_bl {
44 struct da9052 *da9052;
45 uint brightness;
46 uint state;
47 uint led_reg;
48};
49
50static int da9052_adjust_wled_brightness(struct da9052_bl *wleds)
51{
52 unsigned char boost_en;
53 unsigned char i_sink;
54 int ret;
55
56 boost_en = 0x3F;
57 i_sink = 0xFF;
58 if (wleds->state == DA9052_WLEDS_OFF) {
59 boost_en = 0x00;
60 i_sink = 0x00;
61 }
62
63 ret = da9052_reg_write(wleds->da9052, DA9052_BOOST_REG, boost_en);
64 if (ret < 0)
65 return ret;
66
67 ret = da9052_reg_write(wleds->da9052, DA9052_LED_CONT_REG, i_sink);
68 if (ret < 0)
69 return ret;
70
71 ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg], 0x0);
72 if (ret < 0)
73 return ret;
74
75 msleep(10);
76
77 if (wleds->brightness) {
78 ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg],
79 wleds->brightness);
80 if (ret < 0)
81 return ret;
82 }
83
84 return 0;
85}
86
87static int da9052_backlight_update_status(struct backlight_device *bl)
88{
89 int brightness = bl->props.brightness;
90 struct da9052_bl *wleds = bl_get_data(bl);
91
92 wleds->brightness = brightness;
93 wleds->state = DA9052_WLEDS_ON;
94
95 return da9052_adjust_wled_brightness(wleds);
96}
97
98static int da9052_backlight_get_brightness(struct backlight_device *bl)
99{
100 struct da9052_bl *wleds = bl_get_data(bl);
101
102 return wleds->brightness;
103}
104
105static const struct backlight_ops da9052_backlight_ops = {
106 .update_status = da9052_backlight_update_status,
107 .get_brightness = da9052_backlight_get_brightness,
108};
109
110static int da9052_backlight_probe(struct platform_device *pdev)
111{
112 struct backlight_device *bl;
113 struct backlight_properties props;
114 struct da9052_bl *wleds;
115
116 wleds = devm_kzalloc(&pdev->dev, sizeof(struct da9052_bl), GFP_KERNEL);
117 if (!wleds)
118 return -ENOMEM;
119
120 wleds->da9052 = dev_get_drvdata(pdev->dev.parent);
121 wleds->brightness = 0;
122 wleds->led_reg = platform_get_device_id(pdev)->driver_data;
123 wleds->state = DA9052_WLEDS_OFF;
124
125 props.type = BACKLIGHT_RAW;
126 props.max_brightness = DA9052_MAX_BRIGHTNESS;
127
128 bl = backlight_device_register(pdev->name, wleds->da9052->dev, wleds,
129 &da9052_backlight_ops, &props);
130 if (IS_ERR(bl)) {
131 dev_err(&pdev->dev, "Failed to register backlight\n");
132 devm_kfree(&pdev->dev, wleds);
133 return PTR_ERR(bl);
134 }
135
136 bl->props.max_brightness = DA9052_MAX_BRIGHTNESS;
137 bl->props.brightness = 0;
138 platform_set_drvdata(pdev, bl);
139
140 return da9052_adjust_wled_brightness(wleds);
141}
142
143static int da9052_backlight_remove(struct platform_device *pdev)
144{
145 struct backlight_device *bl = platform_get_drvdata(pdev);
146 struct da9052_bl *wleds = bl_get_data(bl);
147
148 wleds->brightness = 0;
149 wleds->state = DA9052_WLEDS_OFF;
150 da9052_adjust_wled_brightness(wleds);
151 backlight_device_unregister(bl);
152 devm_kfree(&pdev->dev, wleds);
153
154 return 0;
155}
156
157static struct platform_device_id da9052_wled_ids[] = {
158 {
159 .name = "da9052-wled1",
160 .driver_data = DA9052_TYPE_WLED1,
161 },
162 {
163 .name = "da9052-wled2",
164 .driver_data = DA9052_TYPE_WLED2,
165 },
166 {
167 .name = "da9052-wled3",
168 .driver_data = DA9052_TYPE_WLED3,
169 },
170};
171
172static struct platform_driver da9052_wled_driver = {
173 .probe = da9052_backlight_probe,
174 .remove = da9052_backlight_remove,
175 .id_table = da9052_wled_ids,
176 .driver = {
177 .name = "da9052-wled",
178 .owner = THIS_MODULE,
179 },
180};
181
182module_platform_driver(da9052_wled_driver);
183
184MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
185MODULE_DESCRIPTION("Backlight driver for DA9052 PMIC");
186MODULE_LICENSE("GPL");
187MODULE_ALIAS("platform:da9052-backlight");