Skip to contentSkip to conversation

backlight: add support for Silergy SY7758

PATCH In review Alexandre Hamamdjian 3 participants 5 messages May 10 – May 15

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover backlight: add support for Silergy SY7758

The Silergy SY7758 is an I2C-controlled multi-channel LED backlight driver used to drive the edge-lit LED strings of LCD panels. It is present on the Ayaneo Pocket DS handheld, where it drives the panel backlight, and is required before the panel can be lit.

This series adds the device tree binding for the new "silergy,sy7758" compatible and the matching driver. The driver registers a backlight class device with a 12-bit linear brightness range and programs the chip's mode and current configuration registers on the first non-zero brightness update.

The Ayaneo Pocket DS device tree, posted as a separate series, depends on the binding introduced here to describe its panel backlight.

---
Alexandre Hamamdjian (2):
dt-bindings: leds: backlight: add Silergy SY7758
backlight: sy7758: add Silergy SY7758 backlight driver

 .../bindings/leds/backlight/silergy,sy7758.yaml    |  47 ++++++
 MAINTAINERS                                        |   7 +
 drivers/video/backlight/Kconfig                    |  14 ++
 drivers/video/backlight/Makefile                   |   1 +
 drivers/video/backlight/sy7758.c                   | 169 +++++++++++++++++++++
 5 files changed, 238 insertions(+)

---
base-commit: e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20260510-sy7758-e46d85fd0876

Best regards,

Signature · 1 line
Alexandre Hamamdjian <[email protected]>
#1 lore raw

PATCH 1/2 dt-bindings: leds: backlight: add Silergy SY7758

The Silergy SY7758 is an I2C-controlled multi-channel LED backlight driver typically used to drive the edge-lit LED strings of LCD panels in handheld and embedded devices. Brightness is programmed as a 12-bit linear value through two 8-bit registers.

Document the binding for the new compatible "silergy,sy7758" so it can be referenced by board device trees and the matching driver, and add a MAINTAINERS entry covering both the binding and the upcoming driver.

---
 .../bindings/leds/backlight/silergy,sy7758.yaml    | 47 ++++++++++++++++++++++
 MAINTAINERS                                        |  7 ++++
 2 files changed, 54 insertions(+)
Documentation/devicetree/bindings/leds/backlight/silergy,sy7758.yaml new file +47 -0
new file mode 100644
index 000000000000..408029e19e2e
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/silergy,sy7758.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Silergy SY7758 I2C LED backlight controller
+
+maintainers:
+  - Alexandre Hamamdjian <[email protected]>
+  - Philippe Simons <[email protected]>
+
+description:
+  The Silergy SY7758 is an I2C-controlled multi-channel LED backlight
+  driver typically used to drive the edge-lit LED strings of LCD panels
+  in handheld and embedded devices. Brightness is programmed as a 12-bit
+  linear value through two 8-bit registers.
+
+allOf:
+  - $ref: common.yaml#
+
+properties:
+  compatible:
+    const: silergy,sy7758
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        backlight@36 {
+            compatible = "silergy,sy7758";
+            reg = <0x36>;
+            max-brightness = <4080>;
+            default-brightness = <1500>;
+        };
+    };
MAINTAINERS +7 -0
index f877e5aaf2c7..9c132394ca41 100644
@@ -24561,6 +24561,13 @@ S:	Maintained
 F:	drivers/input/touchscreen/silead.c
 F:	drivers/platform/x86/touchscreen_dmi.c
 
+SILERGY SY7758 BACKLIGHT DRIVER
+M:	Alexandre Hamamdjian <[email protected]>
+M:	Philippe Simons <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/leds/backlight/silergy,sy7758.yaml
+F:	drivers/video/backlight/sy7758.c
+
 SILICON LABS WIRELESS DRIVERS (for WFxxx series)
 M:	Jérôme Pouiller <[email protected]>
 L:	[email protected]
Signature · 1 line
2.54.0
#2 lore raw

Re: [PATCH 1/2] dt-bindings: leds: backlight: add Silergy SY7758

Quoted 9 lines · Alexandre Hamamdjian

The Silergy SY7758 is an I2C-controlled multi-channel LED backlight driver typically used to drive the edge-lit LED strings of LCD panels in handheld and embedded devices. Brightness is programmed as a 12-bit linear value through two 8-bit registers.

Document the binding for the new compatible "silergy,sy7758" so it can be referenced by board device trees and the matching driver, and add a MAINTAINERS entry covering both the binding and the upcoming driver.

Quoted 5 lines
---
 .../bindings/leds/backlight/silergy,sy7758.yaml    | 47 ++++++++++++++++++++++

This was already sent two weeks ago:
<20260430-topic-sm8650-ayaneo-pocket-s2-sy7758-v2-1-308140640de9@linaro.org> and that posting looks closer to complete.

Best regards,
Krzysztof

#3 lore raw

PATCH 2/2 backlight: sy7758: add Silergy SY7758 backlight driver

In reply to Alexandre Hamamdjian

Add a driver for the Silergy SY7758 I2C-controlled multi-channel LED backlight controller. The chip drives the edge-lit LED strings of LCD panels in handheld and embedded devices, and is for example present on the Ayaneo Pocket DS handheld where it drives the panel backlight.

The driver registers a backlight class device with a 12-bit linear brightness range. On the first non-zero update, the chip's mode and current configuration registers are programmed; subsequent brightness updates only rewrite the two brightness registers. A mutex serialises concurrent updates against the deferred init path.

---
 drivers/video/backlight/Kconfig  |  14 ++++
 drivers/video/backlight/Makefile |   1 +
 drivers/video/backlight/sy7758.c | 169 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 184 insertions(+)
drivers/video/backlight/Kconfig +14 -0
index a7a3fbaf7c29..c529d2861525 100644
@@ -461,6 +461,20 @@ config BACKLIGHT_SKY81452
 	  To compile this driver as a module, choose M here: the module will
 	  be called sky81452-backlight
 
+config BACKLIGHT_SY7758
+	tristate "Backlight Driver for Silergy SY7758"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  This enables support for the Silergy SY7758 I2C-controlled
+	  multi-channel LED backlight driver, commonly used to drive the
+	  edge-lit LED strings of LCD panels in handheld and embedded
+	  devices. The driver exposes a 12-bit linear brightness control
+	  through the standard backlight class.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called sy7758.
+
 config BACKLIGHT_TPS65217
 	tristate "TPS65217 Backlight"
 	depends on MFD_TPS65217
drivers/video/backlight/Makefile +1 -0
index 794820a98ed4..00d3e379b297 100644
@@ -57,6 +57,7 @@ obj-$(CONFIG_BACKLIGHT_QCOM_WLED)	+= qcom-wled.o
 obj-$(CONFIG_BACKLIGHT_RT4831)		+= rt4831-backlight.o
 obj-$(CONFIG_BACKLIGHT_SAHARA)		+= kb3886_bl.o
 obj-$(CONFIG_BACKLIGHT_SKY81452)	+= sky81452-backlight.o
+obj-$(CONFIG_BACKLIGHT_SY7758)		+= sy7758.o
 obj-$(CONFIG_BACKLIGHT_TPS65217)	+= tps65217_bl.o
 obj-$(CONFIG_BACKLIGHT_WM831X)		+= wm831x_bl.o
 obj-$(CONFIG_BACKLIGHT_ARCXCNN) 	+= arcxcnn_bl.o
drivers/video/backlight/sy7758.c new file +169 -0

169 lines not on this page · raw message

Signature · 1 line
2.54.0
#4 lore raw

Re: [PATCH 2/2] backlight: sy7758: add Silergy SY7758 backlight driver

Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider: - [High] Premature device registration exposes initialization race - [Medium] Redundant global mutex causes…

Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [High] Premature device registration exposes initialization race
- [Medium] Redundant global mutex causes cross-device contention
- [Medium] Hardcoded sysfs device name prevents multiple device instances
- [Medium] Unhandled I2C errors during initialization allow phantom devices
- [Medium] Visual glitch due to hardcoded brightness values upon unblanking
- [Medium] Improper brightness bitmasking limits resolution and breaks linearity
- [Medium] Lifecycle race between sysfs writes and device removal
--

commit 0d56a1ebe95bbf1d06c227b2612ebb2fdce6d26a
Author: Alexandre Hamamdjian <[email protected]>

backlight: sy7758: add Silergy SY7758 backlight driver

Add a driver for the Silergy SY7758 I2C-controlled multi-channel LED backlight controller. The chip drives the edge-lit LED strings of LCD panels in handheld and embedded devices, and is for example present on the Ayaneo Pocket DS handheld where it drives the panel backlight.

Quoted 5 lines
drivers/video/backlight/sy7758.c new file +0 -0
new file mode 100644
index 0000000000000..6a318bd62030a

[ ... ]

Quoted 1 line

+static DEFINE_MUTEX(sy7758_update_backlight_mutex);

Could this global mutex cause cross-device contention? Since the backlight core already serializes calls to update_status() for each device using bd->update_lock, is sy7758_update_backlight_mutex necessary?

[ ... ]

Quoted 5 lines
drivers/video/backlight/sy7758.c new file +5 -0
+static int sy7758_backlight_update_status(struct backlight_device *backlight_dev)
+{
+	struct sy7758 *sydev = bl_get_data(backlight_dev);
+	unsigned int brightness = backlight_get_brightness(backlight_dev);
+

drivers/video/backlight/sy7758.c line 59

Quoted 10 lines
drivers/video/backlight/sy7758.c new file +10 -0
+	mutex_lock(&sy7758_update_backlight_mutex);
+
+	if (!sydev->led_on && brightness > 0) {
+		sy7758_init(sydev);
+		sydev->led_on = true;
+	} else if (brightness == 0) {
+		sydev->led_on = false;
+	}
+
+	sy7758_write(sydev, BL_BRT_L, brightness & 0xf0);

Does dropping the lower 4 bits here limit the resolution and break linearity?

The max_brightness is set to 4080, but this masking maps blocks of 16 consecutive brightness values to the exact same hardware output. If the hardware uses an 8-bit resolution shifted by 4 bits, would it be better to expose max_brightness as 255 and shift the value internally?

Quoted 6 lines
drivers/video/backlight/sy7758.c new file +6 -0
+
+	sy7758_write(sydev, BL_BRT_H, (brightness >> 8) & 0xf);
+
+	mutex_unlock(&sy7758_update_backlight_mutex);
+	return 0;
+}

[ ... ]

drivers/video/backlight/sy7758.c line 76

Quoted 5 lines
drivers/video/backlight/sy7758.c new file +5 -0
+static void sy7758_init(struct sy7758 *sydev)
+{
+	sy7758_write(sydev, 0x01, 0x85);
+	sy7758_write(sydev, 0x10, 0x00);
+	sy7758_write(sydev, 0x11, 0x00);

Should we handle I2C errors during initialization?

Since sy7758_write() returns an error code but sy7758_init() ignores it, the probe function will succeed even if the hardware is disconnected or unresponsive, potentially creating a non-functional phantom device.

[ ... ]

drivers/video/backlight/sy7758.c line 86

Quoted 4 lines
drivers/video/backlight/sy7758.c new file +4 -0
+	usleep_range(10000, 11000);
+
+	sy7758_write(sydev, 0x10, 0x40);
+	sy7758_write(sydev, 0x11, 0x01);

Does this hardcoded value cause a brief visual glitch?

When the display is unblanked, update_status() calls sy7758_init(), which unconditionally writes 0x40 and 0x01 (brightness 320) before update_status() overwrites it with the target brightness.

[ ... ]

Quoted 2 lines
drivers/video/backlight/sy7758.c new file +2 -0
+static int sy7758_probe(struct i2c_client *client)
+{

[ ... ]

drivers/video/backlight/sy7758.c line 119

Quoted 1 line
drivers/video/backlight/sy7758.c new file +1 -0
+	backlight_dev = devm_backlight_device_register(&client->dev, "sy7758-backlight",

Is it possible for this hardcoded sysfs device name to prevent multiple device instances from probing? If multiple controllers are present on the same system, the second instance might fail to probe due to a sysfs naming collision. Using dev_name(&client->dev) might avoid this.

drivers/video/backlight/sy7758.c line 125

Quoted 6 lines
drivers/video/backlight/sy7758.c new file +6 -0
+					&client->dev, sydev, &sy7758_backlight_ops, &props);
+	if (IS_ERR(backlight_dev))
+		return dev_err_probe(&client->dev, PTR_ERR(backlight_dev),
+				"failed to register backlight device\n");
+
+	sy7758_init(sydev);

Does registering the device before calling sy7758_init() expose an initialization race?

If a sysfs write occurs right after registration, the backlight core could invoke update_status(), which calls sy7758_init() concurrently with the probe function continuing to call sy7758_init() below.

Quoted 4 lines
drivers/video/backlight/sy7758.c new file +4 -0
+
+	i2c_set_clientdata(client, backlight_dev);
+	backlight_update_status(backlight_dev);
+

drivers/video/backlight/sy7758.c line 139

Quoted 10 lines
drivers/video/backlight/sy7758.c new file +10 -0
+	return 0;
+}
+
+static void sy7758_remove(struct i2c_client *client)
+{
+	struct backlight_device *backlight_dev = i2c_get_clientdata(client);
+
+	backlight_dev->props.brightness = 0;
+	backlight_update_status(backlight_dev);
+}

Could there be a lifecycle race between sysfs writes and device removal here?

Because the driver uses devm_backlight_device_register(), the sysfs interface remains active until the devres cleanup phase executes after remove() returns. A concurrent userspace write to the brightness sysfs file could turn the backlight back on just before unregistration, leaving the hardware stranded in an ON state.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2