Skip to contentSkip to conversation

Qualcomm Light Pulse Generator

PATCH Superseded Bjorn Andersson 3 participants 24 messages Jul 6, 2017 – Aug 12, 2017

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#2 lore raw

Re: [PATCH v2 1/3] leds: core: Introduce generic pattern interface

In reply to Bjorn Andersson

Hi!

Quoted 22 lines

Some LED controllers have support for autonomously controlling brightness over time, according to some preprogrammed pattern or function.

This adds a new optional operator that LED class drivers can implement if they support such functionality as well as a new device attribute to configure the pattern for a given LED.

Documentation/ABI/testing/sysfs-class-led +10 -0
@@ -61,3 +61,23 @@ Description:
 		gpio and backlight triggers. In case of the backlight trigger,
 		it is useful when driving a LED which is intended to indicate
 		a device in a standby like state.
+
+What:		/sys/class/leds/<led>/pattern
+Date:		July 2017
+KernelVersion:	4.14
+Description:
+		Specify a pattern for the LED, for LED hardware that support
+		altering the brightness as a function of time.
+
+		The pattern is given by a series of tuples, of brightness and
+		duration (ms). The LED is expected to traverse the series and

Documentation/ABI/testing/sysfs-class-led Description: · line 83

Quoted 10 lines
Documentation/ABI/testing/sysfs-class-led +10 -0
+		each brightness value for the specified duration.
+
+		Additionally a repeat marker ":|" can be appended to the
+		series, which should cause the pattern to be repeated
+		endlessly.
+
+		As LED hardware might have different capabilities and precision
+		the requested pattern might be slighly adjusted by the driver
+		and the resulting pattern of such operation should be returned
+		when this file is read.

Well. I believe this is mostly useful for RGB LEDs. Unfortunately, having patterns per-LED will present opportunity for different channels becoming de-synchronized from each other, which will not look nice.

Best regards,
Pavel

#12 lore raw
In reply to Bjorn Andersson

Hi!

Quoted 11 lines
Quoted 4 lines
Quoted 1 line

DT: leds: Add Qualcomm Light Pulse Generator binding

This one should be first.

Okay, no problems.

Quoted 3 lines

And I guess I'd prefer the driver to go in first, before the generic pattern interface.

Quoted 6 lines

The driver won't compile without the additions to the header file. Would you like the rest of the driver to go in first, then the generic interface and finally the pattern part of the driver?

Large portions of the driver doesn't make sense without the pattern part, so I think I would prefer it to go in as one patch.

Can we get minimum driver without the pattern parts?

Sorry about the additional work.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#0 lore raw

v2 cover Qualcomm Light Pulse Generator

This series introduces a generic pattern interface in the LED class and a driver for the Qualcomm Light Pulse Generator.

Bjorn Andersson (3):
leds: core: Introduce generic pattern interface
leds: Add driver for Qualcomm LPG
DT: leds: Add Qualcomm Light Pulse Generator binding

 Documentation/ABI/testing/sysfs-class-led          |  20 +
 .../devicetree/bindings/leds/leds-qcom-lpg.txt     | 145 ++++
 drivers/leds/Kconfig                               |   7 +
 drivers/leds/Makefile                              |   3 +
 drivers/leds/led-class.c                           | 150 ++++
 drivers/leds/leds-qcom-lpg-lut.c                   | 296 ++++++++
 drivers/leds/leds-qcom-lpg.c                       | 782 +++++++++++++++++++++
 drivers/leds/leds-qcom-lpg.h                       |  30 +
 drivers/leds/leds-qcom-triled.c                    | 193 +++++
 include/linux/leds.h                               |  21 +
 10 files changed, 1647 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt
 create mode 100644 drivers/leds/leds-qcom-lpg-lut.c
 create mode 100644 drivers/leds/leds-qcom-lpg.c
 create mode 100644 drivers/leds/leds-qcom-lpg.h
 create mode 100644 drivers/leds/leds-qcom-triled.c
Signature · 6 lines
2.12.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH v2 1/3 leds: core: Introduce generic pattern interface

Some LED controllers have support for autonomously controlling brightness over time, according to some preprogrammed pattern or function.

This adds a new optional operator that LED class drivers can implement if they support such functionality as well as a new device attribute to configure the pattern for a given LED.

---

Changes since v1:
- New patch, based on discussions following v1

 Documentation/ABI/testing/sysfs-class-led |  20 ++++
 drivers/leds/led-class.c                  | 150 ++++++++++++++++++++++++++++++
 include/linux/leds.h                      |  21 +++++
 3 files changed, 191 insertions(+)
Documentation/ABI/testing/sysfs-class-led +20 -0
index 5f67f7ab277b..74a7f5b1f89b 100644
@@ -61,3 +61,23 @@ Description:
 		gpio and backlight triggers. In case of the backlight trigger,
 		it is useful when driving a LED which is intended to indicate
 		a device in a standby like state.
+
+What:		/sys/class/leds/<led>/pattern
+Date:		July 2017
+KernelVersion:	4.14
+Description:
+		Specify a pattern for the LED, for LED hardware that support
+		altering the brightness as a function of time.
+
+		The pattern is given by a series of tuples, of brightness and
+		duration (ms). The LED is expected to traverse the series and
+		each brightness value for the specified duration.
+
+		Additionally a repeat marker ":|" can be appended to the
+		series, which should cause the pattern to be repeated
+		endlessly.
+
+		As LED hardware might have different capabilities and precision
+		the requested pattern might be slighly adjusted by the driver
+		and the resulting pattern of such operation should be returned
+		when this file is read.
drivers/leds/led-class.c +150 -0

167 lines not on this page · raw message

include/linux/leds.h +21 -0
index 64c56d454f7d..0ffbc86c36d5 100644
@@ -33,6 +33,8 @@ enum led_brightness {
 	LED_FULL	= 255,
 };
 
+struct led_pattern;
+
 struct led_classdev {
 	const char		*name;
 	enum led_brightness	 brightness;
@@ -87,6 +89,15 @@ struct led_classdev {
 				     unsigned long *delay_on,
 				     unsigned long *delay_off);
 
+	int		(*pattern_set)(struct led_classdev *led_cdev,
+				       struct led_pattern *pattern, int len,
+				       bool repeat);
+
+	int		(*pattern_clear)(struct led_classdev *led_cdev);
+
+	struct led_pattern *(*pattern_get)(struct led_classdev *led_cdev,
+					   size_t *len, bool *repeat);
+
 	struct device		*dev;
 	const struct attribute_group	**groups;
 
@@ -444,4 +455,14 @@ static inline void led_classdev_notify_brightness_hw_changed(
 	struct led_classdev *led_cdev, enum led_brightness brightness) { }
 #endif
 
+/**
+ * struct led_pattern - brigheness value in a pattern
+ * @delta_t:	delay until next entry, in milliseconds
+ * @brightness:	brightness at time = 0
+ */
+struct led_pattern {
+	int delta_t;
+	int brightness;
+};
+
 #endif		/* __LINUX_LEDS_H_INCLUDED */
Signature · 1 line
2.12.0
#15 lore raw

PATCH v2 2/3 leds: Add driver for Qualcomm LPG

In reply to Bjorn Andersson

The Light Pulse Generator (LPG) is a PWM-block found in a wide range of PMICs from Qualcomm. It can operate on fixed parameters or based on a lookup-table, altering the duty cycle over time - which provides the means for e.g. hardware assisted transitions of LED brightness.

---

Changes since v1:
- Remove custom DT properties for patterns
- Extract pattern interface into the LED core

 drivers/leds/Kconfig             |   7 +
 drivers/leds/Makefile            |   3 +
 drivers/leds/leds-qcom-lpg-lut.c | 296 +++++++++++++++
 drivers/leds/leds-qcom-lpg.c     | 782 +++++++++++++++++++++++++++++++++++++++
 drivers/leds/leds-qcom-lpg.h     |  30 ++
 drivers/leds/leds-qcom-triled.c  | 193 ++++++++++
 6 files changed, 1311 insertions(+)
 create mode 100644 drivers/leds/leds-qcom-lpg-lut.c
 create mode 100644 drivers/leds/leds-qcom-lpg.c
 create mode 100644 drivers/leds/leds-qcom-lpg.h
 create mode 100644 drivers/leds/leds-qcom-triled.c
drivers/leds/Kconfig +7 -0
index 6c2999872090..1b858f7af01c 100644
@@ -641,6 +641,13 @@ config LEDS_POWERNV
 	  To compile this driver as a module, choose 'm' here: the module
 	  will be called leds-powernv.
 
+config LEDS_QCOM_LPG
+	tristate "LED support for Qualcomm LPG"
+	depends on LEDS_CLASS
+	help
+	  This option enables support for the Light Pulse Generator found in a
+	  wide variety of Qualcomm PMICs.
+
 config LEDS_SYSCON
 	bool "LED support for LEDs on system controllers"
 	depends on LEDS_CLASS=y
drivers/leds/Makefile +3 -0
index 45f133962ed8..b42998418b22 100644
@@ -61,6 +61,9 @@ obj-$(CONFIG_LEDS_MAX77693)		+= leds-max77693.o
 obj-$(CONFIG_LEDS_MAX8997)		+= leds-max8997.o
 obj-$(CONFIG_LEDS_LM355x)		+= leds-lm355x.o
 obj-$(CONFIG_LEDS_BLINKM)		+= leds-blinkm.o
+obj-$(CONFIG_LEDS_QCOM_LPG)		+= leds-qcom-lpg.o
+obj-$(CONFIG_LEDS_QCOM_LPG)		+= leds-qcom-lpg-lut.o
+obj-$(CONFIG_LEDS_QCOM_LPG)		+= leds-qcom-triled.o
 obj-$(CONFIG_LEDS_SYSCON)		+= leds-syscon.o
 obj-$(CONFIG_LEDS_VERSATILE)		+= leds-versatile.o
 obj-$(CONFIG_LEDS_MENF21BMC)		+= leds-menf21bmc.o
drivers/leds/leds-qcom-lpg-lut.c new file +296 -0

296 lines not on this page · raw message

drivers/leds/leds-qcom-lpg.c new file +782 -0

782 lines not on this page · raw message

drivers/leds/leds-qcom-lpg.h new file +30 -0
new file mode 100644
index 000000000000..164a049fda3c
@@ -0,0 +1,30 @@
+#ifndef __LEDS_QCOM_LPG_H__
+#define __LEDS_QCOM_LPG_H__
+
+struct qcom_tri_led;
+struct qcom_lpg_lut;
+
+/*
+ * qcom_lpg_pattern - object tracking allocated LUT entries
+ * @lut:	reference to the client & LUT device context
+ * @lo_idx:	index of first entry in the LUT used by pattern
+ * @hi_idx:	index of the last entry in the LUT used by pattern
+ */
+struct qcom_lpg_pattern {
+	struct qcom_lpg_lut *lut;
+
+	unsigned int lo_idx;
+	unsigned int hi_idx;
+};
+
+struct qcom_tri_led *qcom_tri_led_get(struct device *dev);
+int qcom_tri_led_set(struct qcom_tri_led *tri, bool enabled);
+
+struct qcom_lpg_lut *qcom_lpg_lut_get(struct device *dev);
+struct qcom_lpg_pattern *qcom_lpg_lut_store(struct qcom_lpg_lut *lut,
+					    const u16 *values, size_t len);
+u16 *qcom_lpg_lut_read(struct qcom_lpg_pattern *pattern, size_t *len);
+void qcom_lpg_lut_free(struct qcom_lpg_pattern *pattern);
+int qcom_lpg_lut_sync(struct qcom_lpg_lut *lut);
+
+#endif
drivers/leds/leds-qcom-triled.c new file +193 -0

193 lines not on this page · raw message

Signature · 1 line
2.12.0
#16 lore raw

PATCH v2 3/3 DT: leds: Add Qualcomm Light Pulse Generator binding

In reply to Bjorn Andersson

This adds the binding document describing the three hardware blocks related to the Light Pulse Generator found in a wide range of Qualcomm PMICs.

---

Changes since v1:
- Dropped custom pattern properties
- Renamed cell-index to qcom,lpg-channel to clarify its purpose

 .../devicetree/bindings/leds/leds-qcom-lpg.txt     | 145 +++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +145 -0
new file mode 100644
index 000000000000..cc9ffee6586b
@@ -0,0 +1,145 @@
+Binding for Qualcomm Light Pulse Generator
+
+The Qualcomm Light Pulse Generator consists of three different hardware blocks;
+a ramp generator with lookup table, the light pulse generator and a three
+channel current sink. These blocks are found in a wide range of Qualcomm PMICs.
+Each of these are described individually below.
+
+= Lookup Table (LUT)
+
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "qcom,spmi-lpg-lut"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: base address of the LUT block
+
+- qcom,lut-size:
+	Usage: required
+	Value type: <u32>
+	Definition: number of elements available in the lookup table
+
+= Light Pulse Generator (LPG)
+The Light Pulse Generator can operate either as a standard PWM controller or in
+a more advanced lookup-table based mode. These are described separately below.
+
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "qcom,spmi-lpg"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: base address of the LPG block
+
+== PWM mode
+
+- #pwm-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: must be 1
+
+== Lookup-table mode
+
+- qcom,lpg-channel:
+	Usage: required, when referencing a LUT
+	Value type: <u32>
+	Definition: identifier of the LPG channel, used to associate the LPG
+		    with a particular ramp generator in the LUT block
+
+- default-state:
+	Usage: optional
+	Value type: <string>
+	Definition: default state, as defined in common.txt
+
+- label:
+	Usage: optional
+	Value type: <string>
+	Definition: label of the LED, as defined in common.txt
+
+- linux,default-trigger:
+	Usage: optional
+	Value type: <string>
+	Definition: default trigger, as defined in common.txt
+
+- qcom,tri-led:
+	Usage: optional
+	Value type: <prop-encoded-array>
+	Definition: a phandle of a TRILED node and a single u32 denoting which
+		    output channel to control
+
+- qcom,lut:
+	Usage: optional
+	Value type: <prop-encoded-array>
+	Definition: phandle of a LUT node
+
+- qcom,dtest:
+	Usage: optional
+	Value type: <prop-encoded-array>
+	Definition: configures the output into an internal test line of the
+		    pmic. A first u32 defines which test line to use and the
+		    second cell configures how the value should be outputed
+		    (available lines and configuration differs between PMICs)
+
+= LED Current Sink (TRILED)
+
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "qcom,spmi-tri-led"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: base address of the TRILED block
+
+- qcom,power-source:
+	Usage: required
+	Value type: <u32>
+	Definition: power-source used to drive the output, as defined in the
+		    datasheet
+
+= EXAMPLE:
+The following example defines a single output of the PMI8994, sinking current
+into a LED.
+
+&spmi_bus {
+	pmic@3 {
+		compatible = "qcom,pmi8994", "qcom,spmi-pmic";
+		reg = <0x3 SPMI_USID>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pmi8994_lpg_lut: lpg-lut@b000 {
+			compatible = "qcom,spmi-lpg-lut";
+			reg = <0xb000>;
+
+			qcom,lut-size = <24>;
+		};
+
+		lpg@b200 {
+			compatible = "qcom,spmi-lpg";
+			reg = <0xb200>;
+
+			cell-index = <2>;
+
+			label = "lpg:green:user0";
+
+			qcom,tri-led = <&pmi8994_tri_led 1>;
+			qcom,lut = <&pmi8994_lpg_lut>;
+
+			default-state = "on";
+		};
+
+		pmi8994_tri_led: tri-led@d000 {
+			compatible = "qcom,spmi-tri-led";
+			reg = <0xd000>;
+
+			qcom,power-source = <1>;
+		};
+	};
+};
Signature · 6 lines
2.12.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw
In reply to Bjorn Andersson

Hi!

Quoted 5 lines

This series introduces a generic pattern interface in the LED class and a driver for the Qualcomm Light Pulse Generator.

Bjorn Andersson (3):
leds: core: Introduce generic pattern interface

This one should be last. Let me review that, it is important to get this one right.

Quoted 3 lines

leds: Add driver for Qualcomm LPG

DT: leds: Add Qualcomm Light Pulse Generator binding

This one should be first.

And I guess I'd prefer the driver to go in first, before the generic pattern interface.

Thanks,

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#17 lore raw

Re: [PATCH v2 3/3] DT: leds: Add Qualcomm Light Pulse Generator binding

In reply to Bjorn Andersson

Hi!

Quoted 21 lines

This adds the binding document describing the three hardware blocks related to the Light Pulse Generator found in a wide range of Qualcomm PMICs.

---

Changes since v1:
- Dropped custom pattern properties
- Renamed cell-index to qcom,lpg-channel to clarify its purpose

 .../devicetree/bindings/leds/leds-qcom-lpg.txt     | 145 +++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +0 -0
new file mode 100644
index 000000000000..cc9ffee6586b

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 2

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
@@ -0,0 +1,145 @@
+Binding for Qualcomm Light Pulse Generator
+

Can we use similar format to other files in the directory?

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 13

Quoted 11 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +11 -0
+The Qualcomm Light Pulse Generator consists of three different hardware blocks;
+a ramp generator with lookup table, the light pulse generator and a three
+channel current sink. These blocks are found in a wide range of Qualcomm PMICs.
+Each of these are described individually below.
+
+= Lookup Table (LUT)
+
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "qcom,spmi-lpg-lut"

I guess we don't need to know type of the compatible atribute, other files say

Required properties:

- compatible : Must be "skyworks,aat1290".
- flen-gpios : Must be device tree identifier of the flash device
...

which is easier to understand.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#11 lore raw
In reply to Pavel Machek
Quoted 8 lines · Pavel Machek

Hi!

Quoted 5 lines

This series introduces a generic pattern interface in the LED class and a driver for the Qualcomm Light Pulse Generator.

Bjorn Andersson (3):
leds: core: Introduce generic pattern interface

Quoted 9 lines

This one should be last. Let me review that, it is important to get this one right.

Quoted 3 lines

leds: Add driver for Qualcomm LPG

DT: leds: Add Qualcomm Light Pulse Generator binding

This one should be first.

Okay, no problems.

Quoted 3 lines

And I guess I'd prefer the driver to go in first, before the generic pattern interface.

The driver won't compile without the additions to the header file. Would you like the rest of the driver to go in first, then the generic interface and finally the pattern part of the driver?

Large portions of the driver doesn't make sense without the pattern part, so I think I would prefer it to go in as one patch.

Please let me know and I'll update the series.

Regards,
Bjorn

#18 lore raw

Re: [PATCH v2 3/3] DT: leds: Add Qualcomm Light Pulse Generator binding

In reply to Pavel Machek
Quoted 17 lines · Pavel Machek

Hi!

Quoted 15 lines

This adds the binding document describing the three hardware blocks related to the Light Pulse Generator found in a wide range of Qualcomm PMICs.

---

Changes since v1:
- Dropped custom pattern properties
- Renamed cell-index to qcom,lpg-channel to clarify its purpose

 .../devicetree/bindings/leds/leds-qcom-lpg.txt     | 145 +++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt
Quoted 11 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 2

Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
new file mode 100644
index 000000000000..cc9ffee6586b
@@ -0,0 +1,145 @@
+Binding for Qualcomm Light Pulse Generator
+

Can we use similar format to other files in the directory?

Sure thing, I'll rework this patch.

Regards,
Bjorn

#3 lore raw

Re: [PATCH v2 1/3] leds: core: Introduce generic pattern interface

In reply to Pavel Machek

Hi,

Quoted 30 lines · Pavel Machek

Hi!

Quoted 28 lines

Some LED controllers have support for autonomously controlling brightness over time, according to some preprogrammed pattern or function.

This adds a new optional operator that LED class drivers can implement if they support such functionality as well as a new device attribute to configure the pattern for a given LED.

Documentation/ABI/testing/sysfs-class-led +16 -0
@@ -61,3 +61,23 @@ Description:
 		gpio and backlight triggers. In case of the backlight trigger,
 		it is useful when driving a LED which is intended to indicate
 		a device in a standby like state.
+
+What:		/sys/class/leds/<led>/pattern
+Date:		July 2017
+KernelVersion:	4.14
+Description:
+		Specify a pattern for the LED, for LED hardware that support
+		altering the brightness as a function of time.
+
+		The pattern is given by a series of tuples, of brightness and
+		duration (ms). The LED is expected to traverse the series and
+		each brightness value for the specified duration.
+
+		Additionally a repeat marker ":|" can be appended to the
+		series, which should cause the pattern to be repeated
+		endlessly.
+
Quoted 8 lines

Documentation/ABI/testing/sysfs-class-led Description: · line 83

Quoted 4 lines
Documentation/ABI/testing/sysfs-class-led +4 -0
+		As LED hardware might have different capabilities and precision
+		the requested pattern might be slighly adjusted by the driver
+		and the resulting pattern of such operation should be returned
+		when this file is read.

Well. I believe this is mostly useful for RGB LEDs. Unfortunately, having patterns per-LED will present opportunity for different channels becoming de-synchronized from each other, which will not look nice.

Hmm, they are only [brightness duration] tuples, and no definition of R, G and B LED device is covered here, so how it can be useful for RGB LEDs?

I've been working on addition of RGB LED support to the LED core for some time now, in the way as we agreed upon at [0], but it turns out to be less trivial if we want to do it in an elegant way.

Less elegant way would be duplicating led-core functions and changing single enum led_brightness argument with the three ones (or a struct containing three brightness components)

I chose to go the elegant way and tried to introduce led_classdev_base type that would be customizable with the set of ops, that would allow for making the number of brightness components to be set at once customizable. This of course entails significant amount of changes in the LED core and some changes in LED Trigger core.

Unfortunately I can't predict how much time it will take to submit an RFC due to limited amount of time I can spend working on it.

[0] https://www.spinics.net/lists/linux-leds/msg07959.html

Signature · 2 lines
Best regards,
Jacek Anaszewski
#19 lore raw

Re: [PATCH v2 3/3] DT: leds: Add Qualcomm Light Pulse Generator binding

In reply to Bjorn Andersson

Hi Bjorn,

Quoted 21 lines · Bjorn Andersson

This adds the binding document describing the three hardware blocks related to the Light Pulse Generator found in a wide range of Qualcomm PMICs.

---

Changes since v1:
- Dropped custom pattern properties
- Renamed cell-index to qcom,lpg-channel to clarify its purpose

 .../devicetree/bindings/leds/leds-qcom-lpg.txt     | 145 +++++++++++++++++++++
 1 file changed, 145 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +0 -0
new file mode 100644
index 000000000000..cc9ffee6586b

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 3

Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +3 -0
@@ -0,0 +1,145 @@
+Binding for Qualcomm Light Pulse Generator
+
+The Qualcomm Light Pulse Generator consists of three different hardware blocks;

Is there a freely available documentation thereof?

Quoted 14 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +14 -0
+a ramp generator with lookup table, the light pulse generator and a three
+channel current sink. These blocks are found in a wide range of Qualcomm PMICs.
+Each of these are described individually below.
+
+= Lookup Table (LUT)
+
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "qcom,spmi-lpg-lut"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 27

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +10 -0
+	Definition: base address of the LUT block
+
+- qcom,lut-size:
+	Usage: required
+	Value type: <u32>
+	Definition: number of elements available in the lookup table
+
+= Light Pulse Generator (LPG)
+The Light Pulse Generator can operate either as a standard PWM controller or in
+a more advanced lookup-table based mode. These are described separately below.

Why a user would prefer one option over the other? I assume that both controllers offer at least slightly different capabilities. If so, then it could be the driver which would decide which one fits better for the requested LED class device configuration.

Quoted 105 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +105 -0
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "qcom,spmi-lpg"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: base address of the LPG block
+
+== PWM mode
+
+- #pwm-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: must be 1
+
+== Lookup-table mode
+
+- qcom,lpg-channel:
+	Usage: required, when referencing a LUT
+	Value type: <u32>
+	Definition: identifier of the LPG channel, used to associate the LPG
+		    with a particular ramp generator in the LUT block
+
+- default-state:
+	Usage: optional
+	Value type: <string>
+	Definition: default state, as defined in common.txt
+
+- label:
+	Usage: optional
+	Value type: <string>
+	Definition: label of the LED, as defined in common.txt
+
+- linux,default-trigger:
+	Usage: optional
+	Value type: <string>
+	Definition: default trigger, as defined in common.txt
+
+- qcom,tri-led:
+	Usage: optional
+	Value type: <prop-encoded-array>
+	Definition: a phandle of a TRILED node and a single u32 denoting which
+		    output channel to control
+
+- qcom,lut:
+	Usage: optional
+	Value type: <prop-encoded-array>
+	Definition: phandle of a LUT node
+
+- qcom,dtest:
+	Usage: optional
+	Value type: <prop-encoded-array>
+	Definition: configures the output into an internal test line of the
+		    pmic. A first u32 defines which test line to use and the
+		    second cell configures how the value should be outputed
+		    (available lines and configuration differs between PMICs)
+
+= LED Current Sink (TRILED)
+
+- compatible:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "qcom,spmi-tri-led"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: base address of the TRILED block
+
+- qcom,power-source:
+	Usage: required
+	Value type: <u32>
+	Definition: power-source used to drive the output, as defined in the
+		    datasheet
+
+= EXAMPLE:
+The following example defines a single output of the PMI8994, sinking current
+into a LED.
+
+&spmi_bus {
+	pmic@3 {
+		compatible = "qcom,pmi8994", "qcom,spmi-pmic";
+		reg = <0x3 SPMI_USID>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pmi8994_lpg_lut: lpg-lut@b000 {
+			compatible = "qcom,spmi-lpg-lut";
+			reg = <0xb000>;
+
+			qcom,lut-size = <24>;
+		};
+
+		lpg@b200 {
+			compatible = "qcom,spmi-lpg";
+			reg = <0xb200>;
+
+			cell-index = <2>;
+
+			label = "lpg:green:user0";
+
+			qcom,tri-led = <&pmi8994_tri_led 1>;
+			qcom,lut = <&pmi8994_lpg_lut>;

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 143

Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +10 -0
+
+			default-state = "on";
+		};
+
+		pmi8994_tri_led: tri-led@d000 {
+			compatible = "qcom,spmi-tri-led";
+			reg = <0xd000>;
+
+			qcom,power-source = <1>;
+		};

Such a design is uncommon for LED class DT bindings. It should suffice to have a single DT LED node per LED. I have an impression that you're exposing too many hardware details here.
You can use led-sources property (see Documentation/devicetree/bindings /leds/common.txt and drivers/leds/leds-max77693.c where it is used).

It is also not clear to me why single green color LED presented here would have to use tri-led sink? I suppose that the sink is predestined for three-color LEDs.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#9 lore raw

Re: [PATCH v2 1/3] leds: core: Introduce generic pattern interface

In reply to Pavel Machek
Quoted 30 lines · Pavel Machek

Hi!

Quoted 28 lines

Some LED controllers have support for autonomously controlling brightness over time, according to some preprogrammed pattern or function.

This adds a new optional operator that LED class drivers can implement if they support such functionality as well as a new device attribute to configure the pattern for a given LED.

Documentation/ABI/testing/sysfs-class-led +16 -0
@@ -61,3 +61,23 @@ Description:
 		gpio and backlight triggers. In case of the backlight trigger,
 		it is useful when driving a LED which is intended to indicate
 		a device in a standby like state.
+
+What:		/sys/class/leds/<led>/pattern
+Date:		July 2017
+KernelVersion:	4.14
+Description:
+		Specify a pattern for the LED, for LED hardware that support
+		altering the brightness as a function of time.
+
+		The pattern is given by a series of tuples, of brightness and
+		duration (ms). The LED is expected to traverse the series and
+		each brightness value for the specified duration.
+
+		Additionally a repeat marker ":|" can be appended to the
+		series, which should cause the pattern to be repeated
+		endlessly.
+
Quoted 9 lines

Documentation/ABI/testing/sysfs-class-led Description: · line 83

Quoted 4 lines
Documentation/ABI/testing/sysfs-class-led +4 -0
+		As LED hardware might have different capabilities and precision
+		the requested pattern might be slighly adjusted by the driver
+		and the resulting pattern of such operation should be returned
+		when this file is read.

Well. I believe this is mostly useful for RGB LEDs. Unfortunately, having patterns per-LED will present opportunity for different channels becoming de-synchronized from each other, which will not look nice.

The two laptops on my desk indicates suspend state by pulsing a white and a green LED respectively, so there's definitely people out there who found it useful to do single channel patterns.

In the case of the Qualcomm LPG each channel (4-8 in a typical Qualcomm PMIC) is implemented as a standalone hardware block. The pattern generator is in a separate hardware block that is shared between the LPGs and to synchronize pattern between channels the "start signal" to the pattern generator can cover multiple channels.

But any combination of the LPG channels can be routed to any of the RGB channels and there are use cases where you want to use a single LPG channel to drive a single LED (or some other sink).

It therefor doesn't make sense to enforce any such groupings in the driver itself - at least not for the LPG.

Similarly it's conceivable to design a board where one uses 3 PWM channels to drive a RBG LED, in which case we would like to use the leds-pwm driver, rather than creating a 3-channel-pwm LED driver.

So, based on our previous discussions on this topic, I think it makes sense to have a virtual multi-channel LED driver, that through triggers can have any LED instances associated with its channels. It would then "broadcast" the brightness and pattern requests to the individual LED instances.

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw
In reply to Pavel Machek
Quoted 13 lines · Pavel Machek

Hi!

Quoted 11 lines
Quoted 4 lines
Quoted 1 line

DT: leds: Add Qualcomm Light Pulse Generator binding

This one should be first.

Okay, no problems.

Quoted 3 lines

And I guess I'd prefer the driver to go in first, before the generic pattern interface.

Quoted 9 lines
Quoted 6 lines

The driver won't compile without the additions to the header file. Would you like the rest of the driver to go in first, then the generic interface and finally the pattern part of the driver?

Large portions of the driver doesn't make sense without the pattern part, so I think I would prefer it to go in as one patch.

Can we get minimum driver without the pattern parts?

It's possible to do, but I must admit I find it slightly contrived.

The overall design of different parts of the driver does relate to how I decided to structure and implement the pattern support, so this would mean that the driver we merge has a conceptual dependency on a out-of-tree part.

May I ask about the reasoning for your request? Is it just to not leave the driver hanging while we conclude the discussion on the pattern interface?

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH v2 1/3] leds: core: Introduce generic pattern interface

In reply to Jacek Anaszewski
Quoted 42 lines · Jacek Anaszewski

Hi,

Quoted 30 lines · Pavel Machek

Hi!

Quoted 28 lines

Some LED controllers have support for autonomously controlling brightness over time, according to some preprogrammed pattern or function.

This adds a new optional operator that LED class drivers can implement if they support such functionality as well as a new device attribute to configure the pattern for a given LED.

Documentation/ABI/testing/sysfs-class-led +16 -0
@@ -61,3 +61,23 @@ Description:
 		gpio and backlight triggers. In case of the backlight trigger,
 		it is useful when driving a LED which is intended to indicate
 		a device in a standby like state.
+
+What:		/sys/class/leds/<led>/pattern
+Date:		July 2017
+KernelVersion:	4.14
+Description:
+		Specify a pattern for the LED, for LED hardware that support
+		altering the brightness as a function of time.
+
+		The pattern is given by a series of tuples, of brightness and
+		duration (ms). The LED is expected to traverse the series and
+		each brightness value for the specified duration.
+
+		Additionally a repeat marker ":|" can be appended to the
+		series, which should cause the pattern to be repeated
+		endlessly.
+
Quoted 8 lines

Documentation/ABI/testing/sysfs-class-led Description: · line 83

Quoted 4 lines
Documentation/ABI/testing/sysfs-class-led +4 -0
+		As LED hardware might have different capabilities and precision
+		the requested pattern might be slighly adjusted by the driver
+		and the resulting pattern of such operation should be returned
+		when this file is read.

Well. I believe this is mostly useful for RGB LEDs. Unfortunately, having patterns per-LED will present opportunity for different channels becoming de-synchronized from each other, which will not look nice.

Quoted 4 lines

Hmm, they are only [brightness duration] tuples, and no definition of R, G and B LED device is covered here, so how it can be useful for RGB LEDs?

The typical Qualcomm PMIC sports 4-8 LPG channels. The output of these channels can be configured to some extent, but in theory any combination of the 8 could be hooked up to the three channels of a RGB LED.

So looking at the LPG hw block, there's no such thing as RGB.

Quoted 4 lines

I've been working on addition of RGB LED support to the LED core for some time now, in the way as we agreed upon at [0], but it turns out to be less trivial if we want to do it in an elegant way.

Generally 3 predefined LPG blocks are routed to the TRILED current sink.

Exposing the TRILED block as a RGB LED instance would make sense in its own, but it doesn't give us a coherent solution for the LPG.

The current board I'm working on (DragonBoard820c) has 4 LEDs, 3 of them are connected to the TRILED and the fourth is on a "GPIO" in current sink mode.

By having each LPG represented as a LED device gives us a unified view of the hardware even though there are two different types of current sinks.

Further more, per the 96boards specification we're expected to have different triggers on the different "colors" of the TRILED.

So I do not agree with imposing this kind of decisions on the board design just to support this higher level feature.

Quoted 10 lines

Less elegant way would be duplicating led-core functions and changing single enum led_brightness argument with the three ones (or a struct containing three brightness components)

I chose to go the elegant way and tried to introduce led_classdev_base type that would be customizable with the set of ops, that would allow for making the number of brightness components to be set at once customizable. This of course entails significant amount of changes in the LED core and some changes in LED Trigger core.

I think that the RGB interface has to be a "frontend" of any configurable LED instances and not tied to a particular hardware controller.

For patterns you need to have some sort of synchronization between the channels, but for non-pattern cases you can have any combination of LED drivers to drive the individual components and I believe this should be possible to expose through our RGB interface.

Quoted 5 lines

Unfortunately I can't predict how much time it will take to submit an RFC due to limited amount of time I can spend working on it.

[0] https://www.spinics.net/lists/linux-leds/msg07959.html

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw
In reply to Bjorn Andersson

Hi!

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 4 lines
Quoted 1 line

DT: leds: Add Qualcomm Light Pulse Generator binding

This one should be first.

Okay, no problems.

Quoted 3 lines

And I guess I'd prefer the driver to go in first, before the generic pattern interface.

The driver won't compile without the additions to the header file. Would you like the rest of the driver to go in first, then the generic interface and finally the pattern part of the driver?

Large portions of the driver doesn't make sense without the pattern part, so I think I would prefer it to go in as one patch.

Quoted 8 lines
Quoted 1 line

Can we get minimum driver without the pattern parts?

It's possible to do, but I must admit I find it slightly contrived.

The overall design of different parts of the driver does relate to how I decided to structure and implement the pattern support, so this would mean that the driver we merge has a conceptual dependency on a out-of-tree part.

Ok... but I guess that's something we can live with?

Quoted 3 lines

May I ask about the reasoning for your request? Is it just to not leave the driver hanging while we conclude the discussion on the pattern interface?

Yes; it would be good to have driver in the tree. OTOH new userland interface is a "big" decission, and we'll have to support the interface "forever" once it is merged.

Actually even complete driver (but w/o the userland interface) would be acceptable. Drivers we can fix. Userland interfaces... not so.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#20 lore raw

Re: [PATCH v2 3/3] DT: leds: Add Qualcomm Light Pulse Generator binding

In reply to Jacek Anaszewski
Quoted 13 lines · Jacek Anaszewski

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 3

Quoted 9 lines · Bjorn Andersson
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +3 -0
new file mode 100644
index 000000000000..cc9ffee6586b
@@ -0,0 +1,145 @@
+Binding for Qualcomm Light Pulse Generator
+
+The Qualcomm Light Pulse Generator consists of three different hardware blocks;

Is there a freely available documentation thereof?

The only publicly available Qualcomm PMIC documentation that I'm aware of only have the PWM hardware block, so it will be possible to use this driver but with limited functionality.

[..]

Quoted 9 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 27

Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +3 -0
+= Light Pulse Generator (LPG)
+The Light Pulse Generator can operate either as a standard PWM controller or in
+a more advanced lookup-table based mode. These are described separately below.

Why a user would prefer one option over the other? I assume that both controllers offer at least slightly different capabilities. If so, then it could be the driver which would decide which one fits better for the requested LED class device configuration.

I have never seen this hardware block been used as a PWM, but I imagine it to be used when someone has another driver that expects to be able to use the PWM API to control an output.

In this case the node would need a #pwm-cells property, which it doesn't when it's acting as a LED and it wouldn't make much sense to expose the pin as a LED at the same time.

Perhaps I overthought this? Maybe I should just leave the PWM mode out for now and it could be added in the future?

[..]

Quoted 32 lines
Quoted 32 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +32 -0
+&spmi_bus {
+	pmic@3 {
+		compatible = "qcom,pmi8994", "qcom,spmi-pmic";
+		reg = <0x3 SPMI_USID>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pmi8994_lpg_lut: lpg-lut@b000 {
+			compatible = "qcom,spmi-lpg-lut";
+			reg = <0xb000>;
+
+			qcom,lut-size = <24>;
+		};
+
+		lpg@b200 {
+			compatible = "qcom,spmi-lpg";
+			reg = <0xb200>;
+
+			cell-index = <2>;
+
+			label = "lpg:green:user0";
+
+			qcom,tri-led = <&pmi8994_tri_led 1>;
+			qcom,lut = <&pmi8994_lpg_lut>;
+
+			default-state = "on";
+		};
+
+		pmi8994_tri_led: tri-led@d000 {
+			compatible = "qcom,spmi-tri-led";
+			reg = <0xd000>;
+
Quoted 9 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 40

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
+			qcom,power-source = <1>;
+		};

Such a design is uncommon for LED class DT bindings. It should suffice to have a single DT LED node per LED. I have an impression that you're exposing too many hardware details here.
You can use led-sources property (see Documentation/devicetree/bindings /leds/common.txt and drivers/leds/leds-max77693.c where it is used).

The LUT is shared among the (up to) 8 LPG blocks, so while I did consider just including the LUT in each LPG block it didn't look nice and I had to implement the LUT as a singleton in the driver itself.

The TRILED is only one of the available current sinks in the PMIC that can be driven by the LPG; the other one I use so far is a special GPIO pin acting as a current sink.

Also the power-source configuration is shared among the three channels of the TRILED, so it doesn't really make sense to put this configuration in the LPG blocks themselves.

And note that these are different blocks within the Qualcomm PMIC, with my design only one of them is actually representing the LED instance.

Quoted 4 lines

It is also not clear to me why single green color LED presented here would have to use tri-led sink? I suppose that the sink is predestined for three-color LEDs.

The board I'm working on (DragonBoard820c) has 4 green LEDs, the first 3 are connected to the 3 channels of the TRILED and the fourth is connected to a special GPIO in current sink mode. But I choose to shorted the example to one channel.

So I end up having one LUT node, four LPG nodes, one TRILED and one GPIO node and the user space is presented with a unified interface to all four.

Regards,
Bjorn

#5 lore raw

Re: [PATCH v2 1/3] leds: core: Introduce generic pattern interface

In reply to Bjorn Andersson
Quoted 69 lines · Bjorn Andersson
Quoted 42 lines · Jacek Anaszewski

Hi,

Quoted 30 lines · Pavel Machek

Hi!

Quoted 28 lines

Some LED controllers have support for autonomously controlling brightness over time, according to some preprogrammed pattern or function.

This adds a new optional operator that LED class drivers can implement if they support such functionality as well as a new device attribute to configure the pattern for a given LED.

Documentation/ABI/testing/sysfs-class-led +16 -0
@@ -61,3 +61,23 @@ Description:
 		gpio and backlight triggers. In case of the backlight trigger,
 		it is useful when driving a LED which is intended to indicate
 		a device in a standby like state.
+
+What:		/sys/class/leds/<led>/pattern
+Date:		July 2017
+KernelVersion:	4.14
+Description:
+		Specify a pattern for the LED, for LED hardware that support
+		altering the brightness as a function of time.
+
+		The pattern is given by a series of tuples, of brightness and
+		duration (ms). The LED is expected to traverse the series and
+		each brightness value for the specified duration.
+
+		Additionally a repeat marker ":|" can be appended to the
+		series, which should cause the pattern to be repeated
+		endlessly.
+
Quoted 8 lines

Documentation/ABI/testing/sysfs-class-led Description: · line 83

Quoted 4 lines
Documentation/ABI/testing/sysfs-class-led +4 -0
+		As LED hardware might have different capabilities and precision
+		the requested pattern might be slighly adjusted by the driver
+		and the resulting pattern of such operation should be returned
+		when this file is read.

Well. I believe this is mostly useful for RGB LEDs. Unfortunately, having patterns per-LED will present opportunity for different channels becoming de-synchronized from each other, which will not look nice.

Quoted 4 lines

Hmm, they are only [brightness duration] tuples, and no definition of R, G and B LED device is covered here, so how it can be useful for RGB LEDs?

The typical Qualcomm PMIC sports 4-8 LPG channels. The output of these channels can be configured to some extent, but in theory any combination of the 8 could be hooked up to the three channels of a RGB LED.

So looking at the LPG hw block, there's no such thing as RGB.

Quoted 4 lines

I've been working on addition of RGB LED support to the LED core for some time now, in the way as we agreed upon at [0], but it turns out to be less trivial if we want to do it in an elegant way.

Generally 3 predefined LPG blocks are routed to the TRILED current sink.

Exposing the TRILED block as a RGB LED instance would make sense in its own, but it doesn't give us a coherent solution for the LPG.

The current board I'm working on (DragonBoard820c) has 4 LEDs, 3 of them are connected to the TRILED and the fourth is on a "GPIO" in current sink mode.

Quoted 7 lines

By having each LPG represented as a LED device gives us a unified view of the hardware even though there are two different types of current sinks.

Further more, per the 96boards specification we're expected to have different triggers on the different "colors" of the TRILED.

What is the function of TRILED block then? My first impression was that it allows for setting brightness on all three LED synchronously?

Quoted 15 lines

So I do not agree with imposing this kind of decisions on the board design just to support this higher level feature.

Quoted 10 lines

Less elegant way would be duplicating led-core functions and changing single enum led_brightness argument with the three ones (or a struct containing three brightness components)

I chose to go the elegant way and tried to introduce led_classdev_base type that would be customizable with the set of ops, that would allow for making the number of brightness components to be set at once customizable. This of course entails significant amount of changes in the LED core and some changes in LED Trigger core.

Quoted 3 lines

I think that the RGB interface has to be a "frontend" of any configurable LED instances and not tied to a particular hardware controller.

That doesn't assure brightness setting synchronization which is especially vital in case of triggers like timer.

Quoted 14 lines

For patterns you need to have some sort of synchronization between the channels, but for non-pattern cases you can have any combination of LED drivers to drive the individual components and I believe this should be possible to expose through our RGB interface.

Quoted 5 lines

Unfortunately I can't predict how much time it will take to submit an RFC due to limited amount of time I can spend working on it.

[0] https://www.spinics.net/lists/linux-leds/msg07959.html

Regards,
Bjorn

Signature · 2 lines
Best regards,
Jacek Anaszewski
#21 lore raw

Re: [PATCH v2 3/3] DT: leds: Add Qualcomm Light Pulse Generator binding

In reply to Bjorn Andersson
Quoted 15 lines · Bjorn Andersson
Quoted 13 lines · Jacek Anaszewski

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 3

Quoted 9 lines · Bjorn Andersson
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +3 -0
new file mode 100644
index 000000000000..cc9ffee6586b
@@ -0,0 +1,145 @@
+Binding for Qualcomm Light Pulse Generator
+
+The Qualcomm Light Pulse Generator consists of three different hardware blocks;

Is there a freely available documentation thereof?

Quoted 3 lines

The only publicly available Qualcomm PMIC documentation that I'm aware of only have the PWM hardware block, so it will be possible to use this driver but with limited functionality.

I asked because having an access to the doc would speed up the contribution process a lot I think. Of course we will manage to make it also basing on the details you're providing us with, but it will take a bit longer, taking into account the device complexity.

Quoted 11 lines

[..]

Quoted 9 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 27

Quoted 3 lines

+= Light Pulse Generator (LPG)

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
+The Light Pulse Generator can operate either as a standard PWM controller or in
+a more advanced lookup-table based mode. These are described separately below.

Why a user would prefer one option over the other? I assume that both controllers offer at least slightly different capabilities. If so, then it could be the driver which would decide which one fits better for the requested LED class device configuration.

Quoted 3 lines

I have never seen this hardware block been used as a PWM, but I imagine it to be used when someone has another driver that expects to be able to use the PWM API to control an output.

We have already leds-pwm driver and related DT bindings. We could think of making some part of leds-pwm code reusable. I'd skip it for now though.

Quoted 6 lines

In this case the node would need a #pwm-cells property, which it doesn't when it's acting as a LED and it wouldn't make much sense to expose the pin as a LED at the same time.

Perhaps I overthought this? Maybe I should just leave the PWM mode out for now and it could be added in the future?

Sounds reasonable.

Quoted 47 lines

[..]

Quoted 32 lines
Quoted 32 lines

+&spmi_bus {

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +31 -0
+	pmic@3 {
+		compatible = "qcom,pmi8994", "qcom,spmi-pmic";
+		reg = <0x3 SPMI_USID>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pmi8994_lpg_lut: lpg-lut@b000 {
+			compatible = "qcom,spmi-lpg-lut";
+			reg = <0xb000>;
+
+			qcom,lut-size = <24>;
+		};
+
+		lpg@b200 {
+			compatible = "qcom,spmi-lpg";
+			reg = <0xb200>;
+
+			cell-index = <2>;
+
+			label = "lpg:green:user0";
+
+			qcom,tri-led = <&pmi8994_tri_led 1>;
+			qcom,lut = <&pmi8994_lpg_lut>;
+
+			default-state = "on";
+		};
+
+		pmi8994_tri_led: tri-led@d000 {
+			compatible = "qcom,spmi-tri-led";
+			reg = <0xd000>;
+
Quoted 9 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
+			qcom,power-source = <1>;
+		};

Such a design is uncommon for LED class DT bindings. It should suffice to have a single DT LED node per LED. I have an impression that you're exposing too many hardware details here.
You can use led-sources property (see Documentation/devicetree/bindings /leds/common.txt and drivers/leds/leds-max77693.c where it is used).

The LUT is shared among the (up to) 8 LPG blocks, so while I did consider just including the LUT in each LPG block it didn't look nice and I had to implement the LUT as a singleton in the driver itself.

Quoted 7 lines

The TRILED is only one of the available current sinks in the PMIC that can be driven by the LPG; the other one I use so far is a special GPIO pin acting as a current sink.

Also the power-source configuration is shared among the three channels of the TRILED, so it doesn't really make sense to put this configuration in the LPG blocks themselves.

I'll mention led-sources once again. Probably it could be of help here.

Quoted 3 lines

And note that these are different blocks within the Qualcomm PMIC, with my design only one of them is actually representing the LED instance.

Maybe the core of the driver should be placed in MFD subsystem then?

Quoted 5 lines
Quoted 4 lines

It is also not clear to me why single green color LED presented here would have to use tri-led sink? I suppose that the sink is predestined for three-color LEDs.

Quoted 8 lines

The board I'm working on (DragonBoard820c) has 4 green LEDs, the first 3 are connected to the 3 channels of the TRILED and the fourth is connected to a special GPIO in current sink mode. But I choose to shorted the example to one channel.

So I end up having one LUT node, four LPG nodes, one TRILED and one GPIO node and the user space is presented with a unified interface to all four.

Generally I'd prefer to have a single LED class driver for this device, or alternatively a LED class driver for a LED cell of MFD device. DT bindings would define which hw blocks are LED related. All routing related issues should be solvable with use of led-sources property.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#6 lore raw

Re: [PATCH v2 1/3] leds: core: Introduce generic pattern interface

In reply to Jacek Anaszewski
Quoted 3 lines · Jacek Anaszewski
Quoted 2 lines · Bjorn Andersson
Quoted 1 line · Jacek Anaszewski

On 07/06/2017 05:18 AM, Pavel Machek wrote:

[..]

Quoted 19 lines
Quoted 19 lines
Quoted 4 lines

I've been working on addition of RGB LED support to the LED core for some time now, in the way as we agreed upon at [0], but it turns out to be less trivial if we want to do it in an elegant way.

Generally 3 predefined LPG blocks are routed to the TRILED current sink.

Exposing the TRILED block as a RGB LED instance would make sense in its own, but it doesn't give us a coherent solution for the LPG.

The current board I'm working on (DragonBoard820c) has 4 LEDs, 3 of them are connected to the TRILED and the fourth is on a "GPIO" in current sink mode.

By having each LPG represented as a LED device gives us a unified view of the hardware even though there are two different types of current sinks.

Quoted 6 lines
Quoted 2 lines

Further more, per the 96boards specification we're expected to have different triggers on the different "colors" of the TRILED.

What is the function of TRILED block then? My first impression was that it allows for setting brightness on all three LED synchronously?

It's nothing more than one hardware block providing 3 current sinks.

Quoted 15 lines
Quoted 15 lines

So I do not agree with imposing this kind of decisions on the board design just to support this higher level feature.

Quoted 10 lines

Less elegant way would be duplicating led-core functions and changing single enum led_brightness argument with the three ones (or a struct containing three brightness components)

I chose to go the elegant way and tried to introduce led_classdev_base type that would be customizable with the set of ops, that would allow for making the number of brightness components to be set at once customizable. This of course entails significant amount of changes in the LED core and some changes in LED Trigger core.

Quoted 7 lines
Quoted 3 lines

I think that the RGB interface has to be a "frontend" of any configurable LED instances and not tied to a particular hardware controller.

That doesn't assure brightness setting synchronization which is especially vital in case of triggers like timer.

If you look at any available Android based device you can see what happens when you set red, then green and then blue brightness independently - from user space even. The LED might be red/green/blue/purple whatever, but I would argue that it's not noticeable due to the short duration between the updates.

The case where synchronization matters is if you have pattern transitions as you're extending the time of the transition and you can spot the color variation in the transitions.

Regards,
Bjorn

#22 lore raw

Re: [PATCH v2 3/3] DT: leds: Add Qualcomm Light Pulse Generator binding

In reply to Jacek Anaszewski
Quoted 16 lines · Jacek Anaszewski
Quoted 15 lines · Bjorn Andersson
Quoted 13 lines · Jacek Anaszewski

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 3

Quoted 9 lines · Bjorn Andersson
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +3 -0
new file mode 100644
index 000000000000..cc9ffee6586b
@@ -0,0 +1,145 @@
+Binding for Qualcomm Light Pulse Generator
+
+The Qualcomm Light Pulse Generator consists of three different hardware blocks;

Is there a freely available documentation thereof?

Quoted 9 lines
Quoted 3 lines

The only publicly available Qualcomm PMIC documentation that I'm aware of only have the PWM hardware block, so it will be possible to use this driver but with limited functionality.

I asked because having an access to the doc would speed up the contribution process a lot I think. Of course we will manage to make it also basing on the details you're providing us with, but it will take a bit longer, taking into account the device complexity.

I agree that it would be convenient. Please do let me know if there are any parts that are unclear and I'll try to explain things further.

Quoted 11 lines
Quoted 11 lines

[..]

Quoted 9 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 27

Quoted 3 lines

+= Light Pulse Generator (LPG)

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
+The Light Pulse Generator can operate either as a standard PWM controller or in
+a more advanced lookup-table based mode. These are described separately below.

Why a user would prefer one option over the other? I assume that both controllers offer at least slightly different capabilities. If so, then it could be the driver which would decide which one fits better for the requested LED class device configuration.

Quoted 8 lines
Quoted 3 lines

I have never seen this hardware block been used as a PWM, but I imagine it to be used when someone has another driver that expects to be able to use the PWM API to control an output.

We have already leds-pwm driver and related DT bindings. We could think of making some part of leds-pwm code reusable. I'd skip it for now though.

I know of a few different attempts where people have tried to start off with a PWM driver and leds-pwm and then extend that to support patterns.

Quoted 1 line

From this I concluded that any LED use cases better be implemented in

this way, but still offer the system designer to use the hardware block as a PWM source - if any other device drivers/use cases expects a PWM source.

Quoted 60 lines
Quoted 6 lines

In this case the node would need a #pwm-cells property, which it doesn't when it's acting as a LED and it wouldn't make much sense to expose the pin as a LED at the same time.

Perhaps I overthought this? Maybe I should just leave the PWM mode out for now and it could be added in the future?

Sounds reasonable.

Quoted 51 lines

[..]

Quoted 32 lines
Quoted 32 lines

+&spmi_bus {

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +31 -0
+	pmic@3 {
+		compatible = "qcom,pmi8994", "qcom,spmi-pmic";
+		reg = <0x3 SPMI_USID>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pmi8994_lpg_lut: lpg-lut@b000 {
+			compatible = "qcom,spmi-lpg-lut";
+			reg = <0xb000>;
+
+			qcom,lut-size = <24>;
+		};
+
+		lpg@b200 {
+			compatible = "qcom,spmi-lpg";
+			reg = <0xb200>;
+
+			cell-index = <2>;
+
+			label = "lpg:green:user0";
+
+			qcom,tri-led = <&pmi8994_tri_led 1>;
+			qcom,lut = <&pmi8994_lpg_lut>;
+
+			default-state = "on";
+		};
+
+		pmi8994_tri_led: tri-led@d000 {
+			compatible = "qcom,spmi-tri-led";
+			reg = <0xd000>;
+
Quoted 9 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
+			qcom,power-source = <1>;
+		};

Such a design is uncommon for LED class DT bindings. It should suffice to have a single DT LED node per LED. I have an impression that you're exposing too many hardware details here.
You can use led-sources property (see Documentation/devicetree/bindings /leds/common.txt and drivers/leds/leds-max77693.c where it is used).

The LUT is shared among the (up to) 8 LPG blocks, so while I did consider just including the LUT in each LPG block it didn't look nice and I had to implement the LUT as a singleton in the driver itself.

The TRILED is only one of the available current sinks in the PMIC that can be driven by the LPG; the other one I use so far is a special GPIO pin acting as a current sink.

Quoted 6 lines
Quoted 3 lines

Also the power-source configuration is shared among the three channels of the TRILED, so it doesn't really make sense to put this configuration in the LPG blocks themselves.

I'll mention led-sources once again. Probably it could be of help here.

I wasn't aware of the led-sources, thanks for highlighting it (once more).

Perhaps if we go with your suggested redesign of having a single node for all LPG related parts the led-sources would be used for some of those channels to tie them to the TRILED...

Quoted 6 lines
Quoted 3 lines

And note that these are different blocks within the Qualcomm PMIC, with my design only one of them is actually representing the LED instance.

Maybe the core of the driver should be placed in MFD subsystem then?

If we're to move things around I would say the current sink (TRILED) should go elsewhere, and we should hide the LUT somewhere (although it's very much tied to the LPG block) and then keep the LPG as "the LED driver".

The overarching PMIC driver is already a MFD, so I don't think it makes sense to group some of the MFD children into a new MFD.

Quoted 14 lines
Quoted 5 lines
Quoted 4 lines

It is also not clear to me why single green color LED presented here would have to use tri-led sink? I suppose that the sink is predestined for three-color LEDs.

Quoted 8 lines

The board I'm working on (DragonBoard820c) has 4 green LEDs, the first 3 are connected to the 3 channels of the TRILED and the fourth is connected to a special GPIO in current sink mode. But I choose to shorted the example to one channel.

So I end up having one LUT node, four LPG nodes, one TRILED and one GPIO node and the user space is presented with a unified interface to all four.

Quoted 6 lines

Generally I'd prefer to have a single LED class driver for this device, or alternatively a LED class driver for a LED cell of MFD device. DT bindings would define which hw blocks are LED related. All routing related issues should be solvable with use of led-sources property.

Based on the fact that I'm writing a driver for a MFD child block and there can be 1-8 instances of the hardware block, we got a pretty nice representation of the hardware in DT. But for e.g. GPIOs we do have a single driver instance for multiple blocks, so it wouldn't be the only case.

The DeviceTree would in this case be a single node covering the N LPG blocks, the TRILED and the LUT and would have to have N child nodes to express the properties of each channel. The driver would register a led_cdev for each of the channels.

My initial concern with this approach is that we have a variable number of LPG blocks and the LUT and TRILED blocks are not found in all PMICs. But if we are allowed to rely on "reg-names" we would be fine and it would reduce the complexity of tying the multiple devices together a bit.

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH v2 1/3] leds: core: Introduce generic pattern interface

In reply to Bjorn Andersson
Quoted 25 lines · Bjorn Andersson
Quoted 3 lines · Jacek Anaszewski
Quoted 2 lines · Bjorn Andersson
Quoted 1 line · Jacek Anaszewski

On 07/06/2017 05:18 AM, Pavel Machek wrote:

[..]

Quoted 19 lines
Quoted 19 lines
Quoted 4 lines

I've been working on addition of RGB LED support to the LED core for some time now, in the way as we agreed upon at [0], but it turns out to be less trivial if we want to do it in an elegant way.

Generally 3 predefined LPG blocks are routed to the TRILED current sink.

Exposing the TRILED block as a RGB LED instance would make sense in its own, but it doesn't give us a coherent solution for the LPG.

The current board I'm working on (DragonBoard820c) has 4 LEDs, 3 of them are connected to the TRILED and the fourth is on a "GPIO" in current sink mode.

By having each LPG represented as a LED device gives us a unified view of the hardware even though there are two different types of current sinks.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Further more, per the 96boards specification we're expected to have different triggers on the different "colors" of the TRILED.

What is the function of TRILED block then? My first impression was that it allows for setting brightness on all three LED synchronously?

It's nothing more than one hardware block providing 3 current sinks.

What's the benefit of grouping three sinks? Is there some other gain besides possibility of turning on/off the whole block at once?

Quoted 29 lines
Quoted 15 lines
Quoted 15 lines

So I do not agree with imposing this kind of decisions on the board design just to support this higher level feature.

Quoted 10 lines

Less elegant way would be duplicating led-core functions and changing single enum led_brightness argument with the three ones (or a struct containing three brightness components)

I chose to go the elegant way and tried to introduce led_classdev_base type that would be customizable with the set of ops, that would allow for making the number of brightness components to be set at once customizable. This of course entails significant amount of changes in the LED core and some changes in LED Trigger core.

Quoted 7 lines
Quoted 3 lines

I think that the RGB interface has to be a "frontend" of any configurable LED instances and not tied to a particular hardware controller.

That doesn't assure brightness setting synchronization which is especially vital in case of triggers like timer.

If you look at any available Android based device you can see what happens when you set red, then green and then blue brightness independently - from user space even. The LED might be red/green/blue/purple whatever, but I would argue that it's not noticeable due to the short duration between the updates.

Quoted 3 lines

The case where synchronization matters is if you have pattern transitions as you're extending the time of the transition and you can spot the color variation in the transitions.

It would require more thorough analysis across various devices programmed via different buses. Probably in most cases applying the userspace frontend mentioned by you would work just fine.

And when it comes to higher frequencies, we have had already attempts of adding hr timer support for "fast LEDs" like the ones driven through GPIOs, and those could benefit from the kernel level synchronization.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#23 lore raw

Re: [PATCH v2 3/3] DT: leds: Add Qualcomm Light Pulse Generator binding

In reply to Bjorn Andersson
Quoted 22 lines · Bjorn Andersson
Quoted 20 lines · Jacek Anaszewski
Quoted 18 lines · Bjorn Andersson
Quoted 13 lines · Jacek Anaszewski

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 3

Quoted 9 lines · Bjorn Andersson
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +3 -0
new file mode 100644
index 000000000000..cc9ffee6586b
@@ -0,0 +1,145 @@
+Binding for Qualcomm Light Pulse Generator
+
+The Qualcomm Light Pulse Generator consists of three different hardware blocks;

Is there a freely available documentation thereof?

The only publicly available Qualcomm PMIC documentation that I'm aware of only have the PWM hardware block, so it will be possible to use this driver but with limited functionality.

Quoted 8 lines
Quoted 5 lines

I asked because having an access to the doc would speed up the contribution process a lot I think. Of course we will manage to make it also basing on the details you're providing us with, but it will take a bit longer, taking into account the device complexity.

I agree that it would be convenient. Please do let me know if there are any parts that are unclear and I'll try to explain things further.

I'd be especially interested in possible topologies of routing between pattern generator units and TRILEDs.

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines

[..]

Quoted 9 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt line 27

Quoted 3 lines

+= Light Pulse Generator (LPG)

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
+The Light Pulse Generator can operate either as a standard PWM controller or in
+a more advanced lookup-table based mode. These are described separately below.

Why a user would prefer one option over the other? I assume that both controllers offer at least slightly different capabilities. If so, then it could be the driver which would decide which one fits better for the requested LED class device configuration.

Quoted 8 lines
Quoted 3 lines

I have never seen this hardware block been used as a PWM, but I imagine it to be used when someone has another driver that expects to be able to use the PWM API to control an output.

We have already leds-pwm driver and related DT bindings. We could think of making some part of leds-pwm code reusable. I'd skip it for now though.

Quoted 7 lines

I know of a few different attempts where people have tried to start off with a PWM driver and leds-pwm and then extend that to support patterns.

Quoted 1 line

From this I concluded that any LED use cases better be implemented in

this way, but still offer the system designer to use the hardware block as a PWM source - if any other device drivers/use cases expects a PWM source.

Frankly speaking leds-pwm driver provides quite generic interface for driving pwm devices. This use case is even advertised in the first place in Documentation/pwm.txt. LED subsystem is already used for non-LED specific purposes like vibrate hardware control
(see Documentation/leds/ledtrig-transient.txt). In effect I don't see any specific gain in exposing generic pwm device instead of the LED class one.

Quoted 80 lines
Quoted 60 lines
Quoted 6 lines

In this case the node would need a #pwm-cells property, which it doesn't when it's acting as a LED and it wouldn't make much sense to expose the pin as a LED at the same time.

Perhaps I overthought this? Maybe I should just leave the PWM mode out for now and it could be added in the future?

Sounds reasonable.

Quoted 51 lines

[..]

Quoted 32 lines
Quoted 32 lines

+&spmi_bus {

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +31 -0
+	pmic@3 {
+		compatible = "qcom,pmi8994", "qcom,spmi-pmic";
+		reg = <0x3 SPMI_USID>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pmi8994_lpg_lut: lpg-lut@b000 {
+			compatible = "qcom,spmi-lpg-lut";
+			reg = <0xb000>;
+
+			qcom,lut-size = <24>;
+		};
+
+		lpg@b200 {
+			compatible = "qcom,spmi-lpg";
+			reg = <0xb200>;
+
+			cell-index = <2>;
+
+			label = "lpg:green:user0";
+
+			qcom,tri-led = <&pmi8994_tri_led 1>;
+			qcom,lut = <&pmi8994_lpg_lut>;
+
+			default-state = "on";
+		};
+
+		pmi8994_tri_led: tri-led@d000 {
+			compatible = "qcom,spmi-tri-led";
+			reg = <0xd000>;
+
Quoted 9 lines

Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt

Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-qcom-lpg.txt new file +2 -0
+			qcom,power-source = <1>;
+		};

Such a design is uncommon for LED class DT bindings. It should suffice to have a single DT LED node per LED. I have an impression that you're exposing too many hardware details here.
You can use led-sources property (see Documentation/devicetree/bindings /leds/common.txt and drivers/leds/leds-max77693.c where it is used).

The LUT is shared among the (up to) 8 LPG blocks, so while I did consider just including the LUT in each LPG block it didn't look nice and I had to implement the LUT as a singleton in the driver itself.

The TRILED is only one of the available current sinks in the PMIC that can be driven by the LPG; the other one I use so far is a special GPIO pin acting as a current sink.

Quoted 6 lines
Quoted 3 lines

Also the power-source configuration is shared among the three channels of the TRILED, so it doesn't really make sense to put this configuration in the LPG blocks themselves.

I'll mention led-sources once again. Probably it could be of help here.

I wasn't aware of the led-sources, thanks for highlighting it (once more).

Perhaps if we go with your suggested redesign of having a single node for all LPG related parts the led-sources would be used for some of those channels to tie them to the TRILED...

Quoted 6 lines
Quoted 3 lines

And note that these are different blocks within the Qualcomm PMIC, with my design only one of them is actually representing the LED instance.

Maybe the core of the driver should be placed in MFD subsystem then?

Quoted 7 lines

If we're to move things around I would say the current sink (TRILED) should go elsewhere, and we should hide the LUT somewhere (although it's very much tied to the LPG block) and then keep the LPG as "the LED driver".

The overarching PMIC driver is already a MFD, so I don't think it makes sense to group some of the MFD children into a new MFD.

Now I'm starting to wonder if it wouldn't make sense to create a pattern trigger that would handle this type of patterns. Something similar to ledtrig-timer but it would expose pattern sysfs file similar to delay_on/delay_off. In case given LED class device isn't routed to the suitable pattern generator the software fallback would be applied.

Quoted 21 lines
Quoted 14 lines
Quoted 5 lines
Quoted 4 lines

It is also not clear to me why single green color LED presented here would have to use tri-led sink? I suppose that the sink is predestined for three-color LEDs.

Quoted 8 lines

The board I'm working on (DragonBoard820c) has 4 green LEDs, the first 3 are connected to the 3 channels of the TRILED and the fourth is connected to a special GPIO in current sink mode. But I choose to shorted the example to one channel.

So I end up having one LUT node, four LPG nodes, one TRILED and one GPIO node and the user space is presented with a unified interface to all four.

Quoted 6 lines

Generally I'd prefer to have a single LED class driver for this device, or alternatively a LED class driver for a LED cell of MFD device. DT bindings would define which hw blocks are LED related. All routing related issues should be solvable with use of led-sources property.

Quoted 5 lines

Based on the fact that I'm writing a driver for a MFD child block and there can be 1-8 instances of the hardware block, we got a pretty nice representation of the hardware in DT. But for e.g. GPIOs we do have a single driver instance for multiple blocks, so it wouldn't be the only case.

Please keep in mind that for registering gpio LED class device you have gpio_led_register_device() API (drivers/leds/leds-gpio-register.c) for your disposal.

Quoted 11 lines

The DeviceTree would in this case be a single node covering the N LPG blocks, the TRILED and the LUT and would have to have N child nodes to express the properties of each channel. The driver would register a led_cdev for each of the channels.

My initial concern with this approach is that we have a variable number of LPG blocks and the LUT and TRILED blocks are not found in all PMICs. But if we are allowed to rely on "reg-names" we would be fine and it would reduce the complexity of tying the multiple devices together a bit.

I propose to have a main DT node for the whole device, which would contain all required hardware resources and the child DT nodes describing LED class devices to create. The child nodes could contain led-sources property if necessary. In the main node you could have an array of LPG and LUT base addresses.

Signature · 6 lines
Best regards,
Jacek Anaszewski
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

Re: [PATCH v2 1/3] leds: core: Introduce generic pattern interface

In reply to Bjorn Andersson

Hi!

Quoted 10 lines
Quoted 4 lines

Hmm, they are only [brightness duration] tuples, and no definition of R, G and B LED device is covered here, so how it can be useful for RGB LEDs?

The typical Qualcomm PMIC sports 4-8 LPG channels. The output of these channels can be configured to some extent, but in theory any combination of the 8 could be hooked up to the three channels of a RGB LED.

So looking at the LPG hw block, there's no such thing as RGB.

Well, there are certainly RGB leds. And we need kernel to know about them, so user can (for example) ask for white color.

Quoted 2 lines

Further more, per the 96boards specification we're expected to have different triggers on the different "colors" of the TRILED.

So the specs is stupid. We may end up allowing that, but lets not introduce a bad design just because of that.

[You may get that functionality by lying in the dts and claiming it is three LEDs, not one RGB LED.]

You want to be able to set a color of RGB LED... which is not as easy as it looks.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html