aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@sonymobile.com>2015-07-21 20:44:49 -0400
committerLee Jones <lee.jones@linaro.org>2015-08-25 03:41:56 -0400
commit7ddbc2423c3301280b883bbb04b998203f30312c (patch)
treeae41f93655fd5a8bdd920363479934653d06cb51
parentfe009175ae3ec3724c1414440e22a1d32d806ec5 (diff)
backlight: pm8941-wled: Move PM8941 WLED driver to backlight
The Qualcomm PM8941 WLED block is used for backlight and should therefor be in the backlight framework and not in the LED framework. This moves the driver and adapts to the backlight api instead. Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> Tested-by: Rob Clark <robdclark@gmail.com> Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com> Acked-by: Jingoo Han <jingoohan1@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt (renamed from Documentation/devicetree/bindings/leds/leds-pm8941-wled.txt)5
-rw-r--r--drivers/leds/Kconfig8
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/video/backlight/Kconfig7
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/pm8941-wled.c (renamed from drivers/leds/leds-pm8941-wled.c)60
6 files changed, 35 insertions, 47 deletions
diff --git a/Documentation/devicetree/bindings/leds/leds-pm8941-wled.txt b/Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt
index a85a964d61f5..424f8444a6cd 100644
--- a/Documentation/devicetree/bindings/leds/leds-pm8941-wled.txt
+++ b/Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt
@@ -5,10 +5,7 @@ Required properties:
5- reg: slave address 5- reg: slave address
6 6
7Optional properties: 7Optional properties:
8- label: The label for this led 8- label: The name of the backlight device
9 See Documentation/devicetree/bindings/leds/common.txt
10- linux,default-trigger: Default trigger assigned to the LED
11 See Documentation/devicetree/bindings/leds/common.txt
12- qcom,cs-out: bool; enable current sink output 9- qcom,cs-out: bool; enable current sink output
13- qcom,cabc: bool; enable content adaptive backlight control 10- qcom,cabc: bool; enable content adaptive backlight control
14- qcom,ext-gen: bool; use externally generated modulator signal to dim 11- qcom,ext-gen: bool; use externally generated modulator signal to dim
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 9ad35f72ab4c..b8d4b965ca2a 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -578,14 +578,6 @@ config LEDS_VERSATILE
578 This option enabled support for the LEDs on the ARM Versatile 578 This option enabled support for the LEDs on the ARM Versatile
579 and RealView boards. Say Y to enabled these. 579 and RealView boards. Say Y to enabled these.
580 580
581config LEDS_PM8941_WLED
582 tristate "LED support for the Qualcomm PM8941 WLED block"
583 depends on LEDS_CLASS
584 select REGMAP
585 help
586 This option enables support for the 'White' LED block
587 on Qualcomm PM8941 PMICs.
588
589comment "LED Triggers" 581comment "LED Triggers"
590source "drivers/leds/trigger/Kconfig" 582source "drivers/leds/trigger/Kconfig"
591 583
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 8d6a24a2f513..abe96d960ebe 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -63,7 +63,6 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
63obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o 63obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o
64obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o 64obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o
65obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o 65obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o
66obj-$(CONFIG_LEDS_PM8941_WLED) += leds-pm8941-wled.o
67obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o 66obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o
68 67
69# LED SPI Drivers 68# LED SPI Drivers
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 0505b796d743..5ffa4b4e26c0 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -299,6 +299,13 @@ config BACKLIGHT_TOSA
299 If you have an Sharp SL-6000 Zaurus say Y to enable a driver 299 If you have an Sharp SL-6000 Zaurus say Y to enable a driver
300 for its backlight 300 for its backlight
301 301
302config BACKLIGHT_PM8941_WLED
303 tristate "Qualcomm PM8941 WLED Driver"
304 select REGMAP
305 help
306 If you have the Qualcomm PM8941, say Y to enable a driver for the
307 WLED block.
308
302config BACKLIGHT_SAHARA 309config BACKLIGHT_SAHARA
303 tristate "Tabletkiosk Sahara Touch-iT Backlight Driver" 310 tristate "Tabletkiosk Sahara Touch-iT Backlight Driver"
304 depends on X86 311 depends on X86
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index d67073f9d421..16ec534cff30 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
48obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o 48obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o
49obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o 49obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o
50obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o 50obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
51obj-$(CONFIG_BACKLIGHT_PM8941_WLED) += pm8941-wled.o
51obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o 52obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
52obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o 53obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o
53obj-$(CONFIG_BACKLIGHT_SKY81452) += sky81452-backlight.o 54obj-$(CONFIG_BACKLIGHT_SKY81452) += sky81452-backlight.o
diff --git a/drivers/leds/leds-pm8941-wled.c b/drivers/video/backlight/pm8941-wled.c
index bf64a593fbf1..c704c3236034 100644
--- a/drivers/leds/leds-pm8941-wled.c
+++ b/drivers/video/backlight/pm8941-wled.c
@@ -11,7 +11,7 @@
11 */ 11 */
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/leds.h> 14#include <linux/backlight.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/of_device.h> 17#include <linux/of_device.h>
@@ -76,30 +76,29 @@ struct pm8941_wled_config {
76}; 76};
77 77
78struct pm8941_wled { 78struct pm8941_wled {
79 const char *name;
79 struct regmap *regmap; 80 struct regmap *regmap;
80 u16 addr; 81 u16 addr;
81 82
82 struct led_classdev cdev;
83
84 struct pm8941_wled_config cfg; 83 struct pm8941_wled_config cfg;
85}; 84};
86 85
87static int pm8941_wled_set(struct led_classdev *cdev, 86static int pm8941_wled_update_status(struct backlight_device *bl)
88 enum led_brightness value)
89{ 87{
90 struct pm8941_wled *wled; 88 struct pm8941_wled *wled = bl_get_data(bl);
89 u16 val = bl->props.brightness;
91 u8 ctrl = 0; 90 u8 ctrl = 0;
92 u16 val;
93 int rc; 91 int rc;
94 int i; 92 int i;
95 93
96 wled = container_of(cdev, struct pm8941_wled, cdev); 94 if (bl->props.power != FB_BLANK_UNBLANK ||
95 bl->props.fb_blank != FB_BLANK_UNBLANK ||
96 bl->props.state & BL_CORE_FBBLANK)
97 val = 0;
97 98
98 if (value != 0) 99 if (val != 0)
99 ctrl = PM8941_WLED_REG_MOD_EN_BIT; 100 ctrl = PM8941_WLED_REG_MOD_EN_BIT;
100 101
101 val = value * PM8941_WLED_REG_VAL_MAX / LED_FULL;
102
103 rc = regmap_update_bits(wled->regmap, 102 rc = regmap_update_bits(wled->regmap,
104 wled->addr + PM8941_WLED_REG_MOD_EN, 103 wled->addr + PM8941_WLED_REG_MOD_EN,
105 PM8941_WLED_REG_MOD_EN_MASK, ctrl); 104 PM8941_WLED_REG_MOD_EN_MASK, ctrl);
@@ -128,16 +127,6 @@ static int pm8941_wled_set(struct led_classdev *cdev,
128 return rc; 127 return rc;
129} 128}
130 129
131static void pm8941_wled_set_brightness(struct led_classdev *cdev,
132 enum led_brightness value)
133{
134 if (pm8941_wled_set(cdev, value)) {
135 dev_err(cdev->dev, "Unable to set brightness\n");
136 return;
137 }
138 cdev->brightness = value;
139}
140
141static int pm8941_wled_setup(struct pm8941_wled *wled) 130static int pm8941_wled_setup(struct pm8941_wled *wled)
142{ 131{
143 int rc; 132 int rc;
@@ -336,12 +325,9 @@ static int pm8941_wled_configure(struct pm8941_wled *wled, struct device *dev)
336 } 325 }
337 wled->addr = val; 326 wled->addr = val;
338 327
339 rc = of_property_read_string(dev->of_node, "label", &wled->cdev.name); 328 rc = of_property_read_string(dev->of_node, "label", &wled->name);
340 if (rc) 329 if (rc)
341 wled->cdev.name = dev->of_node->name; 330 wled->name = dev->of_node->name;
342
343 wled->cdev.default_trigger = of_get_property(dev->of_node,
344 "linux,default-trigger", NULL);
345 331
346 *cfg = pm8941_wled_config_defaults; 332 *cfg = pm8941_wled_config_defaults;
347 for (i = 0; i < ARRAY_SIZE(u32_opts); ++i) { 333 for (i = 0; i < ARRAY_SIZE(u32_opts); ++i) {
@@ -377,8 +363,14 @@ static int pm8941_wled_configure(struct pm8941_wled *wled, struct device *dev)
377 return 0; 363 return 0;
378} 364}
379 365
366static const struct backlight_ops pm8941_wled_ops = {
367 .update_status = pm8941_wled_update_status,
368};
369
380static int pm8941_wled_probe(struct platform_device *pdev) 370static int pm8941_wled_probe(struct platform_device *pdev)
381{ 371{
372 struct backlight_properties props;
373 struct backlight_device *bl;
382 struct pm8941_wled *wled; 374 struct pm8941_wled *wled;
383 struct regmap *regmap; 375 struct regmap *regmap;
384 int rc; 376 int rc;
@@ -403,13 +395,14 @@ static int pm8941_wled_probe(struct platform_device *pdev)
403 if (rc) 395 if (rc)
404 return rc; 396 return rc;
405 397
406 wled->cdev.brightness_set = pm8941_wled_set_brightness; 398 memset(&props, 0, sizeof(struct backlight_properties));
407 399 props.type = BACKLIGHT_RAW;
408 rc = devm_led_classdev_register(&pdev->dev, &wled->cdev); 400 props.max_brightness = PM8941_WLED_REG_VAL_MAX;
409 if (rc) 401 bl = devm_backlight_device_register(&pdev->dev, wled->name,
410 return rc; 402 &pdev->dev, wled,
411 403 &pm8941_wled_ops, &props);
412 platform_set_drvdata(pdev, wled); 404 if (IS_ERR(bl))
405 return PTR_ERR(bl);
413 406
414 return 0; 407 return 0;
415}; 408};
@@ -432,4 +425,3 @@ module_platform_driver(pm8941_wled_driver);
432 425
433MODULE_DESCRIPTION("pm8941 wled driver"); 426MODULE_DESCRIPTION("pm8941 wled driver");
434MODULE_LICENSE("GPL v2"); 427MODULE_LICENSE("GPL v2");
435MODULE_ALIAS("platform:pm8941-wled");