Skip to contentSkip to conversation

Add the property to make ocp level selectable

PATCH Superseded cy_huang 4 participants 15 messages May 26, 2022 – Jun 6, 2022

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

cy_huang

author
#0 lore raw

cover Add the property to make ocp level selectable

From: ChiYuan Huang <[email protected]>

This patch series is to make ocp level selectable.

Some application design use small inductor. And it's easy to trigger the over current protection. Due to the OCP limit, It make the brightness current not match the configured value.

To meet the HW design, the ocp level have to be selectable.

ChiYuan Huang (2):
dt-bindings: backlight: rt4831: Add the new property for ocp level
selection
backlight: rt4831: Add the property parsing for ocp level selection

 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml   |  8 ++++++++
 drivers/video/backlight/rt4831-backlight.c                  | 13 +++++++++++++
 include/dt-bindings/leds/rt4831-backlight.h                 |  5 +++++
 3 files changed, 26 insertions(+)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/2 dt-bindings: backlight: rt4831: Add the new property for ocp level selection

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +8 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
+  richtek,bled-ocp-sel:
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A
+    $ref: /schemas/types.yaml#/definitions/uint8
+    default: 1
+    minimum: 0
+    maximum: 3
+
   richtek,channel-use:
     description: |
       Backlight LED channel to be used.
include/dt-bindings/leds/rt4831-backlight.h +5 -0
index 125c635..e8b8609 100644
@@ -14,6 +14,11 @@
 #define RT4831_BLOVPLVL_25V	2
 #define RT4831_BLOVPLVL_29V	3
 
+#define RT4831_BLOCPLVL_0P9A	0
+#define RT4831_BLOCPLVL_1P2A	1
+#define RT4831_BLOCPLVL_1P5A	2
+#define RT4831_BLOCPLVL_1P8A	3
+
 #define RT4831_BLED_CH1EN	(1 << 0)
 #define RT4831_BLED_CH2EN	(1 << 1)
 #define RT4831_BLED_CH3EN	(1 << 2)
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Quoted 15 lines · cy_huang

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 4 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 52

Quoted 2 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A

Could you explain here what is OCP (unfold the acronym)?

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Krzysztof Kozlowski <[email protected]> 於 2022年5月26日 週四 下午4:06寫道:

Quoted 20 lines · cy_huang
Quoted 18 lines

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

OK, if so, do I need to rename all properties from 'bled' to 'backlight' ? If only this property is naming as 'backlight'. it may conflict with the others like as "richtek,bled-ovp-sel".

Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 52

Quoted 3 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A

Could you explain here what is OCP (unfold the acronym)?

Yes. And the full name is 'over current protection'.

Quoted 4 lines

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Quoted 21 lines · ChiYuan Huang

Krzysztof Kozlowski <[email protected]> 於 2022年5月26日 週四 下午4:06寫道:

Quoted 20 lines · cy_huang
Quoted 18 lines

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

OK, if so, do I need to rename all properties from 'bled' to 'backlight' ? If only this property is naming as 'backlight'. it may conflict with the others like as "richtek,bled-ovp-sel".

Ah, no, no need.

Quoted 6 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 52

Quoted 3 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A

Could you explain here what is OCP (unfold the acronym)?

Yes. And the full name is 'over current protection'.

Thanks and this leads to second thing - you encode register value instead of logical value. This must be a logical value in mA, so "richtek,bled-ocp-microamp".

I see you already did some register-style for voltage. It's wrong but it was done, so let it be. But let's don't make that a pattern...

Quoted 4 lines
Quoted 4 lines

Best regards,
Krzysztof

Best regards,
Krzysztof

maintainer
#5 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Quoted 37 lines · Krzysztof Kozlowski
Quoted 21 lines · ChiYuan Huang

Krzysztof Kozlowski <[email protected]> 於 2022年5月26日 週四 下午4:06寫道:

Quoted 20 lines · cy_huang
Quoted 18 lines

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

OK, if so, do I need to rename all properties from 'bled' to 'backlight' ? If only this property is naming as 'backlight'. it may conflict with the others like as "richtek,bled-ovp-sel".

Ah, no, no need.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

Could you explain here what is OCP (unfold the acronym)?

Yes. And the full name is 'over current protection'.

Thanks and this leads to second thing - you encode register value instead of logical value. This must be a logical value in mA, so "richtek,bled-ocp-microamp".

We already have common properties for setting current of LEDs. We should use that here I think.

Rob

#6 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Quoted 39 lines · Rob Herring
Quoted 38 lines · Krzysztof Kozlowski
Quoted 21 lines · ChiYuan Huang

Krzysztof Kozlowski <[email protected]> 於 2022年5月26日 週四 下午4:06寫道:

Quoted 20 lines · cy_huang
Quoted 18 lines

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

OK, if so, do I need to rename all properties from 'bled' to 'backlight' ? If only this property is naming as 'backlight'. it may conflict with the others like as "richtek,bled-ovp-sel".

Ah, no, no need.

Quoted 5 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 52

Quoted 3 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A

Could you explain here what is OCP (unfold the acronym)?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yes. And the full name is 'over current protection'.

Thanks and this leads to second thing - you encode register value instead of logical value. This must be a logical value in mA, so "richtek,bled-ocp-microamp".

We already have common properties for setting current of LEDs. We should use that here I think.

It might not be exactly the same. We have "led-max-microamp" which is the maximum allowed current. I guess over-current protection level is slightly higher (e.g. led-max-microamp + 1). IOW, led-max-microamp is something which still can be set and used by system/hardware. OCP should not.

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Krzysztof Kozlowski <[email protected]> 於 2022年6月2日 週四 下午9:58寫道:

Quoted 47 lines · Rob Herring
Quoted 45 lines · Krzysztof Kozlowski
Quoted 43 lines · ChiYuan Huang
Quoted 21 lines

Krzysztof Kozlowski <[email protected]> 於 2022年5月26日 週四 下午4:06寫道:

Quoted 20 lines · cy_huang
Quoted 18 lines

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

OK, if so, do I need to rename all properties from 'bled' to 'backlight' ? If only this property is naming as 'backlight'. it may conflict with the others like as "richtek,bled-ovp-sel".

Ah, no, no need.

Quoted 6 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 52

Quoted 3 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A

Could you explain here what is OCP (unfold the acronym)?

Yes. And the full name is 'over current protection'.

Thanks and this leads to second thing - you encode register value instead of logical value. This must be a logical value in mA, so "richtek,bled-ocp-microamp".

Quoted 9 lines
Quoted 2 lines

We already have common properties for setting current of LEDs. We should use that here I think.

It might not be exactly the same. We have "led-max-microamp" which is the maximum allowed current. I guess over-current protection level is slightly higher (e.g. led-max-microamp + 1). IOW, led-max-microamp is something which still can be set and used by system/hardware. OCP should not.

Yap, you're right.
From the modern backlight IC design, it uses the boost converter architecture. This OCP level is to limit the inductor current when the internal MOS switch turn on.
Details can refer to the below wiki link
https://en.wikipedia.org/wiki/Boost_converter

And based on it, OVP is used to limit the inductor output voltage. Each channel maximum current is based on the IC affordable limit. It is more like as what you said 'led-max-microamp'.

So boost voltage level may depend on the LED VF.
The different series of LED may cause different boost voltage.

RT4831's OVP/OCP is not just the protection, more like as the limit.

Quoted 3 lines

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Quoted 51 lines · ChiYuan Huang

Krzysztof Kozlowski <[email protected]> 於 2022年6月2日 週四 下午9:58寫道:

Quoted 50 lines · Rob Herring
Quoted 47 lines · Krzysztof Kozlowski
Quoted 37 lines · ChiYuan Huang
Quoted 21 lines

Krzysztof Kozlowski <[email protected]> 於 2022年5月26日 週四 下午4:06寫道:

Quoted 20 lines · cy_huang
Quoted 18 lines

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

OK, if so, do I need to rename all properties from 'bled' to 'backlight' ? If only this property is naming as 'backlight'. it may conflict with the others like as "richtek,bled-ovp-sel".

Ah, no, no need.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

Could you explain here what is OCP (unfold the acronym)?

Yes. And the full name is 'over current protection'.

Thanks and this leads to second thing - you encode register value instead of logical value. This must be a logical value in mA, so "richtek,bled-ocp-microamp".

We already have common properties for setting current of LEDs. We should use that here I think.

Quoted 7 lines
Quoted 6 lines

It might not be exactly the same. We have "led-max-microamp" which is the maximum allowed current. I guess over-current protection level is slightly higher (e.g. led-max-microamp + 1). IOW, led-max-microamp is something which still can be set and used by system/hardware. OCP should not.

Yap, you're right.

So I am right or Rob?

Quoted 6 lines

From the modern backlight IC design, it uses the boost converter architecture. This OCP level is to limit the inductor current when the internal MOS switch turn on.
Details can refer to the below wiki link
https://en.wikipedia.org/wiki/Boost_converter

Quoted 8 lines

And based on it, OVP is used to limit the inductor output voltage. Each channel maximum current is based on the IC affordable limit. It is more like as what you said 'led-max-microamp'.

So boost voltage level may depend on the LED VF.
The different series of LED may cause different boost voltage.

RT4831's OVP/OCP is not just the protection, more like as the limit.

This suggests Rob is right, so let's use led-max-microamp property?

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Krzysztof Kozlowski <[email protected]> 於 2022年6月6日 週一 上午12:11寫道:

Quoted 59 lines · ChiYuan Huang
Quoted 57 lines

Krzysztof Kozlowski <[email protected]> 於 2022年6月2日 週四 下午9:58寫道:

Quoted 56 lines · Rob Herring
Quoted 39 lines · Krzysztof Kozlowski
Quoted 38 lines · ChiYuan Huang
Quoted 21 lines

Krzysztof Kozlowski <[email protected]> 於 2022年5月26日 週四 下午4:06寫道:

Quoted 20 lines · cy_huang
Quoted 18 lines

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

OK, if so, do I need to rename all properties from 'bled' to 'backlight' ? If only this property is naming as 'backlight'. it may conflict with the others like as "richtek,bled-ovp-sel".

Ah, no, no need.

Quoted 5 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 52

Quoted 3 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A

Could you explain here what is OCP (unfold the acronym)?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yes. And the full name is 'over current protection'.

Thanks and this leads to second thing - you encode register value instead of logical value. This must be a logical value in mA, so "richtek,bled-ocp-microamp".

We already have common properties for setting current of LEDs. We should use that here I think.

It might not be exactly the same. We have "led-max-microamp" which is the maximum allowed current. I guess over-current protection level is slightly higher (e.g. led-max-microamp + 1). IOW, led-max-microamp is something which still can be set and used by system/hardware. OCP should not.

Quoted 4 lines
Quoted 1 line

Yap, you're right.

So I am right or Rob?

As I know, both are incorrect.

Quoted 10 lines
Quoted 10 lines

From the modern backlight IC design, it uses the boost converter architecture. This OCP level is to limit the inductor current when the internal MOS switch turn on.
Details can refer to the below wiki link
https://en.wikipedia.org/wiki/Boost_converter

And based on it, OVP is used to limit the inductor output voltage. Each channel maximum current is based on the IC affordable limit. It is more like as what you said 'led-max-microamp'.

Quoted 7 lines
Quoted 4 lines

So boost voltage level may depend on the LED VF.
The different series of LED may cause different boost voltage.

RT4831's OVP/OCP is not just the protection, more like as the limit.

This suggests Rob is right, so let's use led-max-microamp property?

No, the meaning is different. 'led-max-microamp' always means the channel output current.
It already can be adjusted by backlight brightness node.

For example
low voltage side (3.3~4.4V) to generate the boost voltage to 16~17V, even 20V for BLED Vout.
This OCP is to limit the input current of low voltage side.

After the explanation, do you still think it's the same thing?

Quoted 2 lines

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH 1/2] dt-bindings: backlight: rt4831: Add the new property for ocp level selection

Quoted 86 lines · ChiYuan Huang

Krzysztof Kozlowski <[email protected]> 於 2022年6月6日 週一 上午12:11寫道:

Quoted 59 lines · ChiYuan Huang
Quoted 57 lines

Krzysztof Kozlowski <[email protected]> 於 2022年6月2日 週四 下午9:58寫道:

Quoted 56 lines · Rob Herring
Quoted 39 lines · Krzysztof Kozlowski
Quoted 38 lines · ChiYuan Huang
Quoted 21 lines

Krzysztof Kozlowski <[email protected]> 於 2022年5月26日 週四 下午4:06寫道:

Quoted 20 lines · cy_huang
Quoted 18 lines

From: ChiYuan Huang <[email protected]>

Add the new property for ocp level selection.

---
 .../bindings/leds/backlight/richtek,rt4831-backlight.yaml         | 8 ++++++++
 include/dt-bindings/leds/rt4831-backlight.h                       | 5 +++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +0 -0
index e0ac686..c1c59de 100644
@@ -47,6 +47,14 @@ properties:
     minimum: 0
     maximum: 3
 
Quoted 8 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +1 -0
+  richtek,bled-ocp-sel:

Skip "sel" as it is a shortcut of selection. Name instead:
"richtek,backlight-ocp"

OK, if so, do I need to rename all properties from 'bled' to 'backlight' ? If only this property is naming as 'backlight'. it may conflict with the others like as "richtek,bled-ovp-sel".

Ah, no, no need.

Quoted 5 lines
Quoted 5 lines

Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml properties: · line 52

Quoted 3 lines
Documentation/devicetree/bindings/leds/backlight/richtek,rt4831-backlight.yaml +2 -0
+    description: |
+      Backlight OCP level selection, currently support 0.9A/1.2A/1.5A/1.8A

Could you explain here what is OCP (unfold the acronym)?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Yes. And the full name is 'over current protection'.

Thanks and this leads to second thing - you encode register value instead of logical value. This must be a logical value in mA, so "richtek,bled-ocp-microamp".

We already have common properties for setting current of LEDs. We should use that here I think.

It might not be exactly the same. We have "led-max-microamp" which is the maximum allowed current. I guess over-current protection level is slightly higher (e.g. led-max-microamp + 1). IOW, led-max-microamp is something which still can be set and used by system/hardware. OCP should not.

Quoted 4 lines
Quoted 1 line

Yap, you're right.

So I am right or Rob?

As I know, both are incorrect.

Quoted 10 lines
Quoted 10 lines

From the modern backlight IC design, it uses the boost converter architecture. This OCP level is to limit the inductor current when the internal MOS switch turn on.
Details can refer to the below wiki link
https://en.wikipedia.org/wiki/Boost_converter

And based on it, OVP is used to limit the inductor output voltage. Each channel maximum current is based on the IC affordable limit. It is more like as what you said 'led-max-microamp'.

Quoted 7 lines
Quoted 4 lines

So boost voltage level may depend on the LED VF.
The different series of LED may cause different boost voltage.

RT4831's OVP/OCP is not just the protection, more like as the limit.

This suggests Rob is right, so let's use led-max-microamp property?

No, the meaning is different. 'led-max-microamp' always means the channel output current.
It already can be adjusted by backlight brightness node.

Quoted 6 lines

For example
low voltage side (3.3~4.4V) to generate the boost voltage to 16~17V, even 20V for BLED Vout.
This OCP is to limit the input current of low voltage side.

After the explanation, do you still think it's the same thing?

This sounds differently so I propose to use this dedicated property with the changes I asked for.

Best regards,
Krzysztof

author
#11 lore raw

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

In reply to cy_huang

From: ChiYuan Huang <[email protected]>

Add the property parsing for ocp level selection.

---
 drivers/video/backlight/rt4831-backlight.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/video/backlight/rt4831-backlight.c +13 -0
index 42155c7..c81f7d9 100644
@@ -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");
Signature · 1 line
2.7.4
#12 lore raw

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

Quoted 3 lines · cy_huang

From: ChiYuan Huang <[email protected]>

Add the property parsing for ocp level selection.

Isn't this just restating the Subject: line?

It would be better to provide information useful to the reviewer here. Something like:

"Currently this driver simply inherits whatever over-current protection level is programmed into the hardware when it is handed over. Typically this will be the reset value, <whatever>A, although the bootloader could have established a different value.

Allow the correct OCP value to be provided by the DT."

BTW please don't uncritically copy the above into the patch header. It is just made something up as an example and I did no fact checking...

Quoted 29 lines
---
 drivers/video/backlight/rt4831-backlight.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/video/backlight/rt4831-backlight.c +3 -0
index 42155c7..c81f7d9 100644
@@ -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;

drivers/video/backlight/rt4831-backlight.c static int rt4831_parse_backlight_properties(struct rt4831_priv *priv, · line 128

Quoted 6 lines
drivers/video/backlight/rt4831-backlight.c +3 -0
@@ -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;

Is 1.2A the reset value for the register?

Additionally, it looks like adding a hard-coded default would cause problems for existing platforms where the bootloader doesn't use richtek,bled-ocp-sel and pre-configures a different value itself.

Would it be safer (in terms of working nicely with older bootloaders) to only write to the RT4831_BLOCP_MASK if the new property is set?

Daniel.

Quoted 13 lines
drivers/video/backlight/rt4831-backlight.c +7 -0
+
+	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");
Signature · 1 line
2.7.4
#13 lore raw

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

Daniel Thompson <[email protected]> 於 2022年5月26日 週四 下午6:05寫道:

Quoted 8 lines · cy_huang
Quoted 3 lines

From: ChiYuan Huang <[email protected]>

Add the property parsing for ocp level selection.

Isn't this just restating the Subject: line?

Ah, that's my fault. I didn't state too much in the patch comment. I only left it in the cover letter.

Quoted 8 lines

It would be better to provide information useful to the reviewer here. Something like:

"Currently this driver simply inherits whatever over-current protection level is programmed into the hardware when it is handed over. Typically this will be the reset value, <whatever>A, although the bootloader could have established a different value.

Quoted 5 lines

Allow the correct OCP value to be provided by the DT."

BTW please don't uncritically copy the above into the patch header. It is just made something up as an example and I did no fact checking...

OK, got it.

Quoted 33 lines
Quoted 33 lines
---
 drivers/video/backlight/rt4831-backlight.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/video/backlight/rt4831-backlight.c +3 -0
index 42155c7..c81f7d9 100644
@@ -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;
 
Quoted 5 lines

drivers/video/backlight/rt4831-backlight.c static int rt4831_parse_backlight_properties(struct rt4831_priv *priv, · line 128

Quoted 3 lines
drivers/video/backlight/rt4831-backlight.c +3 -0
+     ret = device_property_read_u8(dev, "richtek,bled-ocp-sel", &propval);
+     if (ret)
+             propval = RT4831_BLOCPLVL_1P2A;

Is 1.2A the reset value for the register?

Yes, it's the HW default value.

Quoted 8 lines

Additionally, it looks like adding a hard-coded default would cause problems for existing platforms where the bootloader doesn't use richtek,bled-ocp-sel and pre-configures a different value itself.

Would it be safer (in terms of working nicely with older bootloaders) to only write to the RT4831_BLOCP_MASK if the new property is set?

Ah, my excuse. I really didn't consider the case that you mentioned. It seems it's better to do the judgement here for two cases.
1) property not exist, keep the current HW value
2) property exist, clamp align and update the suitable selector to HW.

Thanks.

Quoted 18 lines

Daniel.

Quoted 13 lines
drivers/video/backlight/rt4831-backlight.c +7 -1
+
+     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

#14 lore raw

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

Quoted 70 lines · ChiYuan Huang

Daniel Thompson <[email protected]> 於 2022年5月26日 週四 下午6:05寫道:

Quoted 8 lines · cy_huang
Quoted 3 lines

From: ChiYuan Huang <[email protected]>

Add the property parsing for ocp level selection.

Isn't this just restating the Subject: line?

Ah, that's my fault. I didn't state too much in the patch comment. I only left it in the cover letter.

Quoted 8 lines

It would be better to provide information useful to the reviewer here. Something like:

"Currently this driver simply inherits whatever over-current protection level is programmed into the hardware when it is handed over. Typically this will be the reset value, <whatever>A, although the bootloader could have established a different value.

Quoted 5 lines

Allow the correct OCP value to be provided by the DT."

BTW please don't uncritically copy the above into the patch header. It is just made something up as an example and I did no fact checking...

OK, got it.

Quoted 33 lines
Quoted 33 lines
---
 drivers/video/backlight/rt4831-backlight.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/video/backlight/rt4831-backlight.c +3 -0
index 42155c7..c81f7d9 100644
@@ -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;
 
Quoted 5 lines

drivers/video/backlight/rt4831-backlight.c static int rt4831_parse_backlight_properties(struct rt4831_priv *priv, · line 128

Quoted 3 lines
drivers/video/backlight/rt4831-backlight.c +3 -0
+     ret = device_property_read_u8(dev, "richtek,bled-ocp-sel", &propval);
+     if (ret)
+             propval = RT4831_BLOCPLVL_1P2A;

Is 1.2A the reset value for the register?

Yes, it's the HW default value.

Quoted 5 lines

Additionally, it looks like adding a hard-coded default would cause problems for existing platforms where the bootloader doesn't use richtek,bled-ocp-sel and pre-configures a different value itself.

Quoted 7 lines
Quoted 3 lines

Would it be safer (in terms of working nicely with older bootloaders) to only write to the RT4831_BLOCP_MASK if the new property is set?

Ah, my excuse. I really didn't consider the case that you mentioned. It seems it's better to do the judgement here for two cases.
1) property not exist, keep the current HW value
2) property exist, clamp align and update the suitable selector to HW.

Ok, great.

When you make this change can you make sure there is a comment in the source code explaining that concerns about older firmware is *why* we treat bled-ocp-sel differently to bled-ovp-sel!

Thanks

Daniel.