dt-bindings: Add docs for EL15203000
Subsystems (2)
PATCH v4 1/2 dt-bindings: Add docs for EL15203000
Add documentation and example for dt-bindings EL15203000. LED board (aka RED LED board) from Crane Merchandising Systems.
--- .../bindings/leds/leds-el15203000.txt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-el15203000.txt
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +47 -0
@@ -0,0 +1,47 @@ +Crane Merchandising System - el15203000 LED driver +-------------------------------------------------- + +This LED Board (aka RED LEDs board) is widely used in +coffee vending machines produced by Crane Merchandising Systems. + +Required properties: +- compatible : "crane,el15203000" +- reg : + see Documentation/devicetree/bindings/spi/spi-bus.txt +- spi-max-frequency : (optional) + see Documentation/devicetree/bindings/spi/spi-bus.txt + +Optional LED sub-node properties: +- label : + see Documentation/devicetree/bindings/leds/common.txt +- linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Example +------- + +led-controller@0 { + compatible = "crane,el15203000"; + reg = <0>; + spi-max-frequency = <50000>; + #address-cells = <1>; + #size-cells = <0>; + + /* water pipe */ + pipe@50 { + reg = <0x50>; + label = "red:pipe"; + }; + + /* screen frame */ + screen@53 { + reg = <0x53>; + label = "red:screen"; + }; + + /* vending area */ + vend@56 { + reg = <0x56>; + label = "red:vend"; + }; +};
Signature · 1 line
2.21.0
PATCH v4 2/2 leds: add LED driver for EL15203000 board
This patch adds a LED class driver for the RGB LEDs found on the Crane Merchandising System EL15203000 LEDs board (aka RED LEDs board).
--- .../testing/sysfs-class-led-driver-el15203000 | 22 + drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-el15203000.c | 478 ++++++++++++++++++ 4 files changed, 514 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-driver-el15203000 create mode 100644 drivers/leds/leds-el15203000.c
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +22 -0
@@ -0,0 +1,22 @@ +What: /sys/class/leds/<led>/hw_pattern +Date: August 2019 +KernelVersion: 5.3 +Description: + Specify a hardware pattern for the EL15203000 LED. + The LEDs board supports only predefined patterns by firmware + for specific LEDs. + + Breathing mode for Screen frame light tube: + "0 4000 1 4000" + + Cascade mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 1 800 2 800 4 800 8 800 16 800" + + Inverted cascade mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 30 800 29 800 27 800 23 800 15 800" + + Bounce mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800" + + Inverted bounce mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
drivers/leds/Kconfig +13 -0
@@ -129,6 +129,19 @@ config LEDS_CR0014114 To compile this driver as a module, choose M here: the module will be called leds-cr0014114. +config LEDS_EL15203000 + tristate "LED Support for Crane EL15203000" + depends on LEDS_CLASS + depends on SPI + depends on OF + help + This option enables support for EL15203000 LED Board + (aka RED LED board) which is widely used in coffee vending + machines produced by Crane Merchandising Systems. + + To compile this driver as a module, choose M here: the module + will be called leds-el15203000. + config LEDS_LM3530 tristate "LCD Backlight driver for LM3530" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -85,6 +85,7 @@ obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o # LED SPI Drivers obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o +obj-$(CONFIG_LEDS_EL15203000) += leds-el15203000.o # LED Userspace Drivers obj-$(CONFIG_LEDS_USER) += uleds.o
drivers/leds/leds-el15203000.c new file +478 -0
478 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Hi Oleh,
Thank you for the patch set.
Quoted 23 lines · Oleh Kravchenko
This patch adds a LED class driver for the RGB LEDs found on the Crane Merchandising System EL15203000 LEDs board (aka RED LEDs board).
Signed-off-by Oleh Kravchenko <[email protected]>--- .../testing/sysfs-class-led-driver-el15203000 | 22 + drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-el15203000.c | 478 ++++++++++++++++++ 4 files changed, 514 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-driver-el15203000 create mode 100644 drivers/leds/leds-el15203000.cDocumentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0@@ -0,0 +1,22 @@ +What: /sys/class/leds/<led>/hw_pattern +Date: August 2019 +KernelVersion: 5.3
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 13
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +10
-0+Description: + Specify a hardware pattern for the EL15203000 LED. + The LEDs board supports only predefined patterns by firmware + for specific LEDs. + + Breathing mode for Screen frame light tube: + "0 4000 1 4000" + + Cascade mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 1 800 2 800 4 800 8 800 16 800"
Why the sequence "1 800 2 800 4 800 8 800 16 800" is duplicated here? It seems redundant. But aside of that - aren't the timings modifiable? In other words - are these all patterns somehow configurable or they are pre-programmed?
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 16
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted cascade mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 30 800 29 800 27 800 23 800 15 800"
Similar duplication here.
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 19
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Bounce mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"
Instead of two repeating "16 800" you could provide "16 1600". But here again is the question whether these values are configurable.
Quoted 1 line
From what I can see in your driver implementation you're expecting
exactly the values provided in these examples to enable given hardware pattern (led_pattern_cmp()).
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted bounce mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Hello Jacek,
Thank you for your useful review,
13.08.19 23:28, Jacek Anaszewski пише:
Quoted 17 lines
Hi Oleh,
Thank you for the patch set.
Quoted 12 lines · Oleh Kravchenko
+++ b/Documentation/ABI/testing/sysfs-class-led-driver-el15203000
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +10
-0@@ -0,0 +1,22 @@ +What: /sys/class/leds/<led>/hw_pattern +Date: August 2019 +KernelVersion: 5.3 +Description: + Specify a hardware pattern for the EL15203000 LED. + The LEDs board supports only predefined patterns by firmware + for specific LEDs. + + Breathing mode for Screen frame light tube: + "0 4000 1 4000"
Quoted 9 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 13
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Cascade mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 1 800 2 800 4 800 8 800 16 800"Why the sequence "1 800 2 800 4 800 8 800 16 800" is duplicated here? It seems redundant. But aside of that - aren't the timings modifiable? In other words - are these all patterns somehow configurable or they are pre-programmed?
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
Quoted 16 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 16
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted cascade mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 30 800 29 800 27 800 23 800 15 800"Similar duplication here.
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 19
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Bounce mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"Instead of two repeating "16 800" you could provide "16 1600". But here again is the question whether these values are configurable. From what I can see in your driver implementation you're expecting exactly the values provided in these examples to enable given hardware pattern (
led_pattern_cmp()).
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 22
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted bounce mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
Should I cut this patterns to smaller? Or let keep it?
Signature · 2 lines
Best regards, Oleh Kravchenko
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Hi Oleh,
Quoted 32 lines · Oleh Kravchenko
Hello Jacek,
Thank you for your useful review,
13.08.19 23:28, Jacek Anaszewski пише:
Quoted 17 lines
Hi Oleh,
Thank you for the patch set.
Quoted 12 lines · Oleh Kravchenko
+++ b/Documentation/ABI/testing/sysfs-class-led-driver-el15203000
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +10
-0@@ -0,0 +1,22 @@ +What: /sys/class/leds/<led>/hw_pattern +Date: August 2019 +KernelVersion: 5.3 +Description: + Specify a hardware pattern for the EL15203000 LED. + The LEDs board supports only predefined patterns by firmware + for specific LEDs. + + Breathing mode for Screen frame light tube: + "0 4000 1 4000"Quoted 9 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 13
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Cascade mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 1 800 2 800 4 800 8 800 16 800"Why the sequence "1 800 2 800 4 800 8 800 16 800" is duplicated here? It seems redundant. But aside of that - aren't the timings modifiable? In other words - are these all patterns somehow configurable or they are pre-programmed?
Quoted 3 lines
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
It makes me wonder how you figured out the values? If you have a documentation for this controller, could you share how the pattern settings are documented?
Quoted 16 lines
Quoted 16 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 16
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted cascade mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 30 800 29 800 27 800 23 800 15 800"Similar duplication here.
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 19
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Bounce mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"Instead of two repeating "16 800" you could provide "16 1600". But here again is the question whether these values are configurable. From what I can see in your driver implementation you're expecting exactly the values provided in these examples to enable given hardware pattern (
led_pattern_cmp()).
Quoted 7 lines
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 22
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted bounce mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"Should I cut this patterns to smaller? Or let keep it?
For the first two we could do without sequence duplication.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Hello Jacek,
14.08.19 21:18, Jacek Anaszewski пише:
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Why the sequence "1 800 2 800 4 800 8 800 16 800" is duplicated here? It seems redundant. But aside of that - aren't the timings modifiable? In other words - are these all patterns somehow configurable or they are pre-programmed?
Quoted 7 lines
Quoted 3 lines
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
It makes me wonder how you figured out the values? If you have a documentation for this controller, could you share how the pattern settings are documented?
I saw the code of firmware.
Not sure if I can find any documentation for it right now.
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 16
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted cascade mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 30 800 29 800 27 800 23 800 15 800"Similar duplication here.
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 19
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Bounce mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"Instead of two repeating "16 800" you could provide "16 1600". But here again is the question whether these values are configurable. From what I can see in your driver implementation you're expecting exactly the values provided in these examples to enable given hardware pattern (
led_pattern_cmp()).Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted bounce mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
Quoted 4 lines
Quoted 2 lines
Should I cut this patterns to smaller? Or let keep it?
For the first two we could do without sequence duplication.
Ok, I will reduce it.
Signature · 2 lines
Best regards, Oleh Kravchenko
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Quoted 13 lines · Oleh Kravchenko
Hello Jacek,
14.08.19 21:18, Jacek Anaszewski пише:
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
Why the sequence "1 800 2 800 4 800 8 800 16 800" is duplicated here? It seems redundant. But aside of that - aren't the timings modifiable? In other words - are these all patterns somehow configurable or they are pre-programmed?
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
Quoted 6 lines
Quoted 3 lines
It makes me wonder how you figured out the values? If you have a documentation for this controller, could you share how the pattern settings are documented?
I saw the code of firmware.
Not sure if I can find any documentation for it right now.
Have you tried to alter the values? Or check what happens when the duplication is removed?
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 16
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted cascade mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 30 800 29 800 27 800 23 800 15 800"Similar duplication here.
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 19
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Bounce mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"Instead of two repeating "16 800" you could provide "16 1600". But here again is the question whether these values are configurable. From what I can see in your driver implementation you're expecting exactly the values provided in these examples to enable given hardware pattern (
led_pattern_cmp()).Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted bounce mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Should I cut this patterns to smaller? Or let keep it?
For the first two we could do without sequence duplication.
Ok, I will reduce it.
Please hold on for a while. I will have some more remarks to the driver, just collecting missing info for now to gain more complete view on this device.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Hello Jacek,
14.08.19 22:57, Jacek Anaszewski пише:
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
It makes me wonder how you figured out the values? If you have a documentation for this controller, could you share how the pattern settings are documented?
Quoted 5 lines
Quoted 2 lines
I saw the code of firmware.
Not sure if I can find any documentation for it right now.Have you tried to alter the values? Or check what happens when the duplication is removed?
What do you mean alter? It doesn't make any sense. Board is accepts only brightness level from '0' to '5'. I'm really confused :-)
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
For the first two we could do without sequence duplication.
Ok, I will reduce it.
Please hold on for a while. I will have some more remarks to the driver, just collecting missing info for now to gain more complete view on this device.
Here is the full story:
EL15203000 LEDs board (aka RED LEDs board, because it has only RED LEDs). It's provide access to 3 LEDs:
- First LED (Screen) is a light tube around big 21" screen It's have 3 brightness levels:
* OFF
* ON
* Breathing mode (8 seconds full cycle)
- Second LED (Vending area) is highlight coffee cap
* OFF
* ON
- Third LED (Pipe) is actually virtual, because consists from 5 LEDs
* OFF for all 5 LEDs
* ON for all 5 LEDs
* Cascade
* Inverses cascade
* Bounce
* Inverses bounce
Signature · 2 lines
Best regards, Oleh Kravchenko
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Quoted 15 lines · Oleh Kravchenko
Hello Jacek,
14.08.19 22:57, Jacek Anaszewski пише:
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
It makes me wonder how you figured out the values? If you have a documentation for this controller, could you share how the pattern settings are documented?
I saw the code of firmware.
Not sure if I can find any documentation for it right now.
Quoted 6 lines
Quoted 2 lines
Have you tried to alter the values? Or check what happens when the duplication is removed?
What do you mean alter? It doesn't make any sense. Board is accepts only brightness level from '0' to '5'. I'm really confused :-)
OK, I didn't analyze the driver thoroughly enough. Now everything is clear to me. Patterns are triggered just by writing two-byte command.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
For the first two we could do without sequence duplication.
Ok, I will reduce it.
Please hold on for a while. I will have some more remarks to the driver, just collecting missing info for now to gain more complete view on this device.
Here is the full story:
Quoted 8 lines
EL15203000 LEDs board (aka RED LEDs board, because it has only RED LEDs). It's provide access to 3 LEDs:
- First LED (Screen) is a light tube around big 21" screen It's have 3 brightness levels:
* OFF
* ON
* Breathing mode (8 seconds full cycle)
OK, so this is LED string. We would need to bend rules to make it appearing as a single LED class device, but allowing non-synchronous blinking of LEDs in the string.
Quoted 10 lines
- Second LED (Vending area) is highlight coffee cap
* OFF
* ON
- Third LED (Pipe) is actually virtual, because consists from 5 LEDs
* OFF for all 5 LEDs
* ON for all 5 LEDs
* Cascade
* Inverses cascade
* Bounce
* Inverses bounce
Similarly in case of this one. I will give you a feedback on how to define the patterns within few days.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
By the way,
14.08.19 23:53, Jacek Anaszewski пише:
Quoted 47 lines · Oleh Kravchenko
Quoted 15 lines
Hello Jacek,
14.08.19 22:57, Jacek Anaszewski пише:
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
It makes me wonder how you figured out the values? If you have a documentation for this controller, could you share how the pattern settings are documented?
I saw the code of firmware.
Not sure if I can find any documentation for it right now.Quoted 6 lines
Quoted 2 lines
Have you tried to alter the values? Or check what happens when the duplication is removed?
What do you mean alter? It doesn't make any sense. Board is accepts only brightness level from '0' to '5'. I'm really confused :-)
OK, I didn't analyze the driver thoroughly enough. Now everything is clear to me. Patterns are triggered just by writing two-byte command.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
For the first two we could do without sequence duplication.
Ok, I will reduce it.
Please hold on for a while. I will have some more remarks to the driver, just collecting missing info for now to gain more complete view on this device.
Here is the full story:
Quoted 8 lines
EL15203000 LEDs board (aka RED LEDs board, because it has only RED LEDs). It's provide access to 3 LEDs:
- First LED (Screen) is a light tube around big 21" screen It's have 3 brightness levels:
* OFF
* ON
* Breathing mode (8 seconds full cycle)
Quoted 14 lines
OK, so this is LED string. We would need to bend rules to make it appearing as a single LED class device, but allowing non-synchronous blinking of LEDs in the string.
Quoted 10 lines
- Second LED (Vending area) is highlight coffee cap
* OFF
* ON
- Third LED (Pipe) is actually virtual, because consists from 5 LEDs
* OFF for all 5 LEDs
* ON for all 5 LEDs
* Cascade
* Inverses cascade
* Bounce
* Inverses bounce
Full cycle takes 8 seconds too.
So actually it's splitted into 10 stages, each takes 800ms.
Quoted 3 lines
Similarly in case of this one. I will give you a feedback on how to define the patterns within few days.
Take you time.
Signature · 2 lines
Best regards, Oleh Kravchenko
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
In reply to Oleh KravchenkoHi!
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
It makes me wonder how you figured out the values? If you have a documentation for this controller, could you share how the pattern settings are documented?
I saw the code of firmware.
Not sure if I can find any documentation for it right now.
Quoted 6 lines
Quoted 2 lines
Have you tried to alter the values? Or check what happens when the duplication is removed?
What do you mean alter? It doesn't make any sense. Board is accepts only brightness level from '0' to '5'. I'm really confused :-)
For the record, what you did seems ok to me.
Quoted 11 lines
Quoted 5 lines
Quoted 1 line
Ok, I will reduce it.
Please hold on for a while. I will have some more remarks to the driver, just collecting missing info for now to gain more complete view on this device.
Here is the full story:
EL15203000 LEDs board (aka RED LEDs board, because it has only RED LEDs). It's provide access to 3 LEDs:
Quoted 8 lines
- First LED (Screen) is a light tube around big 21" screen It's have 3 brightness levels:
* OFF
* ON
* Breathing mode (8 seconds full cycle)
- Second LED (Vending area) is highlight coffee cap
* OFF
* ON
Again, this is ok.
Quoted 7 lines
- Third LED (Pipe) is actually virtual, because consists from 5 LEDs
* OFF for all 5 LEDs
* ON for all 5 LEDs
* Cascade
* Inverses cascade
* Bounce
* Inverses bounce
But having one virtual LED that is really five LEDs scares me a tiny bit. But I guess its ok for your case...
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
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Hello Pavel,
17.08.19 18:02, Pavel Machek пише:
Quoted 13 lines
Hi!
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
All pattern is predefined, you can't change them at all. I just tried to describe real things what happened in LED board. It's ticks every 800 milliseconds for Pipe LEDs.
It makes me wonder how you figured out the values? If you have a documentation for this controller, could you share how the pattern settings are documented?
I saw the code of firmware.
Not sure if I can find any documentation for it right now.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Have you tried to alter the values? Or check what happens when the duplication is removed?
What do you mean alter? It doesn't make any sense. Board is accepts only brightness level from '0' to '5'. I'm really confused :-)
For the record, what you did seems ok to me.
Thanks :)
Quoted 39 lines
Quoted 11 lines
Quoted 5 lines
Quoted 1 line
Ok, I will reduce it.
Please hold on for a while. I will have some more remarks to the driver, just collecting missing info for now to gain more complete view on this device.
Here is the full story:
EL15203000 LEDs board (aka RED LEDs board, because it has only RED LEDs). It's provide access to 3 LEDs:
Quoted 8 lines
- First LED (Screen) is a light tube around big 21" screen It's have 3 brightness levels:
* OFF
* ON
* Breathing mode (8 seconds full cycle)
- Second LED (Vending area) is highlight coffee cap
* OFF
* ONAgain, this is ok.
Quoted 7 lines
- Third LED (Pipe) is actually virtual, because consists from 5 LEDs
* OFF for all 5 LEDs
* ON for all 5 LEDs
* Cascade
* Inverses cascade
* Bounce
* Inverses bounceBut having one virtual LED that is really five LEDs scares me a tiny bit. But I guess its ok for your case...
Best regards,
Pavel
Signature · 2 lines
Best regards, Oleh Kravchenko
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
In reply to Oleh KravchenkoHi Oleh,
Please find my review remarks below.
Quoted 23 lines · Oleh Kravchenko
This patch adds a LED class driver for the RGB LEDs found on the Crane Merchandising System EL15203000 LEDs board (aka RED LEDs board).
Signed-off-by Oleh Kravchenko <[email protected]>--- .../testing/sysfs-class-led-driver-el15203000 | 22 + drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-el15203000.c | 478 ++++++++++++++++++ 4 files changed, 514 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-driver-el15203000 create mode 100644 drivers/leds/leds-el15203000.cDocumentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0@@ -0,0 +1,22 @@ +What: /sys/class/leds/<led>/hw_pattern +Date: August 2019 +KernelVersion: 5.3
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 13
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +10
-0+Description: + Specify a hardware pattern for the EL15203000 LED. + The LEDs board supports only predefined patterns by firmware + for specific LEDs. + + Breathing mode for Screen frame light tube: + "0 4000 1 4000" + + Cascade mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 1 800 2 800 4 800 8 800 16 800"
There's no point in repeating same sequence. Just require to provide it once:
"1 800 2 800 4 800 8 800 16 800"
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 16
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted cascade mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 30 800 29 800 27 800 23 800 15 800"
The same story:
"30 800 29 800 27 800 23 800 15 800"
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 22
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +6
-0+ + Bounce mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800" + + Inverted bounce mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
These can be left as they are now.
Quoted 86 lines
drivers/leds/Kconfig +13
-0@@ -129,6 +129,19 @@ config LEDS_CR0014114 To compile this driver as a module, choose M here: the module will be called leds-cr0014114. +config LEDS_EL15203000 + tristate "LED Support for Crane EL15203000" + depends on LEDS_CLASS + depends on SPI + depends on OF + help + This option enables support for EL15203000 LED Board + (aka RED LED board) which is widely used in coffee vending + machines produced by Crane Merchandising Systems. + + To compile this driver as a module, choose M here: the module + will be called leds-el15203000. + config LEDS_LM3530 tristate "LCD Backlight driver for LM3530" depends on LEDS_CLASSdrivers/leds/Makefile +1
-0@@ -85,6 +85,7 @@ obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o # LED SPI Drivers obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o +obj-$(CONFIG_LEDS_EL15203000) += leds-el15203000.o # LED Userspace Drivers obj-$(CONFIG_LEDS_USER) += uleds.odrivers/leds/leds-el15203000.c new file +44
-0@@ -0,0 +1,478 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2019 Crane Merchandising Systems. All rights reserved. +// Copyright (C) 2019 Oleh Kravchenko <[email protected]> + +#include <linux/delay.h> +#include <linux/leds.h> +#include <linux/limits.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/spi/spi.h> +#include <uapi/linux/uleds.h> + +/* +* EL15203000 SPI protocol description: +* +-----+------------+ +* | LED | BRIGHTNESS | +* +-----+------------+ +* | 1 | 1 | +* +-----+------------+ +* (*) LEDs MCU board expects 20 msec delay per byte. +* +* LEDs: +* +----------+--------------+-------------------------------------------+ +* | ID | NAME | DESCRIPTION | +* +----------+--------------+-------------------------------------------+ +* | 'P' 0x50 | Pipe | Consists from 5 LEDs, controlled by board | +* +----------+--------------+-------------------------------------------+ +* | 'S' 0x53 | Screen frame | Light tube around the screen | +* +----------+--------------+-------------------------------------------+ +* | 'V' 0x56 | Vending area | Highlights a cup of coffee | +* +----------+--------------+-------------------------------------------+ +* +* BRIGHTNESS: +* +----------+-----------------+--------------+--------------+ +* | VALUES | PIPE | SCREEN FRAME | VENDING AREA | +* +----------+-----------------+--------------+--------------+ +* | '0' 0x30 | Off | +* +----------+-----------------------------------------------+ +* | '1' 0x31 | On | +* +----------+-----------------+--------------+--------------+ +* | '2' 0x32 | Cascade | Breathing | +* +----------+-----------------+--------------+ +* | '3' 0x33 | Inverse cascade | +* +----------+-----------------+
drivers/leds/leds-el15203000.c line 54
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+* | '4' 0x34 | Bounce | +* +----------+-----------------+ +* | '5' 0x35 | Inverse bounce | +* +----------+-----------------+ +*/ + +/* EL15203000 default settings */ +#define EL_FW_DELAY_USEC 20000 + +enum el15203000_brightness {
Please change 'brightness' to 'command' or so. Brightness is misleading since this device supports in fact only one level of brightness for non-pattern use case.
Quoted 8 lines
drivers/leds/leds-el15203000.c new file +8
-0+/* for all LEDs */ +EL_OFF ='0' , +EL_ON ='1' , + +/* for Screen LED */ + EL_SCREEN_BREATHING = '2', + +/* for Pipe LED */
drivers/leds/leds-el15203000.c line 72
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+EL_PIPE_CASCADE ='2' , +EL_PIPE_INV_CASCADE ='3' , +EL_PIPE_BOUNCE ='4' , + EL_PIPE_INV_BOUNCE = '5', +}; + +struct el15203000_led { +struct el15203000 *priv; +struct led_classdev ldev; +char name[LED_MAX_NAME_SIZE ];
This field will not be needed if we switch todevm_led_classdev_register_ext().
Quoted 236 lines
drivers/leds/leds-el15203000.c new file +236
-0+u8 reg; +}; + +struct el15203000 { +struct device *dev; +struct mutex lock; +struct spi_device *spi; +unsigned long delay; +size_t count; +struct el15203000_led leds[]; +}; + +static int el15203000_cmd (struct el15203000_led *led,u8 brightness) +{ +int ret; +u8 cmd[2 ]; +size_t i; +unsigned long jdelay, udelay, now; + +mutex_lock (&led->priv->lock); + +dev_dbg (led->priv->dev,"Set brightness of %s to %d" , + led->name, brightness); + +/* to avoid SPI mistiming with firmware we should wait some time */ + now = jiffies; +if (time_after (led->priv->delay, now)) { + jdelay = led->priv->delay - now; + udelay =jiffies_to_usecs (jdelay); + +dev_dbg (led->priv->dev,"Wait %luus (%lu jiffies) to sync" , + udelay, jdelay); + +usleep_range (udelay, udelay +1 ); + } + + cmd[0 ] = led->reg; + cmd[1 ] = brightness; + +for (i =0 ; i <ARRAY_SIZE (cmd); i++) { +if (i) +usleep_range (EL_FW_DELAY_USEC , +EL_FW_DELAY_USEC +1 ); + + ret =spi_write (led->priv->spi, &cmd[i],sizeof (cmd[i])); +if (ret) { +dev_err (led->priv->dev, +"spi_write() error %d" , ret); +break ; + } + } + + led->priv->delay = jiffies +usecs_to_jiffies (EL_FW_DELAY_USEC ); + +mutex_unlock (&led->priv->lock); + +return ret; +} + +static int el15203000_set_blocking (struct led_classdev *ldev, +enum led_brightness brightness) +{ +struct el15203000_led *led =container_of (ldev, + struct el15203000_led, + ldev); + +return el15203000_cmd (led, brightness ==LED_OFF ?EL_OFF :EL_ON ); +} + +static int led_pattern_cmp (const struct led_pattern *p1,u32 p1_len, +const struct led_pattern *p2,u32 p2_len) +{ +u32 i; + +if (p1_len != p2_len) +return -1 ; + +for (i =0 ; i < p1_len; i ++) +if (p1[i].delta_t != p2[i].delta_t || + p1[i].brightness != p2[i].brightness) +return -1 ; + +return 0 ; +} + +int el15203000_pattern_set_S (struct led_classdev *ldev, +struct led_pattern *pattern, +u32 len,int repeat) +{ +struct el15203000_led *led =container_of (ldev, + struct el15203000_led, + ldev); +struct led_pattern scr_pattern[] = {{ + .delta_t =4000 , + .brightness =0 , + }, { + .delta_t =4000 , + .brightness =1 , + }}; + +if (repeat >0 ) +return -EINVAL ; + +if (led_pattern_cmp (scr_pattern,ARRAY_SIZE (scr_pattern), pattern, len)) +return -EINVAL ; + +dev_dbg (led->priv->dev,"Breathing mode for '%s'" , led->name); + +return el15203000_cmd (led,EL_SCREEN_BREATHING ); +} + +int el15203000_pattern_set_P (struct led_classdev *ldev, +struct led_pattern *pattern, +u32 len,int repeat) +{ +struct el15203000_led *led =container_of (ldev, + struct el15203000_led, + ldev); + +struct led_pattern cascade[] = {{ + .delta_t =800 , + .brightness =1 , + }, { + .delta_t =800 , + .brightness =2 , + }, { + .delta_t =800 , + .brightness =4 , + }, { + .delta_t =800 , + .brightness =8 , + }, { + .delta_t =800 , + .brightness =16 , + }, { + .delta_t =800 , + .brightness =1 , + }, { + .delta_t =800 , + .brightness =2 , + }, { + .delta_t =800 , + .brightness =4 , + }, { + .delta_t =800 , + .brightness =8 , + }, { + .delta_t =800 , + .brightness =16 , + }}; + +struct led_pattern inv_cascade[] = {{ + .delta_t =800 , + .brightness =30 , + }, { + .delta_t =800 , + .brightness =29 , + }, { + .delta_t =800 , + .brightness =27 , + }, { + .delta_t =800 , + .brightness =23 , + }, { + .delta_t =800 , + .brightness =15 , + }, { + .delta_t =800 , + .brightness =30 , + }, { + .delta_t =800 , + .brightness =29 , + }, { + .delta_t =800 , + .brightness =27 , + }, { + .delta_t =800 , + .brightness =23 , + }, { + .delta_t =800 , + .brightness =15 , + }}; + +struct led_pattern bounce[] = {{ + .delta_t =800 , + .brightness =1 , + }, { + .delta_t =800 , + .brightness =2 , + }, { + .delta_t =800 , + .brightness =4 , + }, { + .delta_t =800 , + .brightness =8 , + }, { + .delta_t =800 , + .brightness =16 , + }, { + .delta_t =800 , + .brightness =16 , + }, { + .delta_t =800 , + .brightness =8 , + }, { + .delta_t =800 , + .brightness =4 , + }, { + .delta_t =800 , + .brightness =2 , + }, { + .delta_t =800 , + .brightness =1 , + }}; + +struct led_pattern inv_bounce[] = {{ + .delta_t =800 , + .brightness =30 , + }, { + .delta_t =800 , + .brightness =29 , + }, { + .delta_t =800 , + .brightness =27 , + }, { + .delta_t =800 , + .brightness =23 , + }, { + .delta_t =800 , + .brightness =15 , + }, { + .delta_t =800 , + .brightness =15 , + }, { + .delta_t =800 , + .brightness =23 ,
drivers/leds/leds-el15203000.c line 318
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+ }, { + .delta_t = 800, + .brightness = 27, + }, { + .delta_t = 800, + .brightness = 29, + }, { + .delta_t = 800, + .brightness = 30, + }};
There is no need for these arrays. We can come up with formulas for validating the pattern tuples. Basically all of them involve differences in brightness being powers of two:
"1 800 2 800 4 800 8 800 16 800"
Here each next step should be equal to (1 << i) staring from i = 0.
"30 800 29 800 27 800 23 800 15 800"
brightness = 30;
for (i = 0; i < pattern_len; i++) {
br_diff = (i > 0) ? (1 << (i - 1)) : 0;
brightness -= br_diff;
}"1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"
"30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
Above two can be handled by slightly modifying what I proposed above.
And for delta_t just require by default always 800.
Quoted 29 lines
drivers/leds/leds-el15203000.c new file +29
-0+if (repeat >0 ) +return -EINVAL ; + +if (!led_pattern_cmp (cascade,ARRAY_SIZE (cascade), pattern, len)) { +dev_dbg (led->priv->dev,"Cascade mode for '%s'" , led->name); +return el15203000_cmd (led,EL_PIPE_CASCADE ); + }else if (!led_pattern_cmp (inv_cascade,ARRAY_SIZE (inv_cascade), pattern, len)) { +dev_dbg (led->priv->dev,"Inverse cascade mode for '%s'" , led->name); +return el15203000_cmd (led,EL_PIPE_INV_CASCADE ); + }else if (!led_pattern_cmp (bounce,ARRAY_SIZE (bounce), pattern, len)) { +dev_dbg (led->priv->dev,"Bounce mode for '%s'" , led->name); +return el15203000_cmd (led,EL_PIPE_BOUNCE ); + }else if (!led_pattern_cmp (inv_bounce,ARRAY_SIZE (inv_bounce), pattern, len)) { +dev_dbg (led->priv->dev,"Inverse bounce mode for '%s'" , led->name); +return el15203000_cmd (led,EL_PIPE_INV_BOUNCE ); + } + +return -EINVAL ; +} + +int el15203000_pattern_clear (struct led_classdev *ldev) +{ +struct el15203000_led *led =container_of (ldev, + struct el15203000_led, + ldev); + +return el15203000_cmd (led,EL_OFF ); +} +
drivers/leds/leds-el15203000.c line 358
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+static int el15203000_probe_dt (struct el15203000 *priv) +{ +size_t i =0 ; +struct el15203000_led *led; +struct fwnode_handle *child; +int ret; +const char *str; +u32 reg; + +device_for_each_child_node (priv->dev, child) {
struct led_init_data init_data = {};Please add above declaration here.
Quoted 13 lines
drivers/leds/leds-el15203000.c new file +13
-0+ led = &priv->leds[i]; + + ret =fwnode_property_read_u32 (child,"reg" , ®); +if (ret) { +dev_err (priv->dev,"LED without ID number" ); +fwnode_handle_put (child); + +return ret; + } + +if (reg >U8_MAX ) { +dev_err (priv->dev,"LED value %d is invalid" , reg); +fwnode_handle_put (child);
drivers/leds/leds-el15203000.c line 381
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+ +return -EINVAL ; + } + + led->reg = reg; + + ret =fwnode_property_read_string (child,"label" , &str); +if (ret) + str =":" ; +snprintf (led->name,sizeof (led->name),"el15203000:%s" , str);
And instead of the four above lines please just do the below assignment:
init_data.fwnode = child;
but let's do it right before calling devm_led_classdev_register_ext().
drivers/leds/leds-el15203000.c line 388
Quoted 7 lines
drivers/leds/leds-el15203000.c new file +7
-0+ +fwnode_property_read_string (child,"linux,default-trigger" , + &led->ldev.default_trigger); + + led->ldev.max_brightness =LED_ON ; + led->priv = priv; + led->ldev.name = led->name;
Please also remove the above line.
drivers/leds/leds-el15203000.c line 399
Quoted 11 lines
drivers/leds/leds-el15203000.c new file +11
-0+ led->ldev.brightness_set_blocking = el15203000_set_blocking; + +if (reg =='S' ) { + led->ldev.pattern_set = el15203000_pattern_set_S; + led->ldev.pattern_clear = el15203000_pattern_clear; + }else if (reg =='P' ) { + led->ldev.pattern_set = el15203000_pattern_set_P; + led->ldev.pattern_clear = el15203000_pattern_clear; + } + + ret =devm_led_classdev_register (priv->dev, &led->ldev);
And here let's switch to the new LED registration API:
ret = devm_led_classdev_register_ext(priv->dev, &led->ldev, &init_data);
Quoted 34 lines
drivers/leds/leds-el15203000.c new file +34
-0+if (ret) { +dev_err (priv->dev, +"failed to register LED device %s, err %d" , + led->name, ret); +fwnode_handle_put (child); +return ret; + } + + i++; + } + +return ret; +} + +static int el15203000_probe (struct spi_device *spi) +{ +struct el15203000 *priv; +size_t count; +int ret; + + count =device_get_child_node_count (&spi->dev); +if (!count) { +dev_err (&spi->dev,"LEDs are not defined in device tree!" ); +return -ENODEV ; + } + + priv =devm_kzalloc (&spi->dev,struct_size (priv, leds, count), +GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +mutex_init (&priv->lock); + priv->count = count; + priv->dev = &spi->dev;
drivers/leds/leds-el15203000.c line 443
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+ priv->spi = spi; + priv->delay = jiffies - +usecs_to_jiffies (EL_FW_DELAY_USEC ); + + ret =el15203000_probe_dt (priv); +if (ret) +return ret; + +spi_set_drvdata (spi, priv); +dev_dbg (priv->dev,"%zd LEDs registered" , priv->count);
Please remove this debug log.
Quoted 26 lines
drivers/leds/leds-el15203000.c new file +25
-0+ +return 0 ; +} + +static int el15203000_remove (struct spi_device *spi) +{ +struct el15203000 *priv =spi_get_drvdata (spi); + +mutex_destroy (&priv->lock); + +return 0 ; +} + +static const struct of_device_id el15203000_dt_ids[] = { + { .compatible ="crane,el15203000" , }, + {}, +}; + +MODULE_DEVICE_TABLE (of, el15203000_dt_ids); + +static struct spi_driver el15203000_driver = { + .probe = el15203000_probe, + .remove = el15203000_remove, + .driver = { + .name =KBUILD_MODNAME ,
drivers/leds/leds-el15203000.c line 478
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+ .of_match_table = el15203000_dt_ids, + }, +}; + +module_spi_driver (el15203000_driver); + +MODULE_AUTHOR ("Oleh Kravchenko <[email protected]>" ); +MODULE_DESCRIPTION ("el15203000 LED driver" ); +MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("spi:el15203000" );
Please also fix the issues checkpatch.pl complains about.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Hello Jacek,
what status of linux-leds.git?
git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git
Is it outdated? Because I have a errors:
drivers/leds/leds-el15203000.c:234:9: error: variable ‘init_data’ has initializer but incomplete type
struct led_init_data init_data = {};
^~~~~~~~~~~~~18.08.19 16:47, Jacek Anaszewski пише:
Quoted 641 lines
Hi Oleh,
Please find my review remarks below.
Quoted 23 lines · Oleh Kravchenko
This patch adds a LED class driver for the RGB LEDs found on the Crane Merchandising System EL15203000 LEDs board (aka RED LEDs board).
Signed-off-by Oleh Kravchenko <[email protected]>--- .../testing/sysfs-class-led-driver-el15203000 | 22 + drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-el15203000.c | 478 ++++++++++++++++++ 4 files changed, 514 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-driver-el15203000 create mode 100644 drivers/leds/leds-el15203000.cDocumentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0@@ -0,0 +1,22 @@ +What: /sys/class/leds/<led>/hw_pattern +Date: August 2019 +KernelVersion: 5.3Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 13
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +10
-0+Description: + Specify a hardware pattern for the EL15203000 LED. + The LEDs board supports only predefined patterns by firmware + for specific LEDs. + + Breathing mode for Screen frame light tube: + "0 4000 1 4000" + + Cascade mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 1 800 2 800 4 800 8 800 16 800"There's no point in repeating same sequence. Just require to provide it once:
"1 800 2 800 4 800 8 800 16 800"
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 16
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +3
-0+ + Inverted cascade mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 30 800 29 800 27 800 23 800 15 800"The same story:
"30 800 29 800 27 800 23 800 15 800"
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 line 22
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-led-driver-el15203000 new file +6
-0+ + Bounce mode for Pipe LED: + "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800" + + Inverted bounce mode for Pipe LED: + "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"These can be left as they are now.
Quoted 86 lines
drivers/leds/Kconfig +13
-0@@ -129,6 +129,19 @@ config LEDS_CR0014114 To compile this driver as a module, choose M here: the module will be called leds-cr0014114. +config LEDS_EL15203000 + tristate "LED Support for Crane EL15203000" + depends on LEDS_CLASS + depends on SPI + depends on OF + help + This option enables support for EL15203000 LED Board + (aka RED LED board) which is widely used in coffee vending + machines produced by Crane Merchandising Systems. + + To compile this driver as a module, choose M here: the module + will be called leds-el15203000. + config LEDS_LM3530 tristate "LCD Backlight driver for LM3530" depends on LEDS_CLASSdrivers/leds/Makefile +1
-0@@ -85,6 +85,7 @@ obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o # LED SPI Drivers obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o +obj-$(CONFIG_LEDS_EL15203000) += leds-el15203000.o # LED Userspace Drivers obj-$(CONFIG_LEDS_USER) += uleds.odrivers/leds/leds-el15203000.c new file +44
-0@@ -0,0 +1,478 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2019 Crane Merchandising Systems. All rights reserved. +// Copyright (C) 2019 Oleh Kravchenko <[email protected]> + +#include <linux/delay.h> +#include <linux/leds.h> +#include <linux/limits.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/spi/spi.h> +#include <uapi/linux/uleds.h> + +/* +* EL15203000 SPI protocol description: +* +-----+------------+ +* | LED | BRIGHTNESS | +* +-----+------------+ +* | 1 | 1 | +* +-----+------------+ +* (*) LEDs MCU board expects 20 msec delay per byte. +* +* LEDs: +* +----------+--------------+-------------------------------------------+ +* | ID | NAME | DESCRIPTION | +* +----------+--------------+-------------------------------------------+ +* | 'P' 0x50 | Pipe | Consists from 5 LEDs, controlled by board | +* +----------+--------------+-------------------------------------------+ +* | 'S' 0x53 | Screen frame | Light tube around the screen | +* +----------+--------------+-------------------------------------------+ +* | 'V' 0x56 | Vending area | Highlights a cup of coffee | +* +----------+--------------+-------------------------------------------+ +* +* BRIGHTNESS: +* +----------+-----------------+--------------+--------------+ +* | VALUES | PIPE | SCREEN FRAME | VENDING AREA | +* +----------+-----------------+--------------+--------------+ +* | '0' 0x30 | Off | +* +----------+-----------------------------------------------+ +* | '1' 0x31 | On | +* +----------+-----------------+--------------+--------------+ +* | '2' 0x32 | Cascade | Breathing | +* +----------+-----------------+--------------+ +* | '3' 0x33 | Inverse cascade | +* +----------+-----------------+ drivers/leds/leds-el15203000.c line 54
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+* | '4' 0x34 | Bounce | +* +----------+-----------------+ +* | '5' 0x35 | Inverse bounce | +* +----------+-----------------+ +*/ + +/* EL15203000 default settings */ +#define EL_FW_DELAY_USEC 20000 + +enum el15203000_brightness {Please change 'brightness' to 'command' or so. Brightness is misleading since this device supports in fact only one level of brightness for non-pattern use case.
Quoted 8 lines
drivers/leds/leds-el15203000.c new file +8
-0+/* for all LEDs */ +EL_OFF ='0' , +EL_ON ='1' , + +/* for Screen LED */ + EL_SCREEN_BREATHING = '2', + +/* for Pipe LED */ drivers/leds/leds-el15203000.c line 72
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+EL_PIPE_CASCADE ='2' , +EL_PIPE_INV_CASCADE ='3' , +EL_PIPE_BOUNCE ='4' , + EL_PIPE_INV_BOUNCE = '5', +}; + +struct el15203000_led { +struct el15203000 *priv; +struct led_classdev ldev; +char name[LED_MAX_NAME_SIZE ];This field will not be needed if we switch to
devm_led_classdev_register_ext().Quoted 236 lines
drivers/leds/leds-el15203000.c new file +236
-0+u8 reg; +}; + +struct el15203000 { +struct device *dev; +struct mutex lock; +struct spi_device *spi; +unsigned long delay; +size_t count; +struct el15203000_led leds[]; +}; + +static int el15203000_cmd (struct el15203000_led *led,u8 brightness) +{ +int ret; +u8 cmd[2 ]; +size_t i; +unsigned long jdelay, udelay, now; + +mutex_lock (&led->priv->lock); + +dev_dbg (led->priv->dev,"Set brightness of %s to %d" , + led->name, brightness); + +/* to avoid SPI mistiming with firmware we should wait some time */ + now = jiffies; +if (time_after (led->priv->delay, now)) { + jdelay = led->priv->delay - now; + udelay =jiffies_to_usecs (jdelay); + +dev_dbg (led->priv->dev,"Wait %luus (%lu jiffies) to sync" , + udelay, jdelay); + +usleep_range (udelay, udelay +1 ); + } + + cmd[0 ] = led->reg; + cmd[1 ] = brightness; + +for (i =0 ; i <ARRAY_SIZE (cmd); i++) { +if (i) +usleep_range (EL_FW_DELAY_USEC , +EL_FW_DELAY_USEC +1 ); + + ret =spi_write (led->priv->spi, &cmd[i],sizeof (cmd[i])); +if (ret) { +dev_err (led->priv->dev, +"spi_write() error %d" , ret); +break ; + } + } + + led->priv->delay = jiffies +usecs_to_jiffies (EL_FW_DELAY_USEC ); + +mutex_unlock (&led->priv->lock); + +return ret; +} + +static int el15203000_set_blocking (struct led_classdev *ldev, +enum led_brightness brightness) +{ +struct el15203000_led *led =container_of (ldev, + struct el15203000_led, + ldev); + +return el15203000_cmd (led, brightness ==LED_OFF ?EL_OFF :EL_ON ); +} + +static int led_pattern_cmp (const struct led_pattern *p1,u32 p1_len, +const struct led_pattern *p2,u32 p2_len) +{ +u32 i; + +if (p1_len != p2_len) +return -1 ; + +for (i =0 ; i < p1_len; i ++) +if (p1[i].delta_t != p2[i].delta_t || + p1[i].brightness != p2[i].brightness) +return -1 ; + +return 0 ; +} + +int el15203000_pattern_set_S (struct led_classdev *ldev, +struct led_pattern *pattern, +u32 len,int repeat) +{ +struct el15203000_led *led =container_of (ldev, + struct el15203000_led, + ldev); +struct led_pattern scr_pattern[] = {{ + .delta_t =4000 , + .brightness =0 , + }, { + .delta_t =4000 , + .brightness =1 , + }}; + +if (repeat >0 ) +return -EINVAL ; + +if (led_pattern_cmp (scr_pattern,ARRAY_SIZE (scr_pattern), pattern, len)) +return -EINVAL ; + +dev_dbg (led->priv->dev,"Breathing mode for '%s'" , led->name); + +return el15203000_cmd (led,EL_SCREEN_BREATHING ); +} + +int el15203000_pattern_set_P (struct led_classdev *ldev, +struct led_pattern *pattern, +u32 len,int repeat) +{ +struct el15203000_led *led =container_of (ldev, + struct el15203000_led, + ldev); + +struct led_pattern cascade[] = {{ + .delta_t =800 , + .brightness =1 , + }, { + .delta_t =800 , + .brightness =2 , + }, { + .delta_t =800 , + .brightness =4 , + }, { + .delta_t =800 , + .brightness =8 , + }, { + .delta_t =800 , + .brightness =16 , + }, { + .delta_t =800 , + .brightness =1 , + }, { + .delta_t =800 , + .brightness =2 , + }, { + .delta_t =800 , + .brightness =4 , + }, { + .delta_t =800 , + .brightness =8 , + }, { + .delta_t =800 , + .brightness =16 , + }}; + +struct led_pattern inv_cascade[] = {{ + .delta_t =800 , + .brightness =30 , + }, { + .delta_t =800 , + .brightness =29 , + }, { + .delta_t =800 , + .brightness =27 , + }, { + .delta_t =800 , + .brightness =23 , + }, { + .delta_t =800 , + .brightness =15 , + }, { + .delta_t =800 , + .brightness =30 , + }, { + .delta_t =800 , + .brightness =29 , + }, { + .delta_t =800 , + .brightness =27 , + }, { + .delta_t =800 , + .brightness =23 , + }, { + .delta_t =800 , + .brightness =15 , + }}; + +struct led_pattern bounce[] = {{ + .delta_t =800 , + .brightness =1 , + }, { + .delta_t =800 , + .brightness =2 , + }, { + .delta_t =800 , + .brightness =4 , + }, { + .delta_t =800 , + .brightness =8 , + }, { + .delta_t =800 , + .brightness =16 , + }, { + .delta_t =800 , + .brightness =16 , + }, { + .delta_t =800 , + .brightness =8 , + }, { + .delta_t =800 , + .brightness =4 , + }, { + .delta_t =800 , + .brightness =2 , + }, { + .delta_t =800 , + .brightness =1 , + }}; + +struct led_pattern inv_bounce[] = {{ + .delta_t =800 , + .brightness =30 , + }, { + .delta_t =800 , + .brightness =29 , + }, { + .delta_t =800 , + .brightness =27 , + }, { + .delta_t =800 , + .brightness =23 , + }, { + .delta_t =800 , + .brightness =15 , + }, { + .delta_t =800 , + .brightness =15 , + }, { + .delta_t =800 , + .brightness =23 ,drivers/leds/leds-el15203000.c line 318
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+ }, { + .delta_t = 800, + .brightness = 27, + }, { + .delta_t = 800, + .brightness = 29, + }, { + .delta_t = 800, + .brightness = 30, + }};There is no need for these arrays. We can come up with formulas for validating the pattern tuples. Basically all of them involve differences in brightness being powers of two:
"1 800 2 800 4 800 8 800 16 800"
Here each next step should be equal to (1 << i) staring from i = 0.
"30 800 29 800 27 800 23 800 15 800"
brightness = 30;
for (i = 0; i < pattern_len; i++) { br_diff = (i > 0) ? (1 << (i - 1)) : 0; brightness -= br_diff; }"1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"
"30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
Above two can be handled by slightly modifying what I proposed above.
And for
delta_tjust require by default always 800.Quoted 29 lines
drivers/leds/leds-el15203000.c new file +29
-0+if (repeat >0 ) +return -EINVAL ; + +if (!led_pattern_cmp (cascade,ARRAY_SIZE (cascade), pattern, len)) { +dev_dbg (led->priv->dev,"Cascade mode for '%s'" , led->name); +return el15203000_cmd (led,EL_PIPE_CASCADE ); + }else if (!led_pattern_cmp (inv_cascade,ARRAY_SIZE (inv_cascade), pattern, len)) { +dev_dbg (led->priv->dev,"Inverse cascade mode for '%s'" , led->name); +return el15203000_cmd (led,EL_PIPE_INV_CASCADE ); + }else if (!led_pattern_cmp (bounce,ARRAY_SIZE (bounce), pattern, len)) { +dev_dbg (led->priv->dev,"Bounce mode for '%s'" , led->name); +return el15203000_cmd (led,EL_PIPE_BOUNCE ); + }else if (!led_pattern_cmp (inv_bounce,ARRAY_SIZE (inv_bounce), pattern, len)) { +dev_dbg (led->priv->dev,"Inverse bounce mode for '%s'" , led->name); +return el15203000_cmd (led,EL_PIPE_INV_BOUNCE ); + } + +return -EINVAL ; +} + +int el15203000_pattern_clear (struct led_classdev *ldev) +{ +struct el15203000_led *led =container_of (ldev, + struct el15203000_led, + ldev); + +return el15203000_cmd (led,EL_OFF ); +} +drivers/leds/leds-el15203000.c line 358
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+static int el15203000_probe_dt (struct el15203000 *priv) +{ +size_t i =0 ; +struct el15203000_led *led; +struct fwnode_handle *child; +int ret; +const char *str; +u32 reg; + +device_for_each_child_node (priv->dev, child) {struct led_init_data init_data = {};Please add above declaration here.
Quoted 13 lines
drivers/leds/leds-el15203000.c new file +13
-0+ led = &priv->leds[i]; + + ret =fwnode_property_read_u32 (child,"reg" , ®); +if (ret) { +dev_err (priv->dev,"LED without ID number" ); +fwnode_handle_put (child); + +return ret; + } + +if (reg >U8_MAX ) { +dev_err (priv->dev,"LED value %d is invalid" , reg); +fwnode_handle_put (child);drivers/leds/leds-el15203000.c line 381
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+ +return -EINVAL ; + } + + led->reg = reg; + + ret =fwnode_property_read_string (child,"label" , &str); +if (ret) + str =":" ; +snprintf (led->name,sizeof (led->name),"el15203000:%s" , str);And instead of the four above lines please just do the below assignment:
init_data.fwnode = child;but let's do it right before calling
devm_led_classdev_register_ext().drivers/leds/leds-el15203000.c line 388
Quoted 7 lines
drivers/leds/leds-el15203000.c new file +7
-0+ +fwnode_property_read_string (child,"linux,default-trigger" , + &led->ldev.default_trigger); + + led->ldev.max_brightness =LED_ON ; + led->priv = priv; + led->ldev.name = led->name;Please also remove the above line.
drivers/leds/leds-el15203000.c line 399
Quoted 11 lines
drivers/leds/leds-el15203000.c new file +11
-0+ led->ldev.brightness_set_blocking = el15203000_set_blocking; + +if (reg =='S' ) { + led->ldev.pattern_set = el15203000_pattern_set_S; + led->ldev.pattern_clear = el15203000_pattern_clear; + }else if (reg =='P' ) { + led->ldev.pattern_set = el15203000_pattern_set_P; + led->ldev.pattern_clear = el15203000_pattern_clear; + } + + ret =devm_led_classdev_register (priv->dev, &led->ldev);And here let's switch to the new LED registration API:
ret = devm_led_classdev_register_ext(priv->dev, &led->ldev, &init_data);Quoted 34 lines
drivers/leds/leds-el15203000.c new file +34
-0+if (ret) { +dev_err (priv->dev, +"failed to register LED device %s, err %d" , + led->name, ret); +fwnode_handle_put (child); +return ret; + } + + i++; + } + +return ret; +} + +static int el15203000_probe (struct spi_device *spi) +{ +struct el15203000 *priv; +size_t count; +int ret; + + count =device_get_child_node_count (&spi->dev); +if (!count) { +dev_err (&spi->dev,"LEDs are not defined in device tree!" ); +return -ENODEV ; + } + + priv =devm_kzalloc (&spi->dev,struct_size (priv, leds, count), +GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +mutex_init (&priv->lock); + priv->count = count; + priv->dev = &spi->dev;drivers/leds/leds-el15203000.c line 443
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+ priv->spi = spi; + priv->delay = jiffies - +usecs_to_jiffies (EL_FW_DELAY_USEC ); + + ret =el15203000_probe_dt (priv); +if (ret) +return ret; + +spi_set_drvdata (spi, priv); +dev_dbg (priv->dev,"%zd LEDs registered" , priv->count);Please remove this debug log.
Quoted 26 lines
drivers/leds/leds-el15203000.c new file +25
-0+ +return 0 ; +} + +static int el15203000_remove (struct spi_device *spi) +{ +struct el15203000 *priv =spi_get_drvdata (spi); + +mutex_destroy (&priv->lock); + +return 0 ; +} + +static const struct of_device_id el15203000_dt_ids[] = { + { .compatible ="crane,el15203000" , }, + {}, +}; + +MODULE_DEVICE_TABLE (of, el15203000_dt_ids); + +static struct spi_driver el15203000_driver = { + .probe = el15203000_probe, + .remove = el15203000_remove, + .driver = { + .name =KBUILD_MODNAME ,drivers/leds/leds-el15203000.c line 478
Quoted 10 lines
drivers/leds/leds-el15203000.c new file +10
-0+ .of_match_table = el15203000_dt_ids, + }, +}; + +module_spi_driver (el15203000_driver); + +MODULE_AUTHOR ("Oleh Kravchenko <[email protected]>" ); +MODULE_DESCRIPTION ("el15203000 LED driver" ); +MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("spi:el15203000" );Please also fix the issues checkpatch.pl complains about.
Signature · 2 lines
Best regards, Oleh Kravchenko
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Hi Oleh,
Quoted 8 lines · Oleh Kravchenko
Hello Jacek,
what status of linux-leds.git?
git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.gitIs it outdated? Because I have a errors:
drivers/leds/leds-el15203000.c:234:9: error: variable ‘init_data’ has initializer but incomplete type
structled_init_datainit_data= {};
I've just compiled drivers/leds/leds-aat1290.c driver that contains the same declaration and it went just fine.
I know this is trivial, but did you "#include <linux/leds.h>" ?
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Yes it has this include :)
$ git remote -v origin git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git (fetch) origin git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git (push)
$ git fetch --all -p Fetching origin
$ git log origin/master -1 commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b (tag: v5.3-rc1, origin/master, origin/HEAD) Author: Linus Torvalds <[email protected]> Date: Sun Jul 21 14:05:38 2019 -0700
Linus 5.3-rc1
$ grep -R led_init_data --include='*.h'
returns nothing..
27.08.19 23:56, Jacek Anaszewski пише:
Quoted 17 lines
Hi Oleh,
Quoted 8 lines · Oleh Kravchenko
Hello Jacek,
what status of linux-leds.git?
git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.gitIs it outdated? Because I have a errors:
drivers/leds/leds-el15203000.c:234:9: error: variable ‘init_data’ has initializer but incomplete type
structled_init_datainit_data= {};I've just compiled
drivers/leds/leds-aat1290.cdriver that contains the same declaration and it went just fine.I know this is trivial, but did you "#include <
linux/leds.h>" ?
Signature · 2 lines
Best regards, Oleh Kravchenko
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Oleh,
Quoted 6 lines · Oleh Kravchenko
Yes it has this include :)
$ git remote -v origin git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git (fetch) origin git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git (push)
Quoted 7 lines
$ git fetch --all -p Fetching origin$ git log origin/master -1 commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b (tag: v5.3-rc1, origin/master, origin/HEAD) Author: Linus Torvalds <[email protected]> Date: Sun Jul 21 14:05:38 2019 -0700
You need to checkout for-next branch.
Quoted 25 lines
Linus 5.3-rc1$ grep -R led_init_data --include='*.h'returns nothing..
27.08.19 23:56, Jacek Anaszewski пише:
Quoted 17 lines
Hi Oleh,
Quoted 8 lines · Oleh Kravchenko
Hello Jacek,
what status of linux-leds.git?
git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.gitIs it outdated? Because I have a errors:
drivers/leds/leds-el15203000.c:234:9: error: variable ‘init_data’ has initializer but incomplete type
structled_init_datainit_data= {};I've just compiled
drivers/leds/leds-aat1290.cdriver that contains the same declaration and it went just fine.I know this is trivial, but did you "#include <
linux/leds.h>" ?
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v4 2/2] leds: add LED driver for EL15203000 board
Thanks :-)
28.08.19 00:18, Jacek Anaszewski пише:
Quoted 45 lines
Oleh,
Quoted 6 lines · Oleh Kravchenko
Yes it has this include :)
$ git remote -v origin git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git (fetch) origin git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git (push)Quoted 7 lines
$ git fetch --all -p Fetching origin$ git log origin/master -1 commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b (tag: v5.3-rc1, origin/master, origin/HEAD) Author: Linus Torvalds <[email protected]> Date: Sun Jul 21 14:05:38 2019 -0700You need to checkout for-next branch.
Quoted 25 lines
Linus 5.3-rc1$ grep -R led_init_data --include='*.h'returns nothing..
27.08.19 23:56, Jacek Anaszewski пише:
Quoted 17 lines
Hi Oleh,
Quoted 8 lines · Oleh Kravchenko
Hello Jacek,
what status of linux-leds.git?
git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.gitIs it outdated? Because I have a errors:
drivers/leds/leds-el15203000.c:234:9: error: variable ‘init_data’ has initializer but incomplete type
structled_init_datainit_data= {};I've just compiled
drivers/leds/leds-aat1290.cdriver that contains the same declaration and it went just fine.I know this is trivial, but did you "#include <
linux/leds.h>" ?
Signature · 2 lines
Best regards, Oleh Kravchenko
Jacek
Need your input below
Quoted 38 lines · Oleh Kravchenko
Add documentation and example for dt-bindings EL15203000. LED board (aka RED LED board) from Crane Merchandising Systems.
Signed-off-by Oleh Kravchenko <[email protected]>--- .../bindings/leds/leds-el15203000.txt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+)create mode 100644
Documentation/devicetree/bindings/leds/leds-el15203000.txtDocumentation/devicetree/bindings/leds/leds-el15203000.txt new file +23
-0@@ -0,0 +1,47 @@ +Crane Merchandising System - el15203000 LED driver +-------------------------------------------------- + +This LED Board (aka RED LEDs board) is widely used in +coffee vending machines produced by Crane Merchandising Systems. + +Required properties: +- compatible : "crane,el15203000" +- reg : + see Documentation/devicetree/bindings/spi/spi-bus.txt +- spi-max-frequency : (optional) + see Documentation/devicetree/bindings/spi/spi-bus.txt + +Optional LED sub-node properties: +- label : + see Documentation/devicetree/bindings/leds/common.txt +- linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Example +------- + +led-controller@0 {
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 33
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +10
-0+ compatible = "crane,el15203000"; + reg = <0>; + spi-max-frequency = <50000>; + #address-cells = <1>; + #size-cells = <0>; + + /* water pipe */ + pipe@50 { + reg = <0x50>; + label = "red:pipe";
Should we use the color and function property here?
Not sure what function would be for pipe, screen or vending but there may be
comparable functions that may fit.
Dan
<snip>
Dan,
Quoted 50 lines · Dan Murphy
Jacek
Need your input below
Quoted 45 lines · Oleh Kravchenko
Add documentation and example for dt-bindings EL15203000. LED board (aka RED LED board) from Crane Merchandising Systems.
Signed-off-by Oleh Kravchenko <[email protected]>---
.../bindings/leds/leds-el15203000.txt | 47 +++++++++++++++++++1 file changed, 47 insertions(+)create mode 100644
Documentation/devicetree/bindings/leds/leds-el15203000.txtdiff --git
a/Documentation/devicetree/bindings/leds/leds-el15203000.txtb/Documentation/devicetree/bindings/leds/leds-el15203000.txtnew file mode 100644
index 000000000000..4c2245babfdcDocumentation/devicetree/bindings/leds/leds-el15203000.txt new file +27
-0@@ -0,0 +1,47 @@ +Crane Merchandising System - el15203000 LED driver +-------------------------------------------------- + +This LED Board (aka RED LEDs board) is widely used in +coffee vending machines produced by Crane Merchandising Systems. + +Required properties: +- compatible : "crane,el15203000" +- reg : + see Documentation/devicetree/bindings/spi/spi-bus.txt +- spi-max-frequency : (optional) + see Documentation/devicetree/bindings/spi/spi-bus.txt + +Optional LED sub-node properties: +- label : + see Documentation/devicetree/bindings/leds/common.txt +- linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Example +------- + +led-controller@0 { + compatible = "crane,el15203000"; + reg = <0>; + spi-max-frequency = <50000>; + #address-cells = <1>;
Quoted 8 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 33
Quoted 6 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +6
-0+ #size-cells = <0>; + + /* water pipe */ + pipe@50 { + reg = <0x50>; + label = "red:pipe";Should we use the color and function property here?
Yes, label is already deprecated in the common LED bindings in linux-next. We need separate color and function here.
Quoted 4 lines
Not sure what function would be for pipe, screen or vending but there may be
comparable functions that may fit.
These are functions specific to this board and it is not something that could have some vast system-wide use. Common LED functions aim rather to unify the naming for LEDs on standard system devices and peripherals.
I'd not strive for creating common LED_FUNCTION macros for these.
Signature · 2 lines
Best regards, Jacek Anaszewski
Hi Oleh,
Quoted 21 lines · Oleh Kravchenko
Add documentation and example for dt-bindings EL15203000. LED board (aka RED LED board) from Crane Merchandising Systems.
Signed-off-by Oleh Kravchenko <[email protected]>--- .../bindings/leds/leds-el15203000.txt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-el15203000.txtDocumentation/devicetree/bindings/leds/leds-el15203000.txt new file +6
-0@@ -0,0 +1,47 @@ +Crane Merchandising System - el15203000 LED driver +-------------------------------------------------- + +This LED Board (aka RED LEDs board) is widely used in +coffee vending machines produced by Crane Merchandising Systems. +
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 16
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +10
-0+Required properties: +- compatible : "crane,el15203000" +- reg : + see Documentation/devicetree/bindings/spi/spi-bus.txt +- spi-max-frequency : (optional) + see Documentation/devicetree/bindings/spi/spi-bus.txt + +Optional LED sub-node properties: +- label : + see Documentation/devicetree/bindings/leds/common.txt
Please change this label description to the below:
- function: see Documentation/devicetree/bindings/leds/common.txt.
- color: See Documentation/devicetree/bindings/leds/common.txt.
- label: See Documentation/devicetree/bindings/leds/common.txt (deprecated).
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 21
Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +5
-0+- linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Example +-------
#include <dt-bindings/leds/common.h>
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 31
Quoted 9 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +9
-0+led-controller@0 { + compatible = "crane,el15203000"; + reg = <0>; + spi-max-frequency = <50000>; + #address-cells = <1>; + #size-cells = <0>; + + /* water pipe */ + pipe@50 {
s/pipe/led/
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 33
Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +2
-0+ reg = <0x50>; + label = "red:pipe";
label is now deprecated.
Please use function and color:
function = "pipe"; color = <LED_COLOR_ID_RED>;
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 37
Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +4
-0+ }; + + /* screen frame */ + screen@53 {
s/screen/led/
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 39
Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +2
-0+ reg = <0x53>; + label = "red:screen";
function = "screen"; color = <LED_COLOR_ID_RED>;
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 43
Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +4
-0+ }; + + /* vending area */ + vend@56 {
s/vend/led/
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 45
Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +2
-0+ reg = <0x56>; + label = "red:vend";
function = "vend"; color = <LED_COLOR_ID_RED>;
Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +2
-0+ }; +};
Signature · 2 lines
Best regards, Jacek Anaszewski
Hello Jacek,
thanks for your review.
18.08.19 16:41, Jacek Anaszewski пише:
Quoted 102 lines
Hi Oleh,
Quoted 21 lines · Oleh Kravchenko
Add documentation and example for dt-bindings EL15203000. LED board (aka RED LED board) from Crane Merchandising Systems.
Signed-off-by Oleh Kravchenko <[email protected]>--- .../bindings/leds/leds-el15203000.txt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-el15203000.txtDocumentation/devicetree/bindings/leds/leds-el15203000.txt new file +6
-0@@ -0,0 +1,47 @@ +Crane Merchandising System - el15203000 LED driver +-------------------------------------------------- + +This LED Board (aka RED LEDs board) is widely used in +coffee vending machines produced by Crane Merchandising Systems. +Documentation/devicetree/bindings/leds/leds-el15203000.txt line 16
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +10
-0+Required properties: +- compatible : "crane,el15203000" +- reg : + see Documentation/devicetree/bindings/spi/spi-bus.txt +- spi-max-frequency : (optional) + see Documentation/devicetree/bindings/spi/spi-bus.txt + +Optional LED sub-node properties: +- label : + see Documentation/devicetree/bindings/leds/common.txtPlease change this label description to the below:
- function: see
Documentation/devicetree/bindings/leds/common.txt.
- color: SeeDocumentation/devicetree/bindings/leds/common.txt.
- label: SeeDocumentation/devicetree/bindings/leds/common.txt(deprecated).Documentation/devicetree/bindings/leds/leds-el15203000.txt line 21
Quoted 5 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +5
-0+- linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Example +-------#include <
dt-bindings/leds/common.h>Documentation/devicetree/bindings/leds/leds-el15203000.txt line 31
Quoted 9 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +9
-0+led-controller@0 { + compatible = "crane,el15203000"; + reg = <0>; + spi-max-frequency = <50000>; + #address-cells = <1>; + #size-cells = <0>; + + /* water pipe */ + pipe@50 {s/pipe/led/
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 33
Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +2
-0+ reg = <0x50>; + label = "red:pipe";label is now deprecated.
Please use function and color:
function = "pipe"; color = <LED_COLOR_ID_RED>;Documentation/devicetree/bindings/leds/leds-el15203000.txt line 37
Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +4
-0+ }; + + /* screen frame */ + screen@53 {s/screen/led/
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 39
Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +2
-0+ reg = <0x53>; + label = "red:screen";function = "screen"; color = <LED_COLOR_ID_RED>;Documentation/devicetree/bindings/leds/leds-el15203000.txt line 43
Quoted 4 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +4
-0+ }; + + /* vending area */ + vend@56 {s/vend/led/
Documentation/devicetree/bindings/leds/leds-el15203000.txt line 45
Quoted 2 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +2
-0+ reg = <0x56>; + label = "red:vend";function = "vend"; color = <LED_COLOR_ID_RED>;Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-el15203000.txt new file +2
-0+ }; +};
Signature · 2 lines
Best regards, Oleh Kravchenko