Subject: [PATCH v3 0/8] Add support for MT6331 and MT6332 LEDs

Changes in v3:
- Rebase over next-20230601
- Beautified ISINK_CON0 comment
- Added binding for mediatek,is-wled property

Changes in v2:
- Rebase over next-20230412

NOTE: Since v1 of this series was sent in Semptember 2022 and got
ignored for *7 months* with no feedback, I'm retrying the upstreaming
of this same series.
There are no changes, if not just a simple rebase and another test
run on the same hardware.


MT6323 is not the only PMIC that has a LEDs controller IP and it was
found that the others do have a compatible register layout, except
for some register offsets.
The logic contained in this driver can be totally reused for other
PMICs as well, so I can't see any reason to keep this specific to
the MT6323 part.

This series brings meaningful platform data to this driver, giving
it flexibility and adding support for LED controllers found in the
MT6331 and MT6332 PMICs.

Tested on MT6795 Sony Xperia M5 smartphone.

AngeloGioacchino Del Regno (8):
dt-bindings: leds: leds-mt6323: Document mt6331 compatible
dt-bindings: leds: leds-mt6323: Document mt6332 compatible
dt-bindings: leds: leds-mt6323: Support WLED output
leds: leds-mt6323: Specify registers and specs in platform data
leds: leds-mt6323: Drop MT6323_ prefix from macros and defines
leds: leds-mt6323: Open code and drop MT6323_CAL_HW_DUTY macro
leds: leds-mt6323: Add support for MT6331 leds
leds: leds-mt6323: Add support for WLEDs and MT6332

.../devicetree/bindings/leds/leds-mt6323.txt | 6 +-
drivers/leds/leds-mt6323.c | 448 ++++++++++++++----
2 files changed, 352 insertions(+), 102 deletions(-)

--
2.40.1



Subject: [PATCH v3 2/8] dt-bindings: leds: leds-mt6323: Document mt6332 compatible

Add support for MT6332 LEDs/WLEDs with compatible "mediatek,mt6332-led".

Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
Acked-by: Krzysztof Kozlowski <[email protected]>
Reviewed-by: Alexandre Mergnat <[email protected]>
Acked-by: Pavel Machek <[email protected]>
---
Documentation/devicetree/bindings/leds/leds-mt6323.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/leds/leds-mt6323.txt b/Documentation/devicetree/bindings/leds/leds-mt6323.txt
index 7dc63af41562..052dccb8f2ce 100644
--- a/Documentation/devicetree/bindings/leds/leds-mt6323.txt
+++ b/Documentation/devicetree/bindings/leds/leds-mt6323.txt
@@ -15,6 +15,7 @@ Required properties:
- compatible : Must be one of
- "mediatek,mt6323-led"
- "mediatek,mt6331-led"
+ - "mediatek,mt6332-led"
- address-cells : Must be 1
- size-cells : Must be 0

--
2.40.1


Subject: [PATCH v3 6/8] leds: leds-mt6323: Open code and drop MT6323_CAL_HW_DUTY macro

There is only one instance of using this macro and it's anyway not
simplifying the flow, or increasing the readability of this driver.

Drop this macro by open coding it in mt6323_led_set_blink().

No functional changes.

Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
Reviewed-by: Alexandre Mergnat <[email protected]>
---
drivers/leds/leds-mt6323.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c
index dae782de09c4..f8bd9f17e89c 100644
--- a/drivers/leds/leds-mt6323.c
+++ b/drivers/leds/leds-mt6323.c
@@ -57,8 +57,6 @@
#define ISINK_CH_EN(i) BIT(i)

#define MAX_SUPPORTED_LEDS 8
-#define MT6323_CAL_HW_DUTY(o, p, u) DIV_ROUND_CLOSEST((o) * 100000ul,\
- (p) * (u))

struct mt6323_leds;

@@ -316,7 +314,7 @@ static int mt6323_led_set_blink(struct led_classdev *cdev,
* Calculate duty_hw based on the percentage of period during
* which the led is ON.
*/
- duty_hw = MT6323_CAL_HW_DUTY(*delay_on, period, spec->unit_duty);
+ duty_hw = DIV_ROUND_CLOSEST(*delay_on * 100000ul, period * spec->unit_duty);

/* hardware doesn't support zero duty cycle. */
if (!duty_hw)
--
2.40.1


2023-06-09 06:54:48

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v3 6/8] leds: leds-mt6323: Open code and drop MT6323_CAL_HW_DUTY macro

On Thu, 01 Jun 2023, AngeloGioacchino Del Regno wrote:

> There is only one instance of using this macro and it's anyway not
> simplifying the flow, or increasing the readability of this driver.
>
> Drop this macro by open coding it in mt6323_led_set_blink().
>
> No functional changes.
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
> Reviewed-by: Alexandre Mergnat <[email protected]>
> ---
> drivers/leds/leds-mt6323.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)

Applied, thanks

--
Lee Jones [李琼斯]

2023-06-09 06:55:12

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v3 2/8] dt-bindings: leds: leds-mt6323: Document mt6332 compatible

On Thu, 01 Jun 2023, AngeloGioacchino Del Regno wrote:

> Add support for MT6332 LEDs/WLEDs with compatible "mediatek,mt6332-led".
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
> Acked-by: Krzysztof Kozlowski <[email protected]>
> Reviewed-by: Alexandre Mergnat <[email protected]>
> Acked-by: Pavel Machek <[email protected]>
> ---
> Documentation/devicetree/bindings/leds/leds-mt6323.txt | 1 +
> 1 file changed, 1 insertion(+)

Applied, thanks

--
Lee Jones [李琼斯]