diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-14 20:29:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-14 20:29:55 -0400 |
commit | f0c1bc95a108b36677dde6c9d96a5bb810a05b75 (patch) | |
tree | 335c33469407d0ebda5670dabb49c6ecad64263e /drivers/video | |
parent | 1dcf58d6e6e6eb7ec10e9abc56887b040205b06f (diff) | |
parent | e554a99ee8d09132e80dc467433c9a4df9054645 (diff) |
Merge tag 'mfd-for-linus-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
Pull MFD updates from Lee Jones:
"Changes to existing drivers:
- Rename child driver [axp288_battery => axp288_fuel_gauge]; axp20x
- Rename child driver [max77693-flash => max77693-led]; max77693
- Error handling fixes; intel_soc_pmic
- GPIO tweaking; intel_soc_pmic
- Remove non-DT code; vexpress-sysreg, tc3589x
- Remove unused/legacy code; ti_am335x_tscadc, rts5249, rtsx_gops, rtsx_pcr,
rtc-s5m, sec-core, max77693, menelaus,
wm5102-tables
- Trivial fixups; rtsx_pci, da9150-core, sec-core, max7769, max77693,
mc13xxx-core, dln2, hi6421-pmic-core, rk808, twl4030-power,
lpc_ich, menelaus, twl6040
- Update register/address values; rts5227, rts5249
- DT and/or binding document fixups; arizona, da9150, mt6397, axp20x,
qcom-rpm, qcom-spmi-pmic
- Couple of trivial core Kconfig fixups
- Remove use of seq_printf return value; ab8500-debugfs
- Remove __exit markups; menelaus, tps65010
- Fix platform-device name collisions; mfd-core
New drivers/supported devices:
- Add support for wm8280/wm8281 into arizona
- Add support for COMe-cBL6 into kempld-core
- Add support for rts524a and rts525a into rts5249
- Add support for ipq8064 into qcom_rpm
- Add support for extcon into axp20x
- New MediaTek MT6397 PMIC driver
- New Maxim MAX77843 PMIC dirver
- New Intel Quark X1000 I2C-GPIO driver
- New Skyworks SKY81452 driver"
* tag 'mfd-for-linus-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (76 commits)
mfd: sec: Fix RTC alarm interrupt number on S2MPS11
mfd: wm5102: Remove registers for output 3R from readable list
mfd: tps65010: Remove incorrect __exit markups
mfd: devicetree: bindings: Add Qualcomm RPM regulator subnodes
mfd: axp20x: Add support for extcon cell
mfd: lpc_ich: Sort IDs
mfd: twl6040: Remove wrong and unneeded "platform:twl6040" modalias
mfd: qcom-spmi-pmic: Add specific compatible strings for Qualcomm's SPMI PMIC's
mfd: axp20x: Fix duplicate const for model names
mfd: menelaus: Use macro for magic number
mfd: menelaus: Drop support for SW controller VCORE
mfd: menelaus: Delete omap_has_menelaus
mfd: arizona: Correct type of gpio_defaults
mfd: lpc_ich: Sort IDs
mfd: Fix a typo in Kconfig
mfd: qcom_rpm: Add support for IPQ8064
mfd: devicetree: qcom_rpm: Document IPQ8064 resources
mfd: core: Fix platform-device name collisions
mfd: intel_quark_i2c_gpio: Don't crash if !DMI
dt-bindings: Add vendor-prefix for X-Powers
...
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/Kconfig | 10 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 1 | ||||
-rw-r--r-- | drivers/video/backlight/sky81452-backlight.c | 353 |
3 files changed, 364 insertions, 0 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index efb09046a8cf..2d9923a60076 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -408,6 +408,16 @@ config BACKLIGHT_PANDORA | |||
408 | If you have a Pandora console, say Y to enable the | 408 | If you have a Pandora console, say Y to enable the |
409 | backlight driver. | 409 | backlight driver. |
410 | 410 | ||
411 | config BACKLIGHT_SKY81452 | ||
412 | tristate "Backlight driver for SKY81452" | ||
413 | depends on BACKLIGHT_CLASS_DEVICE && MFD_SKY81452 | ||
414 | help | ||
415 | If you have a Skyworks SKY81452, say Y to enable the | ||
416 | backlight driver. | ||
417 | |||
418 | To compile this driver as a module, choose M here: the module will | ||
419 | be called sky81452-backlight | ||
420 | |||
411 | config BACKLIGHT_TPS65217 | 421 | config BACKLIGHT_TPS65217 |
412 | tristate "TPS65217 Backlight" | 422 | tristate "TPS65217 Backlight" |
413 | depends on BACKLIGHT_CLASS_DEVICE && MFD_TPS65217 | 423 | depends on BACKLIGHT_CLASS_DEVICE && MFD_TPS65217 |
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index fcd50b732165..d67073f9d421 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -50,6 +50,7 @@ obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o | |||
50 | obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o | 50 | obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o |
51 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o | 51 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o |
52 | obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o | 52 | obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o |
53 | obj-$(CONFIG_BACKLIGHT_SKY81452) += sky81452-backlight.o | ||
53 | obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o | 54 | obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o |
54 | obj-$(CONFIG_BACKLIGHT_TPS65217) += tps65217_bl.o | 55 | obj-$(CONFIG_BACKLIGHT_TPS65217) += tps65217_bl.o |
55 | obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o | 56 | obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o |
diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c new file mode 100644 index 000000000000..052fa1bac03d --- /dev/null +++ b/drivers/video/backlight/sky81452-backlight.c | |||
@@ -0,0 +1,353 @@ | |||
1 | /* | ||
2 | * sky81452-backlight.c SKY81452 backlight driver | ||
3 | * | ||
4 | * Copyright 2014 Skyworks Solutions Inc. | ||
5 | * Author : Gyungoh Yoo <jack.yoo@skyworksinc.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 | ||
9 | * as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #include <linux/backlight.h> | ||
21 | #include <linux/err.h> | ||
22 | #include <linux/gpio.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/of.h> | ||
27 | #include <linux/of_gpio.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | #include <linux/regmap.h> | ||
30 | #include <linux/platform_data/sky81452-backlight.h> | ||
31 | #include <linux/slab.h> | ||
32 | |||
33 | /* registers */ | ||
34 | #define SKY81452_REG0 0x00 | ||
35 | #define SKY81452_REG1 0x01 | ||
36 | #define SKY81452_REG2 0x02 | ||
37 | #define SKY81452_REG4 0x04 | ||
38 | #define SKY81452_REG5 0x05 | ||
39 | |||
40 | /* bit mask */ | ||
41 | #define SKY81452_CS 0xFF | ||
42 | #define SKY81452_EN 0x3F | ||
43 | #define SKY81452_IGPW 0x20 | ||
44 | #define SKY81452_PWMMD 0x10 | ||
45 | #define SKY81452_PHASE 0x08 | ||
46 | #define SKY81452_ILIM 0x04 | ||
47 | #define SKY81452_VSHRT 0x03 | ||
48 | #define SKY81452_OCP 0x80 | ||
49 | #define SKY81452_OTMP 0x40 | ||
50 | #define SKY81452_SHRT 0x3F | ||
51 | #define SKY81452_OPN 0x3F | ||
52 | |||
53 | #define SKY81452_DEFAULT_NAME "lcd-backlight" | ||
54 | #define SKY81452_MAX_BRIGHTNESS (SKY81452_CS + 1) | ||
55 | |||
56 | #define CTZ(b) __builtin_ctz(b) | ||
57 | |||
58 | static int sky81452_bl_update_status(struct backlight_device *bd) | ||
59 | { | ||
60 | const struct sky81452_bl_platform_data *pdata = | ||
61 | dev_get_platdata(bd->dev.parent); | ||
62 | const unsigned int brightness = (unsigned int)bd->props.brightness; | ||
63 | struct regmap *regmap = bl_get_data(bd); | ||
64 | int ret; | ||
65 | |||
66 | if (brightness > 0) { | ||
67 | ret = regmap_write(regmap, SKY81452_REG0, brightness - 1); | ||
68 | if (IS_ERR_VALUE(ret)) | ||
69 | return ret; | ||
70 | |||
71 | return regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN, | ||
72 | pdata->enable << CTZ(SKY81452_EN)); | ||
73 | } | ||
74 | |||
75 | return regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN, 0); | ||
76 | } | ||
77 | |||
78 | static const struct backlight_ops sky81452_bl_ops = { | ||
79 | .update_status = sky81452_bl_update_status, | ||
80 | }; | ||
81 | |||
82 | static ssize_t sky81452_bl_store_enable(struct device *dev, | ||
83 | struct device_attribute *attr, const char *buf, size_t count) | ||
84 | { | ||
85 | struct regmap *regmap = bl_get_data(to_backlight_device(dev)); | ||
86 | unsigned long value; | ||
87 | int ret; | ||
88 | |||
89 | ret = kstrtoul(buf, 16, &value); | ||
90 | if (IS_ERR_VALUE(ret)) | ||
91 | return ret; | ||
92 | |||
93 | ret = regmap_update_bits(regmap, SKY81452_REG1, SKY81452_EN, | ||
94 | value << CTZ(SKY81452_EN)); | ||
95 | if (IS_ERR_VALUE(ret)) | ||
96 | return ret; | ||
97 | |||
98 | return count; | ||
99 | } | ||
100 | |||
101 | static ssize_t sky81452_bl_show_open_short(struct device *dev, | ||
102 | struct device_attribute *attr, char *buf) | ||
103 | { | ||
104 | struct regmap *regmap = bl_get_data(to_backlight_device(dev)); | ||
105 | unsigned int reg, value = 0; | ||
106 | char tmp[3]; | ||
107 | int i, ret; | ||
108 | |||
109 | reg = !strcmp(attr->attr.name, "open") ? SKY81452_REG5 : SKY81452_REG4; | ||
110 | ret = regmap_read(regmap, reg, &value); | ||
111 | if (IS_ERR_VALUE(ret)) | ||
112 | return ret; | ||
113 | |||
114 | if (value & SKY81452_SHRT) { | ||
115 | *buf = 0; | ||
116 | for (i = 0; i < 6; i++) { | ||
117 | if (value & 0x01) { | ||
118 | sprintf(tmp, "%d ", i + 1); | ||
119 | strcat(buf, tmp); | ||
120 | } | ||
121 | value >>= 1; | ||
122 | } | ||
123 | strcat(buf, "\n"); | ||
124 | } else { | ||
125 | strcpy(buf, "none\n"); | ||
126 | } | ||
127 | |||
128 | return strlen(buf); | ||
129 | } | ||
130 | |||
131 | static ssize_t sky81452_bl_show_fault(struct device *dev, | ||
132 | struct device_attribute *attr, char *buf) | ||
133 | { | ||
134 | struct regmap *regmap = bl_get_data(to_backlight_device(dev)); | ||
135 | unsigned int value = 0; | ||
136 | int ret; | ||
137 | |||
138 | ret = regmap_read(regmap, SKY81452_REG4, &value); | ||
139 | if (IS_ERR_VALUE(ret)) | ||
140 | return ret; | ||
141 | |||
142 | *buf = 0; | ||
143 | |||
144 | if (value & SKY81452_OCP) | ||
145 | strcat(buf, "over-current "); | ||
146 | |||
147 | if (value & SKY81452_OTMP) | ||
148 | strcat(buf, "over-temperature"); | ||
149 | |||
150 | strcat(buf, "\n"); | ||
151 | return strlen(buf); | ||
152 | } | ||
153 | |||
154 | static DEVICE_ATTR(enable, S_IWGRP | S_IWUSR, NULL, sky81452_bl_store_enable); | ||
155 | static DEVICE_ATTR(open, S_IRUGO, sky81452_bl_show_open_short, NULL); | ||
156 | static DEVICE_ATTR(short, S_IRUGO, sky81452_bl_show_open_short, NULL); | ||
157 | static DEVICE_ATTR(fault, S_IRUGO, sky81452_bl_show_fault, NULL); | ||
158 | |||
159 | static struct attribute *sky81452_bl_attribute[] = { | ||
160 | &dev_attr_enable.attr, | ||
161 | &dev_attr_open.attr, | ||
162 | &dev_attr_short.attr, | ||
163 | &dev_attr_fault.attr, | ||
164 | NULL | ||
165 | }; | ||
166 | |||
167 | static const struct attribute_group sky81452_bl_attr_group = { | ||
168 | .attrs = sky81452_bl_attribute, | ||
169 | }; | ||
170 | |||
171 | #ifdef CONFIG_OF | ||
172 | static struct sky81452_bl_platform_data *sky81452_bl_parse_dt( | ||
173 | struct device *dev) | ||
174 | { | ||
175 | struct device_node *np = of_node_get(dev->of_node); | ||
176 | struct sky81452_bl_platform_data *pdata; | ||
177 | int num_entry; | ||
178 | unsigned int sources[6]; | ||
179 | int ret; | ||
180 | |||
181 | if (!np) { | ||
182 | dev_err(dev, "backlight node not found.\n"); | ||
183 | return ERR_PTR(-ENODATA); | ||
184 | } | ||
185 | |||
186 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
187 | if (!pdata) { | ||
188 | of_node_put(np); | ||
189 | return ERR_PTR(-ENOMEM); | ||
190 | } | ||
191 | |||
192 | of_property_read_string(np, "name", &pdata->name); | ||
193 | pdata->ignore_pwm = of_property_read_bool(np, "skyworks,ignore-pwm"); | ||
194 | pdata->dpwm_mode = of_property_read_bool(np, "skyworks,dpwm-mode"); | ||
195 | pdata->phase_shift = of_property_read_bool(np, "skyworks,phase-shift"); | ||
196 | pdata->gpio_enable = of_get_gpio(np, 0); | ||
197 | |||
198 | ret = of_property_count_u32_elems(np, "led-sources"); | ||
199 | if (IS_ERR_VALUE(ret)) { | ||
200 | pdata->enable = SKY81452_EN >> CTZ(SKY81452_EN); | ||
201 | } else { | ||
202 | num_entry = ret; | ||
203 | if (num_entry > 6) | ||
204 | num_entry = 6; | ||
205 | |||
206 | ret = of_property_read_u32_array(np, "led-sources", sources, | ||
207 | num_entry); | ||
208 | if (IS_ERR_VALUE(ret)) { | ||
209 | dev_err(dev, "led-sources node is invalid.\n"); | ||
210 | return ERR_PTR(-EINVAL); | ||
211 | } | ||
212 | |||
213 | pdata->enable = 0; | ||
214 | while (--num_entry) | ||
215 | pdata->enable |= (1 << sources[num_entry]); | ||
216 | } | ||
217 | |||
218 | ret = of_property_read_u32(np, | ||
219 | "skyworks,short-detection-threshold-volt", | ||
220 | &pdata->short_detection_threshold); | ||
221 | if (IS_ERR_VALUE(ret)) | ||
222 | pdata->short_detection_threshold = 7; | ||
223 | |||
224 | ret = of_property_read_u32(np, "skyworks,current-limit-mA", | ||
225 | &pdata->boost_current_limit); | ||
226 | if (IS_ERR_VALUE(ret)) | ||
227 | pdata->boost_current_limit = 2750; | ||
228 | |||
229 | of_node_put(np); | ||
230 | return pdata; | ||
231 | } | ||
232 | #else | ||
233 | static struct sky81452_bl_platform_data *sky81452_bl_parse_dt( | ||
234 | struct device *dev) | ||
235 | { | ||
236 | return ERR_PTR(-EINVAL); | ||
237 | } | ||
238 | #endif | ||
239 | |||
240 | static int sky81452_bl_init_device(struct regmap *regmap, | ||
241 | struct sky81452_bl_platform_data *pdata) | ||
242 | { | ||
243 | unsigned int value; | ||
244 | |||
245 | value = pdata->ignore_pwm ? SKY81452_IGPW : 0; | ||
246 | value |= pdata->dpwm_mode ? SKY81452_PWMMD : 0; | ||
247 | value |= pdata->phase_shift ? 0 : SKY81452_PHASE; | ||
248 | |||
249 | if (pdata->boost_current_limit == 2300) | ||
250 | value |= SKY81452_ILIM; | ||
251 | else if (pdata->boost_current_limit != 2750) | ||
252 | return -EINVAL; | ||
253 | |||
254 | if (pdata->short_detection_threshold < 4 || | ||
255 | pdata->short_detection_threshold > 7) | ||
256 | return -EINVAL; | ||
257 | value |= (7 - pdata->short_detection_threshold) << CTZ(SKY81452_VSHRT); | ||
258 | |||
259 | return regmap_write(regmap, SKY81452_REG2, value); | ||
260 | } | ||
261 | |||
262 | static int sky81452_bl_probe(struct platform_device *pdev) | ||
263 | { | ||
264 | struct device *dev = &pdev->dev; | ||
265 | struct regmap *regmap = dev_get_drvdata(dev->parent); | ||
266 | struct sky81452_bl_platform_data *pdata = dev_get_platdata(dev); | ||
267 | struct backlight_device *bd; | ||
268 | struct backlight_properties props; | ||
269 | const char *name; | ||
270 | int ret; | ||
271 | |||
272 | if (!pdata) { | ||
273 | pdata = sky81452_bl_parse_dt(dev); | ||
274 | if (IS_ERR(pdata)) | ||
275 | return PTR_ERR(pdata); | ||
276 | } | ||
277 | |||
278 | if (gpio_is_valid(pdata->gpio_enable)) { | ||
279 | ret = devm_gpio_request_one(dev, pdata->gpio_enable, | ||
280 | GPIOF_OUT_INIT_HIGH, "sky81452-en"); | ||
281 | if (IS_ERR_VALUE(ret)) { | ||
282 | dev_err(dev, "failed to request GPIO. err=%d\n", ret); | ||
283 | return ret; | ||
284 | } | ||
285 | } | ||
286 | |||
287 | ret = sky81452_bl_init_device(regmap, pdata); | ||
288 | if (IS_ERR_VALUE(ret)) { | ||
289 | dev_err(dev, "failed to initialize. err=%d\n", ret); | ||
290 | return ret; | ||
291 | } | ||
292 | |||
293 | memset(&props, 0, sizeof(props)); | ||
294 | props.max_brightness = SKY81452_MAX_BRIGHTNESS, | ||
295 | name = pdata->name ? pdata->name : SKY81452_DEFAULT_NAME; | ||
296 | bd = devm_backlight_device_register(dev, name, dev, regmap, | ||
297 | &sky81452_bl_ops, &props); | ||
298 | if (IS_ERR(bd)) { | ||
299 | dev_err(dev, "failed to register. err=%ld\n", PTR_ERR(bd)); | ||
300 | return PTR_ERR(bd); | ||
301 | } | ||
302 | |||
303 | platform_set_drvdata(pdev, bd); | ||
304 | |||
305 | ret = sysfs_create_group(&bd->dev.kobj, &sky81452_bl_attr_group); | ||
306 | if (IS_ERR_VALUE(ret)) { | ||
307 | dev_err(dev, "failed to create attribute. err=%d\n", ret); | ||
308 | return ret; | ||
309 | } | ||
310 | |||
311 | return ret; | ||
312 | } | ||
313 | |||
314 | static int sky81452_bl_remove(struct platform_device *pdev) | ||
315 | { | ||
316 | const struct sky81452_bl_platform_data *pdata = | ||
317 | dev_get_platdata(&pdev->dev); | ||
318 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
319 | |||
320 | sysfs_remove_group(&bd->dev.kobj, &sky81452_bl_attr_group); | ||
321 | |||
322 | bd->props.power = FB_BLANK_UNBLANK; | ||
323 | bd->props.brightness = 0; | ||
324 | backlight_update_status(bd); | ||
325 | |||
326 | if (gpio_is_valid(pdata->gpio_enable)) | ||
327 | gpio_set_value_cansleep(pdata->gpio_enable, 0); | ||
328 | |||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | #ifdef CONFIG_OF | ||
333 | static const struct of_device_id sky81452_bl_of_match[] = { | ||
334 | { .compatible = "skyworks,sky81452-backlight", }, | ||
335 | { } | ||
336 | }; | ||
337 | MODULE_DEVICE_TABLE(of, sky81452_bl_of_match); | ||
338 | #endif | ||
339 | |||
340 | static struct platform_driver sky81452_bl_driver = { | ||
341 | .driver = { | ||
342 | .name = "sky81452-backlight", | ||
343 | .of_match_table = of_match_ptr(sky81452_bl_of_match), | ||
344 | }, | ||
345 | .probe = sky81452_bl_probe, | ||
346 | .remove = sky81452_bl_remove, | ||
347 | }; | ||
348 | |||
349 | module_platform_driver(sky81452_bl_driver); | ||
350 | |||
351 | MODULE_DESCRIPTION("Skyworks SKY81452 backlight driver"); | ||
352 | MODULE_AUTHOR("Gyungoh Yoo <jack.yoo@skyworksinc.com>"); | ||
353 | MODULE_LICENSE("GPL v2"); | ||