[PATCH v1 5/6] video: backlight: lm3533_bl: Set initial mapping mode from DT
From: Svyatoslav Ryhel
Date: Sun May 17 2026 - 03:43:55 EST
Add support to obtain the initial mapping mode from DT instead of leaving
it unconfigured. Additionally, update the linear sysfs code, which uses a
similar coding pattern.
Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>
---
drivers/video/backlight/lm3533_bl.c | 32 ++++++++++++++++-------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
index 42da652df58d..be9114b7e0ad 100644
--- a/drivers/video/backlight/lm3533_bl.c
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -22,6 +22,7 @@
#define LM3533_BL_MAX_BRIGHTNESS 255
#define LM3533_REG_CTRLBANK_AB_BCONF 0x1a
+#define CTRLBANK_AB_BCONF_MODE(n) BIT(2 * (n) + 1)
struct lm3533_bl {
@@ -32,6 +33,7 @@ struct lm3533_bl {
u32 max_current;
u32 pwm;
+ bool linear;
};
@@ -135,8 +137,9 @@ static ssize_t show_linear(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct lm3533_bl *bl = dev_get_drvdata(dev);
+ int id = lm3533_bl_get_ctrlbank_id(bl);
+ u8 mask = CTRLBANK_AB_BCONF_MODE(id);
u8 val;
- u8 mask;
int linear;
int ret;
@@ -144,8 +147,6 @@ static ssize_t show_linear(struct device *dev,
if (ret)
return ret;
- mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
-
if (val & mask)
linear = 1;
else
@@ -159,23 +160,16 @@ static ssize_t store_linear(struct device *dev,
const char *buf, size_t len)
{
struct lm3533_bl *bl = dev_get_drvdata(dev);
+ int id = lm3533_bl_get_ctrlbank_id(bl);
unsigned long linear;
- u8 mask;
- u8 val;
int ret;
if (kstrtoul(buf, 0, &linear))
return -EINVAL;
- mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
-
- if (linear)
- val = mask;
- else
- val = 0;
-
- ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, val,
- mask);
+ ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF,
+ linear ? CTRLBANK_AB_BCONF_MODE(id) : 0,
+ CTRLBANK_AB_BCONF_MODE(id));
if (ret)
return ret;
@@ -253,8 +247,15 @@ static struct attribute_group lm3533_bl_attribute_group = {
static int lm3533_bl_setup(struct lm3533_bl *bl)
{
+ int id = lm3533_bl_get_ctrlbank_id(bl);
int ret;
+ ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF,
+ bl->linear ? CTRLBANK_AB_BCONF_MODE(id) : 0,
+ CTRLBANK_AB_BCONF_MODE(id));
+ if (ret)
+ return ret;
+
ret = lm3533_ctrlbank_set_max_current(&bl->cb, bl->max_current);
if (ret)
return ret;
@@ -333,6 +334,9 @@ static int lm3533_bl_probe(struct platform_device *pdev)
bl->pwm = 0;
device_property_read_u32(&pdev->dev, "ti,pwm-config-mask", &bl->pwm);
+ bl->linear = device_property_read_bool(&pdev->dev,
+ "ti,linear-mapping-mode");
+
ret = lm3533_bl_setup(bl);
if (ret)
goto err_sysfs_remove;
--
2.51.0