Add an I2C backlight driver for the VIEWE 7KF82 module MCU at address 0x45, register 0x86 (brightness 0..255).
Signed-off-by: Hefei <[email protected]> --- MAINTAINERS | 7 +++ drivers/video/backlight/Kconfig | 11 ++++ drivers/video/backlight/Makefile | 1 + drivers/video/backlight/viewe_bl_i2c.c | 82 ++++++++++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 drivers/video/backlight/viewe_bl_i2c.c diff --git a/MAINTAINERS b/MAINTAINERS index 1679f1cc9..1abbe62c8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27202,6 +27202,13 @@ W: https://linuxtv.org T: git git://linuxtv.org/media.git F: drivers/media/test-drivers/vimc/* +VIEWE I2C BACKLIGHT DRIVER +M: Hefei <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/leds/backlight/viewe,7kf82-backlight.yaml +F: drivers/video/backlight/viewe_bl_i2c.c + VIRT LIB M: Alex Williamson <[email protected]> M: Paolo Bonzini <[email protected]> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 7b836f9ad..f57894073 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -501,6 +501,17 @@ config BACKLIGHT_LED If you have a LCD backlight adjustable by LED class driver, say Y to enable this driver. +config BACKLIGHT_VIEWE_I2C + tristate "VIEWE I2C backlight" + depends on I2C + help + Say Y here to enable the I2C backlight driver for VIEWE DSI + modules such as 7KF82. Brightness 0..255 is written to the + panel MCU at I2C address 0x45, register 0x86. + + To compile this driver as a module, choose M here: the module + will be called viewe_bl_i2c. + endif # BACKLIGHT_CLASS_DEVICE endmenu diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index bcb568afe..b82d959dd 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -61,3 +61,4 @@ obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o obj-$(CONFIG_BACKLIGHT_ARCXCNN) += arcxcnn_bl.o obj-$(CONFIG_BACKLIGHT_RAVE_SP) += rave-sp-backlight.o obj-$(CONFIG_BACKLIGHT_LED) += led_bl.o +obj-$(CONFIG_BACKLIGHT_VIEWE_I2C) += viewe_bl_i2c.o diff --git a/drivers/video/backlight/viewe_bl_i2c.c b/drivers/video/backlight/viewe_bl_i2c.c new file mode 100644 index 000000000..0f9173dfe --- /dev/null +++ b/drivers/video/backlight/viewe_bl_i2c.c @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2026 VIEWE + * + * I2C backlight for VIEWE 7KF82 DSI modules (MCU @0x45, register 0x86, 0..255). + */ + +#include <linux/backlight.h> +#include <linux/i2c.h> +#include <linux/module.h> +#include <linux/property.h> + +#define VIEWE_BL_REG 0x86 +#define VIEWE_BL_MAX 255 +#define VIEWE_BL_DEFAULT 200 + +static int viewe_bl_update_status(struct backlight_device *bd) +{ + struct i2c_client *client = bl_get_data(bd); + + return i2c_smbus_write_byte_data(client, VIEWE_BL_REG, + backlight_get_brightness(bd)); +} + +static const struct backlight_ops viewe_bl_ops = { + .options = BL_CORE_SUSPENDRESUME, + .update_status = viewe_bl_update_status, +}; + +static int viewe_bl_probe(struct i2c_client *client) +{ + struct backlight_properties props = { + .type = BACKLIGHT_RAW, + .max_brightness = VIEWE_BL_MAX, + }; + struct backlight_device *bd; + u32 brightness = VIEWE_BL_DEFAULT; + int error; + + device_property_read_u32(&client->dev, "default-brightness", &brightness); + if (brightness > VIEWE_BL_MAX) + brightness = VIEWE_BL_MAX; + props.brightness = brightness; + + bd = devm_backlight_device_register(&client->dev, + dev_name(&client->dev), &client->dev, + client, &viewe_bl_ops, &props); + if (IS_ERR(bd)) + return PTR_ERR(bd); + + error = backlight_update_status(bd); + if (error) + return error; + + return 0; +} + +static const struct of_device_id viewe_bl_of_match[] = { + { .compatible = "viewe,7kf82-backlight" }, + { } +}; +MODULE_DEVICE_TABLE(of, viewe_bl_of_match); + +static const struct i2c_device_id viewe_bl_id[] = { + { .name = "7kf82-backlight" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, viewe_bl_id); + +static struct i2c_driver viewe_bl_driver = { + .driver = { + .name = "viewe_bl_i2c", + .of_match_table = viewe_bl_of_match, + }, + .probe = viewe_bl_probe, + .id_table = viewe_bl_id, +}; +module_i2c_driver(viewe_bl_driver); + +MODULE_AUTHOR("Hefei <[email protected]>"); +MODULE_DESCRIPTION("VIEWE 7KF82 I2C backlight"); +MODULE_LICENSE("GPL"); -- 2.55.0.windows.5
