Skip to content

Commit 93d5228

Browse files
committed
Merge tag 'backlight-next-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones: - Apple DWI Backlight: - Added devicetree bindings for backlight controllers on Apple's DWI interface. - Added a new driver (apple_dwi_bl) for these controllers found on some Apple mobile devices. - Added MAINTAINERS entries for the new driver. - led_bl: Fixed a locking issue by holding the led_access lock when calling led_sysfs_disable() during device removal to prevent potential warnings. - Removed unnecessary <linux/fb.h> includes from a bunch of drivers. - tdo24m: Removed redundant whitespace in Kconfig description. - pcf50633-backlight: Removed the driver as the underlying pcf50633 MFD and s3c24xx platform support were removed. * tag 'backlight-next-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: (22 commits) backlight: pcf50633-backlight: Remove unused driver backlight: tdo24m: Eliminate redundant whitespace MAINTAINERS: Add entries for Apple DWI backlight controller backlight: apple_dwi_bl: Add Apple DWI backlight driver dt-bindings: leds: backlight: apple,dwi-bl: Add Apple DWI backlight backlight: led_bl: Hold led_access lock when calling led_sysfs_disable() backlight: wm831x_bl: Do not include <linux/fb.h> backlight: vgg2432a4: Do not include <linux/fb.h> backlight: tps65217_bl: Do not include <linux/fb.h> backlight: max8925_bl: Do not include <linux/fb.h> backlight: lv5207lp: Do not include <linux/fb.h> backlight: locomolcd: Do not include <linux/fb.h> backlight: hp680_bl: Do not include <linux/fb.h> backlight: ep93xx_bl: Do not include <linux/fb.h> backlight: da9052_bl: Do not include <linux/fb.h> backlight: da903x_bl: Do not include <linux/fb.h> backlight: bd6107_bl: Do not include <linux/fb.h> backlight: as3711_bl: Do not include <linux/fb.h> backlight: adp8870_bl: Do not include <linux/fb.h> backlight: adp8860_bl: Do not include <linux/fb.h> ...
2 parents cb9b4c3 + dfc034a commit 93d5228

File tree

25 files changed

+199
-225
lines changed

25 files changed

+199
-225
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/leds/backlight/apple,dwi-bl.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Apple DWI 2-Wire Interface Backlight Controller
8+
9+
maintainers:
10+
- Nick Chan <towinchenmi@gmail.com>
11+
12+
description:
13+
Apple SoCs contain a 2-wire interface called DWI. On some Apple iPhones,
14+
iPads and iPod touches with a LCD display, 1-2 backlight controllers
15+
are connected via DWI. Interfacing with DWI controls all backlight
16+
controllers at the same time. As such, the backlight controllers are
17+
treated as a single controller regardless of the underlying
18+
configuration.
19+
20+
allOf:
21+
- $ref: common.yaml#
22+
23+
properties:
24+
compatible:
25+
items:
26+
- enum:
27+
- apple,s5l8960x-dwi-bl
28+
- apple,t7000-dwi-bl
29+
- apple,s8000-dwi-bl
30+
- apple,t8010-dwi-bl
31+
- apple,t8015-dwi-bl
32+
- const: apple,dwi-bl
33+
34+
reg:
35+
maxItems: 1
36+
37+
power-domains:
38+
maxItems: 1
39+
40+
required:
41+
- compatible
42+
- reg
43+
44+
unevaluatedProperties: false
45+
46+
examples:
47+
- |
48+
soc {
49+
#address-cells = <2>;
50+
#size-cells = <2>;
51+
52+
dwi_bl: backlight@20e200010 {
53+
compatible = "apple,s5l8960x-dwi-bl", "apple,dwi-bl";
54+
reg = <0x2 0x0e200010 0x0 0x8>;
55+
power-domains = <&ps_dwi>;
56+
};
57+
};

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,7 @@ F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml
22322232
F: Documentation/devicetree/bindings/interrupt-controller/apple,*
22332233
F: Documentation/devicetree/bindings/iommu/apple,dart.yaml
22342234
F: Documentation/devicetree/bindings/iommu/apple,sart.yaml
2235+
F: Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml
22352236
F: Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml
22362237
F: Documentation/devicetree/bindings/net/bluetooth/brcm,bcm4377-bluetooth.yaml
22372238
F: Documentation/devicetree/bindings/nvme/apple,nvme-ans.yaml
@@ -2259,6 +2260,7 @@ F: drivers/pinctrl/pinctrl-apple-gpio.c
22592260
F: drivers/pwm/pwm-apple.c
22602261
F: drivers/soc/apple/*
22612262
F: drivers/spi/spi-apple.c
2263+
F: drivers/video/backlight/apple_dwi_bl.c
22622264
F: drivers/watchdog/apple_wdt.c
22632265
F: include/dt-bindings/interrupt-controller/apple-aic.h
22642266
F: include/dt-bindings/pinctrl/apple.h

drivers/video/backlight/88pm860x_bl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/of.h>
1212
#include <linux/platform_device.h>
1313
#include <linux/slab.h>
14-
#include <linux/fb.h>
1514
#include <linux/i2c.h>
1615
#include <linux/backlight.h>
1716
#include <linux/mfd/88pm860x.h>

drivers/video/backlight/Kconfig

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ config LCD_ILI9320
7070
then say y to include a power driver for it.
7171

7272
config LCD_TDO24M
73-
tristate "Toppoly TDO24M and TDO35S LCD Panels support"
73+
tristate "Toppoly TDO24M and TDO35S LCD Panels support"
7474
depends on SPI_MASTER
7575
help
7676
If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to
@@ -290,6 +290,17 @@ config BACKLIGHT_APPLE
290290
If you have an Intel-based Apple say Y to enable a driver for its
291291
backlight.
292292

293+
config BACKLIGHT_APPLE_DWI
294+
tristate "Apple DWI 2-Wire Interface Backlight Driver"
295+
depends on ARCH_APPLE || COMPILE_TEST
296+
help
297+
Say Y to enable the backlight driver for backlight controllers
298+
attached via the Apple DWI 2-wire interface which is found in some
299+
Apple iPhones, iPads and iPod touches.
300+
301+
To compile this driver as a module, choose M here: the module will
302+
be called apple_dwi_bl.
303+
293304
config BACKLIGHT_QCOM_WLED
294305
tristate "Qualcomm PMIC WLED Driver"
295306
select REGMAP
@@ -359,13 +370,6 @@ config BACKLIGHT_88PM860X
359370
help
360371
Say Y to enable the backlight driver for Marvell 88PM8606.
361372

362-
config BACKLIGHT_PCF50633
363-
tristate "Backlight driver for NXP PCF50633 MFD"
364-
depends on MFD_PCF50633
365-
help
366-
If you have a backlight driven by a NXP PCF50633 MFD, say Y here to
367-
enable its driver.
368-
369373
config BACKLIGHT_AAT2870
370374
tristate "AnalogicTech AAT2870 Backlight"
371375
depends on MFD_AAT2870_CORE

drivers/video/backlight/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o
2323
obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o
2424
obj-$(CONFIG_BACKLIGHT_ADP8870) += adp8870_bl.o
2525
obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o
26+
obj-$(CONFIG_BACKLIGHT_APPLE_DWI) += apple_dwi_bl.o
2627
obj-$(CONFIG_BACKLIGHT_AS3711) += as3711_bl.o
2728
obj-$(CONFIG_BACKLIGHT_BD6107) += bd6107.o
2829
obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
@@ -49,7 +50,6 @@ obj-$(CONFIG_BACKLIGHT_MP3309C) += mp3309c.o
4950
obj-$(CONFIG_BACKLIGHT_MT6370) += mt6370-backlight.o
5051
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
5152
obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o
52-
obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
5353
obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
5454
obj-$(CONFIG_BACKLIGHT_QCOM_WLED) += qcom-wled.o
5555
obj-$(CONFIG_BACKLIGHT_RT4831) += rt4831-backlight.o

drivers/video/backlight/adp5520_bl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <linux/kernel.h>
99
#include <linux/init.h>
1010
#include <linux/platform_device.h>
11-
#include <linux/fb.h>
1211
#include <linux/backlight.h>
1312
#include <linux/mfd/adp5520.h>
1413
#include <linux/slab.h>

drivers/video/backlight/adp8860_bl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/pm.h>
1212
#include <linux/platform_device.h>
1313
#include <linux/i2c.h>
14-
#include <linux/fb.h>
1514
#include <linux/backlight.h>
1615
#include <linux/leds.h>
1716
#include <linux/slab.h>

drivers/video/backlight/adp8870_bl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/pm.h>
1212
#include <linux/platform_device.h>
1313
#include <linux/i2c.h>
14-
#include <linux/fb.h>
1514
#include <linux/backlight.h>
1615
#include <linux/leds.h>
1716
#include <linux/workqueue.h>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR MIT
2+
/*
3+
* Driver for backlight controllers attached via Apple DWI 2-wire interface
4+
*
5+
* Copyright (c) 2024 Nick Chan <towinchenmi@gmail.com>
6+
*/
7+
8+
#include <linux/backlight.h>
9+
#include <linux/bitfield.h>
10+
#include <linux/device.h>
11+
#include <linux/io.h>
12+
#include <linux/module.h>
13+
#include <linux/platform_device.h>
14+
15+
#define DWI_BL_CTL 0x0
16+
#define DWI_BL_CTL_SEND1 BIT(0)
17+
#define DWI_BL_CTL_SEND2 BIT(4)
18+
#define DWI_BL_CTL_SEND3 BIT(5)
19+
#define DWI_BL_CTL_LE_DATA BIT(6)
20+
/* Only used on Apple A9 and later */
21+
#define DWI_BL_CTL_SEND4 BIT(12)
22+
23+
#define DWI_BL_CMD 0x4
24+
#define DWI_BL_CMD_TYPE GENMASK(31, 28)
25+
#define DWI_BL_CMD_TYPE_SET_BRIGHTNESS 0xa
26+
#define DWI_BL_CMD_DATA GENMASK(10, 0)
27+
28+
#define DWI_BL_CTL_SEND (DWI_BL_CTL_SEND1 | \
29+
DWI_BL_CTL_SEND2 | \
30+
DWI_BL_CTL_SEND3 | \
31+
DWI_BL_CTL_LE_DATA | \
32+
DWI_BL_CTL_SEND4)
33+
34+
#define DWI_BL_MAX_BRIGHTNESS 2047
35+
36+
struct apple_dwi_bl {
37+
void __iomem *base;
38+
};
39+
40+
static int dwi_bl_update_status(struct backlight_device *bl)
41+
{
42+
struct apple_dwi_bl *dwi_bl = bl_get_data(bl);
43+
44+
int brightness = backlight_get_brightness(bl);
45+
46+
u32 cmd = 0;
47+
48+
cmd |= FIELD_PREP(DWI_BL_CMD_DATA, brightness);
49+
cmd |= FIELD_PREP(DWI_BL_CMD_TYPE, DWI_BL_CMD_TYPE_SET_BRIGHTNESS);
50+
51+
writel(cmd, dwi_bl->base + DWI_BL_CMD);
52+
writel(DWI_BL_CTL_SEND, dwi_bl->base + DWI_BL_CTL);
53+
54+
return 0;
55+
}
56+
57+
static int dwi_bl_get_brightness(struct backlight_device *bl)
58+
{
59+
struct apple_dwi_bl *dwi_bl = bl_get_data(bl);
60+
61+
u32 cmd = readl(dwi_bl->base + DWI_BL_CMD);
62+
63+
return FIELD_GET(DWI_BL_CMD_DATA, cmd);
64+
}
65+
66+
static const struct backlight_ops dwi_bl_ops = {
67+
.options = BL_CORE_SUSPENDRESUME,
68+
.get_brightness = dwi_bl_get_brightness,
69+
.update_status = dwi_bl_update_status
70+
};
71+
72+
static int dwi_bl_probe(struct platform_device *dev)
73+
{
74+
struct apple_dwi_bl *dwi_bl;
75+
struct backlight_device *bl;
76+
struct backlight_properties props;
77+
struct resource *res;
78+
79+
dwi_bl = devm_kzalloc(&dev->dev, sizeof(*dwi_bl), GFP_KERNEL);
80+
if (!dwi_bl)
81+
return -ENOMEM;
82+
83+
dwi_bl->base = devm_platform_get_and_ioremap_resource(dev, 0, &res);
84+
if (IS_ERR(dwi_bl->base))
85+
return PTR_ERR(dwi_bl->base);
86+
87+
memset(&props, 0, sizeof(struct backlight_properties));
88+
props.type = BACKLIGHT_PLATFORM;
89+
props.max_brightness = DWI_BL_MAX_BRIGHTNESS;
90+
props.scale = BACKLIGHT_SCALE_LINEAR;
91+
92+
bl = devm_backlight_device_register(&dev->dev, dev->name, &dev->dev,
93+
dwi_bl, &dwi_bl_ops, &props);
94+
if (IS_ERR(bl))
95+
return PTR_ERR(bl);
96+
97+
platform_set_drvdata(dev, dwi_bl);
98+
99+
bl->props.brightness = dwi_bl_get_brightness(bl);
100+
101+
return 0;
102+
}
103+
104+
static const struct of_device_id dwi_bl_of_match[] = {
105+
{ .compatible = "apple,dwi-bl" },
106+
{},
107+
};
108+
109+
MODULE_DEVICE_TABLE(of, dwi_bl_of_match);
110+
111+
static struct platform_driver dwi_bl_driver = {
112+
.driver = {
113+
.name = "apple-dwi-bl",
114+
.of_match_table = dwi_bl_of_match
115+
},
116+
.probe = dwi_bl_probe,
117+
};
118+
119+
module_platform_driver(dwi_bl_driver);
120+
121+
MODULE_DESCRIPTION("Apple DWI Backlight Driver");
122+
MODULE_AUTHOR("Nick Chan <towinchenmi@gmail.com>");
123+
MODULE_LICENSE("Dual MIT/GPL");

drivers/video/backlight/as3711_bl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/delay.h>
1111
#include <linux/device.h>
1212
#include <linux/err.h>
13-
#include <linux/fb.h>
1413
#include <linux/kernel.h>
1514
#include <linux/mfd/as3711.h>
1615
#include <linux/module.h>

0 commit comments

Comments
 (0)