Thread (15 messages) 15 messages, 4 authors, 2022-06-06
STALE1466d

[PATCH 2/2] backlight: rt4831: Add the property parsing for ocp level selection

From: cy_huang <hidden>
Date: 2022-05-26 03:17:10
Also in: dri-devel, linux-devicetree, linux-leds, lkml
Subsystem: backlight class/subsystem, framebuffer layer, the rest · Maintainers: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller, Linus Torvalds

From: ChiYuan Huang <redacted>

Add the property parsing for ocp level selection.

Reported-by: Lucas Tsai <redacted>
Signed-off-by: ChiYuan Huang <redacted>
---
 drivers/video/backlight/rt4831-backlight.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/drivers/video/backlight/rt4831-backlight.c b/drivers/video/backlight/rt4831-backlight.c
index 42155c7..c81f7d9 100644
--- a/drivers/video/backlight/rt4831-backlight.c
+++ b/drivers/video/backlight/rt4831-backlight.c
@@ -12,6 +12,7 @@
 #define RT4831_REG_BLCFG	0x02
 #define RT4831_REG_BLDIML	0x04
 #define RT4831_REG_ENABLE	0x08
+#define RT4831_REG_BLOPT2	0x11
 
 #define RT4831_BLMAX_BRIGHTNESS	2048
 
@@ -23,6 +24,8 @@
 #define RT4831_BLDIML_MASK	GENMASK(2, 0)
 #define RT4831_BLDIMH_MASK	GENMASK(10, 3)
 #define RT4831_BLDIMH_SHIFT	3
+#define RT4831_BLOCP_MASK	GENMASK(1, 0)
+#define RT4831_BLOCP_SHIFT	0
 
 struct rt4831_priv {
 	struct device *dev;
@@ -120,6 +123,16 @@ static int rt4831_parse_backlight_properties(struct rt4831_priv *priv,
 	if (ret)
 		return ret;
 
+	ret = device_property_read_u8(dev, "richtek,bled-ocp-sel", &propval);
+	if (ret)
+		propval = RT4831_BLOCPLVL_1P2A;
+
+	propval = min_t(u8, propval, RT4831_BLOCPLVL_1P8A);
+	ret = regmap_update_bits(priv->regmap, RT4831_REG_BLOPT2, RT4831_BLOCP_MASK,
+				 propval << RT4831_BLOCP_SHIFT);
+	if (ret)
+		return ret;
+
 	ret = device_property_read_u8(dev, "richtek,channel-use", &propval);
 	if (ret) {
 		dev_err(dev, "richtek,channel-use DT property missing\n");
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help