dt-bindings: leds: Add binding for ubnt-spi LED.
Subsystems (2)
PATCH 1/2 dt-bindings: leds: Add binding for ubnt-spi LED.
From: Christian Mauderer <[email protected]>
This patch adds the binding documentation for the LED controller found in Ubiquity airCube ISP devices.
---
I tested the patches with a 4.14 and a 4.19 kernel on the current OpenWRT. Although I didn't get the kernel running due to file system problems they build fine with a 5.1-rc7.
I shortly described the protocol of the controller in a comment in the driver file in the second patch.
Checkpatch gives the following warning for both patches:
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
To be honest: I don't know what to do with it. Please excuse my ignorance here. It's the first driver that I want to add to the Linux kernel.
Please point me to some documentation if I did miss some big points for submitting patches.
.../bindings/leds/leds-ubnt-spi.txt | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +49 -0
@@ -0,0 +1,49 @@ +Binding for the controller based LED found in Ubiquity airCube ISP and most +likely some other Ubiquity devices. + +The protocol of the controller is quite simple. Only one byte will be sent. The +value of the byte can be between the ubnt-spi,off_bright value and the +ubnt-spi,max_bright value. + +The driver maybe can be used for other devices with a similar protocol too. + +Required properties: +- compatible: Should be "ubnt,spi-led". +- spi-max-frequency: Should be <100000> for this device. + +Optional sub-node properties: +- ubnt-spi,off_bright: The value that will be sent if the LED should be + switched off. Default value is 0. +- ubnt-spi,max_bright: Value for the maximum brightness. Default value for that + is 63. +- label: A label for the LED. If one is given, the LED will be + named "ubnt-spi:<label>" or "ubnt-spi::" otherwise. + +Being a SPI device this driver should be a sub-node of a SPI controller. The +controller only supports one LED. For consistence with other controllers, the +LED is defined as a sub-node. + +Example for the airCube ISP (with SPI controller matching that device): + +led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio 3 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + num-chipselects = <1>; + + led_ubnt@0 { + compatible = "ubnt,spi-led"; + reg = <0>; + spi-max-frequency = <100000>; + + led { + label = "system"; + /* keep the LED slightly on to show powered device */ + ubnt-spi,off_bright = /bits/ 8 <4>; + }; + }; +};
Signature · 1 line
2.21.0
PATCH 2/2 leds: ubnt-spi: Add Ubnt AirCube ISP LED driver
From: Christian Mauderer <[email protected]>
This driver adds support for the custom LED controller used in Ubiquity airCube ISP devices and most likely some other simmilar Ubiquity products.
--- drivers/leds/Kconfig | 10 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-ubnt-spi.c | 140 +++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 drivers/leds/leds-ubnt-spi.c
drivers/leds/Kconfig +10 -0
@@ -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_UBNT_SPI + tristate "LED support for Ubnt aircube ISP custom SPI LED controller" + depends on LEDS_CLASS + depends on SPI + depends on OF + help + This option enables basic support for the LED controller used in + Ubiquity airCube ISP devices. The controller is microcontroller based + and uses a single byte on the SPI to set brightness or blink patterns. + comment "LED Triggers" source "drivers/leds/trigger/Kconfig"
drivers/leds/Makefile +1 -0
@@ -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_UBNT_SPI) += leds-ubnt-spi.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-ubnt-spi.c new file +140 -0
140 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [PATCH 2/2] leds: ubnt-spi: Add Ubnt AirCube ISP LED driver
Quoted 5 lines · On Sat 2019-05-04 14:28:25, [email protected] wrote:
From: Christian Mauderer <[email protected]>
This driver adds support for the custom LED controller used in Ubiquity airCube ISP devices and most likely some other simmilar Ubiquity products.
similar.
Quoted 19 lines
(quoted diff) +18
-0+config LEDS_UBNT_SPI + tristate "LED support for Ubnt aircube ISP custom SPI LED controller" + depends on LEDS_CLASS + depends on SPI + depends on OF + help + This option enables basic support for the LED controller used in + Ubiquity airCube ISP devices. The controller is microcontroller based + and uses a single byte on the SPI to set brightness or blink patterns. +/* + * Custom controller based LED controller used in Ubiquity airCube ISP. + * + * Reverse engineered protocol: + * - The device uses only a single byte sent via SPI. + * - The SPI input doesn't contain any relevant information. + * - Higher two bits set a mode. Lower six bits are a parameter. + * - Mode: 00 -> set brightness between 0x00 (min) and 0x3F (max) + * - Mode: 01 -> pulsing pattern (min -> max -> min) with an interval. From
Review
Quoted 10 lines
(quoted diff) +10
-0+ * some tests, the period is about (50ms + 102ms * parameter). There is a + * slightly different pattern starting from 0x100 (longer gap between the + * pulses) but the time still follows that calculation. + * - Mode: 10 -> same as 01 but with only a ramp from min to max. Again a + * slight jump in the pattern at 0x100. + * - Mode: 11 -> blinking (off -> 25% -> off -> 25% -> ...) with a period of + * (105ms * parameter) + * + * NOTE: This driver currently only implements mode 00 (brightness). + */
Aha, so this is not as simple as I thought.
"Slightly different pattern starting from 0x100"? What does 0x100 mean here.
drivers/leds/leds-ubnt-spi.c line 101
Quoted 4 lines
drivers/leds/leds-ubnt-spi.c new file +4
-0+mutex_init (&led->mutex); + led->ldev.name = led->name; + led->ldev.brightness =LED_OFF ; + led->ldev.max_brightness = led->max_bright - led->off_bright;
What happens when DTS has off_bright > max_bright? :-).
drivers/leds/leds-ubnt-spi.c line 117
Quoted 9 lines
drivers/leds/leds-ubnt-spi.c new file +9
-0+ +static int ubnt_spi_remove (struct spi_device *spi) +{ +struct ubnt_spi_led *led =spi_get_drvdata (spi); + +led_classdev_unregister (&led->ldev); + +return 0 ; +}
Do you need to do mutex_destroy?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 2/2] leds: ubnt-spi: Add Ubnt AirCube ISP LED driver
First: Thanks for the quick review. I haven't expected an answer for some days.
Quoted 8 lines · Pavel Machek
Quoted 5 lines · On Sat 2019-05-04 14:28:25, [email protected] wrote:
From: Christian Mauderer <[email protected]>
This driver adds support for the custom LED controller used in Ubiquity airCube ISP devices and most likely some other simmilar Ubiquity products.
similar.
I'll change that. And I noted another typo too: The company is called Ubiquiti ...
Quoted 31 lines
Quoted 20 lines
(quoted diff) +18
-0+config LEDS_UBNT_SPI + tristate "LED support for Ubnt aircube ISP custom SPI LED controller" + depends on LEDS_CLASS + depends on SPI + depends on OF + help + This option enables basic support for the LED controller used in + Ubiquity airCube ISP devices. The controller is microcontroller based + and uses a single byte on the SPI to set brightness or blink patterns. +/* + * Custom controller based LED controller used in Ubiquity airCube ISP. + * + * Reverse engineered protocol: + * - The device uses only a single byte sent via SPI. + * - The SPI input doesn't contain any relevant information. + * - Higher two bits set a mode. Lower six bits are a parameter. + * - Mode: 00 -> set brightness between 0x00 (min) and 0x3F (max) + * - Mode: 01 -> pulsing pattern (min -> max -> min) with an interval. FromReview
Quoted 10 lines
(quoted diff) +10
-0+ * some tests, the period is about (50ms + 102ms * parameter). There is a + * slightly different pattern starting from 0x100 (longer gap between the + * pulses) but the time still follows that calculation. + * - Mode: 10 -> same as 01 but with only a ramp from min to max. Again a + * slight jump in the pattern at 0x100. + * - Mode: 11 -> blinking (off -> 25% -> off -> 25% -> ...) with a period of + * (105ms * parameter) + * + * NOTE: This driver currently only implements mode 00 (brightness). + */
Quoted 1 line
Aha, so this is not as simple as I thought.
Yes, right. But maybe implementing a generic driver would be a good idea anyway. I don't think that it is useful to support more than the brightness in the near future. Currently the only application I know of would be to port OpenWRT to the device. OpenWRT only switches the LED to max or min.
If you don't object, I'll use the generic approach (including the name change to led-spi-byte).
Quoted 3 lines
"Slightly different pattern starting from
0x100"? What does0x100mean here.
That should be 0x10 instead of 0x100. So for example the jump from 0x4f to 0x50. But if I use the generic approach, that text will change anyway.
Quoted 7 lines
drivers/leds/leds-ubnt-spi.c line 101
Quoted 5 lines
drivers/leds/leds-ubnt-spi.c new file +4
-0+mutex_init (&led->mutex); + led->ldev.name = led->name; + led->ldev.brightness =LED_OFF ; + led->ldev.max_brightness = led->max_bright - led->off_bright;What happens when DTS has
off_bright>max_bright? :-).
That slipped me. I'll create a check for that.
Quoted 12 lines
drivers/leds/leds-ubnt-spi.c line 117
Quoted 10 lines
drivers/leds/leds-ubnt-spi.c new file +9
-0+ +static int ubnt_spi_remove (struct spi_device *spi) +{ +struct ubnt_spi_led *led =spi_get_drvdata (spi); + +led_classdev_unregister (&led->ldev); + +return 0 ; +}Do you need to do
mutex_destroy?
Yes. I'll add it.
Quoted 2 lines
Pavel
Re: [PATCH 2/2] leds: ubnt-spi: Add Ubnt AirCube ISP LED driver
Hi!
Quoted 2 lines
First: Thanks for the quick review. I haven't expected an answer for some days.
Thanks for simple driver :-).
You may want to wait day or two before submitting v2, you may get some other review comment.
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
Quoted 12 lines · On Sat 2019-05-04 14:28:24, [email protected] wrote:
From: Christian Mauderer <[email protected]>
This patch adds the binding documentation for the LED controller found in Ubiquity airCube ISP devices.
Signed-off-by Christian Mauderer <[email protected]>---
I tested the patches with a 4.14 and a 4.19 kernel on the current OpenWRT. Although I didn't get the kernel running due to file system problems they build fine with a 5.1-rc7.
Quoted 7 lines
I shortly described the protocol of the controller in a comment in the driver file in the second patch.
Checkpatch gives the following warning for both patches:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed
updating?
Ignore that :-).
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 2
Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +2
-0@@ -0,0 +1,49 @@ +Binding for the controller based LED found in Ubiquity airCube ISP and most +likely some other Ubiquity devices.
It would be good to know what chip it is.. and name the binding accordingly.
Alternatively, call its led-spi-byte, or something, as it is really trivial protocol. Maybe other chips will have same interface?
Quoted 14 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +14
-0+Example for the airCube ISP (with SPI controller matching that device): + +led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio 3 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + num-chipselects = <1>; + + led_ubnt@0 { + compatible = "ubnt,spi-led";
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 49
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +10
-0+ reg = <0>; + spi-max-frequency = <100000>; + + led { + label = "system"; + /* keep the LED slightly on to show powered device */ + ubnt-spi,off_bright = /bits/ 8 <4>; + }; + }; +};
Otherwise looks good to me,
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 16 lines · Pavel Machek
Quoted 15 lines · On Sat 2019-05-04 14:28:24, [email protected] wrote:
From: Christian Mauderer <[email protected]>
This patch adds the binding documentation for the LED controller found in Ubiquity airCube ISP devices.
Signed-off-by Christian Mauderer <[email protected]>---
I tested the patches with a 4.14 and a 4.19 kernel on the current OpenWRT. Although I didn't get the kernel running due to file system problems they build fine with a 5.1-rc7.
I shortly described the protocol of the controller in a comment in the driver file in the second patch.
Quoted 6 lines
Quoted 4 lines
Checkpatch gives the following warning for both patches:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed
updating?Ignore that :-).
OK. Thanks.
Quoted 12 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 2
Quoted 9 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +2
-0@@ -0,0 +1,49 @@ +Binding for the controller based LED found in Ubiquity airCube ISP and most +likely some other Ubiquity devices.It would be good to know what chip it is.. and name the binding accordingly.
The chip they use is a SONiX 8F26E611LA which is a generic 8-Bit microcontroller. Ubiquiti seems to have programmed it to be a LED controller. But it could do something completely different in another hardware too. Therefore I didn't use the name.
Quoted 3 lines
Alternatively, call its led-spi-byte, or something, as it is really trivial protocol. Maybe other chips will have same interface?
See my other mail: I'll use the generic approach with that name.
Quoted 30 lines
Quoted 15 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +14
-0+Example for the airCube ISP (with SPI controller matching that device): + +led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio 3 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + num-chipselects = <1>; + + led_ubnt@0 { + compatible = "ubnt,spi-led";Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 49
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +10
-0+ reg = <0>; + spi-max-frequency = <100000>; + + led { + label = "system"; + /* keep the LED slightly on to show powered device */ + ubnt-spi,off_bright = /bits/ 8 <4>; + }; + }; +};Otherwise looks good to me,
Acked-by Pavel Machek <[email protected]>
Hi Christian,
Thank you for the patch.
Quoted 15 lines · On 5/4/19 2:28 PM, [email protected] wrote:
From: Christian Mauderer <[email protected]>
This patch adds the binding documentation for the LED controller found in Ubiquity airCube ISP devices.
Signed-off-by Christian Mauderer <[email protected]>---
I tested the patches with a 4.14 and a 4.19 kernel on the current OpenWRT. Although I didn't get the kernel running due to file system problems they build fine with a 5.1-rc7.
I shortly described the protocol of the controller in a comment in the driver file in the second patch.
Quoted 6 lines
Checkpatch gives the following warning for both patches:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?To be honest: I don't know what to do with it. Please excuse my ignorance here. It's the first driver that I want to add to the Linux kernel.
You can add yourself as a maintainer of this driver, but it is customary rather for more complex drivers.
Quoted 40 lines
Please point me to some documentation if I did miss some big points for submitting patches.
.../bindings/leds/leds-ubnt-spi.txt | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+)create mode 100644
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txtDocumentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +26
-0@@ -0,0 +1,49 @@ +Binding for the controller based LED found in Ubiquity airCube ISP and most +likely some other Ubiquity devices. + +The protocol of the controller is quite simple. Only one byte will be sent. The +value of the byte can be between the ubnt-spi,off_bright value and the +ubnt-spi,max_bright value. + +The driver maybe can be used for other devices with a similar protocol too. + +Required properties: +- compatible: Should be "ubnt,spi-led". +- spi-max-frequency: Should be <100000> for this device. + +Optional sub-node properties: +- ubnt-spi,off_bright: The value that will be sent if the LED should be + switched off. Default value is 0. +- ubnt-spi,max_bright: Value for the maximum brightness. Default value for that + is 63. +- label: A label for the LED. If one is given, the LED will be + named "ubnt-spi:<label>" or "ubnt-spi::" otherwise. + +Being a SPI device this driver should be a sub-node of a SPI controller. The +controller only supports one LED. For consistence with other controllers, the +LED is defined as a sub-node. + +Example for the airCube ISP (with SPI controller matching that device):
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 36
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +10
-0+ +led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio 3 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + num-chipselects = <1>;
SPI node implementation is out of LED bindings scope.
Here you're showing spi-gpio configuration, but people are free to use hardware SPI module if available on the platform of their choice.
Effectively, please remove above led_spi node. You can compare other SPI based LED bindings, e.g.:
Documentation/devicetree/bindings/leds/leds-cr0014114.txt
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 38
Quoted 1 line
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +1
-0+ led_ubnt@0 {
s/led_usbnt/led-controller/
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 44
Quoted 6 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +6
-0+ compatible = "ubnt,spi-led"; + reg = <0>; + spi-max-frequency = <100000>; + + led { + label = "system";
In label we expect "color:function" pattern. If section is to be left empty than just leave it blank, e.g.:
label = ":system"
But, is this LED function name telling something useful? What is the actual function of this LED?
I work for some time on LED unification patch set and there is a patch with common LED function names [0], but there is nothing suitable for access points. There is "wlan", but is is rather for wifi dongle LEDs (side note: "wifi" seems to be more ubiquitous, so I will probably go for it finally).
So, maybe we for access points "wifi-ap" would work? i.e. I propose the label in the form:
label = ":wifi-ap"
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 49
Quoted 6 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +5
-0+ /* keep the LED slightly on to show powered device */ + ubnt-spi,off_bright = /bits/ 8 <4>; + }; + }; +};
[0] https://www.spinics.net/lists/kernel/msg3103824.html
Signature · 2 lines
Best regards, Jacek Anaszewski
I missed two issues, please take a look below.
Quoted 3 lines · On 5/4/19 2:28 PM, [email protected] wrote:
Quoted 2 lines
From: Christian Mauderer <[email protected]>
[...]
Quoted 1 line
Quoted 1 line
+- ubnt-spi,max_bright: Value for the maximum brightness. Default
From DT POV the only valid reason for which max brightness level would need to be limited is a protection against hardware damage. Please use led-max-microamp property for that if this is the case. Otherwise such setting can be skipped.
There are two bindings that allow for configuring max-brightness level but they quite old.
Quoted 5 lines
Quoted 5 lines
value for that
+ is 63.
+- label: A label for the LED. If one is given, the LED will be + named "ubnt-spi:<label>" or "ubnt-spi::" otherwise. +
Please use just:
label : see Documentation/devicetree/bindings/leds/common.txt
Signature · 2 lines
Best regards, Jacek Anaszewski
Quoted 8 lines · Jacek Anaszewski
I missed two issues, please take a look below.
Quoted 3 lines · On 5/4/19 2:28 PM, [email protected] wrote:
Quoted 2 lines
From: Christian Mauderer <[email protected]>
[...]
Quoted 1 line
Quoted 1 line
+- ubnt-spi,max_bright: Value for the maximum brightness. Default
Quoted 8 lines
From DT POV the only valid reason for which max brightness level would need to be limited is a protection against hardware damage. Please use led-max-microamp property for that if this is the case. Otherwise such setting can be skipped.
There are two bindings that allow for configuring max-brightness level but they quite old.
My intention with that has been slightly different than limiting the current:
The driver uses a very simple protocol for setting the brightness: It sends one byte via SPI. The value of that byte can be (for that controller) between 0 and 63. My intention when adding the limits has been to allow adaption to similar hardware by changing the values. If for example some other controller wants brightness values between 42 and 173 the off_bright could be set to 42 and the max_bright to 173.
Note that Pavel Machek suggested: "Alternatively, call its led-spi-byte, or something, as it is really trivial protocol. Maybe other chips will have same interface?"
If I follow that suggestion (which I think would be a good idea), I would even need the values as mandatory ones instead of optional ones. Would "led-spi-byte,off-value" and "led-spi-byte,max-value" be better names in that case?
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
value for that
+ is 63.
+- label: A label for the LED. If one is given, the LED will be + named "ubnt-spi:<label>" or "ubnt-spi::" otherwise. +Please use just:
label : see
Documentation/devicetree/bindings/leds/common.txt
I'll use that.
Quoted 28 lines · Christian Mauderer
Quoted 8 lines · Jacek Anaszewski
I missed two issues, please take a look below.
Quoted 3 lines · On 5/4/19 2:28 PM, [email protected] wrote:
Quoted 2 lines
From: Christian Mauderer <[email protected]>
[...]
Quoted 1 line
Quoted 1 line
+- ubnt-spi,max_bright: Value for the maximum brightness. Default
Quoted 8 lines
From DT POV the only valid reason for which max brightness level would
need to be limited is a protection against hardware damage. Please use led-max-microamp property for that if this is the case. Otherwise such setting can be skipped.There are two bindings that allow for configuring max-brightness level but they quite old.
My intention with that has been slightly different than limiting the current:
The driver uses a very simple protocol for setting the brightness: It sends one byte via SPI. The value of that byte can be (for that controller) between 0 and 63. My intention when adding the limits has been to allow adaption to similar hardware by changing the values. If for example some other controller wants brightness values between 42 and 173 the
off_brightcould be set to 42 and themax_brightto 173.
Quoted 8 lines
Note that Pavel Machek suggested: "Alternatively, call its led-spi-byte, or something, as it is really trivial protocol. Maybe other chips will have same interface?"
If I follow that suggestion (which I think would be a good idea), I would even need the values as mandatory ones instead of optional ones. Would "led-spi-byte,off-value" and "led-spi-byte,max-value" be better names in that case?
Yes, that makes perfect sense.
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
value for that
+ is 63.
+- label: A label for the LED. If one is given, the LED will be + named "ubnt-spi:<label>" or "ubnt-spi::" otherwise. +Please use just:
label : see
Documentation/devicetree/bindings/leds/common.txtI'll use that.
Thanks!
Signature · 2 lines
Best regards, Jacek Anaszewski
Quoted 3 lines · Jacek Anaszewski
Hi Christian,
Thank you for the patch.
Hello Jacek,
thank you for your time to review it.
Quoted 25 lines · On 5/4/19 2:28 PM, [email protected] wrote:
Quoted 23 lines
From: Christian Mauderer <[email protected]>
This patch adds the binding documentation for the LED controller found in Ubiquity airCube ISP devices.
Signed-off-by Christian Mauderer <[email protected]>---
I tested the patches with a 4.14 and a 4.19 kernel on the current OpenWRT.
Although I didn't get the kernel running due to file system problems they build
fine with a 5.1-rc7.I shortly described the protocol of the controller in a comment in the driver
file in the second patch.Checkpatch gives the following warning for both patches:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?
Quoted 6 lines
Quoted 3 lines
To be honest: I don't know what to do with it. Please excuse my ignorance here.
It's the first driver that I want to add to the Linux kernel.You can add yourself as a maintainer of this driver, but it is customary rather for more complex drivers.
I would like to follow the best practice here. So if you say that for this simple driver it's not usual, I won't add me. Except if you think it is useful to have someone to blame for it ;-)
Quoted 65 lines
Quoted 50 lines
Please point me to some documentation if I did miss some big points for submitting patches.
.../bindings/leds/leds-ubnt-spi.txt | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)create mode 100644
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txtDocumentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +1
-0@@ -0,0 +1,49 @@ +Binding for the controller based LED found in Ubiquity airCube ISPand most
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +3
-0+likely some other Ubiquity devices. + +The protocol of the controller is quite simple. Only one byte will besent. The
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +4
-0+value of the byte can be between the ubnt-spi,off_bright value and the +ubnt-spi,max_bright value. + +The driver maybe can be used for other devices with a similarprotocol too.
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +7
-0+ +Required properties: +- compatible: Should be "ubnt,spi-led". +- spi-max-frequency: Should be <100000> for this device. + +Optional sub-node properties: +- ubnt-spi,off_bright: The value that will be sent if the LEDshould be
+ switched off. Default value is 0.
+- ubnt-spi,max_bright: Value for the maximum brightness. Default value for that
+ is 63.
+- label: A label for the LED. If one is given, the LED will be + named "ubnt-spi:<label>" or "ubnt-spi::" otherwise.Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +2
-0+ +Being a SPI device this driver should be a sub-node of a SPIcontroller. The
+controller only supports one LED. For consistence with other controllers, theDocumentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +3
-0+LED is defined as a sub-node. + +Example for the airCube ISP (with SPI controller matching that device):Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 36
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +10
-0+ +led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio 3 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + num-chipselects = <1>;SPI node implementation is out of LED bindings scope.
Here you're showing spi-gpio configuration, but people are free to use hardware SPI module if available on the platform of their choice.
Quoted 4 lines
Effectively, please remove above
led_spinode. You can compare other SPI based LED bindings, e.g.:
Documentation/devicetree/bindings/leds/leds-cr0014114.txt
Reason behind adding it was that most likely the controller is only useful for that device. Of course that's no longer true together with the suggestion from Pavel Machek to make it more generic.
I'll follow your suggestion.
Quoted 12 lines
Quoted 2 lines
+ led_ubnt@0 {
s/led_usbnt/led-controller/
Quoted 6 lines
+ compatible = "ubnt,spi-led";
+ reg = <0>;
+ spi-max-frequency = <100000>;
+
+ led {
+ label = "system";
Quoted 7 lines
In label we expect "color:function" pattern. If section is to be left empty than just leave it blank, e.g.:
label = ":system"
But, is this LED function name telling something useful? What is the actual function of this LED?
The LED is a white one. It's the only LED of a WLAN access point. There are not even any network LEDs. Ubiquiti uses it to show some system states with different pulsing patterns during boot. After that it's always on.
In OpenWRT it maybe could also show some network traffic (blinking between dim and bright). But that's user configurable. My plan was to just let it dim when the system is booted.
Quoted 7 lines
I work for some time on LED unification patch set and there is a patch with common LED function names [0], but there is nothing suitable for access points. There is "wlan", but is is rather for wifi dongle LEDs (side note: "wifi" seems to be more ubiquitous, so I will probably go for it finally).
Quoted 5 lines
So, maybe we for access points "wifi-ap" would work? i.e. I propose the label in the form:
label = ":wifi-ap"
I wasn't aware of that list. Maybe "power" or even better "status" would match the function.
Should I add the color too? So "white:status"?
Quoted 10 lines
Quoted 7 lines
+ /* keep the LED slightly on to show powered device */ + ubnt-spi,off_bright = /bits/ 8 <4>;
+ };
+ };
+};
Quoted 8 lines · Christian Mauderer
Quoted 3 lines · Jacek Anaszewski
Hi Christian,
Thank you for the patch.
Hello Jacek,
thank you for your time to review it.
You're welcome.
Quoted 29 lines
Quoted 29 lines · On 5/4/19 2:28 PM, [email protected] wrote:
Quoted 26 lines
From: Christian Mauderer <[email protected]>
This patch adds the binding documentation for the LED controller found in Ubiquity airCube ISP devices.
Signed-off-by Christian Mauderer <[email protected]>---
I tested the patches with a 4.14 and a 4.19 kernel on the current OpenWRT.
Although I didn't get the kernel running due to file system problems they build
fine with a 5.1-rc7.I shortly described the protocol of the controller in a comment in the driver
file in the second patch.Checkpatch gives the following warning for both patches:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed
updating?To be honest: I don't know what to do with it. Please excuse my ignorance here.
It's the first driver that I want to add to the Linux kernel.
Quoted 6 lines
Quoted 2 lines
You can add yourself as a maintainer of this driver, but it is customary rather for more complex drivers.
I would like to follow the best practice here. So if you say that for this simple driver it's not usual, I won't add me. Except if you think it is useful to have someone to blame for it ;-)
People will always have your email in the driver, so I'd ignore that warning as Pavel already proposed.
Quoted 67 lines
Quoted 67 lines
Quoted 49 lines
Please point me to some documentation if I did miss some big points for submitting patches.
.../bindings/leds/leds-ubnt-spi.txt | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+)create mode 100644
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txtDocumentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +1
-0@@ -0,0 +1,49 @@ +Binding for the controller based LED found in Ubiquity airCube ISPand most
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +3
-0+likely some other Ubiquity devices. + +The protocol of the controller is quite simple. Only one byte will besent. The
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +4
-0+value of the byte can be between the ubnt-spi,off_bright value and the +ubnt-spi,max_bright value. + +The driver maybe can be used for other devices with a similarprotocol too.
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +7
-0+ +Required properties: +- compatible: Should be "ubnt,spi-led". +- spi-max-frequency: Should be <100000> for this device. + +Optional sub-node properties: +- ubnt-spi,off_bright: The value that will be sent if the LEDshould be
+ switched off. Default value is 0.
+- ubnt-spi,max_bright: Value for the maximum brightness. Default value for that
+ is 63.
+- label: A label for the LED. If one is given, the LED will be + named "ubnt-spi:<label>" or "ubnt-spi::" otherwise.Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +2
-0+ +Being a SPI device this driver should be a sub-node of a SPIcontroller. The
+controller only supports one LED. For consistence with other controllers, theDocumentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +3
-0+LED is defined as a sub-node. + +Example for the airCube ISP (with SPI controller matching that device):Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt line 36
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-ubnt-spi.txt new file +10
-0+ +led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio 3 GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio 2 GPIO_ACTIVE_HIGH>; + cs-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + num-chipselects = <1>;SPI node implementation is out of LED bindings scope.
Here you're showing spi-gpio configuration, but people are free to use hardware SPI module if available on the platform of their choice.Effectively, please remove above
led_spinode. You can compare other SPI based LED bindings, e.g.:
Quoted 7 lines
Quoted 1 line
Documentation/devicetree/bindings/leds/leds-cr0014114.txtReason behind adding it was that most likely the controller is only useful for that device. Of course that's no longer true together with the suggestion from Pavel Machek to make it more generic.
I'll follow your suggestion.
Thank you.
Quoted 19 lines
Quoted 11 lines
Quoted 1 line
+ led_ubnt@0 {
s/led_usbnt/led-controller/
Quoted 6 lines
+ compatible = "ubnt,spi-led";
+ reg = <0>;
+ spi-max-frequency = <100000>;
+
+ led {
+ label = "system";Quoted 7 lines
In label we expect "color:function" pattern. If section is to be left empty than just leave it blank, e.g.:
label = ":system"
But, is this LED function name telling something useful? What is the actual function of this LED?
Quoted 8 lines
The LED is a white one. It's the only LED of a WLAN access point. There are not even any network LEDs. Ubiquiti uses it to show some system states with different pulsing patterns during boot. After that it's always on.
In OpenWRT it maybe could also show some network traffic (blinking between dim and bright). But that's user configurable. My plan was to just let it dim when the system is booted.
Thank you for this explanation.
Quoted 7 lines
Quoted 7 lines
I work for some time on LED unification patch set and there is a patch with common LED function names [0], but there is nothing suitable for access points. There is "wlan", but is is rather for wifi dongle LEDs (side note: "wifi" seems to be more ubiquitous, so I will probably go for it finally).
Quoted 8 lines
Quoted 5 lines
So, maybe we for access points "wifi-ap" would work? i.e. I propose the label in the form:
label = ":wifi-ap"
I wasn't aware of that list. Maybe "power" or even better "status" would match the function.
Hmm, I've just found out that there are two "wlan-ap" occurrences in the existing mainline bindings, so I propose to follow that.
Quoted 1 line
Should I add the color too? So "white:status"?
Yes, why not if it is known. So, having the above I propose:
label = "white:wlan-ap";
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
+ /* keep the LED slightly on to show powered device */ + ubnt-spi,off_bright = /bits/ 8 <4>;
+ };
+ };
+};
Signature · 2 lines
Best regards, Jacek Anaszewski
Hi!
Quoted 11 lines
Quoted 2 lines
I wasn't aware of that list. Maybe "power" or even better "status" would match the function.
Hmm, I've just found out that there are two "wlan-ap" occurrences in the existing mainline bindings, so I propose to follow that.
Quoted 1 line
Should I add the color too? So "white:status"?
Yes, why not if it is known. So, having the above I propose:
label = "white:wlan-ap";
Linux now runs on many different devices, and I believe userland wants to know "this is main notification LED for this device" (and the only one in this case).
Phones normally have at most one such LED. Now access point. Someone will make ethernet switch with just one LED. Maybe thermostat will have only one LED. Bluetooth GPS. ...
I'd prefer not to mention type of device, and simply state that this is status LED for the device. Droid 4 uses "status-led:{red,green,blue}", so "status-led:white" would seem reasonable.
"white:status" sounds good, too. But I'd prefer not to mention type of the device, it is simply status LED.
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
Hi!
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I wasn't aware of that list. Maybe "power" or even better "status" would match the function.
Hmm, I've just found out that there are two "wlan-ap" occurrences in the existing mainline bindings, so I propose to follow that.
Let me see... dove-d3plug.dts has "status", "wlan-ap", "wlan-act".
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Should I add the color too? So "white:status"?
Yes, why not if it is known. So, having the above I propose:
label = "white:wlan-ap";Linux now runs on many different devices, and I believe userland wants to know "this is main notification LED for this device" (and the only one in this case).
...and I guess if you have single LED it will be used for more than "is AP active". IOW it will likely to be more similar to "status" than "wlan-ap".
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
Quoted 20 lines · Pavel Machek
Hi!
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I wasn't aware of that list. Maybe "power" or even better "status" would match the function.
Hmm, I've just found out that there are two "wlan-ap" occurrences in the existing mainline bindings, so I propose to follow that.
Let me see...
dove-d3plug.dtshas "status", "wlan-ap", "wlan-act".Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Should I add the color too? So "white:status"?
Yes, why not if it is known. So, having the above I propose:
label = "white:wlan-ap";Linux now runs on many different devices, and I believe userland wants to know "this is main notification LED for this device" (and the only one in this case).
Quoted 7 lines
...and I guess if you have single LED it will be used for more than "is AP active". IOW it will likely to be more similar to "status" than "wlan-ap".
Best regards,
Pavel
As far as I understand it the dt-bindings is an example anyway, right? So it's not really relevant what the LED does in my specific system. Jacek said
Quoted 1 line
In label we expect "color:function" pattern.
Therefore I think that a "white:status" would be a good example label and I'll use that.
I'll prepare a patch set v2 and (hopefully) send it in the next hours after I've tested in on my hardware.
Best regards
Christian
Hi,
Quoted 19 lines · Pavel Machek
Hi!
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I wasn't aware of that list. Maybe "power" or even better "status" would match the function.
Hmm, I've just found out that there are two "wlan-ap" occurrences in the existing mainline bindings, so I propose to follow that.
Let me see...
dove-d3plug.dtshas "status", "wlan-ap", "wlan-act".Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Should I add the color too? So "white:status"?
Yes, why not if it is known. So, having the above I propose:
label = "white:wlan-ap";Linux now runs on many different devices, and I believe userland wants to know "this is main notification LED for this device" (and the only one in this case).
This LED is on the access point, so it should have this affiliation somehow represented in the name.
Quoted 3 lines
...and I guess if you have single LED it will be used for more than "is AP active". IOW it will likely to be more similar to "status" than "wlan-ap".
IMO if a LED is on some specific device, then it should be reflected in the "function" section of the LED name. It facilitates locating in physically. If usersapce wants to change its purpose it is free to do so. e.g. via triggers. But it will not affect the LED name.
Signature · 2 lines
Best regards, Jacek Anaszewski
Quoted 27 lines · Jacek Anaszewski
Hi,
Quoted 20 lines · Pavel Machek
Hi!
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
I wasn't aware of that list. Maybe "power" or even better "status" would
match the function.Hmm, I've just found out that there are two "wlan-ap" occurrences in the existing mainline bindings, so I propose to follow that.
Let me see...
dove-d3plug.dtshas "status", "wlan-ap", "wlan-act".Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Should I add the color too? So "white:status"?
Yes, why not if it is known. So, having the above I propose:
������� label = "white:wlan-ap";
Linux now runs on many different devices, and I believe userland wants to know "this is main notification LED for this device" (and the only one in this case).
This LED is on the access point, so it should have this affiliation somehow represented in the name.
Quoted 9 lines
Quoted 3 lines
...and I guess if you have single LED it will be used for more than "is AP active". IOW it will likely to be more similar to "status" than "wlan-ap".
IMO if a LED is on some specific device, then it should be reflected in the "function" section of the LED name. It facilitates locating in physically. If usersapce wants to change its purpose it is free to do so. e.g. via triggers. But it will not affect the LED name.
This looks like a strongly opinion based discussion. Currently it's only relevant for the name in the examble in the dt-binding document. Isn't it completely irrelevant what I use there? The controller could be used on any device, couldn't it?
Regarding your argument toward naming (maybe relevant when I add it to the device tree files in OpenWRT): Would that mean that if a hypothetical server has one LED to show some arbitrary system states it should be named "green:server" instead of "green:status" because it is on a specific device (server in that case)?
I would expect a LED called "wlan-ap" to show the status of the WLAN. Like many small WLAN access points, the airCube has multiple ports. So it could be used as a generic router with WLAN switched off too. In that case "wlan-ap" wouldn't really fit the function of the LED.
Like I said: Ubiquiti uses the LED in the original software to show some system events like "I'm finished booting" (steady brightness) or "I'm currently upgrading" (blinking pattern).
Best regards
Christian
Quoted 49 lines · Christian Mauderer
Quoted 27 lines · Jacek Anaszewski
Hi,
Quoted 20 lines · Pavel Machek
Hi!
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
I wasn't aware of that list. Maybe "power" or even better "status" would
match the function.Hmm, I've just found out that there are two "wlan-ap" occurrences in the existing mainline bindings, so I propose to follow that.
Let me see...
dove-d3plug.dtshas "status", "wlan-ap", "wlan-act".Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Should I add the color too? So "white:status"?
Yes, why not if it is known. So, having the above I propose:
������� label = "white:wlan-ap";
Linux now runs on many different devices, and I believe userland wants to know "this is main notification LED for this device" (and the only one in this case).
This LED is on the access point, so it should have this affiliation somehow represented in the name.
Quoted 9 lines
Quoted 3 lines
...and I guess if you have single LED it will be used for more than "is AP active". IOW it will likely to be more similar to "status" than "wlan-ap".
IMO if a LED is on some specific device, then it should be reflected in the "function" section of the LED name. It facilitates locating in physically. If usersapce wants to change its purpose it is free to do so. e.g. via triggers. But it will not affect the LED name.
This looks like a strongly opinion based discussion. Currently it's only relevant for the name in the examble in the dt-binding document. Isn't it completely irrelevant what I use there? The controller could be used on any device, couldn't it?
Regarding your argument toward naming (maybe relevant when I add it to the device tree files in OpenWRT): Would that mean that if a hypothetical server has one LED to show some arbitrary system states it should be named "green:server" instead of "green:status" because it is on a specific device (server in that case)?
Quoted 8 lines
I would expect a LED called "wlan-ap" to show the status of the WLAN. Like many small WLAN access points, the airCube has multiple ports. So it could be used as a generic router with WLAN switched off too. In that case "wlan-ap" wouldn't really fit the function of the LED.
Like I said: Ubiquiti uses the LED in the original software to show some system events like "I'm finished booting" (steady brightness) or "I'm currently upgrading" (blinking pattern).
OK, I've misinterpreted something here. Let's have "white:status" in the example.
Signature · 2 lines
Best regards, Jacek Anaszewski
Quoted 26 lines · Jacek Anaszewski
Hi,
Quoted 19 lines · Pavel Machek
Hi!
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I wasn't aware of that list. Maybe "power" or even better "status" would match the function.
Hmm, I've just found out that there are two "wlan-ap" occurrences in the existing mainline bindings, so I propose to follow that.
Let me see...
dove-d3plug.dtshas "status", "wlan-ap", "wlan-act".Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Should I add the color too? So "white:status"?
Yes, why not if it is known. So, having the above I propose:
label = "white:wlan-ap";Linux now runs on many different devices, and I believe userland wants to know "this is main notification LED for this device" (and the only one in this case).
This LED is on the access point, so it should have this affiliation somehow represented in the name.
Quoted 8 lines
Quoted 3 lines
...and I guess if you have single LED it will be used for more than "is AP active". IOW it will likely to be more similar to "status" than "wlan-ap".
IMO if a LED is on some specific device, then it should be reflected in the "function" section of the LED name. It facilitates locating in physically. If usersapce wants to change its purpose it is free to do so. e.g. via triggers. But it will not affect the LED name.
I'd prefer not to do that. Existing ":wlan-ap" LED is a LED probably indicating that access point is on; while this will normally indicate system status. Its function is more similar to "status" on dove-d3plug.dts.
I'd prefer LED names not to depend on function of system they are in. Status LED on phone should be named same way status LED of wireless AP is.
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