* [PATCH v4 0/2] Add the property to make backlight OCP level selectable @ 2022-06-21 10:36 ` cy_huang 0 siblings, 0 replies; 10+ messages in thread From: cy_huang @ 2022-06-21 10:36 UTC (permalink / raw) To: robh+dt, krzysztof.kozlowski+dt, lee.jones, daniel.thompson, jingoohan1 Cc: pavel, deller, cy_huang, lucas_tsai, devicetree, dri-devel, linux-fbdev, linux-leds, linux-kernel From: ChiYuan Huang <cy_huang@richtek.com> This patch series is to add the backlight ocp level property parsing. Since v4 - Fix wrong macro usage, must be 'DIV_ROUND_UP', not 'roundup' Since v3 - Refine the description for backlight ocp property. - Use the enum to list the supported value. Since v2 - change the property name from the register style 'richtek,bled-ocp-cel' to 'richtek,bled-ocp-microamp'. - Use the clamp and roundup to get the ovp level selector. ChiYuan Huang (2): dt-bindings: backlight: rt4831: Add the new ocp level property backlight: rt4831: Apply ocp level from devicetree .../leds/backlight/richtek,rt4831-backlight.yaml | 5 ++++ drivers/video/backlight/rt4831-backlight.c | 33 +++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 0/2] Add the property to make backlight OCP level selectable @ 2022-06-21 10:36 ` cy_huang 0 siblings, 0 replies; 10+ messages in thread From: cy_huang @ 2022-06-21 10:36 UTC (permalink / raw) To: robh+dt, krzysztof.kozlowski+dt, lee.jones, daniel.thompson, jingoohan1 Cc: devicetree, linux-fbdev, lucas_tsai, deller, linux-kernel, dri-devel, cy_huang, pavel, linux-leds From: ChiYuan Huang <cy_huang@richtek.com> This patch series is to add the backlight ocp level property parsing. Since v4 - Fix wrong macro usage, must be 'DIV_ROUND_UP', not 'roundup' Since v3 - Refine the description for backlight ocp property. - Use the enum to list the supported value. Since v2 - change the property name from the register style 'richtek,bled-ocp-cel' to 'richtek,bled-ocp-microamp'. - Use the clamp and roundup to get the ovp level selector. ChiYuan Huang (2): dt-bindings: backlight: rt4831: Add the new ocp level property backlight: rt4831: Apply ocp level from devicetree .../leds/backlight/richtek,rt4831-backlight.yaml | 5 ++++ drivers/video/backlight/rt4831-backlight.c | 33 +++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 1/2] dt-bindings: backlight: rt4831: Add the new ocp level property 2022-06-21 10:36 ` cy_huang @ 2022-06-21 10:36 ` cy_huang -1 siblings, 0 replies; 10+ messages in thread From: cy_huang @ 2022-06-21 10:36 UTC (permalink / raw) To: robh+dt, krzysztof.kozlowski+dt, lee.jones, daniel.thompson, jingoohan1 Cc: pavel, deller, cy_huang, lucas_tsai, devicetree, dri-devel, linux-fbdev, linux-leds, linux-kernel From: ChiYuan Huang <cy_huang@richtek.com> Add 'richtek,bled-ocp-microamp' property to make it chooseable. The wrong backlight ocp level may affect the backlight channel output current smaller than configured. Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> --- Since v3: - Refine the description for backlight ocp property. - Use the enum to list the supported value. Since v2: - Change the property name from 'richtek,bled-ocp-sel' to 'richtek,bled-ocp-microamp'. --- .../devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml b/Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml index e0ac686..99e9e13 100644 --- a/Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +++ b/Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml @@ -47,6 +47,11 @@ properties: minimum: 0 maximum: 3 + richtek,bled-ocp-microamp: + description: | + Backlight over current protection level. + enum: [900000, 1200000, 1500000, 1800000] + richtek,channel-use: description: | Backlight LED channel to be used. -- 2.7.4 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 1/2] dt-bindings: backlight: rt4831: Add the new ocp level property @ 2022-06-21 10:36 ` cy_huang 0 siblings, 0 replies; 10+ messages in thread From: cy_huang @ 2022-06-21 10:36 UTC (permalink / raw) To: robh+dt, krzysztof.kozlowski+dt, lee.jones, daniel.thompson, jingoohan1 Cc: devicetree, linux-fbdev, lucas_tsai, deller, linux-kernel, dri-devel, cy_huang, pavel, linux-leds From: ChiYuan Huang <cy_huang@richtek.com> Add 'richtek,bled-ocp-microamp' property to make it chooseable. The wrong backlight ocp level may affect the backlight channel output current smaller than configured. Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> --- Since v3: - Refine the description for backlight ocp property. - Use the enum to list the supported value. Since v2: - Change the property name from 'richtek,bled-ocp-sel' to 'richtek,bled-ocp-microamp'. --- .../devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml b/Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml index e0ac686..99e9e13 100644 --- a/Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +++ b/Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml @@ -47,6 +47,11 @@ properties: minimum: 0 maximum: 3 + richtek,bled-ocp-microamp: + description: | + Backlight over current protection level. + enum: [900000, 1200000, 1500000, 1800000] + richtek,channel-use: description: | Backlight LED channel to be used. -- 2.7.4 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: backlight: rt4831: Add the new ocp level property 2022-06-21 10:36 ` cy_huang @ 2022-06-27 14:07 ` Lee Jones -1 siblings, 0 replies; 10+ messages in thread From: Lee Jones @ 2022-06-27 14:07 UTC (permalink / raw) To: cy_huang Cc: robh+dt, krzysztof.kozlowski+dt, daniel.thompson, jingoohan1, pavel, deller, cy_huang, lucas_tsai, devicetree, dri-devel, linux-fbdev, linux-leds, linux-kernel On Tue, 21 Jun 2022, cy_huang wrote: > From: ChiYuan Huang <cy_huang@richtek.com> > > Add 'richtek,bled-ocp-microamp' property to make it chooseable. > > The wrong backlight ocp level may affect the backlight channel output > current smaller than configured. > > Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> > Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > --- > Since v3: > - Refine the description for backlight ocp property. > - Use the enum to list the supported value. > > Since v2: > - Change the property name from 'richtek,bled-ocp-sel' to 'richtek,bled-ocp-microamp'. > > --- > .../devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml | 5 +++++ > 1 file changed, 5 insertions(+) Applied, thanks. -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: backlight: rt4831: Add the new ocp level property @ 2022-06-27 14:07 ` Lee Jones 0 siblings, 0 replies; 10+ messages in thread From: Lee Jones @ 2022-06-27 14:07 UTC (permalink / raw) To: cy_huang Cc: devicetree, daniel.thompson, krzysztof.kozlowski+dt, lucas_tsai, jingoohan1, deller, linux-fbdev, dri-devel, linux-kernel, cy_huang, robh+dt, pavel, linux-leds On Tue, 21 Jun 2022, cy_huang wrote: > From: ChiYuan Huang <cy_huang@richtek.com> > > Add 'richtek,bled-ocp-microamp' property to make it chooseable. > > The wrong backlight ocp level may affect the backlight channel output > current smaller than configured. > > Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> > Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > --- > Since v3: > - Refine the description for backlight ocp property. > - Use the enum to list the supported value. > > Since v2: > - Change the property name from 'richtek,bled-ocp-sel' to 'richtek,bled-ocp-microamp'. > > --- > .../devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml | 5 +++++ > 1 file changed, 5 insertions(+) Applied, thanks. -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 2/2] backlight: rt4831: Apply ocp level from devicetree 2022-06-21 10:36 ` cy_huang @ 2022-06-21 10:36 ` cy_huang -1 siblings, 0 replies; 10+ messages in thread From: cy_huang @ 2022-06-21 10:36 UTC (permalink / raw) To: robh+dt, krzysztof.kozlowski+dt, lee.jones, daniel.thompson, jingoohan1 Cc: pavel, deller, cy_huang, lucas_tsai, devicetree, dri-devel, linux-fbdev, linux-leds, linux-kernel From: ChiYuan Huang <cy_huang@richtek.com> Add 'richtek,bled-ocp-microamp' property parsing in device_property_init function. This value may configure prior to the kernel driver. If it's not specified in devicetree, keep the original setting. Else, use clamp to align the value in min/max range and also roundup to choose the best selector. Reported-by: Lucas Tsai <lucas_tsai@richtek.com> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> --- Hi, Daniel: I may use the wrong macro, must be 'DIV_ROUND_UP', not 'roundup'. the v4 is to fix it. Since v4 - Fix wrong macro usage, must be 'DIV_ROUND_UP', not 'roundup' Since v2: - Prase the 'richtek,bled-ocp-microamp', clamp the value in min/max range, and roundup to get the best selector. --- drivers/video/backlight/rt4831-backlight.c | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/video/backlight/rt4831-backlight.c b/drivers/video/backlight/rt4831-backlight.c index 42155c7..eb8c59e 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,11 @@ #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_MINUA 900000 +#define RT4831_BLOCP_MAXUA 1800000 +#define RT4831_BLOCP_STEPUA 300000 struct rt4831_priv { struct device *dev; @@ -85,7 +91,7 @@ static int rt4831_parse_backlight_properties(struct rt4831_priv *priv, { struct device *dev = priv->dev; u8 propval; - u32 brightness; + u32 brightness, ocp_uA; unsigned int val = 0; int ret; @@ -120,6 +126,31 @@ static int rt4831_parse_backlight_properties(struct rt4831_priv *priv, if (ret) return ret; + /* + * This OCP level is used to protect and limit the inductor current. + * If inductor peak current reach the level, low-side MOSFET will be + * turned off. Meanwhile, the output channel current may be limited. + * To match the configured channel current, the inductor chosen must + * be higher than the OCP level. + * + * Not like the OVP level, the default 21V can be used in the most + * application. But if the chosen OCP level is smaller than needed, + * it will also affect the backlight channel output current to be + * smaller than the register setting. + */ + ret = device_property_read_u32(dev, "richtek,bled-ocp-microamp", + &ocp_uA); + if (!ret) { + ocp_uA = clamp_val(ocp_uA, RT4831_BLOCP_MINUA, + RT4831_BLOCP_MAXUA); + val = DIV_ROUND_UP(ocp_uA - RT4831_BLOCP_MINUA, + RT4831_BLOCP_STEPUA); + ret = regmap_update_bits(priv->regmap, RT4831_REG_BLOPT2, + RT4831_BLOCP_MASK, val); + 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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v4 2/2] backlight: rt4831: Apply ocp level from devicetree @ 2022-06-21 10:36 ` cy_huang 0 siblings, 0 replies; 10+ messages in thread From: cy_huang @ 2022-06-21 10:36 UTC (permalink / raw) To: robh+dt, krzysztof.kozlowski+dt, lee.jones, daniel.thompson, jingoohan1 Cc: devicetree, linux-fbdev, lucas_tsai, deller, linux-kernel, dri-devel, cy_huang, pavel, linux-leds From: ChiYuan Huang <cy_huang@richtek.com> Add 'richtek,bled-ocp-microamp' property parsing in device_property_init function. This value may configure prior to the kernel driver. If it's not specified in devicetree, keep the original setting. Else, use clamp to align the value in min/max range and also roundup to choose the best selector. Reported-by: Lucas Tsai <lucas_tsai@richtek.com> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> --- Hi, Daniel: I may use the wrong macro, must be 'DIV_ROUND_UP', not 'roundup'. the v4 is to fix it. Since v4 - Fix wrong macro usage, must be 'DIV_ROUND_UP', not 'roundup' Since v2: - Prase the 'richtek,bled-ocp-microamp', clamp the value in min/max range, and roundup to get the best selector. --- drivers/video/backlight/rt4831-backlight.c | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/video/backlight/rt4831-backlight.c b/drivers/video/backlight/rt4831-backlight.c index 42155c7..eb8c59e 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,11 @@ #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_MINUA 900000 +#define RT4831_BLOCP_MAXUA 1800000 +#define RT4831_BLOCP_STEPUA 300000 struct rt4831_priv { struct device *dev; @@ -85,7 +91,7 @@ static int rt4831_parse_backlight_properties(struct rt4831_priv *priv, { struct device *dev = priv->dev; u8 propval; - u32 brightness; + u32 brightness, ocp_uA; unsigned int val = 0; int ret; @@ -120,6 +126,31 @@ static int rt4831_parse_backlight_properties(struct rt4831_priv *priv, if (ret) return ret; + /* + * This OCP level is used to protect and limit the inductor current. + * If inductor peak current reach the level, low-side MOSFET will be + * turned off. Meanwhile, the output channel current may be limited. + * To match the configured channel current, the inductor chosen must + * be higher than the OCP level. + * + * Not like the OVP level, the default 21V can be used in the most + * application. But if the chosen OCP level is smaller than needed, + * it will also affect the backlight channel output current to be + * smaller than the register setting. + */ + ret = device_property_read_u32(dev, "richtek,bled-ocp-microamp", + &ocp_uA); + if (!ret) { + ocp_uA = clamp_val(ocp_uA, RT4831_BLOCP_MINUA, + RT4831_BLOCP_MAXUA); + val = DIV_ROUND_UP(ocp_uA - RT4831_BLOCP_MINUA, + RT4831_BLOCP_STEPUA); + ret = regmap_update_bits(priv->regmap, RT4831_REG_BLOPT2, + RT4831_BLOCP_MASK, val); + 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 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/2] backlight: rt4831: Apply ocp level from devicetree 2022-06-21 10:36 ` cy_huang @ 2022-06-27 14:08 ` Lee Jones -1 siblings, 0 replies; 10+ messages in thread From: Lee Jones @ 2022-06-27 14:08 UTC (permalink / raw) To: cy_huang Cc: robh+dt, krzysztof.kozlowski+dt, daniel.thompson, jingoohan1, pavel, deller, cy_huang, lucas_tsai, devicetree, dri-devel, linux-fbdev, linux-leds, linux-kernel On Tue, 21 Jun 2022, cy_huang wrote: > From: ChiYuan Huang <cy_huang@richtek.com> > > Add 'richtek,bled-ocp-microamp' property parsing in > device_property_init function. > > This value may configure prior to the kernel driver. If it's not specified in > devicetree, keep the original setting. Else, use clamp to align the > value in min/max range and also roundup to choose the best selector. > > Reported-by: Lucas Tsai <lucas_tsai@richtek.com> > Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> > Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> > --- > Hi, Daniel: > > I may use the wrong macro, must be 'DIV_ROUND_UP', not 'roundup'. > the v4 is to fix it. > > Since v4 > - Fix wrong macro usage, must be 'DIV_ROUND_UP', not 'roundup' > > Since v2: > - Prase the 'richtek,bled-ocp-microamp', clamp the value in min/max range, and > roundup to get the best selector. > > --- > drivers/video/backlight/rt4831-backlight.c | 33 +++++++++++++++++++++++++++++- > 1 file changed, 32 insertions(+), 1 deletion(-) Applied, thanks. -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/2] backlight: rt4831: Apply ocp level from devicetree @ 2022-06-27 14:08 ` Lee Jones 0 siblings, 0 replies; 10+ messages in thread From: Lee Jones @ 2022-06-27 14:08 UTC (permalink / raw) To: cy_huang Cc: devicetree, daniel.thompson, krzysztof.kozlowski+dt, lucas_tsai, jingoohan1, deller, linux-fbdev, dri-devel, linux-kernel, cy_huang, robh+dt, pavel, linux-leds On Tue, 21 Jun 2022, cy_huang wrote: > From: ChiYuan Huang <cy_huang@richtek.com> > > Add 'richtek,bled-ocp-microamp' property parsing in > device_property_init function. > > This value may configure prior to the kernel driver. If it's not specified in > devicetree, keep the original setting. Else, use clamp to align the > value in min/max range and also roundup to choose the best selector. > > Reported-by: Lucas Tsai <lucas_tsai@richtek.com> > Signed-off-by: ChiYuan Huang <cy_huang@richtek.com> > Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> > --- > Hi, Daniel: > > I may use the wrong macro, must be 'DIV_ROUND_UP', not 'roundup'. > the v4 is to fix it. > > Since v4 > - Fix wrong macro usage, must be 'DIV_ROUND_UP', not 'roundup' > > Since v2: > - Prase the 'richtek,bled-ocp-microamp', clamp the value in min/max range, and > roundup to get the best selector. > > --- > drivers/video/backlight/rt4831-backlight.c | 33 +++++++++++++++++++++++++++++- > 1 file changed, 32 insertions(+), 1 deletion(-) Applied, thanks. -- Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-06-27 14:08 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-06-21 10:36 [PATCH v4 0/2] Add the property to make backlight OCP level selectable cy_huang 2022-06-21 10:36 ` cy_huang 2022-06-21 10:36 ` [PATCH v4 1/2] dt-bindings: backlight: rt4831: Add the new ocp level property cy_huang 2022-06-21 10:36 ` cy_huang 2022-06-27 14:07 ` Lee Jones 2022-06-27 14:07 ` Lee Jones 2022-06-21 10:36 ` [PATCH v4 2/2] backlight: rt4831: Apply ocp level from devicetree cy_huang 2022-06-21 10:36 ` cy_huang 2022-06-27 14:08 ` Lee Jones 2022-06-27 14:08 ` Lee Jones
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.