Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bjorn Andersson and committed by
Lee Jones
7ddbc242 fe009175

+35 -47
+1 -4
Documentation/devicetree/bindings/leds/leds-pm8941-wled.txt Documentation/devicetree/bindings/video/backlight/pm8941-wled.txt
··· 5 5 - reg: slave address 6 6 7 7 Optional properties: 8 - - label: The label for this led 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 8 + - label: The name of the backlight device 12 9 - qcom,cs-out: bool; enable current sink output 13 10 - qcom,cabc: bool; enable content adaptive backlight control 14 11 - qcom,ext-gen: bool; use externally generated modulator signal to dim
-8
drivers/leds/Kconfig
··· 578 578 This option enabled support for the LEDs on the ARM Versatile 579 579 and RealView boards. Say Y to enabled these. 580 580 581 - config 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 - 589 581 comment "LED Triggers" 590 582 source "drivers/leds/trigger/Kconfig" 591 583
-1
drivers/leds/Makefile
··· 63 63 obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o 64 64 obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o 65 65 obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o 66 - obj-$(CONFIG_LEDS_PM8941_WLED) += leds-pm8941-wled.o 67 66 obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o 68 67 69 68 # LED SPI Drivers
+26 -34
drivers/leds/leds-pm8941-wled.c drivers/video/backlight/pm8941-wled.c
··· 11 11 */ 12 12 13 13 #include <linux/kernel.h> 14 - #include <linux/leds.h> 14 + #include <linux/backlight.h> 15 15 #include <linux/module.h> 16 16 #include <linux/of.h> 17 17 #include <linux/of_device.h> ··· 76 76 }; 77 77 78 78 struct pm8941_wled { 79 + const char *name; 79 80 struct regmap *regmap; 80 81 u16 addr; 81 - 82 - struct led_classdev cdev; 83 82 84 83 struct pm8941_wled_config cfg; 85 84 }; 86 85 87 - static int pm8941_wled_set(struct led_classdev *cdev, 88 - enum led_brightness value) 86 + static int pm8941_wled_update_status(struct backlight_device *bl) 89 87 { 90 - struct pm8941_wled *wled; 88 + struct pm8941_wled *wled = bl_get_data(bl); 89 + u16 val = bl->props.brightness; 91 90 u8 ctrl = 0; 92 - u16 val; 93 91 int rc; 94 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 100 ctrl = PM8941_WLED_REG_MOD_EN_BIT; 100 - 101 - val = value * PM8941_WLED_REG_VAL_MAX / LED_FULL; 102 101 103 102 rc = regmap_update_bits(wled->regmap, 104 103 wled->addr + PM8941_WLED_REG_MOD_EN, ··· 125 126 wled->addr + PM8941_WLED_REG_SYNC, 126 127 PM8941_WLED_REG_SYNC_MASK, PM8941_WLED_REG_SYNC_CLEAR); 127 128 return rc; 128 - } 129 - 130 - static void pm8941_wled_set_brightness(struct led_classdev *cdev, 131 - enum led_brightness value) 132 - { 133 - if (pm8941_wled_set(cdev, value)) { 134 - dev_err(cdev->dev, "Unable to set brightness\n"); 135 - return; 136 - } 137 - cdev->brightness = value; 138 129 } 139 130 140 131 static int pm8941_wled_setup(struct pm8941_wled *wled) ··· 325 336 } 326 337 wled->addr = val; 327 338 328 - rc = of_property_read_string(dev->of_node, "label", &wled->cdev.name); 339 + rc = of_property_read_string(dev->of_node, "label", &wled->name); 329 340 if (rc) 330 - wled->cdev.name = dev->of_node->name; 331 - 332 - wled->cdev.default_trigger = of_get_property(dev->of_node, 333 - "linux,default-trigger", NULL); 341 + wled->name = dev->of_node->name; 334 342 335 343 *cfg = pm8941_wled_config_defaults; 336 344 for (i = 0; i < ARRAY_SIZE(u32_opts); ++i) { ··· 363 377 return 0; 364 378 } 365 379 380 + static const struct backlight_ops pm8941_wled_ops = { 381 + .update_status = pm8941_wled_update_status, 382 + }; 383 + 366 384 static int pm8941_wled_probe(struct platform_device *pdev) 367 385 { 386 + struct backlight_properties props; 387 + struct backlight_device *bl; 368 388 struct pm8941_wled *wled; 369 389 struct regmap *regmap; 370 390 int rc; ··· 395 403 if (rc) 396 404 return rc; 397 405 398 - wled->cdev.brightness_set = pm8941_wled_set_brightness; 399 - 400 - rc = devm_led_classdev_register(&pdev->dev, &wled->cdev); 401 - if (rc) 402 - return rc; 403 - 404 - platform_set_drvdata(pdev, wled); 406 + memset(&props, 0, sizeof(struct backlight_properties)); 407 + props.type = BACKLIGHT_RAW; 408 + props.max_brightness = PM8941_WLED_REG_VAL_MAX; 409 + bl = devm_backlight_device_register(&pdev->dev, wled->name, 410 + &pdev->dev, wled, 411 + &pm8941_wled_ops, &props); 412 + if (IS_ERR(bl)) 413 + return PTR_ERR(bl); 405 414 406 415 return 0; 407 416 }; ··· 425 432 426 433 MODULE_DESCRIPTION("pm8941 wled driver"); 427 434 MODULE_LICENSE("GPL v2"); 428 - MODULE_ALIAS("platform:pm8941-wled");
+7
drivers/video/backlight/Kconfig
··· 299 299 If you have an Sharp SL-6000 Zaurus say Y to enable a driver 300 300 for its backlight 301 301 302 + config 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 + 302 309 config BACKLIGHT_SAHARA 303 310 tristate "Tabletkiosk Sahara Touch-iT Backlight Driver" 304 311 depends on X86
+1
drivers/video/backlight/Makefile
··· 48 48 obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o 49 49 obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o 50 50 obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o 51 + obj-$(CONFIG_BACKLIGHT_PM8941_WLED) += pm8941-wled.o 51 52 obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o 52 53 obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o 53 54 obj-$(CONFIG_BACKLIGHT_SKY81452) += sky81452-backlight.o