Skip to contentSkip to conversation

dt-bindings: leds: Add binding for spi-byte LED.

PATCH In review [email protected] 4 participants 8 messages May 13, 2019 – May 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 dt-bindings: leds: Add binding for spi-byte LED.

From: Christian Mauderer <[email protected]>

This patch adds the binding documentation for a simple SPI based LED controller which use only one byte for setting the brightness.

---

Changes compared to v3:
- rename binding to ubnt,acb-spi-led
- rewrite description to fit the new binding
- remove off-value and max-value - now determined depending on the compatible string
- add 'default-state'

Changes compared to v2:
- None

Changes compared to v1:
- rename ubnt-spi to leds-spi-byte
- rename "ubnt-spi,off_bright" and "ubnt-spi,max_bright" to "leds-spi-byte,off-value" and "leds-spi-byte,max-value" and mark them required
- rename led-controller node to "led-controller"
- extend description
- remove SPI controller
- use "white:status" for the example label

 .../bindings/leds/leds-spi-byte.txt           | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-spi-byte.txt
Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file +44 -0
new file mode 100644
index 000000000000..28b6b2d9091e
@@ -0,0 +1,44 @@
+* Single Byte SPI LED Device Driver.
+
+The driver can be used for controllers with a very simple SPI protocol:
+- one LED is controlled by a single byte on MOSI
+- the value of the byte gives the brightness between two values (lowest to
+  highest)
+- no return value is necessary (no MISO signal)
+
+The value for lowest and highest brightness is dependent on the device and
+therefore on the compatible string.
+
+Depending on the compatible string some special functions (like hardware
+accelerated blinking) might can be supported too.
+
+The driver currently only supports one LED. The properties of the LED are
+configured in a sub-node in the device node.
+
+Required properties:
+- compatible: should be one of
+   * "ubnt,acb-spi-led"		microcontroller (SONiX 8F26E611LA) based device
+				used for example in Ubiquiti airCube ISP
+
+Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
+apply.
+
+LED sub-node properties:
+- label:
+	see Documentation/devicetree/bindings/leds/common.txt
+- default-state:
+	see Documentation/devicetree/bindings/leds/common.txt
+	Only "on" and "off" are supported.
+
+Example:
+
+led-controller@0 {
+	compatible = "ubnt,acb-spi-led";
+	reg = <0>;
+	spi-max-frequency = <100000>;
+
+	led {
+		label = "white:status";
+		default-state = "on";
+	};
+};
Signature · 1 line
2.21.0
#1 lore raw

PATCH v4 2/2 leds: spi-byte: add single byte SPI LED driver

From: Christian Mauderer <[email protected]>

This driver adds support for simple SPI based LED controller which use only one byte for setting the brightness.

---

Changes compared to v3:
- remove led_classdev_unregister - not longer necessary due to devm_led_classdev_register
- move off_value and max_value to chipdef structure
- reduce intermediate local variables during open firmware parsing
- destroy mutex if devm_led_classdev_register went wrong
- add 'default-state'

Changes compared to v2:
- use "if (ret)" instead of "if (ret != 0)"
- don't initialize ldev-fields with zero
- use devm_led_classdev_register instead of led_classdev_register
- check for error instead of good case with the last if in spi_byte_probe

Changes compared to v1:
- rename ubnt-spi to leds-spi-byte
- rework probe to get all parameters before allocating anything -> error checks all collected together and initializing all fields of the device structure is more obvious
- fix some unsteady indentations during variable declaration
- rework comment with protocol explanation
- handle case of off_bright > max_bright
- fix spelling in commit message
- mutex_destroy in remove
- change label to use either use the given one without a prefix or a default one

 drivers/leds/Kconfig         |  10 +++
 drivers/leds/Makefile        |   1 +
 drivers/leds/leds-spi-byte.c | 161 +++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/leds/leds-spi-byte.c
drivers/leds/Kconfig +10 -0
index a72f97fca57b..b6235e7e1482 100644
@@ -766,6 +766,16 @@ config LEDS_NIC78BX
 	  To compile this driver as a module, choose M here: the module
 	  will be called leds-nic78bx.
 
+config LEDS_SPI_BYTE
+	tristate "LED support for SPI LED controller with a single byte"
+	depends on LEDS_CLASS
+	depends on SPI
+	depends on OF
+	help
+	  This option enables support for LED controller which use a single byte
+	  for controlling the brightness. Currently the following controller is
+	  supported: Ubiquiti airCube ISP microcontroller based LED controller.
+
 comment "LED Triggers"
 source "drivers/leds/trigger/Kconfig"
 
drivers/leds/Makefile +1 -0
index 4c1b0054f379..1786d7e2c236 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_LEDS_PM8058)		+= leds-pm8058.o
 obj-$(CONFIG_LEDS_MLXCPLD)		+= leds-mlxcpld.o
 obj-$(CONFIG_LEDS_MLXREG)		+= leds-mlxreg.o
 obj-$(CONFIG_LEDS_NIC78BX)		+= leds-nic78bx.o
+obj-$(CONFIG_LEDS_SPI_BYTE)		+= leds-spi-byte.o
 obj-$(CONFIG_LEDS_MT6323)		+= leds-mt6323.o
 obj-$(CONFIG_LEDS_LM3692X)		+= leds-lm3692x.o
 obj-$(CONFIG_LEDS_SC27XX_BLTC)		+= leds-sc27xx-bltc.o
drivers/leds/leds-spi-byte.c new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
2.21.0
Acked-by on v4 2/2
#2 lore raw

Re: [PATCH v4 2/2] leds: spi-byte: add single byte SPI LED driver

Quoted 6 lines · On Mon 2019-05-13 21:33:07, [email protected] wrote:

From: Christian Mauderer <[email protected]>

This driver adds support for simple SPI based LED controller which use only one byte for setting the brightness.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
maintainer Reviewed-by on v4 1/2
#3 lore raw
In reply to [email protected]
Quoted 27 lines · On Mon, 13 May 2019 21:33:06 +0200, [email protected] wrote:

From: Christian Mauderer <[email protected]>

This patch adds the binding documentation for a simple SPI based LED controller which use only one byte for setting the brightness.

---

Changes compared to v3:
- rename binding to ubnt,acb-spi-led
- rewrite description to fit the new binding
- remove off-value and max-value - now determined depending on the compatible string
- add 'default-state'

Changes compared to v2:
- None

Changes compared to v1:
- rename ubnt-spi to leds-spi-byte
- rename "ubnt-spi,off_bright" and "ubnt-spi,max_bright" to "leds-spi-byte,off-value" and "leds-spi-byte,max-value" and mark them required
- rename led-controller node to "led-controller"
- extend description
- remove SPI controller
- use "white:status" for the example label

Quoted 4 lines
 .../bindings/leds/leds-spi-byte.txt           | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-spi-byte.txt
#4 lore raw
In reply to [email protected]

Hi!

Quoted 14 lines

From: Christian Mauderer <[email protected]>

This patch adds the binding documentation for a simple SPI based LED controller which use only one byte for setting the brightness.

---

Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file +0 -0
new file mode 100644
index 000000000000..28b6b2d9091e

Documentation/devicetree/bindings/leds/leds-spi-byte.txt line 7

Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file +6 -0
@@ -0,0 +1,44 @@
+* Single Byte SPI LED Device Driver.
 
+The driver can be used for controllers with a very simple SPI protocol:
+- one LED is controlled by a single byte on MOSI
+- the value of the byte gives the brightness between two values (lowest to
+  highest)
+- no return value is necessary (no MISO signal)

I'd expect this file to be named acb-spi-led.txt, or something, and talk about that u-controller, not its device driver -- as devicetree binding describes hardware, not driver.

But you already have an ack from rob, so...
Pavel

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

Hi!

Quoted 14 lines

From: Christian Mauderer <[email protected]>

This patch adds the binding documentation for a simple SPI based LED controller which use only one byte for setting the brightness.

---

Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file +0 -0
new file mode 100644
index 000000000000..28b6b2d9091e

Documentation/devicetree/bindings/leds/leds-spi-byte.txt line 7

Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file +6 -0
@@ -0,0 +1,44 @@
+* Single Byte SPI LED Device Driver.
 
+The driver can be used for controllers with a very simple SPI protocol:
+- one LED is controlled by a single byte on MOSI
+- the value of the byte gives the brightness between two values (lowest to
+  highest)
+- no return value is necessary (no MISO signal)
Quoted 7 lines

I'd expect this file to be named acb-spi-led.txt, or something, and talk about that u-controller, not its device driver -- as devicetree binding describes hardware, not driver.

But you already have an ack from rob, so...
Pavel

So basically it would have been better to move the description that I added to the c-file as "supported devices" in the device tree file?

With both commits already acked: Rob and Pavel: Should I change that?

If you both say yes, I would rename the file in the binding like suggested and move the detailed protocol description from the driver to the binding.

Best regards

Christian

#6 lore raw

Hi Christian,

Quoted 33 lines · Christian Mauderer
Quoted 24 lines · Pavel Machek

Hi!

Quoted 14 lines

From: Christian Mauderer <[email protected]>

This patch adds the binding documentation for a simple SPI based LED controller which use only one byte for setting the brightness.

---

Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file +0 -0
new file mode 100644
index 000000000000..28b6b2d9091e

Documentation/devicetree/bindings/leds/leds-spi-byte.txt line 7

Quoted 7 lines
Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file +6 -0
@@ -0,0 +1,44 @@
+* Single Byte SPI LED Device Driver.
 
+The driver can be used for controllers with a very simple SPI protocol:
+- one LED is controlled by a single byte on MOSI
+- the value of the byte gives the brightness between two values (lowest to
+  highest)
+- no return value is necessary (no MISO signal)
Quoted 7 lines

I'd expect this file to be named acb-spi-led.txt, or something, and talk about that u-controller, not its device driver -- as devicetree binding describes hardware, not driver.

But you already have an ack from rob, so...
Pavel

Quoted 8 lines

So basically it would have been better to move the description that I added to the c-file as "supported devices" in the device tree file?

With both commits already acked: Rob and Pavel: Should I change that?

If you both say yes, I would rename the file in the binding like suggested and move the detailed protocol description from the driver to the binding.

Let's not ramble on it. It is good as is.

Patch set applied to the for-next branch of linux-leds.git.

Thank you for your work.

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

Hello Jacek, Pavel, Rob, Dan and everyone who I might have missed,

thanks for the great feedback, the patience while reviewing my patches and for accepting it.

Although it needed a longer discussion than I expected (partially due to my rush creating new versions at the beginning) it was a quite positive experience and I'm quite ready to repeat it if some other opportunity arises.

Best regards

Christian

Quoted 55 lines · Jacek Anaszewski

Hi Christian,

Quoted 37 lines · Christian Mauderer
Quoted 28 lines · Pavel Machek

Hi!

Quoted 20 lines

From: Christian Mauderer <[email protected]>

This patch adds the binding documentation for a simple SPI based LED controller which use only one byte for setting the brightness.

---

diff --git a/Documentation/devicetree/bindings/leds/leds-spi-byte.txt b/Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file mode 100644
index 000000000000..28b6b2d9091e

Documentation/devicetree/bindings/leds/leds-spi-byte.txt new file +2 -0
@@ -0,0 +1,44 @@
+* Single Byte SPI LED Device Driver.
 
+The driver can be used for controllers with a very simple SPI

protocol:

Quoted 5 lines
+- one LED is controlled by a single byte on MOSI
+- the value of the byte gives the brightness between two values

(lowest to
+� highest)
+- no return value is necessary (no MISO signal)

Quoted 7 lines

I'd expect this file to be named acb-spi-led.txt, or something, and talk about that u-controller, not its device driver -- as devicetree binding describes hardware, not driver.

But you already have an ack from rob, so... ����������������������������������� Pavel �����������������������������������

Quoted 8 lines

So basically it would have been better to move the description that I added to the c-file as "supported devices" in the device tree file?

With both commits already acked: Rob and Pavel: Should I change that?

If you both say yes, I would rename the file in the binding like suggested and move the detailed protocol description from the driver to the binding.

Let's not ramble on it. It is good as is.

Patch set applied to the for-next branch of linux-leds.git.

Thank you for your work.