Commit e0d97b04 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'backlight-next-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
 "New Drivers:
   - Texas Instruments LM3509 Backlight Driver

  Fix-ups:
   - Device Tree binding adaptions/conversions/creation
   - Drop i2c_device_id::driver_data where the value is unused
   - Make use of the new *_scoped() guard APIs
   - Decouple from fbdev by providing Backlight with its own
     BACKLIGHT_POWER_* constrains

  Bug Fixes:
   - Correctly assess return values (NULL vs IS_ERR())
   - Supply a bunch of MODULE_DESCRIPTIONs to silence modpost warnings"

* tag 'backlight-next-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: (23 commits)
  backlight: sky81452-backlight: Use backlight power constants
  backlight: rave-sp-backlight: Use backlight power constants
  backlight: pwm-backlight: Use backlight power constants
  backlight: pcf50633-backlight: Use backlight power constants
  backlight: pandora-backlight: Use backlight power constants
  backlight: mp3309c: Use backlight power constants
  backlight: lm3533-backlight: Use backlight power constants
  backlight: led-backlight: Use backlight power constants
  backlight: ktd253-backlight: Use backlight power constants
  backlight: kb3886-bl: Use backlight power constants
  backlight: journada_bl: Use backlight power constants
  backlight: ipaq-micro-backlight: Use backlight power constants
  backlight: gpio-backlight: Use backlight power constants
  backlight: corgi-lcd: Use backlight power constants
  backlight: ams369fb06: Use backlight power constants
  backlight: aat2870-backlight: Use blacklight power constants
  backlight: Add BACKLIGHT_POWER_ constants for power states
  backlight: lm3509_bl: Fix early returns in for_each_child_of_node()
  backlight: Drop explicit initialization of struct i2c_device_id::driver_data to 0
  backlight: Add missing MODULE_DESCRIPTION() macros
  ...
parents 1200af3a 1df5aa37
......@@ -3,10 +3,11 @@ Date: April 2005
KernelVersion: 2.6.12
Contact: Richard Purdie <rpurdie@rpsys.net>
Description:
Control BACKLIGHT power, values are FB_BLANK_* from fb.h
Control BACKLIGHT power, values are compatible with
FB_BLANK_* from fb.h
- FB_BLANK_UNBLANK (0) : power on.
- FB_BLANK_POWERDOWN (4) : power off
- 0 (FB_BLANK_UNBLANK) : power on.
- 4 (FB_BLANK_POWERDOWN) : power off
Users: HAL
What: /sys/class/backlight/<backlight>/brightness
......
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/backlight/ti,lm3509.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: TI LM3509 High Efficiency Boost for White LED's and/or OLED Displays
maintainers:
- Patrick Gansterer <paroga@paroga.com>
description:
The LM3509 current mode boost converter offers two separate outputs.
https://www.ti.com/product/LM3509
properties:
compatible:
const: ti,lm3509
reg:
maxItems: 1
"#address-cells":
const: 1
"#size-cells":
const: 0
reset-gpios:
maxItems: 1
ti,brightness-rate-of-change-us:
description: Brightness Rate of Change in microseconds.
enum: [51, 13000, 26000, 52000]
ti,oled-mode:
description: Enable OLED mode.
type: boolean
patternProperties:
"^led@[01]$":
type: object
description: Properties for a string of connected LEDs.
$ref: common.yaml#
properties:
reg:
description:
The control register that is used to program the two current sinks.
The LM3509 has two registers (BMAIN and BSUB) and are represented
as 0 or 1 in this property. The two current sinks can be controlled
independently with both registers, or register BMAIN can be
configured to control both sinks with the led-sources property.
minimum: 0
maximum: 1
label: true
led-sources:
minItems: 1
maxItems: 2
items:
minimum: 0
maximum: 1
default-brightness:
minimum: 0
maximum: 31
default: 18
max-brightness:
minimum: 0
maximum: 31
default: 31
required:
- reg
additionalProperties: false
required:
- compatible
- reg
additionalProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
backlight@36 {
compatible = "ti,lm3509";
reg = <0x36>;
reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
ti,oled-mode;
ti,brightness-rate-of-change-us = <52000>;
#address-cells = <1>;
#size-cells = <0>;
led@0 {
reg = <0>;
led-sources = <0 1>;
label = "lcd-backlight";
default-brightness = <12>;
max-brightness = <31>;
};
};
};
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
backlight@36 {
compatible = "ti,lm3509";
reg = <0x36>;
#address-cells = <1>;
#size-cells = <0>;
led@0 {
reg = <0>;
default-brightness = <12>;
};
led@1 {
reg = <1>;
default-brightness = <15>;
};
};
};
......@@ -373,6 +373,13 @@ config BACKLIGHT_AAT2870
If you have a AnalogicTech AAT2870 say Y to enable the
backlight driver.
config BACKLIGHT_LM3509
tristate "Backlight Driver for LM3509"
depends on I2C
select REGMAP_I2C
help
This supports TI LM3509 Backlight Driver
config BACKLIGHT_LM3630A
tristate "Backlight Driver for LM3630A"
depends on I2C && PWM
......
......@@ -36,6 +36,7 @@ obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO) += ipaq_micro_bl.o
obj-$(CONFIG_BACKLIGHT_KTD253) += ktd253-backlight.o
obj-$(CONFIG_BACKLIGHT_KTD2801) += ktd2801-backlight.o
obj-$(CONFIG_BACKLIGHT_KTZ8866) += ktz8866.o
obj-$(CONFIG_BACKLIGHT_LM3509) += lm3509_bl.o
obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o
obj-$(CONFIG_BACKLIGHT_LM3630A) += lm3630a_bl.o
obj-$(CONFIG_BACKLIGHT_LM3639) += lm3639_bl.o
......
......@@ -156,7 +156,7 @@ static int aat2870_bl_probe(struct platform_device *pdev)
bd->props.max_brightness = 255;
aat2870_bl->brightness = 0;
bd->props.power = FB_BLANK_UNBLANK;
bd->props.power = BACKLIGHT_POWER_ON;
bd->props.brightness = bd->props.max_brightness;
ret = aat2870_bl_update_status(bd);
......@@ -176,7 +176,7 @@ static void aat2870_bl_remove(struct platform_device *pdev)
struct aat2870_bl_driver_data *aat2870_bl = platform_get_drvdata(pdev);
struct backlight_device *bd = aat2870_bl->bd;
bd->props.power = FB_BLANK_POWERDOWN;
bd->props.power = BACKLIGHT_POWER_OFF;
bd->props.brightness = 0;
backlight_update_status(bd);
}
......
......@@ -963,7 +963,7 @@ static SIMPLE_DEV_PM_OPS(adp8870_i2c_pm_ops, adp8870_i2c_suspend,
adp8870_i2c_resume);
static const struct i2c_device_id adp8870_id[] = {
{ "adp8870", 0 },
{ "adp8870" },
{ }
};
MODULE_DEVICE_TABLE(i2c, adp8870_id);
......
......@@ -10,7 +10,6 @@
#include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/fb.h>
#include <linux/lcd.h>
#include <linux/module.h>
#include <linux/spi/spi.h>
......@@ -300,7 +299,7 @@ static int ams369fg06_ldi_disable(struct ams369fg06 *lcd)
static int ams369fg06_power_is_on(int power)
{
return power <= FB_BLANK_NORMAL;
return power <= BACKLIGHT_POWER_REDUCED;
}
static int ams369fg06_power_on(struct ams369fg06 *lcd)
......@@ -396,8 +395,8 @@ static int ams369fg06_set_power(struct lcd_device *ld, int power)
{
struct ams369fg06 *lcd = lcd_get_data(ld);
if (power != FB_BLANK_UNBLANK && power != FB_BLANK_POWERDOWN &&
power != FB_BLANK_NORMAL) {
if (power != BACKLIGHT_POWER_ON && power != BACKLIGHT_POWER_OFF &&
power != BACKLIGHT_POWER_REDUCED) {
dev_err(lcd->dev, "power value should be 0, 1 or 4.\n");
return -EINVAL;
}
......@@ -492,11 +491,11 @@ static int ams369fg06_probe(struct spi_device *spi)
* current lcd status is powerdown and then
* it enables lcd panel.
*/
lcd->power = FB_BLANK_POWERDOWN;
lcd->power = BACKLIGHT_POWER_OFF;
ams369fg06_power(lcd, FB_BLANK_UNBLANK);
ams369fg06_power(lcd, BACKLIGHT_POWER_ON);
} else {
lcd->power = FB_BLANK_UNBLANK;
lcd->power = BACKLIGHT_POWER_ON;
}
spi_set_drvdata(spi, lcd);
......@@ -510,7 +509,7 @@ static void ams369fg06_remove(struct spi_device *spi)
{
struct ams369fg06 *lcd = spi_get_drvdata(spi);
ams369fg06_power(lcd, FB_BLANK_POWERDOWN);
ams369fg06_power(lcd, BACKLIGHT_POWER_OFF);
}
#ifdef CONFIG_PM_SLEEP
......@@ -524,16 +523,16 @@ static int ams369fg06_suspend(struct device *dev)
* when lcd panel is suspend, lcd panel becomes off
* regardless of status.
*/
return ams369fg06_power(lcd, FB_BLANK_POWERDOWN);
return ams369fg06_power(lcd, BACKLIGHT_POWER_OFF);
}
static int ams369fg06_resume(struct device *dev)
{
struct ams369fg06 *lcd = dev_get_drvdata(dev);
lcd->power = FB_BLANK_POWERDOWN;
lcd->power = BACKLIGHT_POWER_OFF;
return ams369fg06_power(lcd, FB_BLANK_UNBLANK);
return ams369fg06_power(lcd, BACKLIGHT_POWER_ON);
}
#endif
......@@ -544,7 +543,7 @@ static void ams369fg06_shutdown(struct spi_device *spi)
{
struct ams369fg06 *lcd = spi_get_drvdata(spi);
ams369fg06_power(lcd, FB_BLANK_POWERDOWN);
ams369fg06_power(lcd, BACKLIGHT_POWER_OFF);
}
static struct spi_driver ams369fg06_driver = {
......
......@@ -180,7 +180,7 @@ static void bd6107_remove(struct i2c_client *client)
}
static const struct i2c_device_id bd6107_ids[] = {
{ "bd6107", 0 },
{ "bd6107" },
{ }
};
MODULE_DEVICE_TABLE(i2c, bd6107_ids);
......
......@@ -526,7 +526,7 @@ static int corgi_lcd_probe(struct spi_device *spi)
return PTR_ERR(lcd->bl_dev);
lcd->bl_dev->props.brightness = pdata->default_intensity;
lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
lcd->bl_dev->props.power = BACKLIGHT_POWER_ON;
ret = setup_gpio_backlight(lcd, pdata);
if (ret)
......@@ -547,7 +547,7 @@ static void corgi_lcd_remove(struct spi_device *spi)
{
struct corgi_lcd *lcd = spi_get_drvdata(spi);
lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
lcd->bl_dev->props.power = BACKLIGHT_POWER_ON;
lcd->bl_dev->props.brightness = 0;
backlight_update_status(lcd->bl_dev);
corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
......
......@@ -5,7 +5,6 @@
#include <linux/backlight.h>
#include <linux/err.h>
#include <linux/fb.h>
#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/kernel.h>
......@@ -81,12 +80,12 @@ static int gpio_backlight_probe(struct platform_device *pdev)
/* Set the initial power state */
if (!of_node || !of_node->phandle)
/* Not booted with device tree or no phandle link to the node */
bl->props.power = def_value ? FB_BLANK_UNBLANK
: FB_BLANK_POWERDOWN;
bl->props.power = def_value ? BACKLIGHT_POWER_ON
: BACKLIGHT_POWER_OFF;
else if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
bl->props.power = FB_BLANK_POWERDOWN;
bl->props.power = BACKLIGHT_POWER_OFF;
else
bl->props.power = FB_BLANK_UNBLANK;
bl->props.power = BACKLIGHT_POWER_ON;
bl->props.brightness = 1;
......
......@@ -7,7 +7,6 @@
#include <linux/backlight.h>
#include <linux/err.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/mfd/ipaq-micro.h>
#include <linux/module.h>
......@@ -42,7 +41,7 @@ static const struct backlight_ops micro_bl_ops = {
static const struct backlight_properties micro_bl_props = {
.type = BACKLIGHT_RAW,
.max_brightness = 255,
.power = FB_BLANK_UNBLANK,
.power = BACKLIGHT_POWER_ON,
.brightness = 64,
};
......
......@@ -7,7 +7,6 @@
#include <linux/backlight.h>
#include <linux/device.h>
#include <linux/fb.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
......@@ -121,7 +120,7 @@ static int jornada_bl_probe(struct platform_device *pdev)
return ret;
}
bd->props.power = FB_BLANK_UNBLANK;
bd->props.power = BACKLIGHT_POWER_ON;
bd->props.brightness = BL_DEF_BRIGHT;
/*
* note. make sure max brightness is set otherwise
......
......@@ -10,9 +10,9 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>
#include <linux/fb.h>
#include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/dmi.h>
......@@ -151,7 +151,7 @@ static int kb3886bl_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, kb3886_backlight_device);
kb3886_backlight_device->props.power = FB_BLANK_UNBLANK;
kb3886_backlight_device->props.power = BACKLIGHT_POWER_ON;
kb3886_backlight_device->props.brightness = machinfo->default_intensity;
backlight_update_status(kb3886_backlight_device);
......
......@@ -7,7 +7,6 @@
#include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/fb.h>
#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/kernel.h>
......@@ -190,10 +189,10 @@ static int ktd253_backlight_probe(struct platform_device *pdev)
/* When we just enable the GPIO line we set max brightness */
if (brightness) {
bl->props.brightness = brightness;
bl->props.power = FB_BLANK_UNBLANK;
bl->props.power = BACKLIGHT_POWER_ON;
} else {
bl->props.brightness = 0;
bl->props.power = FB_BLANK_POWERDOWN;
bl->props.power = BACKLIGHT_POWER_OFF;
}
ktd253->bl = bl;
......
......@@ -179,8 +179,8 @@ static void ktz8866_remove(struct i2c_client *client)
}
static const struct i2c_device_id ktz8866_ids[] = {
{ "ktz8866", 0 },
{},
{ "ktz8866" },
{}
};
MODULE_DEVICE_TABLE(i2c, ktz8866_ids);
......
......@@ -200,8 +200,8 @@ static int led_bl_probe(struct platform_device *pdev)
props.type = BACKLIGHT_RAW;
props.max_brightness = priv->max_brightness;
props.brightness = priv->default_brightness;
props.power = (priv->default_brightness > 0) ? FB_BLANK_POWERDOWN :
FB_BLANK_UNBLANK;
props.power = (priv->default_brightness > 0) ? BACKLIGHT_POWER_OFF :
BACKLIGHT_POWER_ON;
priv->bl_dev = backlight_device_register(dev_name(&pdev->dev),
&pdev->dev, priv, &led_bl_ops, &props);
if (IS_ERR(priv->bl_dev)) {
......
// SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
#define LM3509_NAME "lm3509_bl"
#define LM3509_SINK_MAIN 0
#define LM3509_SINK_SUB 1
#define LM3509_NUM_SINKS 2
#define LM3509_DEF_BRIGHTNESS 0x12
#define LM3509_MAX_BRIGHTNESS 0x1F
#define REG_GP 0x10
#define REG_BMAIN 0xA0
#define REG_BSUB 0xB0
#define REG_MAX 0xFF
enum {
REG_GP_ENM_BIT = 0,
REG_GP_ENS_BIT,
REG_GP_UNI_BIT,
REG_GP_RMP0_BIT,
REG_GP_RMP1_BIT,
REG_GP_OLED_BIT,
};
struct lm3509_bl {
struct regmap *regmap;
struct backlight_device *bl_main;
struct backlight_device *bl_sub;
struct gpio_desc *reset_gpio;
};
struct lm3509_bl_led_data {
const char *label;
int led_sources;
u32 brightness;
u32 max_brightness;
};
static void lm3509_reset(struct lm3509_bl *data)
{
if (data->reset_gpio) {
gpiod_set_value(data->reset_gpio, 1);
udelay(1);
gpiod_set_value(data->reset_gpio, 0);
udelay(10);
}
}
static int lm3509_update_status(struct backlight_device *bl,
unsigned int en_mask, unsigned int br_reg)
{
struct lm3509_bl *data = bl_get_data(bl);
int ret;
bool en;
ret = regmap_write(data->regmap, br_reg, backlight_get_brightness(bl));
if (ret < 0)
return ret;
en = !backlight_is_blank(bl);
return regmap_update_bits(data->regmap, REG_GP, en_mask,
en ? en_mask : 0);
}
static int lm3509_main_update_status(struct backlight_device *bl)
{
return lm3509_update_status(bl, BIT(REG_GP_ENM_BIT), REG_BMAIN);
}
static const struct backlight_ops lm3509_main_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = lm3509_main_update_status,
};
static int lm3509_sub_update_status(struct backlight_device *bl)
{
return lm3509_update_status(bl, BIT(REG_GP_ENS_BIT), REG_BSUB);
}
static const struct backlight_ops lm3509_sub_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = lm3509_sub_update_status,
};
static struct backlight_device *
lm3509_backlight_register(struct device *dev, const char *name_suffix,
struct lm3509_bl *data,
const struct backlight_ops *ops,
const struct lm3509_bl_led_data *led_data)
{
struct backlight_device *bd;
struct backlight_properties props;
const char *label = led_data->label;
char name[64];
memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
props.brightness = led_data->brightness;
props.max_brightness = led_data->max_brightness;
props.scale = BACKLIGHT_SCALE_NON_LINEAR;
if (!label) {
snprintf(name, sizeof(name), "lm3509-%s-%s", dev_name(dev),
name_suffix);
label = name;
}
bd = devm_backlight_device_register(dev, label, dev, data, ops, &props);
if (IS_ERR(bd))
return bd;
backlight_update_status(bd);
return bd;
}
static const struct regmap_config lm3509_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = REG_MAX,
};
static int lm3509_parse_led_sources(struct device_node *node,
int default_led_sources)
{
u32 sources[LM3509_NUM_SINKS];
int ret, num_sources, i;
num_sources = of_property_count_u32_elems(node, "led-sources");
if (num_sources < 0)
return default_led_sources;
else if (num_sources > ARRAY_SIZE(sources))
return -EINVAL;
ret = of_property_read_u32_array(node, "led-sources", sources,
num_sources);
if (ret)
return ret;
for (i = 0; i < num_sources; i++) {
if (sources[i] >= LM3509_NUM_SINKS)
return -EINVAL;
ret |= BIT(sources[i]);
}
return ret;
}
static int lm3509_parse_dt_node(struct device *dev,
struct lm3509_bl_led_data *led_data)
{
int seen_led_sources = 0;
for_each_child_of_node_scoped(dev->of_node, child) {
struct lm3509_bl_led_data *ld;
int ret;
u32 reg;
int valid_led_sources;
ret = of_property_read_u32(child, "reg", &reg);
if (ret < 0)
return ret;
if (reg >= LM3509_NUM_SINKS)
return -EINVAL;
ld = &led_data[reg];
ld->led_sources = lm3509_parse_led_sources(child, BIT(reg));
if (ld->led_sources < 0)
return ld->led_sources;
if (reg == 0)
valid_led_sources = BIT(LM3509_SINK_MAIN) |
BIT(LM3509_SINK_SUB);
else
valid_led_sources = BIT(LM3509_SINK_SUB);
if (ld->led_sources != (ld->led_sources & valid_led_sources))
return -EINVAL;
if (seen_led_sources & ld->led_sources)
return -EINVAL;
seen_led_sources |= ld->led_sources;
ld->label = NULL;
of_property_read_string(child, "label", &ld->label);
ld->max_brightness = LM3509_MAX_BRIGHTNESS;
of_property_read_u32(child, "max-brightness",
&ld->max_brightness);
ld->max_brightness =
min_t(u32, ld->max_brightness, LM3509_MAX_BRIGHTNESS);
ld->brightness = LM3509_DEF_BRIGHTNESS;
of_property_read_u32(child, "default-brightness",
&ld->brightness);
ld->brightness = min_t(u32, ld->brightness, ld->max_brightness);
}
return 0;
}
static int lm3509_probe(struct i2c_client *client)
{
struct lm3509_bl *data;
struct device *dev = &client->dev;
int ret;
bool oled_mode = false;
unsigned int reg_gp_val = 0;
struct lm3509_bl_led_data led_data[LM3509_NUM_SINKS];
u32 rate_of_change = 0;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(dev, "i2c functionality check failed\n");
return -EOPNOTSUPP;
}
data = devm_kzalloc(dev, sizeof(struct lm3509_bl), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->regmap = devm_regmap_init_i2c(client, &lm3509_regmap);
if (IS_ERR(data->regmap))
return PTR_ERR(data->regmap);
i2c_set_clientdata(client, data);
data->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(data->reset_gpio))
return dev_err_probe(dev, PTR_ERR(data->reset_gpio),
"Failed to get 'reset' gpio\n");
lm3509_reset(data);
memset(led_data, 0, sizeof(led_data));
ret = lm3509_parse_dt_node(dev, led_data);
if (ret)
return ret;
oled_mode = of_property_read_bool(dev->of_node, "ti,oled-mode");
if (!of_property_read_u32(dev->of_node,
"ti,brightness-rate-of-change-us",
&rate_of_change)) {
switch (rate_of_change) {
case 51:
reg_gp_val = 0;
break;
case 13000:
reg_gp_val = BIT(REG_GP_RMP1_BIT);
break;
case 26000:
reg_gp_val = BIT(REG_GP_RMP0_BIT);
break;
case 52000:
reg_gp_val = BIT(REG_GP_RMP0_BIT) |
BIT(REG_GP_RMP1_BIT);
break;
default:
dev_warn(dev, "invalid rate of change %u\n",
rate_of_change);
break;
}
}
if (led_data[0].led_sources ==
(BIT(LM3509_SINK_MAIN) | BIT(LM3509_SINK_SUB)))
reg_gp_val |= BIT(REG_GP_UNI_BIT);
if (oled_mode)
reg_gp_val |= BIT(REG_GP_OLED_BIT);
ret = regmap_write(data->regmap, REG_GP, reg_gp_val);
if (ret < 0)
return dev_err_probe(dev, ret, "failed to write register\n");
if (led_data[0].led_sources) {
data->bl_main = lm3509_backlight_register(
dev, "main", data, &lm3509_main_ops, &led_data[0]);
if (IS_ERR(data->bl_main)) {
return dev_err_probe(
dev, PTR_ERR(data->bl_main),
"failed to register main backlight\n");
}
}
if (led_data[1].led_sources) {
data->bl_sub = lm3509_backlight_register(
dev, "sub", data, &lm3509_sub_ops, &led_data[1]);
if (IS_ERR(data->bl_sub)) {
return dev_err_probe(
dev, PTR_ERR(data->bl_sub),
"failed to register secondary backlight\n");
}
}
return 0;
}
static void lm3509_remove(struct i2c_client *client)
{
struct lm3509_bl *data = i2c_get_clientdata(client);
regmap_write(data->regmap, REG_GP, 0x00);
}
static const struct i2c_device_id lm3509_id[] = {
{ LM3509_NAME },
{}
};
MODULE_DEVICE_TABLE(i2c, lm3509_id);
static const struct of_device_id lm3509_match_table[] = {
{
.compatible = "ti,lm3509",
},
{},
};
MODULE_DEVICE_TABLE(of, lm3509_match_table);
static struct i2c_driver lm3509_i2c_driver = {
.driver = {
.name = LM3509_NAME,
.of_match_table = lm3509_match_table,
},
.probe = lm3509_probe,
.remove = lm3509_remove,
.id_table = lm3509_id,
};
module_i2c_driver(lm3509_i2c_driver);
MODULE_DESCRIPTION("Texas Instruments Backlight driver for LM3509");
MODULE_AUTHOR("Patrick Gansterer <paroga@paroga.com>");
MODULE_LICENSE("GPL");
......@@ -11,7 +11,6 @@
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/backlight.h>
#include <linux/fb.h>
#include <linux/slab.h>
#include <linux/mfd/lm3533.h>
......@@ -344,7 +343,7 @@ static void lm3533_bl_remove(struct platform_device *pdev)
dev_dbg(&bd->dev, "%s\n", __func__);
bd->props.power = FB_BLANK_POWERDOWN;
bd->props.power = BACKLIGHT_POWER_OFF;
bd->props.brightness = 0;
lm3533_ctrlbank_disable(&bl->cb);
......
......@@ -596,7 +596,7 @@ static void lm3630a_remove(struct i2c_client *client)
}
static const struct i2c_device_id lm3630a_id[] = {
{LM3630A_NAME, 0},
{ LM3630A_NAME },
{}
};
......
......@@ -403,7 +403,7 @@ static void lm3639_remove(struct i2c_client *client)
}
static const struct i2c_device_id lm3639_id[] = {
{LM3639_NAME, 0},
{ LM3639_NAME },
{}
};
......
......@@ -132,7 +132,7 @@ static void lv5207lp_remove(struct i2c_client *client)
}
static const struct i2c_device_id lv5207lp_ids[] = {
{ "lv5207lp", 0 },
{ "lv5207lp" },
{ }
};
MODULE_DEVICE_TABLE(i2c, lv5207lp_ids);
......
......@@ -358,7 +358,7 @@ static int mp3309c_probe(struct i2c_client *client)
props.max_brightness = pdata->max_brightness;
props.scale = BACKLIGHT_SCALE_LINEAR;
props.type = BACKLIGHT_RAW;
props.power = FB_BLANK_UNBLANK;
props.power = BACKLIGHT_POWER_ON;
chip->bl = devm_backlight_device_register(dev, "mp3309c", dev, chip,
&mp3309c_bl_ops, &props);
if (IS_ERR(chip->bl))
......@@ -388,7 +388,7 @@ static void mp3309c_remove(struct i2c_client *client)
struct mp3309c_chip *chip = i2c_get_clientdata(client);
struct backlight_device *bl = chip->bl;
bl->props.power = FB_BLANK_POWERDOWN;
bl->props.power = BACKLIGHT_POWER_OFF;
bl->props.brightness = 0;
backlight_update_status(chip->bl);
}
......@@ -400,7 +400,7 @@ static const struct of_device_id mp3309c_match_table[] = {
MODULE_DEVICE_TABLE(of, mp3309c_match_table);
static const struct i2c_device_id mp3309c_id[] = {
{ "mp3309c", 0 },
{ "mp3309c" },
{ }
};
MODULE_DEVICE_TABLE(i2c, mp3309c_id);
......
......@@ -11,7 +11,6 @@
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/fb.h>
#include <linux/backlight.h>
#include <linux/mfd/twl.h>
#include <linux/err.h>
......@@ -43,7 +42,7 @@ static int pandora_backlight_update_status(struct backlight_device *bl)
struct pandora_private *priv = bl_get_data(bl);
u8 r;
if (bl->props.power != FB_BLANK_UNBLANK)
if (bl->props.power != BACKLIGHT_POWER_ON)
brightness = 0;
if (bl->props.state & BL_CORE_FBBLANK)
brightness = 0;
......
......@@ -10,7 +10,6 @@
#include <linux/platform_device.h>
#include <linux/backlight.h>
#include <linux/fb.h>
#include <linux/mfd/pcf50633/core.h>
#include <linux/mfd/pcf50633/backlight.h>
......@@ -53,7 +52,7 @@ static int pcf50633_bl_update_status(struct backlight_device *bl)
if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK) ||
bl->props.power != FB_BLANK_UNBLANK)
bl->props.power != BACKLIGHT_POWER_ON)
new_brightness = 0;
else if (bl->props.brightness < pcf_bl->brightness_limit)
new_brightness = bl->props.brightness;
......@@ -106,7 +105,7 @@ static int pcf50633_bl_probe(struct platform_device *pdev)
memset(&bl_props, 0, sizeof(bl_props));
bl_props.type = BACKLIGHT_RAW;
bl_props.max_brightness = 0x3f;
bl_props.power = FB_BLANK_UNBLANK;
bl_props.power = BACKLIGHT_POWER_ON;
if (pdata) {
bl_props.brightness = pdata->default_brightness;
......
......@@ -143,5 +143,6 @@ static struct platform_driver platform_lcd_driver = {
module_platform_driver(platform_lcd_driver);
MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>");
MODULE_DESCRIPTION("Generic platform-device LCD power control interface");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:platform-lcd");
......@@ -426,7 +426,7 @@ static int pwm_backlight_initial_power_state(const struct pwm_bl_data *pb)
/* Not booted with device tree or no phandle link to the node */
if (!node || !node->phandle)
return FB_BLANK_UNBLANK;
return BACKLIGHT_POWER_ON;
/*
* If the driver is probed from the device tree and there is a
......@@ -434,7 +434,7 @@ static int pwm_backlight_initial_power_state(const struct pwm_bl_data *pb)
* assume that another driver will enable the backlight at the
* appropriate time. Therefore, if it is disabled, keep it so.
*/
return active ? FB_BLANK_UNBLANK: FB_BLANK_POWERDOWN;
return active ? BACKLIGHT_POWER_ON : BACKLIGHT_POWER_OFF;
}
static int pwm_backlight_probe(struct platform_device *pdev)
......
......@@ -19,7 +19,7 @@ static int rave_sp_backlight_update_status(struct backlight_device *bd)
{
const struct backlight_properties *p = &bd->props;
const u8 intensity =
(p->power == FB_BLANK_UNBLANK) ? p->brightness : 0;
(p->power == BACKLIGHT_POWER_ON) ? p->brightness : 0;
struct rave_sp *sp = dev_get_drvdata(&bd->dev);
u8 cmd[] = {
[0] = RAVE_SP_CMD_SET_BACKLIGHT,
......
......@@ -229,4 +229,5 @@ static struct platform_driver rt4831_bl_driver = {
module_platform_driver(rt4831_bl_driver);
MODULE_AUTHOR("ChiYuan Huang <cy_huang@richtek.com>");
MODULE_DESCRIPTION("Richtek RT4831 Backlight Driver");
MODULE_LICENSE("GPL v2");
......@@ -315,7 +315,7 @@ static void sky81452_bl_remove(struct platform_device *pdev)
sysfs_remove_group(&bd->dev.kobj, &sky81452_bl_attr_group);
bd->props.power = FB_BLANK_UNBLANK;
bd->props.power = BACKLIGHT_POWER_ON;
bd->props.brightness = 0;
backlight_update_status(bd);
......
......@@ -209,15 +209,19 @@ struct backlight_properties {
* attribute: /sys/class/backlight/<backlight>/bl_power
* When the power property is updated update_status() is called.
*
* The possible values are: (0: full on, 1 to 3: power saving
* modes; 4: full off), see FB_BLANK_XXX.
* The possible values are: (0: full on, 4: full off), see
* BACKLIGHT_POWER constants.
*
* When the backlight device is enabled @power is set
* to FB_BLANK_UNBLANK. When the backlight device is disabled
* @power is set to FB_BLANK_POWERDOWN.
* When the backlight device is enabled, @power is set to
* BACKLIGHT_POWER_ON. When the backlight device is disabled,
* @power is set to BACKLIGHT_POWER_OFF.
*/
int power;
#define BACKLIGHT_POWER_ON (0)
#define BACKLIGHT_POWER_OFF (4)
#define BACKLIGHT_POWER_REDUCED (1) // deprecated; don't use in new code
/**
* @type: The type of backlight supported.
*
......@@ -346,7 +350,7 @@ static inline int backlight_enable(struct backlight_device *bd)
if (!bd)
return 0;
bd->props.power = FB_BLANK_UNBLANK;
bd->props.power = BACKLIGHT_POWER_ON;
bd->props.state &= ~BL_CORE_FBBLANK;
return backlight_update_status(bd);
......@@ -361,7 +365,7 @@ static inline int backlight_disable(struct backlight_device *bd)
if (!bd)
return 0;
bd->props.power = FB_BLANK_POWERDOWN;
bd->props.power = BACKLIGHT_POWER_OFF;
bd->props.state |= BL_CORE_FBBLANK;
return backlight_update_status(bd);
......@@ -380,7 +384,7 @@ static inline int backlight_disable(struct backlight_device *bd)
*/
static inline bool backlight_is_blank(const struct backlight_device *bd)
{
return bd->props.power != FB_BLANK_UNBLANK ||
return bd->props.power != BACKLIGHT_POWER_ON ||
bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment