From 9df4477179f1af4ff7adbacfa243819b57134b9c Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:32 +0100 Subject: backlight: 88pm860x_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-2-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/88pm860x_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c index 720b5ada7fe8..0a1db2824076 100644 --- a/drivers/video/backlight/88pm860x_bl.c +++ b/drivers/video/backlight/88pm860x_bl.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 769562042211e7a194e3dfde9436b42a3734e279 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:33 +0100 Subject: backlight: adp5520_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-3-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/adp5520_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c index aa5c15e8db86..81c40d355aae 100644 --- a/drivers/video/backlight/adp5520_bl.c +++ b/drivers/video/backlight/adp5520_bl.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From a84877d7cc5b38dbbaad94ea7f8a784f8b12dbc8 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:34 +0100 Subject: backlight: adp8860_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-4-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/adp8860_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index f51ada4795e8..d4bbd7a7406b 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 1eeab5c83aa3c14790167c4d2b8786b257651bac Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:35 +0100 Subject: backlight: adp8870_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-5-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/adp8870_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index ad4bd4c8f441..e09e20492e7c 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 9800ca9c96bc039a5e19391c446d1d69b211756a Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:36 +0100 Subject: backlight: as3711_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-6-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/as3711_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c index e6f66bb35ef5..9f89eb19894e 100644 --- a/drivers/video/backlight/as3711_bl.c +++ b/drivers/video/backlight/as3711_bl.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From b6c775af0d2f1cf9376261180ce13e997dba583b Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:37 +0100 Subject: backlight: bd6107_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-7-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/bd6107.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c index 90764f83d2f1..74567af84e97 100644 --- a/drivers/video/backlight/bd6107.c +++ b/drivers/video/backlight/bd6107.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 68d112e043a4e9a5078eebc9302d5510d458681e Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:38 +0100 Subject: backlight: da903x_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-8-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/da903x_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c index 71f21bbc7a9f..81ff42bec0ad 100644 --- a/drivers/video/backlight/da903x_bl.c +++ b/drivers/video/backlight/da903x_bl.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From d670a4da1c60ab1004b79204c09b221eba8af93b Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:39 +0100 Subject: backlight: da9052_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-9-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/da9052_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/da9052_bl.c b/drivers/video/backlight/da9052_bl.c index 5e13ef96b717..f41523d78121 100644 --- a/drivers/video/backlight/da9052_bl.c +++ b/drivers/video/backlight/da9052_bl.c @@ -9,7 +9,6 @@ #include #include -#include #include #include -- cgit v1.2.3 From fcb0283338d760d37cd2701f6cd2bba0f5e78eb2 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:40 +0100 Subject: backlight: ep93xx_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-10-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/ep93xx_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c index 2387009d452d..f59effc02352 100644 --- a/drivers/video/backlight/ep93xx_bl.c +++ b/drivers/video/backlight/ep93xx_bl.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #define EP93XX_MAX_COUNT 255 -- cgit v1.2.3 From df14455987587fb5373eb216511e0f3ab24c5480 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:41 +0100 Subject: backlight: hp680_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-11-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/hp680_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c index fa9a983533b2..d8c2e4ada384 100644 --- a/drivers/video/backlight/hp680_bl.c +++ b/drivers/video/backlight/hp680_bl.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 5f02729fadee6dedb638cdb8244f9447c8ad4ef9 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:42 +0100 Subject: backlight: locomolcd: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-12-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/locomolcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c index 346d3e29a843..1b493fb0516d 100644 --- a/drivers/video/backlight/locomolcd.c +++ b/drivers/video/backlight/locomolcd.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 8c71b34c636cabb4101098cc6bb619ded9b0905f Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:43 +0100 Subject: backlight: lv5207lp: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-13-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/lv5207lp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/lv5207lp.c b/drivers/video/backlight/lv5207lp.c index 5f60989fa70f..a205f004eab2 100644 --- a/drivers/video/backlight/lv5207lp.c +++ b/drivers/video/backlight/lv5207lp.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3 From aa021f33d2cb5061a2a02e1a3c8faea3a3d2f844 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:44 +0100 Subject: backlight: max8925_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-14-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/max8925_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c index e607ec6fd4bf..4ac20a59e007 100644 --- a/drivers/video/backlight/max8925_bl.c +++ b/drivers/video/backlight/max8925_bl.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From d520ae4707fd6dafcb55649460059f67f54fc743 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:45 +0100 Subject: backlight: tps65217_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-15-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/tps65217_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c index d96d713fe7db..8aa860350644 100644 --- a/drivers/video/backlight/tps65217_bl.c +++ b/drivers/video/backlight/tps65217_bl.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From d023cc09d9dbd5c6a4a81e0e3866c3b976d70891 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:46 +0100 Subject: backlight: vgg2432a4: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-16-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/vgg2432a4.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/vgg2432a4.c b/drivers/video/backlight/vgg2432a4.c index bfc1913e8b55..3005eba6c82c 100644 --- a/drivers/video/backlight/vgg2432a4.c +++ b/drivers/video/backlight/vgg2432a4.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3 From 373dacfeb55e1ac73dccd91b83437183ca0fbd43 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Fri, 31 Jan 2025 14:58:47 +0100 Subject: backlight: wm831x_bl: Do not include This driver does not require . Remove the include statement. Signed-off-by: Thomas Zimmermann Link: https://lore.kernel.org/r/20250131140103.278158-17-tzimmermann@suse.de Signed-off-by: Lee Jones --- drivers/video/backlight/wm831x_bl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c index c5aaee205bdf..49027f04a1ec 100644 --- a/drivers/video/backlight/wm831x_bl.c +++ b/drivers/video/backlight/wm831x_bl.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 276822a00db3c1061382b41e72cafc09d6a0ec30 Mon Sep 17 00:00:00 2001 From: Herve Codina Date: Wed, 22 Jan 2025 10:19:14 +0100 Subject: backlight: led_bl: Hold led_access lock when calling led_sysfs_disable() Lockdep detects the following issue on led-backlight removal: [ 142.315935] ------------[ cut here ]------------ [ 142.315954] WARNING: CPU: 2 PID: 292 at drivers/leds/led-core.c:455 led_sysfs_enable+0x54/0x80 ... [ 142.500725] Call trace: [ 142.503176] led_sysfs_enable+0x54/0x80 (P) [ 142.507370] led_bl_remove+0x80/0xa8 [led_bl] [ 142.511742] platform_remove+0x30/0x58 [ 142.515501] device_remove+0x54/0x90 ... Indeed, led_sysfs_enable() has to be called with the led_access lock held. Hold the lock when calling led_sysfs_disable(). Fixes: ae232e45acf9 ("backlight: add led-backlight driver") Cc: stable@vger.kernel.org Signed-off-by: Herve Codina Link: https://lore.kernel.org/r/20250122091914.309533-1-herve.codina@bootlin.com Signed-off-by: Lee Jones --- drivers/video/backlight/led_bl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c index ae34d1ecbfbe..d2db157b2c29 100644 --- a/drivers/video/backlight/led_bl.c +++ b/drivers/video/backlight/led_bl.c @@ -229,8 +229,11 @@ static void led_bl_remove(struct platform_device *pdev) backlight_device_unregister(bl); led_bl_power_off(priv); - for (i = 0; i < priv->nb_leds; i++) + for (i = 0; i < priv->nb_leds; i++) { + mutex_lock(&priv->leds[i]->led_access); led_sysfs_enable(priv->leds[i]); + mutex_unlock(&priv->leds[i]->led_access); + } } static const struct of_device_id led_bl_of_match[] = { -- cgit v1.2.3 From 0508d17506fffb6d38df4c2dc737fb4f343a0840 Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Fri, 14 Feb 2025 12:02:12 +0800 Subject: dt-bindings: leds: backlight: apple,dwi-bl: Add Apple DWI backlight Add backlight controllers attached via Apple DWI 2-wire interface. Reviewed-by: Krzysztof Kozlowski Reviewed-by: "Daniel Thompson (RISCstar)" Signed-off-by: Nick Chan Reviewed-by: Neal Gompa Link: https://lore.kernel.org/r/20250214040306.16312-2-towinchenmi@gmail.com Signed-off-by: Lee Jones --- .../bindings/leds/backlight/apple,dwi-bl.yaml | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml diff --git a/Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml b/Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml new file mode 100644 index 000000000000..29caeb356e6f --- /dev/null +++ b/Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/backlight/apple,dwi-bl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple DWI 2-Wire Interface Backlight Controller + +maintainers: + - Nick Chan + +description: + Apple SoCs contain a 2-wire interface called DWI. On some Apple iPhones, + iPads and iPod touches with a LCD display, 1-2 backlight controllers + are connected via DWI. Interfacing with DWI controls all backlight + controllers at the same time. As such, the backlight controllers are + treated as a single controller regardless of the underlying + configuration. + +allOf: + - $ref: common.yaml# + +properties: + compatible: + items: + - enum: + - apple,s5l8960x-dwi-bl + - apple,t7000-dwi-bl + - apple,s8000-dwi-bl + - apple,t8010-dwi-bl + - apple,t8015-dwi-bl + - const: apple,dwi-bl + + reg: + maxItems: 1 + + power-domains: + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + dwi_bl: backlight@20e200010 { + compatible = "apple,s5l8960x-dwi-bl", "apple,dwi-bl"; + reg = <0x2 0x0e200010 0x0 0x8>; + power-domains = <&ps_dwi>; + }; + }; -- cgit v1.2.3 From ea45d216dd4e5b389af984f8c9effa1312e3cd74 Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Fri, 14 Feb 2025 12:02:13 +0800 Subject: backlight: apple_dwi_bl: Add Apple DWI backlight driver Add driver for backlight controllers attached via Apple DWI 2-wire interface, which is found on some Apple iPhones, iPads and iPod touches with a LCD display. Although there is an existing apple_bl driver, it is for backlight controllers on Intel Macs attached via PCI, which is completely different from the Samsung-derived DWI block. Reviewed-by: "Daniel Thompson (RISCstar)" Signed-off-by: Nick Chan Reviewed-by: Neal Gompa Link: https://lore.kernel.org/r/20250214040306.16312-3-towinchenmi@gmail.com Signed-off-by: Lee Jones --- drivers/video/backlight/Kconfig | 11 +++ drivers/video/backlight/Makefile | 1 + drivers/video/backlight/apple_dwi_bl.c | 123 +++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 drivers/video/backlight/apple_dwi_bl.c diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 3614a5d29c71..cee113bba30f 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -290,6 +290,17 @@ config BACKLIGHT_APPLE If you have an Intel-based Apple say Y to enable a driver for its backlight. +config BACKLIGHT_APPLE_DWI + tristate "Apple DWI 2-Wire Interface Backlight Driver" + depends on ARCH_APPLE || COMPILE_TEST + help + Say Y to enable the backlight driver for backlight controllers + attached via the Apple DWI 2-wire interface which is found in some + Apple iPhones, iPads and iPod touches. + + To compile this driver as a module, choose M here: the module will + be called apple_dwi_bl. + config BACKLIGHT_QCOM_WLED tristate "Qualcomm PMIC WLED Driver" select REGMAP diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 8fc98f760a8a..156ff9461fb3 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o obj-$(CONFIG_BACKLIGHT_ADP8870) += adp8870_bl.o obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o +obj-$(CONFIG_BACKLIGHT_APPLE_DWI) += apple_dwi_bl.o obj-$(CONFIG_BACKLIGHT_AS3711) += as3711_bl.o obj-$(CONFIG_BACKLIGHT_BD6107) += bd6107.o obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o diff --git a/drivers/video/backlight/apple_dwi_bl.c b/drivers/video/backlight/apple_dwi_bl.c new file mode 100644 index 000000000000..93bd744972d6 --- /dev/null +++ b/drivers/video/backlight/apple_dwi_bl.c @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Driver for backlight controllers attached via Apple DWI 2-wire interface + * + * Copyright (c) 2024 Nick Chan + */ + +#include +#include +#include +#include +#include +#include + +#define DWI_BL_CTL 0x0 +#define DWI_BL_CTL_SEND1 BIT(0) +#define DWI_BL_CTL_SEND2 BIT(4) +#define DWI_BL_CTL_SEND3 BIT(5) +#define DWI_BL_CTL_LE_DATA BIT(6) +/* Only used on Apple A9 and later */ +#define DWI_BL_CTL_SEND4 BIT(12) + +#define DWI_BL_CMD 0x4 +#define DWI_BL_CMD_TYPE GENMASK(31, 28) +#define DWI_BL_CMD_TYPE_SET_BRIGHTNESS 0xa +#define DWI_BL_CMD_DATA GENMASK(10, 0) + +#define DWI_BL_CTL_SEND (DWI_BL_CTL_SEND1 | \ + DWI_BL_CTL_SEND2 | \ + DWI_BL_CTL_SEND3 | \ + DWI_BL_CTL_LE_DATA | \ + DWI_BL_CTL_SEND4) + +#define DWI_BL_MAX_BRIGHTNESS 2047 + +struct apple_dwi_bl { + void __iomem *base; +}; + +static int dwi_bl_update_status(struct backlight_device *bl) +{ + struct apple_dwi_bl *dwi_bl = bl_get_data(bl); + + int brightness = backlight_get_brightness(bl); + + u32 cmd = 0; + + cmd |= FIELD_PREP(DWI_BL_CMD_DATA, brightness); + cmd |= FIELD_PREP(DWI_BL_CMD_TYPE, DWI_BL_CMD_TYPE_SET_BRIGHTNESS); + + writel(cmd, dwi_bl->base + DWI_BL_CMD); + writel(DWI_BL_CTL_SEND, dwi_bl->base + DWI_BL_CTL); + + return 0; +} + +static int dwi_bl_get_brightness(struct backlight_device *bl) +{ + struct apple_dwi_bl *dwi_bl = bl_get_data(bl); + + u32 cmd = readl(dwi_bl->base + DWI_BL_CMD); + + return FIELD_GET(DWI_BL_CMD_DATA, cmd); +} + +static const struct backlight_ops dwi_bl_ops = { + .options = BL_CORE_SUSPENDRESUME, + .get_brightness = dwi_bl_get_brightness, + .update_status = dwi_bl_update_status +}; + +static int dwi_bl_probe(struct platform_device *dev) +{ + struct apple_dwi_bl *dwi_bl; + struct backlight_device *bl; + struct backlight_properties props; + struct resource *res; + + dwi_bl = devm_kzalloc(&dev->dev, sizeof(*dwi_bl), GFP_KERNEL); + if (!dwi_bl) + return -ENOMEM; + + dwi_bl->base = devm_platform_get_and_ioremap_resource(dev, 0, &res); + if (IS_ERR(dwi_bl->base)) + return PTR_ERR(dwi_bl->base); + + memset(&props, 0, sizeof(struct backlight_properties)); + props.type = BACKLIGHT_PLATFORM; + props.max_brightness = DWI_BL_MAX_BRIGHTNESS; + props.scale = BACKLIGHT_SCALE_LINEAR; + + bl = devm_backlight_device_register(&dev->dev, dev->name, &dev->dev, + dwi_bl, &dwi_bl_ops, &props); + if (IS_ERR(bl)) + return PTR_ERR(bl); + + platform_set_drvdata(dev, dwi_bl); + + bl->props.brightness = dwi_bl_get_brightness(bl); + + return 0; +} + +static const struct of_device_id dwi_bl_of_match[] = { + { .compatible = "apple,dwi-bl" }, + {}, +}; + +MODULE_DEVICE_TABLE(of, dwi_bl_of_match); + +static struct platform_driver dwi_bl_driver = { + .driver = { + .name = "apple-dwi-bl", + .of_match_table = dwi_bl_of_match + }, + .probe = dwi_bl_probe, +}; + +module_platform_driver(dwi_bl_driver); + +MODULE_DESCRIPTION("Apple DWI Backlight Driver"); +MODULE_AUTHOR("Nick Chan "); +MODULE_LICENSE("Dual MIT/GPL"); -- cgit v1.2.3 From d1ebaf003a065d5d337b8fa3d69f9b90d7bb759d Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Fri, 14 Feb 2025 12:02:14 +0800 Subject: MAINTAINERS: Add entries for Apple DWI backlight controller Add MAINTAINERS entries for the driver. Reviewed-by: "Daniel Thompson (RISCstar)" Signed-off-by: Nick Chan Reviewed-by: Neal Gompa Link: https://lore.kernel.org/r/20250214040306.16312-4-towinchenmi@gmail.com Signed-off-by: Lee Jones --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 896a307fa065..a576324807f5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2228,6 +2228,7 @@ F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml F: Documentation/devicetree/bindings/interrupt-controller/apple,* F: Documentation/devicetree/bindings/iommu/apple,dart.yaml F: Documentation/devicetree/bindings/iommu/apple,sart.yaml +F: Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml F: Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml F: Documentation/devicetree/bindings/net/bluetooth/brcm,bcm4377-bluetooth.yaml F: Documentation/devicetree/bindings/nvme/apple,nvme-ans.yaml @@ -2253,6 +2254,7 @@ F: drivers/nvmem/apple-efuses.c F: drivers/pinctrl/pinctrl-apple-gpio.c F: drivers/pwm/pwm-apple.c F: drivers/soc/apple/* +F: drivers/video/backlight/apple_dwi_bl.c F: drivers/watchdog/apple_wdt.c F: include/dt-bindings/interrupt-controller/apple-aic.h F: include/dt-bindings/pinctrl/apple.h -- cgit v1.2.3 From c9fe785857fdfc780d49b60b5bb77ca21a51411b Mon Sep 17 00:00:00 2001 From: WangYuli Date: Mon, 10 Mar 2025 12:56:36 +0800 Subject: backlight: tdo24m: Eliminate redundant whitespace The description for CONFIG_LCD_TDO24M has redundant whitespace. Trim it to keep the code tidy. Signed-off-by: WangYuli Link: https://lore.kernel.org/r/8FC39A4DC2529591+20250310045636.14329-1-wangyuli@uniontech.com Signed-off-by: Lee Jones --- drivers/video/backlight/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index cee113bba30f..6e40262e3110 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -70,7 +70,7 @@ config LCD_ILI9320 then say y to include a power driver for it. config LCD_TDO24M - tristate "Toppoly TDO24M and TDO35S LCD Panels support" + tristate "Toppoly TDO24M and TDO35S LCD Panels support" depends on SPI_MASTER help If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to -- cgit v1.2.3 From dfc034a0494b8fb8ea881aeb41a0c4e2619ff1e4 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Tue, 11 Mar 2025 01:49:57 +0000 Subject: backlight: pcf50633-backlight: Remove unused driver The pcf50633 was used as part of the OpenMoko devices but the support for its main chip was recently removed in: commit 61b7f8920b17 ("ARM: s3c: remove all s3c24xx support") See https://lore.kernel.org/all/Z8z236h4B5A6Ki3D@gallifrey/ Remove it. Signed-off-by: "Dr. David Alan Gilbert" Link: https://lore.kernel.org/r/20250311014959.743322-8-linux@treblig.org Signed-off-by: Lee Jones --- drivers/video/backlight/Kconfig | 7 -- drivers/video/backlight/Makefile | 1 - drivers/video/backlight/pcf50633-backlight.c | 154 --------------------------- include/linux/mfd/pcf50633/backlight.h | 42 -------- include/linux/mfd/pcf50633/core.h | 3 - 5 files changed, 207 deletions(-) delete mode 100644 drivers/video/backlight/pcf50633-backlight.c delete mode 100644 include/linux/mfd/pcf50633/backlight.h diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 6e40262e3110..d9374d208cee 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -370,13 +370,6 @@ config BACKLIGHT_88PM860X help Say Y to enable the backlight driver for Marvell 88PM8606. -config BACKLIGHT_PCF50633 - tristate "Backlight driver for NXP PCF50633 MFD" - 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 MFD_AAT2870_CORE diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 156ff9461fb3..dfbb169bf6ea 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -50,7 +50,6 @@ obj-$(CONFIG_BACKLIGHT_MP3309C) += mp3309c.o obj-$(CONFIG_BACKLIGHT_MT6370) += mt6370-backlight.o obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o -obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o obj-$(CONFIG_BACKLIGHT_QCOM_WLED) += qcom-wled.o obj-$(CONFIG_BACKLIGHT_RT4831) += rt4831-backlight.o diff --git a/drivers/video/backlight/pcf50633-backlight.c b/drivers/video/backlight/pcf50633-backlight.c deleted file mode 100644 index 157be2f366df..000000000000 --- a/drivers/video/backlight/pcf50633-backlight.c +++ /dev/null @@ -1,154 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2009-2010, Lars-Peter Clausen - * PCF50633 backlight device driver - */ - -#include -#include -#include -#include - -#include - -#include -#include - -struct pcf50633_bl { - struct pcf50633 *pcf; - struct backlight_device *bl; - - unsigned int brightness; - unsigned int brightness_limit; -}; - -/* - * pcf50633_bl_set_brightness_limit - * - * Update the brightness limit for the pc50633 backlight. The actual brightness - * will not go above the limit. This is useful to limit power drain for example - * on low battery. - * - * @dev: Pointer to a pcf50633 device - * @limit: The brightness limit. Valid values are 0-63 - */ -int pcf50633_bl_set_brightness_limit(struct pcf50633 *pcf, unsigned int limit) -{ - struct pcf50633_bl *pcf_bl = platform_get_drvdata(pcf->bl_pdev); - - if (!pcf_bl) - return -ENODEV; - - pcf_bl->brightness_limit = limit & 0x3f; - backlight_update_status(pcf_bl->bl); - - return 0; -} - -static int pcf50633_bl_update_status(struct backlight_device *bl) -{ - struct pcf50633_bl *pcf_bl = bl_get_data(bl); - unsigned int new_brightness; - - - if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK) || - bl->props.power != BACKLIGHT_POWER_ON) - new_brightness = 0; - else if (bl->props.brightness < pcf_bl->brightness_limit) - new_brightness = bl->props.brightness; - else - new_brightness = pcf_bl->brightness_limit; - - - if (pcf_bl->brightness == new_brightness) - return 0; - - if (new_brightness) { - pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDOUT, - new_brightness); - if (!pcf_bl->brightness) - pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDENA, 1); - } else { - pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDENA, 0); - } - - pcf_bl->brightness = new_brightness; - - return 0; -} - -static int pcf50633_bl_get_brightness(struct backlight_device *bl) -{ - struct pcf50633_bl *pcf_bl = bl_get_data(bl); - - return pcf_bl->brightness; -} - -static const struct backlight_ops pcf50633_bl_ops = { - .get_brightness = pcf50633_bl_get_brightness, - .update_status = pcf50633_bl_update_status, - .options = BL_CORE_SUSPENDRESUME, -}; - -static int pcf50633_bl_probe(struct platform_device *pdev) -{ - struct pcf50633_bl *pcf_bl; - struct device *parent = pdev->dev.parent; - struct pcf50633_platform_data *pcf50633_data = dev_get_platdata(parent); - struct pcf50633_bl_platform_data *pdata = pcf50633_data->backlight_data; - struct backlight_properties bl_props; - - pcf_bl = devm_kzalloc(&pdev->dev, sizeof(*pcf_bl), GFP_KERNEL); - if (!pcf_bl) - return -ENOMEM; - - memset(&bl_props, 0, sizeof(bl_props)); - bl_props.type = BACKLIGHT_RAW; - bl_props.max_brightness = 0x3f; - bl_props.power = BACKLIGHT_POWER_ON; - - if (pdata) { - bl_props.brightness = pdata->default_brightness; - pcf_bl->brightness_limit = pdata->default_brightness_limit; - } else { - bl_props.brightness = 0x3f; - pcf_bl->brightness_limit = 0x3f; - } - - pcf_bl->pcf = dev_to_pcf50633(pdev->dev.parent); - - pcf_bl->bl = devm_backlight_device_register(&pdev->dev, pdev->name, - &pdev->dev, pcf_bl, - &pcf50633_bl_ops, &bl_props); - - if (IS_ERR(pcf_bl->bl)) - return PTR_ERR(pcf_bl->bl); - - platform_set_drvdata(pdev, pcf_bl); - - pcf50633_reg_write(pcf_bl->pcf, PCF50633_REG_LEDDIM, pdata->ramp_time); - - /* - * Should be different from bl_props.brightness, so we do not exit - * update_status early the first time it's called - */ - pcf_bl->brightness = pcf_bl->bl->props.brightness + 1; - - backlight_update_status(pcf_bl->bl); - - return 0; -} - -static struct platform_driver pcf50633_bl_driver = { - .probe = pcf50633_bl_probe, - .driver = { - .name = "pcf50633-backlight", - }, -}; - -module_platform_driver(pcf50633_bl_driver); - -MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_DESCRIPTION("PCF50633 backlight driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:pcf50633-backlight"); diff --git a/include/linux/mfd/pcf50633/backlight.h b/include/linux/mfd/pcf50633/backlight.h deleted file mode 100644 index fd4a4f8d6c13..000000000000 --- a/include/linux/mfd/pcf50633/backlight.h +++ /dev/null @@ -1,42 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2009-2010, Lars-Peter Clausen - * PCF50633 backlight device driver - */ - -#ifndef __LINUX_MFD_PCF50633_BACKLIGHT -#define __LINUX_MFD_PCF50633_BACKLIGHT - -/* -* @default_brightness: Backlight brightness is initialized to this value -* -* Brightness to be used after the driver has been probed. -* Valid range 0-63. -* -* @default_brightness_limit: The actual brightness is limited by this value -* -* Brightness limit to be used after the driver has been probed. This is useful -* when it is not known how much power is available for the backlight during -* probe. -* Valid range 0-63. Can be changed later with pcf50633_bl_set_brightness_limit. -* -* @ramp_time: Display ramp time when changing brightness -* -* When changing the backlights brightness the change is not instant, instead -* it fades smooth from one state to another. This value specifies how long -* the fade should take. The lower the value the higher the fade time. -* Valid range 0-255 -*/ -struct pcf50633_bl_platform_data { - unsigned int default_brightness; - unsigned int default_brightness_limit; - uint8_t ramp_time; -}; - - -struct pcf50633; - -int pcf50633_bl_set_brightness_limit(struct pcf50633 *pcf, unsigned int limit); - -#endif - diff --git a/include/linux/mfd/pcf50633/core.h b/include/linux/mfd/pcf50633/core.h index 539f27f8bd89..42d2b0e4884e 100644 --- a/include/linux/mfd/pcf50633/core.h +++ b/include/linux/mfd/pcf50633/core.h @@ -15,7 +15,6 @@ #include #include #include -#include struct pcf50633; struct regmap; @@ -42,8 +41,6 @@ struct pcf50633_platform_data { void (*force_shutdown)(struct pcf50633 *); u8 resumers[5]; - - struct pcf50633_bl_platform_data *backlight_data; }; struct pcf50633_irq { -- cgit v1.2.3