Skip to contentSkip to conversation

Add support for WLED5

PATCH Superseded Kiran Gunda 2 participants 5 messages Mar 2, 2020 – Mar 9, 2020

Subsystems (5)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 backlight: qcom-wled: convert the wled bindings to .yaml format

In reply to Kiran Gunda

Convert the qcom-wled bindings from .txt to .yaml format.

---
 .../bindings/leds/backlight/qcom-wled.txt          | 154 -----------------
 .../bindings/leds/backlight/qcom-wled.yaml         | 184 +++++++++++++++++++++
 2 files changed, 184 insertions(+), 154 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/backlight/qcom-wled.txt
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/qcom-wled.yaml
Documentation/devicetree/bindings/leds/backlight/qcom-wled.txt deleted +0 -154
deleted file mode 100644
index c06863b..0000000
@@ -1,154 +0,0 @@
-Binding for Qualcomm Technologies, Inc. WLED driver
-
-WLED (White Light Emitting Diode) driver is used for controlling display
-backlight that is part of PMIC on Qualcomm Technologies, Inc. reference
-platforms. The PMIC is connected to the host processor via SPMI bus.
-
-- compatible
-	Usage:        required
-	Value type:   <string>
-	Definition:   should be one of:
-			"qcom,pm8941-wled"
-			"qcom,pmi8998-wled"
-			"qcom,pm660l-wled"
-
-- reg
-	Usage:        required
-	Value type:   <prop encoded array>
-	Definition:   Base address of the WLED modules.
-
-- default-brightness
-	Usage:        optional
-	Value type:   <u32>
-	Definition:   brightness value on boot, value from: 0-4095.
-		      Default: 2048
-
-- label
-	Usage:        required
-	Value type:   <string>
-	Definition:   The name of the backlight device
-
-- qcom,cs-out
-	Usage:        optional
-	Value type:   <bool>
-	Definition:   enable current sink output.
-		      This property is supported only for PM8941.
-
-- qcom,cabc
-	Usage:        optional
-	Value type:   <bool>
-	Definition:   enable content adaptive backlight control.
-
-- qcom,ext-gen
-	Usage:        optional
-	Value type:   <bool>
-	Definition:   use externally generated modulator signal to dim.
-		      This property is supported only for PM8941.
-
-- qcom,current-limit
-	Usage:        optional
-	Value type:   <u32>
-	Definition:   mA; per-string current limit; value from 0 to 25 with
-		      1 mA step. Default 20 mA.
-		      This property is supported only for pm8941.
-
-- qcom,current-limit-microamp
-	Usage:        optional
-	Value type:   <u32>
-	Definition:   uA; per-string current limit; value from 0 to 30000 with
-		      2500 uA step. Default 25 mA.
-
-- qcom,current-boost-limit
-	Usage:        optional
-	Value type:   <u32>
-	Definition:   mA; boost current limit.
-		      For pm8941: one of: 105, 385, 525, 805, 980, 1260, 1400,
-		      1680. Default: 805 mA.
-		      For pmi8998: one of: 105, 280, 450, 620, 970, 1150, 1300,
-		      1500. Default: 970 mA.
-
-- qcom,switching-freq
-	Usage:        optional
-	Value type:   <u32>
-	 Definition:   kHz; switching frequency; one of: 600, 640, 685, 738,
-		       800, 872, 960, 1066, 1200, 1371, 1600, 1920, 2400, 3200,
-		       4800, 9600.
-		       Default: for pm8941: 1600 kHz
-				for pmi8998: 800 kHz
-
-- qcom,ovp
-	Usage:        optional
-	Value type:   <u32>
-	Definition:   V; Over-voltage protection limit; one of:
-		      27, 29, 32, 35. Default: 29V
-		      This property is supported only for PM8941.
-
-- qcom,ovp-millivolt
-	Usage:        optional
-	Value type:   <u32>
-	Definition:   mV; Over-voltage protection limit;
-		      For pmi8998: one of 18100, 19600, 29600, 31100.
-		      Default 29600 mV.
-		      If this property is not specified for PM8941, it
-		      falls back to "qcom,ovp" property.
-
-- qcom,num-strings
-	Usage:        optional
-	Value type:   <u32>
-	Definition:   #; number of led strings attached;
-		      value: For PM8941 from 1 to 3. Default: 2
-			     For PMI8998 from 1 to 4.
-
-- interrupts
-	Usage:        optional
-	Value type:   <prop encoded array>
-	Definition:   Interrupts associated with WLED. This should be
-		      "short" and "ovp" interrupts. Interrupts can be
-		      specified as per the encoding listed under
-		      Documentation/devicetree/bindings/spmi/
-		      qcom,spmi-pmic-arb.txt.
-
-- interrupt-names
-	Usage:        optional
-	Value type:   <string>
-	Definition:   Interrupt names associated with the interrupts.
-		      Must be "short" and "ovp". The short circuit detection
-		      is not supported for PM8941.
-
-- qcom,enabled-strings
-	Usage:        optional
-	Value tyoe:   <u32 array>
-	Definition:   Array of the WLED strings numbered from 0 to 3. Each
-		      string of leds are operated individually. Specify the
-		      list of strings used by the device. Any combination of
-		      led strings can be used.
-
-- qcom,external-pfet
-	Usage:        optional
-	Value type:   <bool>
-	Definition:   Specify if external PFET control for short circuit
-		      protection is used. This property is supported only
-		      for PMI8998.
-
-- qcom,auto-string-detection
-	Usage:        optional
-	Value type:   <bool>
-	Definition:   Enables auto-detection of the WLED string configuration.
-		      This feature is not supported for PM8941.
-
-
-Example:
-
-pm8941-wled@d800 {
-	compatible = "qcom,pm8941-wled";
-	reg = <0xd800>;
-	label = "backlight";
-
-	qcom,cs-out;
-	qcom,current-limit = <20>;
-	qcom,current-boost-limit = <805>;
-	qcom,switching-freq = <1600>;
-	qcom,ovp = <29>;
-	qcom,num-strings = <2>;
-	qcom,enabled-strings = <0 1>;
-};
Documentation/devicetree/bindings/leds/backlight/qcom-wled.yaml new file +184 -0

184 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
 a Linux Foundation Collaborative Project
#0 lore raw

cover Add support for WLED5

Currently, WLED driver supports only WLED4 peripherals that is present on pmi8998 and pm660L. This patch series converts the existing WLED4 bindings from .txt to .yaml format and adds the support for WLED5 peripheral that is present on PM8150L.

PM8150L WLED supports the following.
- Two modulators and each sink can use any of the modulator
- Multiple CABC selection options
- Multiple brightness width selection (12 bits to 15 bits)

Kiran Gunda (2):
backlight: qcom-wled: convert the wled bindings to .yaml format
backlight: qcom-wled: Add support for WLED5 peripheral in PM8150L

 .../bindings/leds/backlight/qcom-wled.txt          | 154 -------
 .../bindings/leds/backlight/qcom-wled.yaml         | 223 ++++++++++
 drivers/video/backlight/qcom-wled.c                | 463 ++++++++++++++++++---
 3 files changed, 636 insertions(+), 204 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/backlight/qcom-wled.txt
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/qcom-wled.yaml
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
 a Linux Foundation Collaborative Project
#2 lore raw

PATCH 2/2 backlight: qcom-wled: Add support for WLED5 peripheral in PM8150L

Add support for WLED5 peripheral that is present on PM8150L PMICs.

PM8150L WLED supports the following.
- Two modulators and each sink can use any of the modulator
- Multiple CABC selection options
- Multiple brightness width selection (12 bits to 15 bits)

---
 .../bindings/leds/backlight/qcom-wled.yaml         |  39 ++
 drivers/video/backlight/qcom-wled.c                | 463 ++++++++++++++++++---
 2 files changed, 452 insertions(+), 50 deletions(-)
Documentation/devicetree/bindings/leds/backlight/qcom-wled.yaml +39 -0
index d334f81..e0dadc4 100644
@@ -20,6 +20,7 @@ properties:
        - qcom,pm8941-wled
        - qcom,pmi8998-wled
        - qcom,pm660l-wled
+       - qcom,pm8150l-wled
 
   reg:
     maxItems: 1
@@ -28,10 +29,23 @@ properties:
     maxItems: 1
     description:
       brightness value on boot, value from 0-4095.
+      For pm8150l this value vary from 0-4095 or 0-32767
+      depending on the brightness control mode. If CABC is
+      enabled 0-4095 range is used.
     allOf:
       - $ref: /schemas/types.yaml#/definitions/uint32
         default: 2048
 
+  max-brightness:
+    maxItems: 1
+    description:
+      Maximum brightness level. Allowed values are,
+      for pmi8998 it is  0-4095.
+      For pm8150l, this can be either 4095 or 32767.
+      If CABC is enabled, this is capped to 4095.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+
   label:
     maxItems: 1
     description:
@@ -124,6 +138,31 @@ properties:
       value for PM8941 from 1 to 3. Default 2
       For PMI8998 from 1 to 4.
 
+  qcom,modulator-sel:
+    maxItems: 1
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Selects the modulator used for brightness modulation.
+      Allowed values are,
+               0 - Modulator A
+               1 - Modulator B
+      If not specified, then modulator A will be used by default.
+      This property is applicable only to WLED5 peripheral.
+
+  qcom,cabc-sel:
+    maxItems: 1
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Selects the CABC pin signal used for brightness modulation.
+      Allowed values are,
+              0 - CABC disabled
+              1 - CABC 1
+              2 - CABC 2
+              3 - External signal (e.g. LPG) is used for dimming
+      This property is applicable only to WLED5 peripheral.
+
   interrupts:
     maxItems: 2
     description:
drivers/video/backlight/qcom-wled.c +413 -50

653 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
 a Linux Foundation Collaborative Project
#3 lore raw

Re: [PATCH V1 2/2] backlight: qcom-wled: Add support for WLED5 peripheral in PM8150L

Quoted 1 line · Kiran Gunda
drivers/video/backlight/qcom-wled.c +0 -0

[..]

Quoted 6 lines
drivers/video/backlight/qcom-wled.c +1 -0
@@ -147,14 +187,39 @@ struct wled {
 	u32 max_brightness;
 	u32 short_count;
 	u32 auto_detect_count;
+	u32 version;
 	bool disabled_by_short;

drivers/video/backlight/qcom-wled.c struct wled { · line 201

Quoted 10 lines
drivers/video/backlight/qcom-wled.c +3 -0
 	bool has_short_detect;
+	bool cabc_disabled;
 	int short_irq;
 	int ovp_irq;
 
 	struct wled_config cfg;
 	struct delayed_work ovp_work;
 	int (*wled_set_brightness)(struct wled *wled, u16 brightness);
+	int (*cabc_config)(struct wled *wled, bool enable);
+	int (*wled_sync_toggle)(struct wled *wled);

Please split this patch in one that adds these and breaks out the wled3 support, and then a second patch that adds wled5.

Quoted 2 lines
drivers/video/backlight/qcom-wled.c +2 -0
+};
+

[..]

drivers/video/backlight/qcom-wled.c static int wled3_set_brightness(struct wled *wled, u16 brightness) · line 255

Quoted 13 lines
drivers/video/backlight/qcom-wled.c +13 -0
+static int wled5_set_brightness(struct wled *wled, u16 brightness)
+{
+	int rc, offset;
+	u16 low_limit = wled->max_brightness * 1 / 1000;
+	u8 v[2], brightness_msb_mask;
+
+	/* WLED5's lower limit is 0.1% */
+	if (brightness > 0 && brightness < low_limit)
+		brightness = low_limit;
+
+	brightness_msb_mask = 0xf;
+	if (wled->max_brightness = WLED5_SINK_REG_BRIGHT_MAX_15B)
+		brightness_msb_mask = 0x7f;

Why not just brightness &= wled->max_brightness? But given that it seems like the framework ensures that brightness <= max_brightness, why not skip this altogether?

Quoted 22 lines
drivers/video/backlight/qcom-wled.c +14 -1
+
+	v[0] = brightness & 0xff;
+	v[1] = (brightness >> 8) & brightness_msb_mask;
+
+	offset = wled5_brightness_reg[wled->cfg.mod_sel];
+	rc = regmap_bulk_write(wled->regmap, wled->sink_addr + offset,
+			v, 2);
+	return rc;
+}
+
 static int wled4_set_brightness(struct wled *wled, u16 brightness)
 {
 	int rc, i;
@@ -237,7 +325,28 @@ static int wled_module_enable(struct wled *wled, int val)
 	return 0;
 }
 
-static int wled_sync_toggle(struct wled *wled)
+static int wled5_sync_toggle(struct wled *wled)
+{
+	int rc;
+	u8 val;

drivers/video/backlight/qcom-wled.c static int wled_module_enable(struct wled *wled, int val) · line 341

Quoted 10 lines
drivers/video/backlight/qcom-wled.c +10 -0
+
+	val = (wled->cfg.mod_sel = MOD_A) ? WLED5_SINK_REG_SYNC_MOD_A_BIT :
+					     WLED5_SINK_REG_SYNC_MOD_B_BIT;
+	rc = regmap_update_bits(wled->regmap,
+				wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT,
+				WLED5_SINK_REG_SYNC_MASK, val);
+	if (rc < 0)
+		return rc;
+
+	val = 0;

Just plug 0 in the function call.

drivers/video/backlight/qcom-wled.c static int wled_module_enable(struct wled *wled, int val) · line 346

Quoted 5 lines
drivers/video/backlight/qcom-wled.c +5 -0
+	rc = regmap_update_bits(wled->regmap,
+				wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT,
+				WLED5_SINK_REG_SYNC_MASK, val);
+
+	return rc;

And return regmap_update_bits(...);

drivers/video/backlight/qcom-wled.c static int wled_module_enable(struct wled *wled, int val) · line 348

Quoted 2 lines
drivers/video/backlight/qcom-wled.c +2 -0
+}
+

Regards,
Bjorn

#4 lore raw

Re: [PATCH V1 2/2] backlight: qcom-wled: Add support for WLED5 peripheral in PM8150L

Quoted 14 lines · Bjorn Andersson
Quoted 1 line · Kiran Gunda
drivers/video/backlight/qcom-wled.c +0 -0

[..]

Quoted 11 lines
drivers/video/backlight/qcom-wled.c +2 -0
@@ -147,14 +187,39 @@ struct wled {
 	u32 max_brightness;
 	u32 short_count;
 	u32 auto_detect_count;
+	u32 version;
 	bool disabled_by_short;
 	bool has_short_detect;
+	bool cabc_disabled;
 	int short_irq;
 	int ovp_irq;
 
Quoted 9 lines

drivers/video/backlight/qcom-wled.c struct wled { · line 201

Quoted 5 lines
drivers/video/backlight/qcom-wled.c +2 -0
 	struct wled_config cfg;
 	struct delayed_work ovp_work;
 	int (*wled_set_brightness)(struct wled *wled, u16 brightness);
+	int (*cabc_config)(struct wled *wled, bool enable);
+	int (*wled_sync_toggle)(struct wled *wled);

Please split this patch in one that adds these and breaks out the wled3 support, and then a second patch that adds wled5.

Sure. Will make this change in the next post.

Quoted 12 lines
Quoted 2 lines
drivers/video/backlight/qcom-wled.c +2 -0
+};
+

[..]

Quoted 9 lines
drivers/video/backlight/qcom-wled.c +9 -0
+static int wled5_set_brightness(struct wled *wled, u16 brightness)
+{
+	int rc, offset;
+	u16 low_limit = wled->max_brightness * 1 / 1000;
+	u8 v[2], brightness_msb_mask;
+
+	/* WLED5's lower limit is 0.1% */
+	if (brightness > 0 && brightness < low_limit)
+		brightness = low_limit;
Quoted 9 lines

drivers/video/backlight/qcom-wled.c static int wled3_set_brightness(struct wled *wled, u16 brightness) · line 255

Quoted 4 lines
drivers/video/backlight/qcom-wled.c +4 -0
+
+	brightness_msb_mask = 0xf;
+	if (wled->max_brightness == WLED5_SINK_REG_BRIGHT_MAX_15B)
+		brightness_msb_mask = 0x7f;

Why not just brightness &= wled->max_brightness? But given that it seems like the framework ensures that brightness <= max_brightness, why not skip this altogether?

Okay. I will modify the code to remove the min/max, low_limit checks in next post.

Quoted 27 lines
Quoted 27 lines
drivers/video/backlight/qcom-wled.c +18 -1
+
+	v[0] = brightness & 0xff;
+	v[1] = (brightness >> 8) & brightness_msb_mask;
+
+	offset = wled5_brightness_reg[wled->cfg.mod_sel];
+	rc = regmap_bulk_write(wled->regmap, wled->sink_addr + offset,
+			v, 2);
+	return rc;
+}
+
 static int wled4_set_brightness(struct wled *wled, u16 brightness)
 {
 	int rc, i;
@@ -237,7 +325,28 @@ static int wled_module_enable(struct wled *wled, 
 int val)
 	return 0;
 }
 
-static int wled_sync_toggle(struct wled *wled)
+static int wled5_sync_toggle(struct wled *wled)
+{
+	int rc;
+	u8 val;
+
+	val = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_SYNC_MOD_A_BIT :
+					     WLED5_SINK_REG_SYNC_MOD_B_BIT;
+	rc = regmap_update_bits(wled->regmap,
Quoted 9 lines

drivers/video/backlight/qcom-wled.c static int wled_module_enable(struct wled *wled, int val) · line 341

Quoted 6 lines
drivers/video/backlight/qcom-wled.c +6 -0
+				wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT,
+				WLED5_SINK_REG_SYNC_MASK, val);
+	if (rc < 0)
+		return rc;
+
+	val = 0;

Just plug 0 in the function call.

Sure. Will do it in next post.

Quoted 8 lines

drivers/video/backlight/qcom-wled.c static int wled_module_enable(struct wled *wled, int val) · line 346

Quoted 5 lines
drivers/video/backlight/qcom-wled.c +5 -0
+	rc = regmap_update_bits(wled->regmap,
+				wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT,
+				WLED5_SINK_REG_SYNC_MASK, val);
+
+	return rc;

And return regmap_update_bits(...);

Sure. Will do it in next post.

Quoted 5 lines

drivers/video/backlight/qcom-wled.c static int wled_module_enable(struct wled *wled, · line 349

Quoted 2 lines
drivers/video/backlight/qcom-wled.c +2 -0
+}
+

Regards,
Bjorn