提交 7ddbc242 编写于 作者: B Bjorn Andersson 提交者: Lee Jones

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: NBjorn Andersson <bjorn.andersson@sonymobile.com>
Tested-by: NRob Clark <robdclark@gmail.com>
Acked-by: NJacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: NJingoo Han <jingoohan1@gmail.com>
Signed-off-by: NLee Jones <lee.jones@linaro.org>
上级 fe009175
...@@ -5,10 +5,7 @@ Required properties: ...@@ -5,10 +5,7 @@ Required properties:
- reg: slave address - reg: slave address
Optional properties: Optional properties:
- label: The label for this led - label: The name of the backlight device
See Documentation/devicetree/bindings/leds/common.txt
- linux,default-trigger: Default trigger assigned to the LED
See Documentation/devicetree/bindings/leds/common.txt
- qcom,cs-out: bool; enable current sink output - qcom,cs-out: bool; enable current sink output
- qcom,cabc: bool; enable content adaptive backlight control - qcom,cabc: bool; enable content adaptive backlight control
- qcom,ext-gen: bool; use externally generated modulator signal to dim - qcom,ext-gen: bool; use externally generated modulator signal to dim
......
...@@ -578,14 +578,6 @@ config LEDS_VERSATILE ...@@ -578,14 +578,6 @@ config LEDS_VERSATILE
This option enabled support for the LEDs on the ARM Versatile This option enabled support for the LEDs on the ARM Versatile
and RealView boards. Say Y to enabled these. and RealView boards. Say Y to enabled these.
config LEDS_PM8941_WLED
tristate "LED support for the Qualcomm PM8941 WLED block"
depends on LEDS_CLASS
select REGMAP
help
This option enables support for the 'White' LED block
on Qualcomm PM8941 PMICs.
comment "LED Triggers" comment "LED Triggers"
source "drivers/leds/trigger/Kconfig" source "drivers/leds/trigger/Kconfig"
......
...@@ -63,7 +63,6 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o ...@@ -63,7 +63,6 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o
obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o
obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o
obj-$(CONFIG_LEDS_PM8941_WLED) += leds-pm8941-wled.o
obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o
# LED SPI Drivers # LED SPI Drivers
......
...@@ -299,6 +299,13 @@ config BACKLIGHT_TOSA ...@@ -299,6 +299,13 @@ config BACKLIGHT_TOSA
If you have an Sharp SL-6000 Zaurus say Y to enable a driver If you have an Sharp SL-6000 Zaurus say Y to enable a driver
for its backlight for its backlight
config BACKLIGHT_PM8941_WLED
tristate "Qualcomm PM8941 WLED Driver"
select REGMAP
help
If you have the Qualcomm PM8941, say Y to enable a driver for the
WLED block.
config BACKLIGHT_SAHARA config BACKLIGHT_SAHARA
tristate "Tabletkiosk Sahara Touch-iT Backlight Driver" tristate "Tabletkiosk Sahara Touch-iT Backlight Driver"
depends on X86 depends on X86
......
...@@ -48,6 +48,7 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o ...@@ -48,6 +48,7 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o
obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o
obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
obj-$(CONFIG_BACKLIGHT_PM8941_WLED) += pm8941-wled.o
obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o
obj-$(CONFIG_BACKLIGHT_SKY81452) += sky81452-backlight.o obj-$(CONFIG_BACKLIGHT_SKY81452) += sky81452-backlight.o
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/leds.h> #include <linux/backlight.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -76,30 +76,29 @@ struct pm8941_wled_config { ...@@ -76,30 +76,29 @@ struct pm8941_wled_config {
}; };
struct pm8941_wled { struct pm8941_wled {
const char *name;
struct regmap *regmap; struct regmap *regmap;
u16 addr; u16 addr;
struct led_classdev cdev;
struct pm8941_wled_config cfg; struct pm8941_wled_config cfg;
}; };
static int pm8941_wled_set(struct led_classdev *cdev, static int pm8941_wled_update_status(struct backlight_device *bl)
enum led_brightness value)
{ {
struct pm8941_wled *wled; struct pm8941_wled *wled = bl_get_data(bl);
u16 val = bl->props.brightness;
u8 ctrl = 0; u8 ctrl = 0;
u16 val;
int rc; int rc;
int i; int i;
wled = container_of(cdev, struct pm8941_wled, cdev); if (bl->props.power != FB_BLANK_UNBLANK ||
bl->props.fb_blank != FB_BLANK_UNBLANK ||
bl->props.state & BL_CORE_FBBLANK)
val = 0;
if (value != 0) if (val != 0)
ctrl = PM8941_WLED_REG_MOD_EN_BIT; ctrl = PM8941_WLED_REG_MOD_EN_BIT;
val = value * PM8941_WLED_REG_VAL_MAX / LED_FULL;
rc = regmap_update_bits(wled->regmap, rc = regmap_update_bits(wled->regmap,
wled->addr + PM8941_WLED_REG_MOD_EN, wled->addr + PM8941_WLED_REG_MOD_EN,
PM8941_WLED_REG_MOD_EN_MASK, ctrl); PM8941_WLED_REG_MOD_EN_MASK, ctrl);
...@@ -128,16 +127,6 @@ static int pm8941_wled_set(struct led_classdev *cdev, ...@@ -128,16 +127,6 @@ static int pm8941_wled_set(struct led_classdev *cdev,
return rc; return rc;
} }
static void pm8941_wled_set_brightness(struct led_classdev *cdev,
enum led_brightness value)
{
if (pm8941_wled_set(cdev, value)) {
dev_err(cdev->dev, "Unable to set brightness\n");
return;
}
cdev->brightness = value;
}
static int pm8941_wled_setup(struct pm8941_wled *wled) static int pm8941_wled_setup(struct pm8941_wled *wled)
{ {
int rc; int rc;
...@@ -336,12 +325,9 @@ static int pm8941_wled_configure(struct pm8941_wled *wled, struct device *dev) ...@@ -336,12 +325,9 @@ static int pm8941_wled_configure(struct pm8941_wled *wled, struct device *dev)
} }
wled->addr = val; wled->addr = val;
rc = of_property_read_string(dev->of_node, "label", &wled->cdev.name); rc = of_property_read_string(dev->of_node, "label", &wled->name);
if (rc) if (rc)
wled->cdev.name = dev->of_node->name; wled->name = dev->of_node->name;
wled->cdev.default_trigger = of_get_property(dev->of_node,
"linux,default-trigger", NULL);
*cfg = pm8941_wled_config_defaults; *cfg = pm8941_wled_config_defaults;
for (i = 0; i < ARRAY_SIZE(u32_opts); ++i) { 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,8 +363,14 @@ static int pm8941_wled_configure(struct pm8941_wled *wled, struct device *dev)
return 0; return 0;
} }
static const struct backlight_ops pm8941_wled_ops = {
.update_status = pm8941_wled_update_status,
};
static int pm8941_wled_probe(struct platform_device *pdev) static int pm8941_wled_probe(struct platform_device *pdev)
{ {
struct backlight_properties props;
struct backlight_device *bl;
struct pm8941_wled *wled; struct pm8941_wled *wled;
struct regmap *regmap; struct regmap *regmap;
int rc; int rc;
...@@ -403,13 +395,14 @@ static int pm8941_wled_probe(struct platform_device *pdev) ...@@ -403,13 +395,14 @@ static int pm8941_wled_probe(struct platform_device *pdev)
if (rc) if (rc)
return rc; return rc;
wled->cdev.brightness_set = pm8941_wled_set_brightness; memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
rc = devm_led_classdev_register(&pdev->dev, &wled->cdev); props.max_brightness = PM8941_WLED_REG_VAL_MAX;
if (rc) bl = devm_backlight_device_register(&pdev->dev, wled->name,
return rc; &pdev->dev, wled,
&pm8941_wled_ops, &props);
platform_set_drvdata(pdev, wled); if (IS_ERR(bl))
return PTR_ERR(bl);
return 0; return 0;
}; };
...@@ -432,4 +425,3 @@ module_platform_driver(pm8941_wled_driver); ...@@ -432,4 +425,3 @@ module_platform_driver(pm8941_wled_driver);
MODULE_DESCRIPTION("pm8941 wled driver"); MODULE_DESCRIPTION("pm8941 wled driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:pm8941-wled");
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册