diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-11 14:39:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-11 14:39:03 -0500 |
commit | e28870f9b3e92cd3570925089c6bb789c2603bc4 (patch) | |
tree | f0a2c91abd0af5579fde082840995bd7cc5e1876 | |
parent | c1b30e4d9466000c0e287e9245d4397da4d7d2f9 (diff) | |
parent | 3d6969a641d01cc9b6aa199a6f01eb1802522baf (diff) |
Merge tag 'backlight-for-linus-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones:
- Clean-up leaky resources; pwm_bl
- Simplify Device Tree initialisation; lp855x_bl
- Add Regulator support; lp855x
- Remove Bryan from the Maintainer list -- new baby, no time :)
* tag 'backlight-for-linus-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
MAINTAINERS: Remove my name from Backlight subsystem
backlight: lp855x: Add supply regulator to lp855x
backlight: lp855x: Refactor DT parsing code
backlight: pwm: Clean-up pwm requested using legacy API
-rw-r--r-- | Documentation/devicetree/bindings/video/backlight/lp855x.txt | 2 | ||||
-rw-r--r-- | MAINTAINERS | 1 | ||||
-rw-r--r-- | drivers/video/backlight/lp855x_bl.c | 55 | ||||
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 5 | ||||
-rw-r--r-- | include/linux/platform_data/lp855x.h | 2 |
5 files changed, 44 insertions, 21 deletions
diff --git a/Documentation/devicetree/bindings/video/backlight/lp855x.txt b/Documentation/devicetree/bindings/video/backlight/lp855x.txt index 96e83a56048e..0a3ecbc3a1b9 100644 --- a/Documentation/devicetree/bindings/video/backlight/lp855x.txt +++ b/Documentation/devicetree/bindings/video/backlight/lp855x.txt | |||
@@ -12,6 +12,7 @@ Optional properties: | |||
12 | - pwm-period: PWM period value. Set only PWM input mode used (u32) | 12 | - pwm-period: PWM period value. Set only PWM input mode used (u32) |
13 | - rom-addr: Register address of ROM area to be updated (u8) | 13 | - rom-addr: Register address of ROM area to be updated (u8) |
14 | - rom-val: Register value to be updated (u8) | 14 | - rom-val: Register value to be updated (u8) |
15 | - power-supply: Regulator which controls the 3V rail | ||
15 | 16 | ||
16 | Example: | 17 | Example: |
17 | 18 | ||
@@ -56,6 +57,7 @@ Example: | |||
56 | backlight@2c { | 57 | backlight@2c { |
57 | compatible = "ti,lp8557"; | 58 | compatible = "ti,lp8557"; |
58 | reg = <0x2c>; | 59 | reg = <0x2c>; |
60 | power-supply = <&backlight_vdd>; | ||
59 | 61 | ||
60 | dev-ctrl = /bits/ 8 <0x41>; | 62 | dev-ctrl = /bits/ 8 <0x41>; |
61 | init-brt = /bits/ 8 <0x0a>; | 63 | init-brt = /bits/ 8 <0x0a>; |
diff --git a/MAINTAINERS b/MAINTAINERS index 742413fe3d76..7b6e28d825d0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -1869,7 +1869,6 @@ F: drivers/net/wireless/b43legacy/ | |||
1869 | 1869 | ||
1870 | BACKLIGHT CLASS/SUBSYSTEM | 1870 | BACKLIGHT CLASS/SUBSYSTEM |
1871 | M: Jingoo Han <jg1.han@samsung.com> | 1871 | M: Jingoo Han <jg1.han@samsung.com> |
1872 | M: Bryan Wu <cooloney@gmail.com> | ||
1873 | M: Lee Jones <lee.jones@linaro.org> | 1872 | M: Lee Jones <lee.jones@linaro.org> |
1874 | S: Maintained | 1873 | S: Maintained |
1875 | F: drivers/video/backlight/ | 1874 | F: drivers/video/backlight/ |
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 25fb8e3d75b1..a26d3bb25650 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/of.h> | 17 | #include <linux/of.h> |
18 | #include <linux/platform_data/lp855x.h> | 18 | #include <linux/platform_data/lp855x.h> |
19 | #include <linux/pwm.h> | 19 | #include <linux/pwm.h> |
20 | #include <linux/regulator/consumer.h> | ||
20 | 21 | ||
21 | /* LP8550/1/2/3/6 Registers */ | 22 | /* LP8550/1/2/3/6 Registers */ |
22 | #define LP855X_BRIGHTNESS_CTRL 0x00 | 23 | #define LP855X_BRIGHTNESS_CTRL 0x00 |
@@ -341,8 +342,10 @@ static const struct attribute_group lp855x_attr_group = { | |||
341 | }; | 342 | }; |
342 | 343 | ||
343 | #ifdef CONFIG_OF | 344 | #ifdef CONFIG_OF |
344 | static int lp855x_parse_dt(struct device *dev, struct device_node *node) | 345 | static int lp855x_parse_dt(struct lp855x *lp) |
345 | { | 346 | { |
347 | struct device *dev = lp->dev; | ||
348 | struct device_node *node = dev->of_node; | ||
346 | struct lp855x_platform_data *pdata; | 349 | struct lp855x_platform_data *pdata; |
347 | int rom_length; | 350 | int rom_length; |
348 | 351 | ||
@@ -381,12 +384,19 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node) | |||
381 | pdata->rom_data = &rom[0]; | 384 | pdata->rom_data = &rom[0]; |
382 | } | 385 | } |
383 | 386 | ||
384 | dev->platform_data = pdata; | 387 | pdata->supply = devm_regulator_get(dev, "power"); |
388 | if (IS_ERR(pdata->supply)) { | ||
389 | if (PTR_ERR(pdata->supply) == -EPROBE_DEFER) | ||
390 | return -EPROBE_DEFER; | ||
391 | pdata->supply = NULL; | ||
392 | } | ||
393 | |||
394 | lp->pdata = pdata; | ||
385 | 395 | ||
386 | return 0; | 396 | return 0; |
387 | } | 397 | } |
388 | #else | 398 | #else |
389 | static int lp855x_parse_dt(struct device *dev, struct device_node *node) | 399 | static int lp855x_parse_dt(struct lp855x *lp) |
390 | { | 400 | { |
391 | return -EINVAL; | 401 | return -EINVAL; |
392 | } | 402 | } |
@@ -395,18 +405,8 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node) | |||
395 | static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | 405 | static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) |
396 | { | 406 | { |
397 | struct lp855x *lp; | 407 | struct lp855x *lp; |
398 | struct lp855x_platform_data *pdata = dev_get_platdata(&cl->dev); | ||
399 | struct device_node *node = cl->dev.of_node; | ||
400 | int ret; | 408 | int ret; |
401 | 409 | ||
402 | if (!pdata) { | ||
403 | ret = lp855x_parse_dt(&cl->dev, node); | ||
404 | if (ret < 0) | ||
405 | return ret; | ||
406 | |||
407 | pdata = dev_get_platdata(&cl->dev); | ||
408 | } | ||
409 | |||
410 | if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) | 410 | if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) |
411 | return -EIO; | 411 | return -EIO; |
412 | 412 | ||
@@ -414,16 +414,31 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | |||
414 | if (!lp) | 414 | if (!lp) |
415 | return -ENOMEM; | 415 | return -ENOMEM; |
416 | 416 | ||
417 | if (pdata->period_ns > 0) | ||
418 | lp->mode = PWM_BASED; | ||
419 | else | ||
420 | lp->mode = REGISTER_BASED; | ||
421 | |||
422 | lp->client = cl; | 417 | lp->client = cl; |
423 | lp->dev = &cl->dev; | 418 | lp->dev = &cl->dev; |
424 | lp->pdata = pdata; | ||
425 | lp->chipname = id->name; | 419 | lp->chipname = id->name; |
426 | lp->chip_id = id->driver_data; | 420 | lp->chip_id = id->driver_data; |
421 | lp->pdata = dev_get_platdata(&cl->dev); | ||
422 | |||
423 | if (!lp->pdata) { | ||
424 | ret = lp855x_parse_dt(lp); | ||
425 | if (ret < 0) | ||
426 | return ret; | ||
427 | } | ||
428 | |||
429 | if (lp->pdata->period_ns > 0) | ||
430 | lp->mode = PWM_BASED; | ||
431 | else | ||
432 | lp->mode = REGISTER_BASED; | ||
433 | |||
434 | if (lp->pdata->supply) { | ||
435 | ret = regulator_enable(lp->pdata->supply); | ||
436 | if (ret < 0) { | ||
437 | dev_err(&cl->dev, "failed to enable supply: %d\n", ret); | ||
438 | return ret; | ||
439 | } | ||
440 | } | ||
441 | |||
427 | i2c_set_clientdata(cl, lp); | 442 | i2c_set_clientdata(cl, lp); |
428 | 443 | ||
429 | ret = lp855x_configure(lp); | 444 | ret = lp855x_configure(lp); |
@@ -455,6 +470,8 @@ static int lp855x_remove(struct i2c_client *cl) | |||
455 | 470 | ||
456 | lp->bl->props.brightness = 0; | 471 | lp->bl->props.brightness = 0; |
457 | backlight_update_status(lp->bl); | 472 | backlight_update_status(lp->bl); |
473 | if (lp->pdata->supply) | ||
474 | regulator_disable(lp->pdata->supply); | ||
458 | sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group); | 475 | sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group); |
459 | 476 | ||
460 | return 0; | 477 | return 0; |
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index cb5ae4c08469..3a145a643e0d 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
@@ -34,6 +34,7 @@ struct pwm_bl_data { | |||
34 | struct regulator *power_supply; | 34 | struct regulator *power_supply; |
35 | struct gpio_desc *enable_gpio; | 35 | struct gpio_desc *enable_gpio; |
36 | unsigned int scale; | 36 | unsigned int scale; |
37 | bool legacy; | ||
37 | int (*notify)(struct device *, | 38 | int (*notify)(struct device *, |
38 | int brightness); | 39 | int brightness); |
39 | void (*notify_after)(struct device *, | 40 | void (*notify_after)(struct device *, |
@@ -274,7 +275,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
274 | pb->pwm = devm_pwm_get(&pdev->dev, NULL); | 275 | pb->pwm = devm_pwm_get(&pdev->dev, NULL); |
275 | if (IS_ERR(pb->pwm)) { | 276 | if (IS_ERR(pb->pwm)) { |
276 | dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); | 277 | dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); |
277 | 278 | pb->legacy = true; | |
278 | pb->pwm = pwm_request(data->pwm_id, "pwm-backlight"); | 279 | pb->pwm = pwm_request(data->pwm_id, "pwm-backlight"); |
279 | if (IS_ERR(pb->pwm)) { | 280 | if (IS_ERR(pb->pwm)) { |
280 | dev_err(&pdev->dev, "unable to request legacy PWM\n"); | 281 | dev_err(&pdev->dev, "unable to request legacy PWM\n"); |
@@ -339,6 +340,8 @@ static int pwm_backlight_remove(struct platform_device *pdev) | |||
339 | 340 | ||
340 | if (pb->exit) | 341 | if (pb->exit) |
341 | pb->exit(&pdev->dev); | 342 | pb->exit(&pdev->dev); |
343 | if (pb->legacy) | ||
344 | pwm_free(pb->pwm); | ||
342 | 345 | ||
343 | return 0; | 346 | return 0; |
344 | } | 347 | } |
diff --git a/include/linux/platform_data/lp855x.h b/include/linux/platform_data/lp855x.h index 1b2ba24e4e03..9c7fd1efe495 100644 --- a/include/linux/platform_data/lp855x.h +++ b/include/linux/platform_data/lp855x.h | |||
@@ -136,6 +136,7 @@ struct lp855x_rom_data { | |||
136 | Only valid when mode is PWM_BASED. | 136 | Only valid when mode is PWM_BASED. |
137 | * @size_program : total size of lp855x_rom_data | 137 | * @size_program : total size of lp855x_rom_data |
138 | * @rom_data : list of new eeprom/eprom registers | 138 | * @rom_data : list of new eeprom/eprom registers |
139 | * @supply : regulator that supplies 3V input | ||
139 | */ | 140 | */ |
140 | struct lp855x_platform_data { | 141 | struct lp855x_platform_data { |
141 | const char *name; | 142 | const char *name; |
@@ -144,6 +145,7 @@ struct lp855x_platform_data { | |||
144 | unsigned int period_ns; | 145 | unsigned int period_ns; |
145 | int size_program; | 146 | int size_program; |
146 | struct lp855x_rom_data *rom_data; | 147 | struct lp855x_rom_data *rom_data; |
148 | struct regulator *supply; | ||
147 | }; | 149 | }; |
148 | 150 | ||
149 | #endif | 151 | #endif |