Commit e0654264 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull backlight updates from Lee Jones:
 "Fix-ups:
   - Remove unused BACKLIGHT_LCD_SUPPORT symbol
   - Remove unused BACKLIGHT_CLASS_DEVICE dependencies
   - Add DT support to lm3630a_bl

  Bug Fixes:
   - Fix error path issues in lm3630a_bl"

* tag 'backlight-next-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  backlight: lm3630a: Add firmware node support
  dt-bindings: backlight: Add lm3630a bindings
  backlight: lm3630a: Return 0 on success in update_status functions
  video: lcd: Remove useless BACKLIGHT_CLASS_DEVICE dependencies
  video: backlight: Remove useless BACKLIGHT_LCD_SUPPORT kernel symbol
parents ebcf5bb2 8fbce8ef
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/backlight/lm3630a-backlight.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: TI LM3630A High-Efficiency Dual-String White LED
maintainers:
- Lee Jones <lee.jones@linaro.org>
- Daniel Thompson <daniel.thompson@linaro.org>
- Jingoo Han <jingoohan1@gmail.com>
description: |
The LM3630A is a current-mode boost converter which supplies the power and
controls the current in up to two strings of 10 LEDs per string.
https://www.ti.com/product/LM3630A
properties:
compatible:
const: ti,lm3630a
reg:
maxItems: 1
ti,linear-mapping-mode:
description: |
Enable linear mapping mode. If disabled, then it will use exponential
mapping mode in which the ramp up/down appears to have a more uniform
transition to the human eye.
type: boolean
required:
- compatible
- reg
patternProperties:
"^led@[01]$":
type: object
description: |
Properties for a string of connected LEDs.
properties:
reg:
description: |
The control bank that is used to program the two current sinks. The
LM3630A has two control banks (A and B) and are represented as 0 or 1
in this property. The two current sinks can be controlled
independently with both banks, or bank A can be configured to control
both sinks with the led-sources property.
maxItems: 1
minimum: 0
maximum: 1
label:
maxItems: 1
led-sources:
allOf:
- minItems: 1
maxItems: 2
items:
minimum: 0
maximum: 1
default-brightness:
description: Default brightness level on boot.
minimum: 0
maximum: 255
max-brightness:
description: Maximum brightness that is allowed during runtime.
minimum: 0
maximum: 255
required:
- reg
additionalProperties: false
additionalProperties: false
examples:
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
led-controller@38 {
compatible = "ti,lm3630a";
reg = <0x38>;
#address-cells = <1>;
#size-cells = <0>;
led@0 {
reg = <0>;
led-sources = <0 1>;
label = "lcd-backlight";
default-brightness = <200>;
max-brightness = <255>;
};
};
};
- |
i2c {
#address-cells = <1>;
#size-cells = <0>;
led-controller@38 {
compatible = "ti,lm3630a";
reg = <0x38>;
#address-cells = <1>;
#size-cells = <0>;
led@0 {
reg = <0>;
default-brightness = <150>;
ti,linear-mapping-mode;
};
led@1 {
reg = <1>;
default-brightness = <225>;
ti,linear-mapping-mode;
};
};
};
......@@ -191,7 +191,6 @@ config I2C_EEPROM_AT24
config LCD_BACKLIGHT
tristate "LCD Backlight support"
select BACKLIGHT_LCD_SUPPORT
select BACKLIGHT_PWM
endmenu
......
......@@ -200,7 +200,6 @@ config DRM_RADEON
select POWER_SUPPLY
select HWMON
select BACKLIGHT_CLASS_DEVICE
select BACKLIGHT_LCD_SUPPORT
select INTERVAL_TREE
help
Choose this option if you have an ATI Radeon graphics card. There
......@@ -221,7 +220,6 @@ config DRM_AMDGPU
select POWER_SUPPLY
select HWMON
select BACKLIGHT_CLASS_DEVICE
select BACKLIGHT_LCD_SUPPORT
select INTERVAL_TREE
select CHASH
help
......
......@@ -76,7 +76,6 @@ config DRM_PARADE_PS8622
depends on OF
select DRM_PANEL
select DRM_KMS_HELPER
select BACKLIGHT_LCD_SUPPORT
select BACKLIGHT_CLASS_DEVICE
---help---
Parade eDP-LVDS bridge chip driver.
......
......@@ -2,7 +2,6 @@ config DRM_FSL_DCU
tristate "DRM Support for Freescale DCU"
depends on DRM && OF && ARM && COMMON_CLK
select BACKLIGHT_CLASS_DEVICE
select BACKLIGHT_LCD_SUPPORT
select DRM_KMS_HELPER
select DRM_KMS_CMA_HELPER
select DRM_PANEL
......
......@@ -15,7 +15,6 @@ config DRM_I915
select IRQ_WORK
# i915 depends on ACPI_VIDEO when ACPI is enabled
# but for select to work, need to select ACPI_VIDEO's dependencies, ick
select BACKLIGHT_LCD_SUPPORT if ACPI
select BACKLIGHT_CLASS_DEVICE if ACPI
select INPUT if ACPI
select ACPI_VIDEO if ACPI
......
......@@ -5,14 +5,12 @@ config DRM_NOUVEAU
select DRM_KMS_HELPER
select DRM_TTM
select BACKLIGHT_CLASS_DEVICE if DRM_NOUVEAU_BACKLIGHT
select BACKLIGHT_LCD_SUPPORT if DRM_NOUVEAU_BACKLIGHT
select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && INPUT
select X86_PLATFORM_DEVICES if ACPI && X86
select ACPI_WMI if ACPI && X86
select MXM_WMI if ACPI && X86
select POWER_SUPPLY
# Similar to i915, we need to select ACPI_VIDEO and it's dependencies
select BACKLIGHT_LCD_SUPPORT if ACPI && X86
select BACKLIGHT_CLASS_DEVICE if ACPI && X86
select INPUT if ACPI && X86
select THERMAL if ACPI && X86
......
......@@ -4,7 +4,6 @@ config DRM_SHMOBILE
depends on DRM && ARM
depends on ARCH_SHMOBILE || COMPILE_TEST
select BACKLIGHT_CLASS_DEVICE
select BACKLIGHT_LCD_SUPPORT
select DRM_KMS_HELPER
select DRM_KMS_CMA_HELPER
select DRM_GEM_CMA_HELPER
......
......@@ -8,7 +8,6 @@ config DRM_TILCDC
select DRM_PANEL_BRIDGE
select VIDEOMODE_HELPERS
select BACKLIGHT_CLASS_DEVICE
select BACKLIGHT_LCD_SUPPORT
help
Choose this option if you have an TI SoC with LCDC display
controller, for example AM33xx in beagle-bone, DA8xx, or
......
......@@ -3,7 +3,6 @@ config FB_OLPC_DCON
tristate "One Laptop Per Child Display CONtroller support"
depends on OLPC && FB
depends on I2C
depends on BACKLIGHT_LCD_SUPPORT
depends on (GPIO_CS5535 || GPIO_CS5535=n)
select BACKLIGHT_CLASS_DEVICE
help
......
......@@ -142,7 +142,6 @@ config USB_FTDI_ELAN
config USB_APPLEDISPLAY
tristate "Apple Cinema Display support"
select BACKLIGHT_LCD_SUPPORT
select BACKLIGHT_CLASS_DEVICE
help
Say Y here if you want to control the backlight of Apple Cinema
......
......@@ -2,13 +2,7 @@
# Backlight & LCD drivers configuration
#
menuconfig BACKLIGHT_LCD_SUPPORT
bool "Backlight & LCD device support"
help
Enable this to be able to choose the drivers for controlling the
backlight and the LCD panel on some platforms, for example on PDAs.
if BACKLIGHT_LCD_SUPPORT
menu "Backlight & LCD device support"
#
# LCD
......@@ -199,7 +193,6 @@ config BACKLIGHT_IPAQ_MICRO
config BACKLIGHT_LM3533
tristate "Backlight Driver for LM3533"
depends on BACKLIGHT_CLASS_DEVICE
depends on MFD_LM3533
help
Say Y to enable the backlight driver for National Semiconductor / TI
......@@ -323,7 +316,7 @@ config BACKLIGHT_ADP5520
config BACKLIGHT_ADP8860
tristate "Backlight Driver for ADP8860/ADP8861/ADP8863 using WLED"
depends on BACKLIGHT_CLASS_DEVICE && I2C
depends on I2C
select NEW_LEDS
select LEDS_CLASS
help
......@@ -335,7 +328,7 @@ config BACKLIGHT_ADP8860
config BACKLIGHT_ADP8870
tristate "Backlight Driver for ADP8870 using WLED"
depends on BACKLIGHT_CLASS_DEVICE && I2C
depends on I2C
select NEW_LEDS
select LEDS_CLASS
help
......@@ -353,28 +346,28 @@ config BACKLIGHT_88PM860X
config BACKLIGHT_PCF50633
tristate "Backlight driver for NXP PCF50633 MFD"
depends on BACKLIGHT_CLASS_DEVICE && MFD_PCF50633
depends on MFD_PCF50633
help
If you have a backlight driven by a NXP PCF50633 MFD, say Y here to
enable its driver.
config BACKLIGHT_AAT2870
tristate "AnalogicTech AAT2870 Backlight"
depends on BACKLIGHT_CLASS_DEVICE && MFD_AAT2870_CORE
depends on MFD_AAT2870_CORE
help
If you have a AnalogicTech AAT2870 say Y to enable the
backlight driver.
config BACKLIGHT_LM3630A
tristate "Backlight Driver for LM3630A"
depends on BACKLIGHT_CLASS_DEVICE && I2C && PWM
depends on I2C && PWM
select REGMAP_I2C
help
This supports TI LM3630A Backlight Driver
config BACKLIGHT_LM3639
tristate "Backlight Driver for LM3639"
depends on BACKLIGHT_CLASS_DEVICE && I2C
depends on I2C
select REGMAP_I2C
select NEW_LEDS
select LEDS_CLASS
......@@ -383,20 +376,20 @@ config BACKLIGHT_LM3639
config BACKLIGHT_LP855X
tristate "Backlight driver for TI LP855X"
depends on BACKLIGHT_CLASS_DEVICE && I2C && PWM
depends on I2C && PWM
help
This supports TI LP8550, LP8551, LP8552, LP8553, LP8555, LP8556 and
LP8557 backlight driver.
config BACKLIGHT_LP8788
tristate "Backlight driver for TI LP8788 MFD"
depends on BACKLIGHT_CLASS_DEVICE && MFD_LP8788 && PWM
depends on MFD_LP8788 && PWM
help
This supports TI LP8788 backlight driver.
config BACKLIGHT_OT200
tristate "Backlight driver for ot200 visualisation device"
depends on BACKLIGHT_CLASS_DEVICE && CS5535_MFGPT && GPIO_CS5535
depends on CS5535_MFGPT && GPIO_CS5535
help
To compile this driver as a module, choose M here: the module will be
called ot200_bl.
......@@ -410,7 +403,7 @@ config BACKLIGHT_PANDORA
config BACKLIGHT_SKY81452
tristate "Backlight driver for SKY81452"
depends on BACKLIGHT_CLASS_DEVICE && MFD_SKY81452
depends on MFD_SKY81452
help
If you have a Skyworks SKY81452, say Y to enable the
backlight driver.
......@@ -420,14 +413,14 @@ config BACKLIGHT_SKY81452
config BACKLIGHT_TPS65217
tristate "TPS65217 Backlight"
depends on BACKLIGHT_CLASS_DEVICE && MFD_TPS65217
depends on MFD_TPS65217
help
If you have a Texas Instruments TPS65217 say Y to enable the
backlight driver.
config BACKLIGHT_AS3711
tristate "AS3711 Backlight"
depends on BACKLIGHT_CLASS_DEVICE && MFD_AS3711
depends on MFD_AS3711
help
If you have an Austrian Microsystems AS3711 say Y to enable the
backlight driver.
......@@ -466,4 +459,4 @@ config BACKLIGHT_RAVE_SP
endif # BACKLIGHT_CLASS_DEVICE
endif # BACKLIGHT_LCD_SUPPORT
endmenu
......@@ -35,6 +35,14 @@
#define REG_MAX 0x50
#define INT_DEBOUNCE_MSEC 10
#define LM3630A_BANK_0 0
#define LM3630A_BANK_1 1
#define LM3630A_NUM_SINKS 2
#define LM3630A_SINK_0 0
#define LM3630A_SINK_1 1
struct lm3630a_chip {
struct device *dev;
struct delayed_work work;
......@@ -201,7 +209,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
LM3630A_LEDA_ENABLE, LM3630A_LEDA_ENABLE);
if (ret < 0)
goto out_i2c_err;
return bl->props.brightness;
return 0;
out_i2c_err:
dev_err(pchip->dev, "i2c failed to access\n");
......@@ -278,7 +286,7 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
LM3630A_LEDB_ENABLE, LM3630A_LEDB_ENABLE);
if (ret < 0)
goto out_i2c_err;
return bl->props.brightness;
return 0;
out_i2c_err:
dev_err(pchip->dev, "i2c failed to access REG_CTRL\n");
......@@ -329,15 +337,17 @@ static const struct backlight_ops lm3630a_bank_b_ops = {
static int lm3630a_backlight_register(struct lm3630a_chip *pchip)
{
struct backlight_properties props;
struct lm3630a_platform_data *pdata = pchip->pdata;
struct backlight_properties props;
const char *label;
props.type = BACKLIGHT_RAW;
if (pdata->leda_ctrl != LM3630A_LEDA_DISABLE) {
props.brightness = pdata->leda_init_brt;
props.max_brightness = pdata->leda_max_brt;
label = pdata->leda_label ? pdata->leda_label : "lm3630a_leda";
pchip->bleda =
devm_backlight_device_register(pchip->dev, "lm3630a_leda",
devm_backlight_device_register(pchip->dev, label,
pchip->dev, pchip,
&lm3630a_bank_a_ops, &props);
if (IS_ERR(pchip->bleda))
......@@ -348,8 +358,9 @@ static int lm3630a_backlight_register(struct lm3630a_chip *pchip)
(pdata->ledb_ctrl != LM3630A_LEDB_ON_A)) {
props.brightness = pdata->ledb_init_brt;
props.max_brightness = pdata->ledb_max_brt;
label = pdata->ledb_label ? pdata->ledb_label : "lm3630a_ledb";
pchip->bledb =
devm_backlight_device_register(pchip->dev, "lm3630a_ledb",
devm_backlight_device_register(pchip->dev, label,
pchip->dev, pchip,
&lm3630a_bank_b_ops, &props);
if (IS_ERR(pchip->bledb))
......@@ -364,6 +375,123 @@ static const struct regmap_config lm3630a_regmap = {
.max_register = REG_MAX,
};
static int lm3630a_parse_led_sources(struct fwnode_handle *node,
int default_led_sources)
{
u32 sources[LM3630A_NUM_SINKS];
int ret, num_sources, i;
num_sources = fwnode_property_read_u32_array(node, "led-sources", NULL,
0);
if (num_sources < 0)
return default_led_sources;
else if (num_sources > ARRAY_SIZE(sources))
return -EINVAL;
ret = fwnode_property_read_u32_array(node, "led-sources", sources,
num_sources);
if (ret)
return ret;
for (i = 0; i < num_sources; i++) {
if (sources[i] < LM3630A_SINK_0 || sources[i] > LM3630A_SINK_1)
return -EINVAL;
ret |= BIT(sources[i]);
}
return ret;
}
static int lm3630a_parse_bank(struct lm3630a_platform_data *pdata,
struct fwnode_handle *node, int *seen_led_sources)
{
int led_sources, ret;
const char *label;
u32 bank, val;
bool linear;
ret = fwnode_property_read_u32(node, "reg", &bank);
if (ret)
return ret;
if (bank < LM3630A_BANK_0 || bank > LM3630A_BANK_1)
return -EINVAL;
led_sources = lm3630a_parse_led_sources(node, BIT(bank));
if (led_sources < 0)
return led_sources;
if (*seen_led_sources & led_sources)
return -EINVAL;
*seen_led_sources |= led_sources;
linear = fwnode_property_read_bool(node,
"ti,linear-mapping-mode");
if (bank) {
if (led_sources & BIT(LM3630A_SINK_0) ||
!(led_sources & BIT(LM3630A_SINK_1)))
return -EINVAL;
pdata->ledb_ctrl = linear ?
LM3630A_LEDB_ENABLE_LINEAR :
LM3630A_LEDB_ENABLE;
} else {
if (!(led_sources & BIT(LM3630A_SINK_0)))
return -EINVAL;
pdata->leda_ctrl = linear ?
LM3630A_LEDA_ENABLE_LINEAR :
LM3630A_LEDA_ENABLE;
if (led_sources & BIT(LM3630A_SINK_1))
pdata->ledb_ctrl = LM3630A_LEDB_ON_A;
}
ret = fwnode_property_read_string(node, "label", &label);
if (!ret) {
if (bank)
pdata->ledb_label = label;
else
pdata->leda_label = label;
}
ret = fwnode_property_read_u32(node, "default-brightness",
&val);
if (!ret) {
if (bank)
pdata->ledb_init_brt = val;
else
pdata->leda_init_brt = val;
}
ret = fwnode_property_read_u32(node, "max-brightness", &val);
if (!ret) {
if (bank)
pdata->ledb_max_brt = val;
else
pdata->leda_max_brt = val;
}
return 0;
}
static int lm3630a_parse_node(struct lm3630a_chip *pchip,
struct lm3630a_platform_data *pdata)
{
int ret = -ENODEV, seen_led_sources = 0;
struct fwnode_handle *node;
device_for_each_child_node(pchip->dev, node) {
ret = lm3630a_parse_bank(pdata, node, &seen_led_sources);
if (ret)
return ret;
}
return ret;
}
static int lm3630a_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
......@@ -396,13 +524,18 @@ static int lm3630a_probe(struct i2c_client *client,
GFP_KERNEL);
if (pdata == NULL)
return -ENOMEM;
/* default values */
pdata->leda_ctrl = LM3630A_LEDA_ENABLE;
pdata->ledb_ctrl = LM3630A_LEDB_ENABLE;
pdata->leda_max_brt = LM3630A_MAX_BRIGHTNESS;
pdata->ledb_max_brt = LM3630A_MAX_BRIGHTNESS;
pdata->leda_init_brt = LM3630A_MAX_BRIGHTNESS;
pdata->ledb_init_brt = LM3630A_MAX_BRIGHTNESS;
rval = lm3630a_parse_node(pchip, pdata);
if (rval) {
dev_err(&client->dev, "fail : parse node\n");
return rval;
}
}
pchip->pdata = pdata;
......@@ -470,11 +603,17 @@ static const struct i2c_device_id lm3630a_id[] = {
{}
};
static const struct of_device_id lm3630a_match_table[] = {
{ .compatible = "ti,lm3630a", },
{ },
};
MODULE_DEVICE_TABLE(i2c, lm3630a_id);
static struct i2c_driver lm3630a_i2c_driver = {
.driver = {
.name = LM3630A_NAME,
.of_match_table = lm3630a_match_table,
},
.probe = lm3630a_probe,
.remove = lm3630a_remove,
......
......@@ -186,7 +186,6 @@ config FB_MACMODES
config FB_BACKLIGHT
tristate
depends on FB
select BACKLIGHT_LCD_SUPPORT
select BACKLIGHT_CLASS_DEVICE
config FB_MODE_HELPERS
......@@ -281,7 +280,6 @@ config FB_ARMCLCD
select FB_CFB_IMAGEBLIT
select FB_MODE_HELPERS if OF
select VIDEOMODE_HELPERS if OF
select BACKLIGHT_LCD_SUPPORT if OF
select BACKLIGHT_CLASS_DEVICE if OF
help
This framebuffer device driver is for the ARM PrimeCell PL110
......@@ -307,7 +305,6 @@ config FB_ACORN
config FB_CLPS711X
tristate "CLPS711X LCD support"
depends on FB && (ARCH_CLPS711X || COMPILE_TEST)
select BACKLIGHT_LCD_SUPPORT
select FB_MODE_HELPERS
select FB_SYS_FILLRECT
select FB_SYS_COPYAREA
......@@ -335,7 +332,6 @@ config FB_SA1100
config FB_IMX
tristate "Freescale i.MX1/21/25/27 LCD support"
depends on FB && ARCH_MXC
select BACKLIGHT_LCD_SUPPORT
select LCD_CLASS_DEVICE
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
......@@ -2184,7 +2180,6 @@ config FB_MX3
tristate "MX3 Framebuffer support"
depends on FB && MX3_IPU
select BACKLIGHT_CLASS_DEVICE
select BACKLIGHT_LCD_SUPPORT
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
......
......@@ -38,9 +38,11 @@ enum lm3630a_ledb_ctrl {
#define LM3630A_MAX_BRIGHTNESS 255
/*
*@leda_label : optional led a label.
*@leda_init_brt : led a init brightness. 4~255
*@leda_max_brt : led a max brightness. 4~255
*@leda_ctrl : led a disable, enable linear, enable exponential
*@ledb_label : optional led b label.
*@ledb_init_brt : led b init brightness. 4~255
*@ledb_max_brt : led b max brightness. 4~255
*@ledb_ctrl : led b disable, enable linear, enable exponential
......@@ -50,10 +52,12 @@ enum lm3630a_ledb_ctrl {
struct lm3630a_platform_data {
/* led a config. */
const char *leda_label;
int leda_init_brt;
int leda_max_brt;
enum lm3630a_leda_ctrl leda_ctrl;
/* led b config. */
const char *ledb_label;
int ledb_init_brt;
int ledb_max_brt;
enum lm3630a_ledb_ctrl ledb_ctrl;
......
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