* [PATCH v5 0/9] Multicolor FW update @ 2019-09-11 18:01 Dan Murphy 2019-09-11 18:01 ` [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition Dan Murphy ` (8 more replies) 0 siblings, 9 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Hello Lots of changes went into this update. The main change was that when writing to the colors/intensity or colors/color_mix file for a specific color the LED intensity will not change until the brightness file is written. Added the LP5012/9 LED devices to the LP50xx code. Converted the class doc to rst format. Dan Dan Murphy (9): leds: multicolor: Add sysfs interface definition documention: leds: Add multicolor class documentation dt: bindings: Add multicolor class dt bindings documention dt-bindings: leds: Add multicolor ID to the color ID list leds: Add multicolor ID to the color ID list leds: multicolor: Introduce a multicolor class definition dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers leds: lp50xx: Add the LP50XX family of the RGB LED driver leds: Update the lp55xx to use the multi color framework .../ABI/testing/sysfs-class-led-multicolor | 73 ++ .../bindings/leds/leds-class-multicolor.txt | 96 +++ .../devicetree/bindings/leds/leds-lp50xx.txt | 148 ++++ Documentation/leds/index.rst | 1 + Documentation/leds/leds-class-multicolor.rst | 149 ++++ drivers/leds/Kconfig | 17 + drivers/leds/Makefile | 2 + drivers/leds/led-class-multicolor.c | 387 +++++++++ drivers/leds/led-core.c | 1 + drivers/leds/leds-lp50xx.c | 807 ++++++++++++++++++ drivers/leds/leds-lp5523.c | 13 + drivers/leds/leds-lp55xx-common.c | 131 ++- drivers/leds/leds-lp55xx-common.h | 9 + include/dt-bindings/leds/common.h | 3 +- include/linux/led-class-multicolor.h | 96 +++ include/linux/platform_data/leds-lp55xx.h | 6 + modules.builtin.modinfo | Bin 0 -> 43550 bytes 17 files changed, 1916 insertions(+), 23 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor create mode 100644 Documentation/devicetree/bindings/leds/leds-class-multicolor.txt create mode 100644 Documentation/devicetree/bindings/leds/leds-lp50xx.txt create mode 100644 Documentation/leds/leds-class-multicolor.rst create mode 100644 drivers/leds/led-class-multicolor.c create mode 100644 drivers/leds/leds-lp50xx.c create mode 100644 include/linux/led-class-multicolor.h create mode 100644 modules.builtin.modinfo -- 2.22.0.214.g8dca754b1e ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-15 13:57 ` Jacek Anaszewski 2019-09-11 18:01 ` [PATCH v5 2/9] documention: leds: Add multicolor class documentation Dan Murphy ` (7 subsequent siblings) 8 siblings, 1 reply; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Add a documentation of LED Multicolor LED class specific sysfs attributes. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- .../ABI/testing/sysfs-class-led-multicolor | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor diff --git a/Documentation/ABI/testing/sysfs-class-led-multicolor b/Documentation/ABI/testing/sysfs-class-led-multicolor new file mode 100644 index 000000000000..4ea54c2ad4c8 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-led-multicolor @@ -0,0 +1,73 @@ +What: /sys/class/leds/<led>/brightness +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy <dmurphy@ti.com> +Description: read/write + The multicolor class will redirect the device drivers call back + function for brightness control to the multicolor class + brightness control function. + + Writing to this file will update all LEDs within the group to a + calculated percentage of what each color LED in the group is set + to. The percentage is calculated via the equation below: + + led_brightness = requested_value * led_color_intensity/led_color_max_intensity + + For additional details please refer to + Documentation/leds/leds-class-multicolor.rst. + + The value of the color is from 0 to + /sys/class/leds/<led>/max_brightness. + +What: /sys/class/leds/<led>/colors/color_mix +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy <dmurphy@ti.com> +Description: read/write + The values written to this file should contain the intensity + values of each multicolor LED within the colors directory. The + index of given color is reported by the color_id file present in + colors/<color> directory. The index determines the position in + the sequence of intensities on which the related intensity + should be passed to this file. + + For additional details please refer to + Documentation/leds/leds-class-multicolor.rst. + +What: /sys/class/leds/<led>/colors/<led_color>/color_id +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy <dmurphy@ti.com> +Description: read only + This file when read will return the index of the color in the + color_mix. + + For additional details please refer to + Documentation/leds/leds-class-multicolor.rst. + +What: /sys/class/leds/<led>/colors/<led_color>/intensity +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy <dmurphy@ti.com> +Description: read/write + The led_color directory is dynamically created based on the + colors defined by the registrar of the class. + The led_color can be but not limited to red, green, blue, + white, amber, yellow and violet. There is one directory per color + presented. The brightness file is created under each + led_color directory and controls the individual LED color + setting. + + The value of the color is from 0 to + /sys/class/leds/<led>/colors/<led_color>/max_intensity. + +What: /sys/class/leds/<led>/colors/<led_color>/max_intensity +Date: Sept 2019 +KernelVersion: 5.5 +Contact: Dan Murphy <dmurphy@ti.com> +Description: read only + Maximum intensity level for the LED color, default is + 255 (LED_FULL). + + If the LED does not support different intensity levels, this + should be 1. -- 2.22.0.214.g8dca754b1e ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition 2019-09-11 18:01 ` [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition Dan Murphy @ 2019-09-15 13:57 ` Jacek Anaszewski 2019-09-16 13:56 ` Dan Murphy 0 siblings, 1 reply; 24+ messages in thread From: Jacek Anaszewski @ 2019-09-15 13:57 UTC (permalink / raw) To: Dan Murphy, pavel; +Cc: robh+dt, linux-leds, linux-kernel Hi Dan, On 9/11/19 8:01 PM, Dan Murphy wrote: > Add a documentation of LED Multicolor LED class specific > sysfs attributes. > > Signed-off-by: Dan Murphy <dmurphy@ti.com> > --- > .../ABI/testing/sysfs-class-led-multicolor | 73 +++++++++++++++++++ > 1 file changed, 73 insertions(+) > create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor > > diff --git a/Documentation/ABI/testing/sysfs-class-led-multicolor b/Documentation/ABI/testing/sysfs-class-led-multicolor > new file mode 100644 > index 000000000000..4ea54c2ad4c8 > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-class-led-multicolor > @@ -0,0 +1,73 @@ > +What: /sys/class/leds/<led>/brightness > +Date: Sept 2019 > +KernelVersion: 5.5 > +Contact: Dan Murphy <dmurphy@ti.com> > +Description: read/write > + The multicolor class will redirect the device drivers call back > + function for brightness control to the multicolor class > + brightness control function. > + > + Writing to this file will update all LEDs within the group to a > + calculated percentage of what each color LED in the group is set > + to. The percentage is calculated via the equation below: > + > + led_brightness = requested_value * led_color_intensity/led_color_max_intensity > + > + For additional details please refer to > + Documentation/leds/leds-class-multicolor.rst. > + > + The value of the color is from 0 to > + /sys/class/leds/<led>/max_brightness. > + > +What: /sys/class/leds/<led>/colors/color_mix > +Date: Sept 2019 > +KernelVersion: 5.5 > +Contact: Dan Murphy <dmurphy@ti.com> > +Description: read/write > + The values written to this file should contain the intensity > + values of each multicolor LED within the colors directory. The > + index of given color is reported by the color_id file present in > + colors/<color> directory. The index determines the position in > + the sequence of intensities on which the related intensity > + should be passed to this file. > + > + For additional details please refer to > + Documentation/leds/leds-class-multicolor.rst. As already mentioned in the reply to Pavel - let's avoid the introduction of another sysfs file with multiple values. Color intensity files will only cache the value and actual write will be performed upon writing brightness file. > + > +What: /sys/class/leds/<led>/colors/<led_color>/color_id > +Date: Sept 2019 > +KernelVersion: 5.5 > +Contact: Dan Murphy <dmurphy@ti.com> > +Description: read only > + This file when read will return the index of the color in the > + color_mix. > + > + For additional details please refer to > + Documentation/leds/leds-class-multicolor.rst. > + > +What: /sys/class/leds/<led>/colors/<led_color>/intensity > +Date: Sept 2019 > +KernelVersion: 5.5 > +Contact: Dan Murphy <dmurphy@ti.com> > +Description: read/write > + The led_color directory is dynamically created based on the > + colors defined by the registrar of the class. > + The led_color can be but not limited to red, green, blue, > + white, amber, yellow and violet. There is one directory per color > + presented. The brightness file is created under each > + led_color directory and controls the individual LED color > + setting. > + > + The value of the color is from 0 to > + /sys/class/leds/<led>/colors/<led_color>/max_intensity. > + > +What: /sys/class/leds/<led>/colors/<led_color>/max_intensity > +Date: Sept 2019 > +KernelVersion: 5.5 > +Contact: Dan Murphy <dmurphy@ti.com> > +Description: read only > + Maximum intensity level for the LED color, default is > + 255 (LED_FULL). > + > + If the LED does not support different intensity levels, this > + should be 1. > -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition 2019-09-15 13:57 ` Jacek Anaszewski @ 2019-09-16 13:56 ` Dan Murphy 2019-09-16 18:31 ` Jacek Anaszewski 0 siblings, 1 reply; 24+ messages in thread From: Dan Murphy @ 2019-09-16 13:56 UTC (permalink / raw) To: Jacek Anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel Hello On 9/15/19 8:57 AM, Jacek Anaszewski wrote: > Hi Dan, > > On 9/11/19 8:01 PM, Dan Murphy wrote: >> Add a documentation of LED Multicolor LED class specific >> sysfs attributes. >> >> Signed-off-by: Dan Murphy <dmurphy@ti.com> >> --- >> .../ABI/testing/sysfs-class-led-multicolor | 73 +++++++++++++++++++ >> 1 file changed, 73 insertions(+) >> create mode 100644 Documentation/ABI/testing/sysfs-class-led-multicolor >> >> diff --git a/Documentation/ABI/testing/sysfs-class-led-multicolor b/Documentation/ABI/testing/sysfs-class-led-multicolor >> new file mode 100644 >> index 000000000000..4ea54c2ad4c8 >> --- /dev/null >> +++ b/Documentation/ABI/testing/sysfs-class-led-multicolor >> @@ -0,0 +1,73 @@ >> +What: /sys/class/leds/<led>/brightness >> +Date: Sept 2019 >> +KernelVersion: 5.5 >> +Contact: Dan Murphy <dmurphy@ti.com> >> +Description: read/write >> + The multicolor class will redirect the device drivers call back >> + function for brightness control to the multicolor class >> + brightness control function. >> + >> + Writing to this file will update all LEDs within the group to a >> + calculated percentage of what each color LED in the group is set >> + to. The percentage is calculated via the equation below: >> + >> + led_brightness = requested_value * led_color_intensity/led_color_max_intensity >> + >> + For additional details please refer to >> + Documentation/leds/leds-class-multicolor.rst. >> + >> + The value of the color is from 0 to >> + /sys/class/leds/<led>/max_brightness. >> + >> +What: /sys/class/leds/<led>/colors/color_mix >> +Date: Sept 2019 >> +KernelVersion: 5.5 >> +Contact: Dan Murphy <dmurphy@ti.com> >> +Description: read/write >> + The values written to this file should contain the intensity >> + values of each multicolor LED within the colors directory. The >> + index of given color is reported by the color_id file present in >> + colors/<color> directory. The index determines the position in >> + the sequence of intensities on which the related intensity >> + should be passed to this file. >> + >> + For additional details please refer to >> + Documentation/leds/leds-class-multicolor.rst. > As already mentioned in the reply to Pavel - let's avoid the > introduction of another sysfs file with multiple values. OK for clarification remove the color_mix and color_id files and keep the intensity files? Dan ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition 2019-09-16 13:56 ` Dan Murphy @ 2019-09-16 18:31 ` Jacek Anaszewski 0 siblings, 0 replies; 24+ messages in thread From: Jacek Anaszewski @ 2019-09-16 18:31 UTC (permalink / raw) To: Dan Murphy, pavel; +Cc: robh+dt, linux-leds, linux-kernel Dan, On 9/16/19 3:56 PM, Dan Murphy wrote: > Hello > > On 9/15/19 8:57 AM, Jacek Anaszewski wrote: >> Hi Dan, >> >> On 9/11/19 8:01 PM, Dan Murphy wrote: >>> Add a documentation of LED Multicolor LED class specific >>> sysfs attributes. >>> >>> Signed-off-by: Dan Murphy <dmurphy@ti.com> >>> --- >>> .../ABI/testing/sysfs-class-led-multicolor | 73 +++++++++++++++++++ >>> 1 file changed, 73 insertions(+) >>> create mode 100644 >>> Documentation/ABI/testing/sysfs-class-led-multicolor >>> >>> diff --git a/Documentation/ABI/testing/sysfs-class-led-multicolor >>> b/Documentation/ABI/testing/sysfs-class-led-multicolor >>> new file mode 100644 >>> index 000000000000..4ea54c2ad4c8 >>> --- /dev/null >>> +++ b/Documentation/ABI/testing/sysfs-class-led-multicolor >>> @@ -0,0 +1,73 @@ >>> +What: /sys/class/leds/<led>/brightness >>> +Date: Sept 2019 >>> +KernelVersion: 5.5 >>> +Contact: Dan Murphy <dmurphy@ti.com> >>> +Description: read/write >>> + The multicolor class will redirect the device drivers call back >>> + function for brightness control to the multicolor class >>> + brightness control function. >>> + >>> + Writing to this file will update all LEDs within the group to a >>> + calculated percentage of what each color LED in the group is >>> set >>> + to. The percentage is calculated via the equation below: >>> + >>> + led_brightness = requested_value * >>> led_color_intensity/led_color_max_intensity >>> + >>> + For additional details please refer to >>> + Documentation/leds/leds-class-multicolor.rst. >>> + >>> + The value of the color is from 0 to >>> + /sys/class/leds/<led>/max_brightness. >>> + >>> +What: /sys/class/leds/<led>/colors/color_mix >>> +Date: Sept 2019 >>> +KernelVersion: 5.5 >>> +Contact: Dan Murphy <dmurphy@ti.com> >>> +Description: read/write >>> + The values written to this file should contain the intensity >>> + values of each multicolor LED within the colors directory. The >>> + index of given color is reported by the color_id file >>> present in >>> + colors/<color> directory. The index determines the position in >>> + the sequence of intensities on which the related intensity >>> + should be passed to this file. >>> + >>> + For additional details please refer to >>> + Documentation/leds/leds-class-multicolor.rst. >> As already mentioned in the reply to Pavel - let's avoid the >> introduction of another sysfs file with multiple values. > > OK for clarification remove the color_mix and color_id files and keep > the intensity files? Exactly. -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v5 2/9] documention: leds: Add multicolor class documentation 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy 2019-09-11 18:01 ` [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-12 20:55 ` Pavel Machek 2019-09-11 18:01 ` [PATCH v5 3/9] dt: bindings: Add multicolor class dt bindings documention Dan Murphy ` (6 subsequent siblings) 8 siblings, 1 reply; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Add the support documentation on the multicolor LED framework. This document defines the directores and file generated by the multicolor framework. It also documents usage. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- Documentation/leds/index.rst | 1 + Documentation/leds/leds-class-multicolor.rst | 149 +++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 Documentation/leds/leds-class-multicolor.rst diff --git a/Documentation/leds/index.rst b/Documentation/leds/index.rst index 060f4e485897..bc70c6aa7138 100644 --- a/Documentation/leds/index.rst +++ b/Documentation/leds/index.rst @@ -9,6 +9,7 @@ LEDs leds-class leds-class-flash + leds-class-multicolor ledtrig-oneshot ledtrig-transient ledtrig-usbport diff --git a/Documentation/leds/leds-class-multicolor.rst b/Documentation/leds/leds-class-multicolor.rst new file mode 100644 index 000000000000..0b40c85f417a --- /dev/null +++ b/Documentation/leds/leds-class-multicolor.rst @@ -0,0 +1,149 @@ +==================================== +Multi Color LED handling under Linux +==================================== + +Description +=========== +There are varying monochrome LED colors available for application. These +LEDs can be used as a single use case LED or can be mixed with other color +LEDs to produce the full spectrum of color. Color LEDs that are grouped +can be presented under a single LED node with individual color control. +The multicolor class groups these LEDs and allows dynamically setting the value +of a single LED or setting the intensity values of the LEDs in the group and +updating the LEDs virtually simultaneously. + +Multicolor Class Control +======================== +The multicolor class presents the LED groups under a directory called "colors". +This directory is a child under the LED parent node created by the led_class +framework. The led_class framework is documented in led-class.rst within this +documentation directory. + +Each colored LED is given its own directory. These directories will be one of +LED_COLOR_ID_* definitions from the header include/dt-bindings/leds/common.h. +Under these directories the intensity and max_intensity files are presented for +each LED. + +Directory Layout Example +======================== +root:/sys/class/leds/rgb:grouped_leds# ls -lR colors/ +colors/: +drwxr-xr-x 2 root root 0 Jun 28 20:21 blue +drwxr-xr-x 2 root root 0 Jun 28 20:21 green +drwxr-xr-x 2 root root 0 Jun 28 20:21 red +-rw------- 1 root root 4096 Jun 28 20:21 color_mix + +colors/blue: +-rw------- 1 root root 4096 Jun 28 20:21 intensity +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity +-r-------- 1 root root 4096 Jun 28 20:21 color_id + +colors/green: +-rw------- 1 root root 4096 Jun 28 20:22 intensity +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity +-r-------- 1 root root 4096 Jun 28 20:21 color_id + +colors/red: +-rw------- 1 root root 4096 Jun 28 20:21 intensity +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity +-r-------- 1 root root 4096 Jun 28 20:21 color_id + +Multicolor Color Mixing +======================= +Multicolor monochrome LEDs intensity can be modified and mixed to produce a +varying array of colors. The color_mix file gives the user the ability to write +all the monochrome LEDs registered in the directory with a single call. +To create a specific color from monochrome LEDs the color_mix file needs to be +written with each color's intensity. The order in which the monochrome LEDs +should be written is based on the colors color_id. The LEDs brightness will be +updated on the next call to the parent brightness file. + +For example: +cat /sys/class/leds/rgb:grouped_leds/red/color_id +0 +cat /sys/class/leds/rgb:grouped_leds/green/color_id +1 +cat /sys/class/leds/rgb:grouped_leds/blue/color_id +2 + +red - color_id = 0 +green - color_id = 1 +blue - color_id = 2 + +These id's are the order in which to write the color_mix file. + +echo "<red> <green> <blue>" > color_mix + +echo "80 00 80" > color_mix + +The order of the monochrome LEDs are determined during multicolor class +registration and will not change unless unregistered and re-registered. + +Other example with amber monochrome LED: +blue - color_id = 0 +amber - color_id = 1 + +In this example blue is at ID 0 and amber ID is 1 so the user would write +echo "<blue> <amber>" > color_mix + +echo "38 80" > color_mix + +If a single monochrome LED needs to be modified then the user would write the +colors/<color>/intensity file. + + +Multicolor Class Brightness Control +=================================== +The multiclor class framework will calculate each monochrome LEDs intensity. + +The brightness level for each LED is calculated based on the color LED +intensity setting divided by the color LED max intensity setting multiplied by +the requested value. + +led_brightness = requested_value * led_color_intensity/led_color_max_intensity + +Example: +Three LEDs are present in the group as defined in "Directory Layout Example" +within this document. + +A user first writes the color LED brightness file with the brightness level that +is necessary to achieve a blueish violet output from the RGB LED group. + +echo 138 > /sys/class/leds/rgb:grouped_leds/red/intensity +echo 43 > /sys/class/leds/rgb:grouped_leds/green/intensity +echo 226 > /sys/class/leds/rgb:grouped_leds/blue/intensity + +red - + intensity = 138 + max_intensity = 255 +green - + intensity = 43 + max_intensity = 255 +blue - + intensity = 226 + max_intensity = 255 + +The user can control the brightness of that RGB group by writing the parent +'brightness' control. Assuming a parent max_brightness of 255 the user may want +to dim the LED color group to half. The user would write a value of 128 to the +parent brightness file then the values written to each LED will be adjusted +base on this value + +cat /sys/class/leds/rgb:grouped_leds/max_brightness +255 +echo 128 > /sys/class/leds/rgb:grouped_leds/brightness + +adjusted_red_value = 128 * 138/255 = 69 +adjusted_green_value = 128 * 43/255 = 21 +adjusted_blue_value = 128 * 226/255 = 113 + +Reading the parent brightness file will return the current brightness value of +the color LED group. + +cat /sys/class/leds/rgb:grouped_leds/max_brightness +255 + +echo 128 > /sys/class/leds/rgb:grouped_leds/brightness + +cat /sys/class/leds/rgb:grouped_leds/max_brightness +128 -- 2.22.0.214.g8dca754b1e ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v5 2/9] documention: leds: Add multicolor class documentation 2019-09-11 18:01 ` [PATCH v5 2/9] documention: leds: Add multicolor class documentation Dan Murphy @ 2019-09-12 20:55 ` Pavel Machek 2019-09-13 2:09 ` Dan Murphy 2019-09-15 12:45 ` Jacek Anaszewski 0 siblings, 2 replies; 24+ messages in thread From: Pavel Machek @ 2019-09-12 20:55 UTC (permalink / raw) To: Dan Murphy; +Cc: jacek.anaszewski, robh+dt, linux-leds, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1135 bytes --] Hi! > +Directory Layout Example > +======================== > +root:/sys/class/leds/rgb:grouped_leds# ls -lR colors/ > +colors/: > +drwxr-xr-x 2 root root 0 Jun 28 20:21 blue > +drwxr-xr-x 2 root root 0 Jun 28 20:21 green > +drwxr-xr-x 2 root root 0 Jun 28 20:21 red > +-rw------- 1 root root 4096 Jun 28 20:21 color_mix > + > +colors/blue: > +-rw------- 1 root root 4096 Jun 28 20:21 intensity > +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity > +-r-------- 1 root root 4096 Jun 28 20:21 color_id I don't really like the directories... A bit too much complexity, and it will have a memory footprint, too. I'd expect max_intensity to be same for all the leds in rgb:grouped_leds... Could we simply rely on max_brightness file? [If not, would one "max_intensity" file in rgb:grouped_leds be enough?] Best regards, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 2/9] documention: leds: Add multicolor class documentation 2019-09-12 20:55 ` Pavel Machek @ 2019-09-13 2:09 ` Dan Murphy 2019-09-15 12:45 ` Jacek Anaszewski 1 sibling, 0 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-13 2:09 UTC (permalink / raw) To: Pavel Machek; +Cc: jacek.anaszewski, robh+dt, linux-leds, linux-kernel Hello Pavel Thanks for looking at this again On 9/12/19 3:55 PM, Pavel Machek wrote: > Hi! > >> +Directory Layout Example >> +======================== >> +root:/sys/class/leds/rgb:grouped_leds# ls -lR colors/ >> +colors/: >> +drwxr-xr-x 2 root root 0 Jun 28 20:21 blue >> +drwxr-xr-x 2 root root 0 Jun 28 20:21 green >> +drwxr-xr-x 2 root root 0 Jun 28 20:21 red >> +-rw------- 1 root root 4096 Jun 28 20:21 color_mix >> + >> +colors/blue: >> +-rw------- 1 root root 4096 Jun 28 20:21 intensity >> +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity >> +-r-------- 1 root root 4096 Jun 28 20:21 color_id > I don't really like the directories... A bit too much complexity, and > it will have a memory footprint, too. The directories should be fine to have I am not seeing the complexity. Is memory footprint really an issue? Maybe in the IoT space but this is small and memory footprint should be able to handle this for IoT and larger systems. Having dedicated directories and files clears up issues for user space to know about the parameters for each LED especially with the color_mix file which I still am not a fan of, but conceded and implemented anyway. It also gives the user space flexibility to call the monochrome LEDs specific intensity file. The user space can either use the color intensity file or the color_mix file it is a choice for them to make. This code was modeled off the LP50xx device which has individual LED intensity controls as well as a overall brightness control. Since we have no feedback from user space folks I feel we have to give some options not very many but some. > > I'd expect max_intensity to be same for all the leds in > rgb:grouped_leds... Could we simply rely on max_brightness file? I went under the assumption that not all grouped LEDs would have the same max_intensity. I don't have specific use cases but wanted this as an option. Dan > [If not, would one "max_intensity" file in rgb:grouped_leds be > enough?] > > Best regards, > Pavel > ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 2/9] documention: leds: Add multicolor class documentation 2019-09-12 20:55 ` Pavel Machek 2019-09-13 2:09 ` Dan Murphy @ 2019-09-15 12:45 ` Jacek Anaszewski 1 sibling, 0 replies; 24+ messages in thread From: Jacek Anaszewski @ 2019-09-15 12:45 UTC (permalink / raw) To: Pavel Machek, Dan Murphy; +Cc: robh+dt, linux-leds, linux-kernel On 9/12/19 10:55 PM, Pavel Machek wrote: > Hi! > >> +Directory Layout Example >> +======================== >> +root:/sys/class/leds/rgb:grouped_leds# ls -lR colors/ >> +colors/: >> +drwxr-xr-x 2 root root 0 Jun 28 20:21 blue >> +drwxr-xr-x 2 root root 0 Jun 28 20:21 green >> +drwxr-xr-x 2 root root 0 Jun 28 20:21 red >> +-rw------- 1 root root 4096 Jun 28 20:21 color_mix >> + >> +colors/blue: >> +-rw------- 1 root root 4096 Jun 28 20:21 intensity >> +-r-------- 1 root root 4096 Jun 28 20:27 max_intensity >> +-r-------- 1 root root 4096 Jun 28 20:21 color_id > > I don't really like the directories... A bit too much complexity, and > it will have a memory footprint, too. We will need separate intensity files for each color anyway so separate max_brightness can go along in the sub-dir - it will be cleaner this way and will leave some flexibility regarding max intensity supported by the LED. And I'm saying about the need for separate intensity files because I've changed my mind regarding color_mix file, basing on the recent experience with trigger file PAGE_SIZE limit rework. That said, I am no longer eager to accept any exception for one-value-per-file rule. This of course render color_mix file format unacceptable. In a new approach intensity files will only cache the values and actual write to registers will occur on write to the brightness file. > I'd expect max_intensity to be same for all the leds in > rgb:grouped_leds... Could we simply rely on max_brightness file? This may not be necessarily true if one will add gpio LED to the cluster of PWM LEDs. > [If not, would one "max_intensity" file in rgb:grouped_leds be > enough?] > > Best regards, > Pavel > > -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v5 3/9] dt: bindings: Add multicolor class dt bindings documention 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy 2019-09-11 18:01 ` [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition Dan Murphy 2019-09-11 18:01 ` [PATCH v5 2/9] documention: leds: Add multicolor class documentation Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-15 14:01 ` Jacek Anaszewski 2019-09-11 18:01 ` [PATCH v5 4/9] dt-bindings: leds: Add multicolor ID to the color ID list Dan Murphy ` (5 subsequent siblings) 8 siblings, 1 reply; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Add DT bindings for the LEDs multicolor class framework. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- .../bindings/leds/leds-class-multicolor.txt | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-class-multicolor.txt diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt b/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt new file mode 100644 index 000000000000..5d36327b18fc --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt @@ -0,0 +1,96 @@ +* Multicolor LED properties + +Multicolor LEDs can consist of a RGB, RGBW or a RGBA LED clusters. These devices +can be grouped together and also provide a modeling mechanism so that the +cluster LEDs can vary in hue and intensity to produce a wide range of colors. + +The nodes and properties defined in this document are unique to the multicolor +LED class. Common LED nodes and properties are inherited from the common.txt +within this documentation directory. + +Required LED Child properties: + - color : For multicolor LED support this property should be defined as + LED_COLOR_ID_MULTI and further definition can be found in + include/linux/leds/common.h. + +led-controller@30 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "ti,lp5024"; + reg = <0x29>; + + multi-led@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + color = <LED_COLOR_ID_MULTI>; + function = LED_FUNCTION_; + + + led@3 { + reg = <3>; + color = <LED_COLOR_ID_RED>; + }; + + led@4 { + reg = <4>; + color = <LED_COLOR_ID_GREEN>; + }; + + led@5 { + reg = <5>; + color = <LED_COLOR_ID_BLUE>; + }; + }; + + multi-led@2 { + #address-cells = <1>; + #size-cells = <0>; + color = <LED_COLOR_ID_MULTI>; + function = LED_FUNCTION_ACTIVITY; + reg = <2>; + ti,led-bank = <2 3 5>; + + led@6 { + reg = <0x6>; + color = <LED_COLOR_ID_RED>; + led-sources = <6 9 15>; + }; + + led@7 { + reg = <0x7>; + color = <LED_COLOR_ID_GREEN>; + led-sources = <7 10 16>; + }; + + led@8 { + reg = <0x8>; + color = <LED_COLOR_ID_BLUE>; + led-sources = <8 11 17>; + }; + }; + + multi-led@4 { + #address-cells = <1>; + #size-cells = <0>; + reg = <4>; + color = <LED_COLOR_ID_MULTI>; + function = LED_FUNCTION_ACTIVITY; + + led@12 { + reg = <12>; + color = <LED_COLOR_ID_RED>; + }; + + led@13 { + reg = <13>; + color = <LED_COLOR_ID_GREEN>; + }; + + led@14 { + reg = <14>; + color = <LED_COLOR_ID_BLUE>; + }; + }; + +}; -- 2.22.0.214.g8dca754b1e ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v5 3/9] dt: bindings: Add multicolor class dt bindings documention 2019-09-11 18:01 ` [PATCH v5 3/9] dt: bindings: Add multicolor class dt bindings documention Dan Murphy @ 2019-09-15 14:01 ` Jacek Anaszewski 2019-09-16 13:58 ` Dan Murphy 0 siblings, 1 reply; 24+ messages in thread From: Jacek Anaszewski @ 2019-09-15 14:01 UTC (permalink / raw) To: Dan Murphy, pavel; +Cc: robh+dt, linux-leds, linux-kernel Dan, This patch has the same issues I mentioned in the v4 review [0]. On 9/11/19 8:01 PM, Dan Murphy wrote: > Add DT bindings for the LEDs multicolor class framework. > > Signed-off-by: Dan Murphy <dmurphy@ti.com> > --- > .../bindings/leds/leds-class-multicolor.txt | 96 +++++++++++++++++++ > 1 file changed, 96 insertions(+) > create mode 100644 Documentation/devicetree/bindings/leds/leds-class-multicolor.txt > > diff --git a/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt b/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt > new file mode 100644 > index 000000000000..5d36327b18fc > --- /dev/null > +++ b/Documentation/devicetree/bindings/leds/leds-class-multicolor.txt > @@ -0,0 +1,96 @@ > +* Multicolor LED properties > + > +Multicolor LEDs can consist of a RGB, RGBW or a RGBA LED clusters. These devices > +can be grouped together and also provide a modeling mechanism so that the > +cluster LEDs can vary in hue and intensity to produce a wide range of colors. > + > +The nodes and properties defined in this document are unique to the multicolor > +LED class. Common LED nodes and properties are inherited from the common.txt > +within this documentation directory. > + > +Required LED Child properties: > + - color : For multicolor LED support this property should be defined as > + LED_COLOR_ID_MULTI and further definition can be found in > + include/linux/leds/common.h. > + > +led-controller@30 { > + #address-cells = <1>; > + #size-cells = <0>; > + compatible = "ti,lp5024"; > + reg = <0x29>; > + > + multi-led@1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + color = <LED_COLOR_ID_MULTI>; > + function = LED_FUNCTION_; > + > + > + led@3 { > + reg = <3>; > + color = <LED_COLOR_ID_RED>; > + }; > + > + led@4 { > + reg = <4>; > + color = <LED_COLOR_ID_GREEN>; > + }; > + > + led@5 { > + reg = <5>; > + color = <LED_COLOR_ID_BLUE>; > + }; > + }; > + > + multi-led@2 { > + #address-cells = <1>; > + #size-cells = <0>; > + color = <LED_COLOR_ID_MULTI>; > + function = LED_FUNCTION_ACTIVITY; > + reg = <2>; > + ti,led-bank = <2 3 5>; > + > + led@6 { > + reg = <0x6>; > + color = <LED_COLOR_ID_RED>; > + led-sources = <6 9 15>; > + }; > + > + led@7 { > + reg = <0x7>; > + color = <LED_COLOR_ID_GREEN>; > + led-sources = <7 10 16>; > + }; > + > + led@8 { > + reg = <0x8>; > + color = <LED_COLOR_ID_BLUE>; > + led-sources = <8 11 17>; > + }; > + }; > + > + multi-led@4 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <4>; > + color = <LED_COLOR_ID_MULTI>; > + function = LED_FUNCTION_ACTIVITY; > + > + led@12 { > + reg = <12>; > + color = <LED_COLOR_ID_RED>; > + }; > + > + led@13 { > + reg = <13>; > + color = <LED_COLOR_ID_GREEN>; > + }; > + > + led@14 { > + reg = <14>; > + color = <LED_COLOR_ID_BLUE>; > + }; > + }; > + > +}; > [0] https://lore.kernel.org/linux-leds/684010e7-a47c-2bc8-2bf6-c632be31649b@gmail.com/ -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 3/9] dt: bindings: Add multicolor class dt bindings documention 2019-09-15 14:01 ` Jacek Anaszewski @ 2019-09-16 13:58 ` Dan Murphy 0 siblings, 0 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-16 13:58 UTC (permalink / raw) To: Jacek Anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel Hello On 9/15/19 9:01 AM, Jacek Anaszewski wrote: > Dan, > > This patch has the same issues I mentioned in the v4 review [0]. Sorry for that with all the rework done to this again the changes may have been lost. I will update per v4 comments Dan > https://lore.kernel.org/linux-leds/684010e7-a47c-2bc8-2bf6-c632be31649b@gmail.com/ > ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v5 4/9] dt-bindings: leds: Add multicolor ID to the color ID list 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy ` (2 preceding siblings ...) 2019-09-11 18:01 ` [PATCH v5 3/9] dt: bindings: Add multicolor class dt bindings documention Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-11 18:01 ` [PATCH v5 5/9] " Dan Murphy ` (4 subsequent siblings) 8 siblings, 0 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Add a new color ID that is declared as MULTICOLOR as with the multicolor framework declaring a definitive color is not accurate as the node can contain multiple colors. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- include/dt-bindings/leds/common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 9e1256a7c1bf..7006d15f71e8 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -29,7 +29,8 @@ #define LED_COLOR_ID_VIOLET 5 #define LED_COLOR_ID_YELLOW 6 #define LED_COLOR_ID_IR 7 -#define LED_COLOR_ID_MAX 8 +#define LED_COLOR_ID_MULTI 8 +#define LED_COLOR_ID_MAX 9 /* Standard LED functions */ #define LED_FUNCTION_ACTIVITY "activity" -- 2.22.0.214.g8dca754b1e ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 5/9] leds: Add multicolor ID to the color ID list 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy ` (3 preceding siblings ...) 2019-09-11 18:01 ` [PATCH v5 4/9] dt-bindings: leds: Add multicolor ID to the color ID list Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-11 18:01 ` [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition Dan Murphy ` (3 subsequent siblings) 8 siblings, 0 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Add a new color ID that is declared as MULTICOLOR as with the multicolor framework declaring a definitive color is not accurate as the node can contain multiple colors. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- drivers/leds/led-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index f1f718dbe0f8..846248a0693d 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -34,6 +34,7 @@ const char * const led_colors[LED_COLOR_ID_MAX] = { [LED_COLOR_ID_VIOLET] = "violet", [LED_COLOR_ID_YELLOW] = "yellow", [LED_COLOR_ID_IR] = "ir", + [LED_COLOR_ID_MULTI] = "multicolor", }; EXPORT_SYMBOL_GPL(led_colors); -- 2.22.0.214.g8dca754b1e ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy ` (4 preceding siblings ...) 2019-09-11 18:01 ` [PATCH v5 5/9] " Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-15 16:20 ` Jacek Anaszewski 2019-09-11 18:01 ` [PATCH v5 7/9] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Dan Murphy ` (2 subsequent siblings) 8 siblings, 1 reply; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Introduce a multicolor class that groups colored LEDs within a LED node. The framework allows for dynamically setting individual LEDs or setting brightness levels of LEDs and updating them virtually simultaneously. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- drivers/leds/Kconfig | 10 + drivers/leds/Makefile | 1 + drivers/leds/led-class-multicolor.c | 387 +++++++++++++++++++++++++++ include/linux/led-class-multicolor.h | 96 +++++++ 4 files changed, 494 insertions(+) create mode 100644 drivers/leds/led-class-multicolor.c create mode 100644 include/linux/led-class-multicolor.h diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1988de1d64c0..71e7fd4f6f15 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -30,6 +30,16 @@ config LEDS_CLASS_FLASH for the flash related features of a LED device. It can be built as a module. +config LEDS_CLASS_MULTI_COLOR + tristate "LED Mulit Color LED Class Support" + depends on LEDS_CLASS + help + This option enables the multicolor LED sysfs class in /sys/class/leds. + It wraps LED class and adds multicolor LED specific sysfs attributes + and kernel internal API to it. You'll need this to provide support + for multicolor LEDs that are grouped together. This class is not + intended for single color LEDs. It can be built as a module. + config LEDS_BRIGHTNESS_HW_CHANGED bool "LED Class brightness_hw_changed attribute support" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 41fb073a39c1..897b810257dd 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_NEW_LEDS) += led-core.o obj-$(CONFIG_LEDS_CLASS) += led-class.o obj-$(CONFIG_LEDS_CLASS_FLASH) += led-class-flash.o +obj-$(CONFIG_LEDS_CLASS_MULTI_COLOR) += led-class-multicolor.o obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o # LED Platform Drivers diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c new file mode 100644 index 000000000000..c733192b31fa --- /dev/null +++ b/drivers/leds/led-class-multicolor.c @@ -0,0 +1,387 @@ +// SPDX-License-Identifier: GPL-2.0 +// LED Multi Color class interface +// Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ + +#include <linux/device.h> +#include <linux/init.h> +#include <linux/led-class-multicolor.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/uaccess.h> + +#include "leds.h" + +struct led_classdev_mc_priv { + struct led_classdev_mc *mcled_cdev; + + struct device_attribute max_intensity_attr; + struct device_attribute intensity_attr; + struct device_attribute color_index_attr; + + enum led_brightness max_intensity; + enum led_brightness intensity; + + struct list_head list; + + int led_color_id; + int color_seq_pos; +}; + +static int led_mc_calculate_brightness(int brightness, int intensity, + int max_intensity) +{ + if (brightness && intensity && max_intensity) + return brightness * intensity / max_intensity; + + return LED_OFF; +} + +void led_mc_set_cluster_brightness(struct led_classdev_mc *mcled_cdev, + enum led_brightness brightness, int adj_value[]) +{ + struct led_classdev_mc_data *data = mcled_cdev->data; + struct led_classdev_mc_priv *priv; + int i = 0; + + list_for_each_entry(priv, &data->color_list, list) { + adj_value[i] = led_mc_calculate_brightness(brightness, + priv->intensity, + priv->max_intensity); + i++; + } + + data->cluster_brightness = brightness; +} + +void led_mc_get_cluster_brightness(struct led_classdev_mc *mcled_cdev, + int brightness_val[]) +{ + struct led_classdev_mc_data *data = mcled_cdev->data; + struct led_classdev_mc_priv *priv; + int i = 0; + + list_for_each_entry(priv, &data->color_list, list) { + brightness_val[i] = priv->intensity; + i++; + } +} + +static ssize_t color_index_show(struct device *dev, + struct device_attribute *color_index_attr, + char *buf) +{ + struct led_classdev_mc_priv *priv = container_of(color_index_attr, + struct led_classdev_mc_priv, + color_index_attr); + + return sprintf(buf, "%d\n", priv->led_color_id); +} + +static ssize_t color_mix_store(struct device *dev, + struct device_attribute *color_mix_attr, + const char *buf, size_t size) +{ + struct led_classdev_mc_data *data = container_of(color_mix_attr, + struct led_classdev_mc_data, + color_mix_attr); + struct led_classdev_mc *mcled_cdev = data->mcled_cdev; + struct led_classdev_mc_priv *priv; + unsigned int value[LED_COLOR_ID_MAX]; + int nrchars, offset = 0; + unsigned int i; + int ret; + + for (i = 0; i < mcled_cdev->num_leds; i++) { + ret = sscanf(buf + offset, "%i%n", &value[i], &nrchars); + if (ret != 1) + break; + + offset += nrchars; + } + + if (i != mcled_cdev->num_leds) { + dev_err(dev, "Wrong number of LEDs defined %i, need %i\n", + i, mcled_cdev->num_leds); + return -EINVAL; + } + + list_for_each_entry(priv, &data->color_list, list) { + priv->intensity = value[priv->color_seq_pos]; + if (mcled_cdev->ops) { + ret = mcled_cdev->ops->set_color_brightness(mcled_cdev, + priv->led_color_id, + priv->intensity); + if (ret) + goto out; + } + } +out: + return size; +} + +static ssize_t intensity_store(struct device *dev, + struct device_attribute *intensity_attr, + const char *buf, size_t size) +{ + struct led_classdev_mc_priv *priv = container_of(intensity_attr, + struct led_classdev_mc_priv, + intensity_attr); + struct led_classdev_mc_data *data = priv->mcled_cdev->data; + struct led_classdev_mc *mcled_cdev = data->mcled_cdev; + struct led_classdev *led_cdev = priv->mcled_cdev->led_cdev; + unsigned long value; + ssize_t ret; + + mutex_lock(&led_cdev->led_access); + + ret = kstrtoul(buf, 10, &value); + if (ret) + goto unlock; + + if (value > priv->max_intensity) { + ret = -EINVAL; + goto unlock; + } + + priv->intensity = value; + + if (mcled_cdev->ops) { + ret = mcled_cdev->ops->set_color_brightness(mcled_cdev, + priv->led_color_id, + priv->intensity); + if (ret) + goto unlock; + } + + ret = size; + +unlock: + mutex_unlock(&led_cdev->led_access); + return ret; +} + +static ssize_t intensity_show(struct device *dev, + struct device_attribute *intensity_attr, + char *buf) +{ + struct led_classdev_mc_priv *priv = container_of(intensity_attr, + struct led_classdev_mc_priv, + intensity_attr); + const struct led_multicolor_ops *ops = priv->mcled_cdev->ops; + int value = 0; + + if (ops->get_color_brightness) { + value = ops->get_color_brightness(priv->mcled_cdev, + priv->led_color_id); + priv->intensity = value; + } else { + value = priv->intensity; + } + + return sprintf(buf, "%d\n", value); +} + +static ssize_t max_intensity_show(struct device *dev, + struct device_attribute *max_intensity_attr, + char *buf) +{ + struct led_classdev_mc_priv *priv = container_of(max_intensity_attr, + struct led_classdev_mc_priv, + max_intensity_attr); + + return sprintf(buf, "%d\n", priv->max_intensity); +} + +static int led_multicolor_init_color(struct led_classdev_mc_data *data, + struct led_classdev_mc *mcled_cdev, + int color_id, int color_index) +{ + struct led_classdev *led_cdev = mcled_cdev->led_cdev; + struct led_classdev_mc_priv *mc_priv; + int ret; + + mc_priv = devm_kzalloc(led_cdev->dev, sizeof(*mc_priv), GFP_KERNEL); + if (!mc_priv) + return -ENOMEM; + + mc_priv->led_color_id = color_id; + mc_priv->mcled_cdev = mcled_cdev; + + data->led_kobj = kobject_create_and_add(led_colors[color_id], + data->color_kobj); + if (!data->led_kobj) + return -EINVAL; + + sysfs_attr_init(&mc_priv->intensity_attr.attr); + mc_priv->intensity_attr.attr.name = "intensity"; + mc_priv->intensity_attr.attr.mode = S_IRUGO | S_IWUGO; + mc_priv->intensity_attr.store = intensity_store; + mc_priv->intensity_attr.show = intensity_show; + ret = sysfs_create_file(data->led_kobj, + &mc_priv->intensity_attr.attr); + if (ret) + goto err_out; + + sysfs_attr_init(&mc_priv->max_intensity_attr.attr); + mc_priv->max_intensity_attr.attr.name = "max_intensity"; + mc_priv->max_intensity_attr.attr.mode = S_IRUGO; + mc_priv->max_intensity_attr.show = max_intensity_show; + ret = sysfs_create_file(data->led_kobj, + &mc_priv->max_intensity_attr.attr); + if (ret) + goto err_out; + + sysfs_attr_init(&mc_priv->color_index_attr.attr); + mc_priv->color_index_attr.attr.name = "color_id"; + mc_priv->color_index_attr.attr.mode = S_IRUGO; + mc_priv->color_index_attr.show = color_index_show; + ret = sysfs_create_file(data->led_kobj, + &mc_priv->color_index_attr.attr); + if (ret) + goto err_out; + + mc_priv->max_intensity = LED_FULL; + mc_priv->color_seq_pos = color_index; + list_add_tail(&mc_priv->list, &data->color_list); + +err_out: + return ret; +} + +static int led_multicolor_init_color_dir(struct led_classdev_mc_data *data, + struct led_classdev_mc *mcled_cdev) +{ + struct led_classdev *led_cdev = mcled_cdev->led_cdev; + u32 color_id; + int ret; + int i, j = 0; + + data->color_kobj = kobject_create_and_add("colors", + &led_cdev->dev->kobj); + if (!data->color_kobj) + return -EINVAL; + + data->mcled_cdev = mcled_cdev; + + for (i = 0; i < LED_COLOR_ID_MAX; i++) { + color_id = (mcled_cdev->available_colors & (1 << i)); + if (color_id) { + ret = led_multicolor_init_color(data, mcled_cdev, i, j); + if (ret) + break; + + j++; + } + } + + sysfs_attr_init(&data->color_mix_attr.attr); + data->color_mix_attr.attr.name = "color_mix"; + data->color_mix_attr.attr.mode = S_IRUGO | S_IWUGO; + data->color_mix_attr.store = color_mix_store; + ret = sysfs_create_file(data->color_kobj, + &data->color_mix_attr.attr); + + return ret; +} + +int led_classdev_multicolor_register_ext(struct device *parent, + struct led_classdev_mc *mcled_cdev, + struct led_init_data *init_data) +{ + struct led_classdev *led_cdev; + struct led_classdev_mc_data *data; + int ret; + + if (!mcled_cdev) + return -EINVAL; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + mcled_cdev->data = data; + led_cdev = mcled_cdev->led_cdev; + INIT_LIST_HEAD(&data->color_list); + + /* Register led class device */ + ret = led_classdev_register_ext(parent, led_cdev, init_data); + if (ret) + return ret; + + return led_multicolor_init_color_dir(data, mcled_cdev); +} +EXPORT_SYMBOL_GPL(led_classdev_multicolor_register_ext); + +void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) +{ + if (!mcled_cdev) + return; + + led_classdev_unregister(mcled_cdev->led_cdev); +} +EXPORT_SYMBOL_GPL(led_classdev_multicolor_unregister); + +static void devm_led_classdev_multicolor_release(struct device *dev, void *res) +{ + led_classdev_multicolor_unregister(*(struct led_classdev_mc **)res); +} + +/** + * devm_of_led_classdev_register - resource managed led_classdev_register() + * + * @parent: parent of LED device + * @led_cdev: the led_classdev structure for this device. + */ +int devm_led_classdev_multicolor_register(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{ + struct led_classdev_mc **dr; + int ret; + + dr = devres_alloc(devm_led_classdev_multicolor_release, + sizeof(*dr), GFP_KERNEL); + if (!dr) + return -ENOMEM; + + ret = led_classdev_multicolor_register(parent, mcled_cdev); + if (ret) { + devres_free(dr); + return ret; + } + + *dr = mcled_cdev; + devres_add(parent, dr); + + return 0; +} +EXPORT_SYMBOL_GPL(devm_led_classdev_multicolor_register); + +static int devm_led_classdev_multicolor_match(struct device *dev, + void *res, void *data) +{ + struct mcled_cdev **p = res; + + if (WARN_ON(!p || !*p)) + return 0; + + return *p == data; +} + +/** + * devm_led_classdev_multicolor_unregister() - resource managed + * led_classdev_multicolor_unregister() + * @parent: The device to unregister. + * @mcled_cdev: the led_classdev_mc structure for this device. + */ +void devm_led_classdev_multicolor_unregister(struct device *dev, + struct led_classdev_mc *mcled_cdev) +{ + WARN_ON(devres_release(dev, + devm_led_classdev_multicolor_release, + devm_led_classdev_multicolor_match, mcled_cdev)); +} +EXPORT_SYMBOL_GPL(devm_led_classdev_multicolor_unregister); + +MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); +MODULE_DESCRIPTION("Multi Color LED class interface"); +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h new file mode 100644 index 000000000000..193ba0e46042 --- /dev/null +++ b/include/linux/led-class-multicolor.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* LED Multicolor class interface + * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ + */ + +#ifndef __LINUX_MULTICOLOR_LEDS_H_INCLUDED +#define __LINUX_MULTICOLOR_LEDS_H_INCLUDED + +#include <linux/leds.h> +#include <dt-bindings/leds/common.h> + +struct led_classdev_mc; + +struct led_classdev_mc_data { + struct led_classdev_mc *mcled_cdev; + + struct kobject *color_kobj; + struct kobject *led_kobj; + + struct device_attribute color_mix_attr; + + struct list_head color_list; + + enum led_brightness cluster_brightness; +}; + +struct led_multicolor_ops { + /* Set brightness for a specific color id */ + int (*set_color_brightness)(struct led_classdev_mc *mcled_cdev, + int color_id, int value); + /* Read current color setting */ + int (*get_color_brightness)(struct led_classdev_mc *mcled_cdev, + int color_id); +}; + +struct led_classdev_mc { + /* led class device */ + struct led_classdev *led_cdev; + + /* multicolor led specific ops */ + struct led_multicolor_ops *ops; + + struct led_classdev_mc_data *data; + + unsigned long available_colors; + int num_leds; +}; + +static inline struct led_classdev_mc *lcdev_to_mccdev( + struct led_classdev *lcdev) +{ + return container_of(lcdev, struct led_classdev_mc, led_cdev); +} + +/** + * led_classdev_multicolor_register_ext - register a new object of led_classdev + * class with support for multicolor LEDs + * @parent: the multicolor LED to register + * @mcled_cdev: the led_classdev_mc structure for this device + * @init_data: the LED class Multi color device initialization data + * + * Returns: 0 on success or negative error value on failure + */ +extern int led_classdev_multicolor_register_ext(struct device *parent, + struct led_classdev_mc *mcled_cdev, + struct led_init_data *init_data); + +#define led_classdev_multicolor_register(parent, mcled_cdev) \ + led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL) + +/** + * led_classdev_multicolor_unregister - unregisters an object of led_classdev + * class with support for multicolor LEDs + * @mcled_cdev: the multicolor LED to unregister + * + * Unregister a previously registered via led_classdev_multicolor_register + * object + */ +extern void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev); + +extern int devm_led_classdev_multicolor_register(struct device *parent, + struct led_classdev_mc *mcled_cdev); + +extern void devm_led_classdev_multicolor_unregister(struct device *parent, + struct led_classdev_mc *mcled_cdev); + +/* Set brightness for the monochrome LED cluster */ +extern void led_mc_set_cluster_brightness(struct led_classdev_mc *mcled_cdev, + enum led_brightness brightness, + int adj_value[]); + +/* Read current cluster brightness */ +extern void led_mc_get_cluster_brightness(struct led_classdev_mc *mcled_cdev, + int brightness_val[]); + +#endif /* __LINUX_MULTICOLOR_LEDS_H_INCLUDED */ -- 2.22.0.214.g8dca754b1e ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition 2019-09-11 18:01 ` [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition Dan Murphy @ 2019-09-15 16:20 ` Jacek Anaszewski 2019-09-16 14:04 ` Dan Murphy 2019-09-16 18:34 ` Dan Murphy 0 siblings, 2 replies; 24+ messages in thread From: Jacek Anaszewski @ 2019-09-15 16:20 UTC (permalink / raw) To: Dan Murphy, pavel; +Cc: robh+dt, linux-leds, linux-kernel Dan, On 9/11/19 8:01 PM, Dan Murphy wrote: > Introduce a multicolor class that groups colored LEDs > within a LED node. > > The framework allows for dynamically setting individual LEDs > or setting brightness levels of LEDs and updating them virtually > simultaneously. > > Signed-off-by: Dan Murphy <dmurphy@ti.com> > --- > drivers/leds/Kconfig | 10 + > drivers/leds/Makefile | 1 + > drivers/leds/led-class-multicolor.c | 387 +++++++++++++++++++++++++++ > include/linux/led-class-multicolor.h | 96 +++++++ > 4 files changed, 494 insertions(+) > create mode 100644 drivers/leds/led-class-multicolor.c > create mode 100644 include/linux/led-class-multicolor.h > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > index 1988de1d64c0..71e7fd4f6f15 100644 > --- a/drivers/leds/Kconfig > +++ b/drivers/leds/Kconfig > @@ -30,6 +30,16 @@ config LEDS_CLASS_FLASH > for the flash related features of a LED device. It can be built > as a module. > > +config LEDS_CLASS_MULTI_COLOR > + tristate "LED Mulit Color LED Class Support" > + depends on LEDS_CLASS > + help > + This option enables the multicolor LED sysfs class in /sys/class/leds. > + It wraps LED class and adds multicolor LED specific sysfs attributes > + and kernel internal API to it. You'll need this to provide support > + for multicolor LEDs that are grouped together. This class is not > + intended for single color LEDs. It can be built as a module. > + > config LEDS_BRIGHTNESS_HW_CHANGED > bool "LED Class brightness_hw_changed attribute support" > depends on LEDS_CLASS > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile > index 41fb073a39c1..897b810257dd 100644 > --- a/drivers/leds/Makefile > +++ b/drivers/leds/Makefile > @@ -4,6 +4,7 @@ > obj-$(CONFIG_NEW_LEDS) += led-core.o > obj-$(CONFIG_LEDS_CLASS) += led-class.o > obj-$(CONFIG_LEDS_CLASS_FLASH) += led-class-flash.o > +obj-$(CONFIG_LEDS_CLASS_MULTI_COLOR) += led-class-multicolor.o > obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o > > # LED Platform Drivers > diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c > new file mode 100644 > index 000000000000..c733192b31fa > --- /dev/null > +++ b/drivers/leds/led-class-multicolor.c > @@ -0,0 +1,387 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// LED Multi Color class interface > +// Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ > + > +#include <linux/device.h> > +#include <linux/init.h> > +#include <linux/led-class-multicolor.h> > +#include <linux/module.h> > +#include <linux/slab.h> > +#include <linux/uaccess.h> > + > +#include "leds.h" > + > +struct led_classdev_mc_priv { I'd go for some more informative struct name here. And also this is not going to be main classdev struct so we can drop that from the name. struct led_mc_color_entry ? > + struct led_classdev_mc *mcled_cdev; > + > + struct device_attribute max_intensity_attr; > + struct device_attribute intensity_attr; > + struct device_attribute color_index_attr; > + > + enum led_brightness max_intensity; > + enum led_brightness intensity; > + > + struct list_head list; > + > + int led_color_id; > + int color_seq_pos; > +}; > + > +static int led_mc_calculate_brightness(int brightness, int intensity, > + int max_intensity) > +{ > + if (brightness && intensity && max_intensity) This check looks odd. I'd drop it entirely. One thing we could worry about would be max_intensity == 0 but this should be secured by the core on registration. Effectively I don't see the need for wrapping below calculation in a function at all. > + return brightness * intensity / max_intensity; > + > + return LED_OFF; > +} > + > +void led_mc_set_cluster_brightness(struct led_classdev_mc *mcled_cdev, We really don't set cluster brightness but calculate it only here (we can skip "cluster" as well): s/led_mc_set_cluster_brightness/led_mc_calc_brightness/ > + enum led_brightness brightness, int adj_value[]) s/adj_value/brightness_val/ > +{ > + struct led_classdev_mc_data *data = mcled_cdev->data; > + struct led_classdev_mc_priv *priv; > + int i = 0; > + > + list_for_each_entry(priv, &data->color_list, list) { > + adj_value[i] = led_mc_calculate_brightness(brightness, > + priv->intensity, > + priv->max_intensity); brightness_val[i] = brightness * priv->intensity / priv->max_intensity; > + i++; > + } > + > + data->cluster_brightness = brightness; Why can't we use led_classdev_mc->led_cdev->brightness for storing cluster brightness? > +} > + > +void led_mc_get_cluster_brightness(struct led_classdev_mc *mcled_cdev, > + int brightness_val[]) > +{ > + struct led_classdev_mc_data *data = mcled_cdev->data; > + struct led_classdev_mc_priv *priv; > + int i = 0; > + > + list_for_each_entry(priv, &data->color_list, list) { > + brightness_val[i] = priv->intensity; > + i++; > + } > +} > + > +static ssize_t color_index_show(struct device *dev, > + struct device_attribute *color_index_attr, > + char *buf) > +{ > + struct led_classdev_mc_priv *priv = container_of(color_index_attr, > + struct led_classdev_mc_priv, > + color_index_attr); > + > + return sprintf(buf, "%d\n", priv->led_color_id); > +} > + > +static ssize_t color_mix_store(struct device *dev, > + struct device_attribute *color_mix_attr, > + const char *buf, size_t size) > +{ > + struct led_classdev_mc_data *data = container_of(color_mix_attr, > + struct led_classdev_mc_data, > + color_mix_attr); > + struct led_classdev_mc *mcled_cdev = data->mcled_cdev; > + struct led_classdev_mc_priv *priv; > + unsigned int value[LED_COLOR_ID_MAX]; > + int nrchars, offset = 0; > + unsigned int i; > + int ret; > + > + for (i = 0; i < mcled_cdev->num_leds; i++) { > + ret = sscanf(buf + offset, "%i%n", &value[i], &nrchars); > + if (ret != 1) > + break; > + > + offset += nrchars; > + } > + > + if (i != mcled_cdev->num_leds) { > + dev_err(dev, "Wrong number of LEDs defined %i, need %i\n", > + i, mcled_cdev->num_leds); > + return -EINVAL; > + } > + > + list_for_each_entry(priv, &data->color_list, list) { > + priv->intensity = value[priv->color_seq_pos]; > + if (mcled_cdev->ops) { > + ret = mcled_cdev->ops->set_color_brightness(mcled_cdev, > + priv->led_color_id, > + priv->intensity); > + if (ret) > + goto out; > + } > + } > +out: > + return size; > +} > + > +static ssize_t intensity_store(struct device *dev, > + struct device_attribute *intensity_attr, > + const char *buf, size_t size) > +{ > + struct led_classdev_mc_priv *priv = container_of(intensity_attr, > + struct led_classdev_mc_priv, > + intensity_attr); > + struct led_classdev_mc_data *data = priv->mcled_cdev->data; > + struct led_classdev_mc *mcled_cdev = data->mcled_cdev; > + struct led_classdev *led_cdev = priv->mcled_cdev->led_cdev; > + unsigned long value; > + ssize_t ret; > + > + mutex_lock(&led_cdev->led_access); > + > + ret = kstrtoul(buf, 10, &value); > + if (ret) > + goto unlock; > + > + if (value > priv->max_intensity) { > + ret = -EINVAL; > + goto unlock; > + } > + > + priv->intensity = value; > + > + if (mcled_cdev->ops) { > + ret = mcled_cdev->ops->set_color_brightness(mcled_cdev, > + priv->led_color_id, > + priv->intensity); > + if (ret) > + goto unlock; > + } > + > + ret = size; > + > +unlock: > + mutex_unlock(&led_cdev->led_access); > + return ret; > +} > + > +static ssize_t intensity_show(struct device *dev, > + struct device_attribute *intensity_attr, > + char *buf) > +{ > + struct led_classdev_mc_priv *priv = container_of(intensity_attr, > + struct led_classdev_mc_priv, > + intensity_attr); > + const struct led_multicolor_ops *ops = priv->mcled_cdev->ops; > + int value = 0; > + > + if (ops->get_color_brightness) { > + value = ops->get_color_brightness(priv->mcled_cdev, > + priv->led_color_id); > + priv->intensity = value; > + } else { > + value = priv->intensity; > + } > + > + return sprintf(buf, "%d\n", value); > +} > + > +static ssize_t max_intensity_show(struct device *dev, > + struct device_attribute *max_intensity_attr, > + char *buf) > +{ > + struct led_classdev_mc_priv *priv = container_of(max_intensity_attr, > + struct led_classdev_mc_priv, > + max_intensity_attr); > + > + return sprintf(buf, "%d\n", priv->max_intensity); > +} > + > +static int led_multicolor_init_color(struct led_classdev_mc_data *data, > + struct led_classdev_mc *mcled_cdev, > + int color_id, int color_index) > +{ > + struct led_classdev *led_cdev = mcled_cdev->led_cdev; > + struct led_classdev_mc_priv *mc_priv; > + int ret; > + > + mc_priv = devm_kzalloc(led_cdev->dev, sizeof(*mc_priv), GFP_KERNEL); > + if (!mc_priv) > + return -ENOMEM; > + > + mc_priv->led_color_id = color_id; > + mc_priv->mcled_cdev = mcled_cdev; > + > + data->led_kobj = kobject_create_and_add(led_colors[color_id], > + data->color_kobj); No change here since previous version? What prevents you from following what has been done for drivers/usb/core/ledtrig-usbport.c? Use sysfs_create_group() for creating color dir and sysfs_add_file_to_group() for adding files to it. > + if (!data->led_kobj) > + return -EINVAL; > + > + sysfs_attr_init(&mc_priv->intensity_attr.attr); > + mc_priv->intensity_attr.attr.name = "intensity"; > + mc_priv->intensity_attr.attr.mode = S_IRUGO | S_IWUGO; > + mc_priv->intensity_attr.store = intensity_store; > + mc_priv->intensity_attr.show = intensity_show; > + ret = sysfs_create_file(data->led_kobj, > + &mc_priv->intensity_attr.attr); > + if (ret) > + goto err_out; > + > + sysfs_attr_init(&mc_priv->max_intensity_attr.attr); > + mc_priv->max_intensity_attr.attr.name = "max_intensity"; > + mc_priv->max_intensity_attr.attr.mode = S_IRUGO; > + mc_priv->max_intensity_attr.show = max_intensity_show; > + ret = sysfs_create_file(data->led_kobj, > + &mc_priv->max_intensity_attr.attr); > + if (ret) > + goto err_out; > + > + sysfs_attr_init(&mc_priv->color_index_attr.attr); > + mc_priv->color_index_attr.attr.name = "color_id"; > + mc_priv->color_index_attr.attr.mode = S_IRUGO; > + mc_priv->color_index_attr.show = color_index_show; > + ret = sysfs_create_file(data->led_kobj, > + &mc_priv->color_index_attr.attr); > + if (ret) > + goto err_out; > + > + mc_priv->max_intensity = LED_FULL; > + mc_priv->color_seq_pos = color_index; > + list_add_tail(&mc_priv->list, &data->color_list); > + > +err_out: > + return ret; > +} > + > +static int led_multicolor_init_color_dir(struct led_classdev_mc_data *data, > + struct led_classdev_mc *mcled_cdev) > +{ > + struct led_classdev *led_cdev = mcled_cdev->led_cdev; > + u32 color_id; > + int ret; > + int i, j = 0; > + > + data->color_kobj = kobject_create_and_add("colors", > + &led_cdev->dev->kobj); Again: use sysfs_create_group(). > + if (!data->color_kobj) > + return -EINVAL; > + > + data->mcled_cdev = mcled_cdev; > + > + for (i = 0; i < LED_COLOR_ID_MAX; i++) { > + color_id = (mcled_cdev->available_colors & (1 << i)); > + if (color_id) { > + ret = led_multicolor_init_color(data, mcled_cdev, i, j); > + if (ret) > + break; > + > + j++; > + } > + } > + > + sysfs_attr_init(&data->color_mix_attr.attr); > + data->color_mix_attr.attr.name = "color_mix"; > + data->color_mix_attr.attr.mode = S_IRUGO | S_IWUGO; > + data->color_mix_attr.store = color_mix_store; > + ret = sysfs_create_file(data->color_kobj, > + &data->color_mix_attr.attr); > + > + return ret; > +} > + > +int led_classdev_multicolor_register_ext(struct device *parent, > + struct led_classdev_mc *mcled_cdev, > + struct led_init_data *init_data) > +{ > + struct led_classdev *led_cdev; > + struct led_classdev_mc_data *data; > + int ret; > + > + if (!mcled_cdev) > + return -EINVAL; > + > + data = kzalloc(sizeof(*data), GFP_KERNEL); > + if (!data) > + return -ENOMEM; > + > + mcled_cdev->data = data; > + led_cdev = mcled_cdev->led_cdev; > + INIT_LIST_HEAD(&data->color_list); > + > + /* Register led class device */ > + ret = led_classdev_register_ext(parent, led_cdev, init_data); > + if (ret) > + return ret; > + > + return led_multicolor_init_color_dir(data, mcled_cdev); > +} > +EXPORT_SYMBOL_GPL(led_classdev_multicolor_register_ext); > + > +void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) > +{ > + if (!mcled_cdev) > + return; > + > + led_classdev_unregister(mcled_cdev->led_cdev); > +} > +EXPORT_SYMBOL_GPL(led_classdev_multicolor_unregister); > + > +static void devm_led_classdev_multicolor_release(struct device *dev, void *res) > +{ > + led_classdev_multicolor_unregister(*(struct led_classdev_mc **)res); > +} > + > +/** > + * devm_of_led_classdev_register - resource managed led_classdev_register() > + * > + * @parent: parent of LED device > + * @led_cdev: the led_classdev structure for this device. > + */ > +int devm_led_classdev_multicolor_register(struct device *parent, > + struct led_classdev_mc *mcled_cdev) > +{ > + struct led_classdev_mc **dr; > + int ret; > + > + dr = devres_alloc(devm_led_classdev_multicolor_release, > + sizeof(*dr), GFP_KERNEL); > + if (!dr) > + return -ENOMEM; > + > + ret = led_classdev_multicolor_register(parent, mcled_cdev); > + if (ret) { > + devres_free(dr); > + return ret; > + } > + > + *dr = mcled_cdev; > + devres_add(parent, dr); > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(devm_led_classdev_multicolor_register); > + > +static int devm_led_classdev_multicolor_match(struct device *dev, > + void *res, void *data) > +{ > + struct mcled_cdev **p = res; > + > + if (WARN_ON(!p || !*p)) > + return 0; > + > + return *p == data; > +} > + > +/** > + * devm_led_classdev_multicolor_unregister() - resource managed > + * led_classdev_multicolor_unregister() > + * @parent: The device to unregister. > + * @mcled_cdev: the led_classdev_mc structure for this device. > + */ > +void devm_led_classdev_multicolor_unregister(struct device *dev, > + struct led_classdev_mc *mcled_cdev) > +{ > + WARN_ON(devres_release(dev, > + devm_led_classdev_multicolor_release, > + devm_led_classdev_multicolor_match, mcled_cdev)); > +} > +EXPORT_SYMBOL_GPL(devm_led_classdev_multicolor_unregister); > + > +MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); > +MODULE_DESCRIPTION("Multi Color LED class interface"); > +MODULE_LICENSE("GPL v2"); > diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h > new file mode 100644 > index 000000000000..193ba0e46042 > --- /dev/null > +++ b/include/linux/led-class-multicolor.h > @@ -0,0 +1,96 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* LED Multicolor class interface > + * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ > + */ > + > +#ifndef __LINUX_MULTICOLOR_LEDS_H_INCLUDED > +#define __LINUX_MULTICOLOR_LEDS_H_INCLUDED > + > +#include <linux/leds.h> > +#include <dt-bindings/leds/common.h> > + > +struct led_classdev_mc; > + > +struct led_classdev_mc_data { > + struct led_classdev_mc *mcled_cdev; > + > + struct kobject *color_kobj; > + struct kobject *led_kobj; > + > + struct device_attribute color_mix_attr; > + > + struct list_head color_list; > + > + enum led_brightness cluster_brightness; > +}; > + > +struct led_multicolor_ops { > + /* Set brightness for a specific color id */ > + int (*set_color_brightness)(struct led_classdev_mc *mcled_cdev, > + int color_id, int value); > + /* Read current color setting */ > + int (*get_color_brightness)(struct led_classdev_mc *mcled_cdev, > + int color_id); > +}; > + > +struct led_classdev_mc { > + /* led class device */ > + struct led_classdev *led_cdev; > + > + /* multicolor led specific ops */ > + struct led_multicolor_ops *ops; > + > + struct led_classdev_mc_data *data; > + > + unsigned long available_colors; > + int num_leds; > +}; > + > +static inline struct led_classdev_mc *lcdev_to_mccdev( > + struct led_classdev *lcdev) > +{ > + return container_of(lcdev, struct led_classdev_mc, led_cdev); > +} > + > +/** > + * led_classdev_multicolor_register_ext - register a new object of led_classdev > + * class with support for multicolor LEDs > + * @parent: the multicolor LED to register > + * @mcled_cdev: the led_classdev_mc structure for this device > + * @init_data: the LED class Multi color device initialization data > + * > + * Returns: 0 on success or negative error value on failure > + */ > +extern int led_classdev_multicolor_register_ext(struct device *parent, > + struct led_classdev_mc *mcled_cdev, > + struct led_init_data *init_data); > + > +#define led_classdev_multicolor_register(parent, mcled_cdev) \ > + led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL) > + > +/** > + * led_classdev_multicolor_unregister - unregisters an object of led_classdev > + * class with support for multicolor LEDs > + * @mcled_cdev: the multicolor LED to unregister > + * > + * Unregister a previously registered via led_classdev_multicolor_register > + * object > + */ > +extern void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev); > + > +extern int devm_led_classdev_multicolor_register(struct device *parent, > + struct led_classdev_mc *mcled_cdev); > + > +extern void devm_led_classdev_multicolor_unregister(struct device *parent, > + struct led_classdev_mc *mcled_cdev); > + > +/* Set brightness for the monochrome LED cluster */ > +extern void led_mc_set_cluster_brightness(struct led_classdev_mc *mcled_cdev, > + enum led_brightness brightness, > + int adj_value[]); > + > +/* Read current cluster brightness */ > +extern void led_mc_get_cluster_brightness(struct led_classdev_mc *mcled_cdev, > + int brightness_val[]); > + > +#endif /* __LINUX_MULTICOLOR_LEDS_H_INCLUDED */ > -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition 2019-09-15 16:20 ` Jacek Anaszewski @ 2019-09-16 14:04 ` Dan Murphy 2019-09-16 18:34 ` Dan Murphy 1 sibling, 0 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-16 14:04 UTC (permalink / raw) To: Jacek Anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel Jacek On 9/15/19 11:20 AM, Jacek Anaszewski wrote: > Dan, > > On 9/11/19 8:01 PM, Dan Murphy wrote: >> Introduce a multicolor class that groups colored LEDs >> within a LED node. >> >> The framework allows for dynamically setting individual LEDs >> or setting brightness levels of LEDs and updating them virtually >> simultaneously. >> >> Signed-off-by: Dan Murphy <dmurphy@ti.com> >> --- >> drivers/leds/Kconfig | 10 + >> drivers/leds/Makefile | 1 + >> drivers/leds/led-class-multicolor.c | 387 +++++++++++++++++++++++++++ >> include/linux/led-class-multicolor.h | 96 +++++++ >> 4 files changed, 494 insertions(+) >> create mode 100644 drivers/leds/led-class-multicolor.c >> create mode 100644 include/linux/led-class-multicolor.h >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index 1988de1d64c0..71e7fd4f6f15 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -30,6 +30,16 @@ config LEDS_CLASS_FLASH >> for the flash related features of a LED device. It can be built >> as a module. >> >> +config LEDS_CLASS_MULTI_COLOR >> + tristate "LED Mulit Color LED Class Support" >> + depends on LEDS_CLASS >> + help >> + This option enables the multicolor LED sysfs class in /sys/class/leds. >> + It wraps LED class and adds multicolor LED specific sysfs attributes >> + and kernel internal API to it. You'll need this to provide support >> + for multicolor LEDs that are grouped together. This class is not >> + intended for single color LEDs. It can be built as a module. >> + >> config LEDS_BRIGHTNESS_HW_CHANGED >> bool "LED Class brightness_hw_changed attribute support" >> depends on LEDS_CLASS >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index 41fb073a39c1..897b810257dd 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -4,6 +4,7 @@ >> obj-$(CONFIG_NEW_LEDS) += led-core.o >> obj-$(CONFIG_LEDS_CLASS) += led-class.o >> obj-$(CONFIG_LEDS_CLASS_FLASH) += led-class-flash.o >> +obj-$(CONFIG_LEDS_CLASS_MULTI_COLOR) += led-class-multicolor.o >> obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o >> >> # LED Platform Drivers >> diff --git a/drivers/leds/led-class-multicolor.c b/drivers/leds/led-class-multicolor.c >> new file mode 100644 >> index 000000000000..c733192b31fa >> --- /dev/null >> +++ b/drivers/leds/led-class-multicolor.c >> @@ -0,0 +1,387 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +// LED Multi Color class interface >> +// Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ >> + >> +#include <linux/device.h> >> +#include <linux/init.h> >> +#include <linux/led-class-multicolor.h> >> +#include <linux/module.h> >> +#include <linux/slab.h> >> +#include <linux/uaccess.h> >> + >> +#include "leds.h" >> + >> +struct led_classdev_mc_priv { > I'd go for some more informative struct name here. > And also this is not going to be main classdev struct > so we can drop that from the name. > > struct led_mc_color_entry ? That would probably be better as a name. > >> + struct led_classdev_mc *mcled_cdev; >> + >> + struct device_attribute max_intensity_attr; >> + struct device_attribute intensity_attr; >> + struct device_attribute color_index_attr; >> + >> + enum led_brightness max_intensity; >> + enum led_brightness intensity; >> + >> + struct list_head list; >> + >> + int led_color_id; >> + int color_seq_pos; >> +}; >> + >> +static int led_mc_calculate_brightness(int brightness, int intensity, >> + int max_intensity) >> +{ >> + if (brightness && intensity && max_intensity) > This check looks odd. I'd drop it entirely. One thing we could worry > about would be max_intensity == 0 but this should be secured by the > core on registration. Effectively I don't see the need for wrapping > below calculation in a function at all. This was made into a function when I had the intensity and color_mix files writing the values. This is no longer needed as a function. > >> + return brightness * intensity / max_intensity; >> + >> + return LED_OFF; >> +} >> + >> +void led_mc_set_cluster_brightness(struct led_classdev_mc *mcled_cdev, > > We really don't set cluster brightness but calculate it only here > (we can skip "cluster" as well): > > s/led_mc_set_cluster_brightness/led_mc_calc_brightness/ Ack > >> + enum led_brightness brightness, int adj_value[]) > s/adj_value/brightness_val/ Ack > >> +{ >> + struct led_classdev_mc_data *data = mcled_cdev->data; >> + struct led_classdev_mc_priv *priv; >> + int i = 0; >> + >> + list_for_each_entry(priv, &data->color_list, list) { >> + adj_value[i] = led_mc_calculate_brightness(brightness, >> + priv->intensity, >> + priv->max_intensity); > brightness_val[i] = brightness * priv->intensity / priv->max_intensity; Ack > >> + i++; >> + } >> + >> + data->cluster_brightness = brightness; > Why can't we use led_classdev_mc->led_cdev->brightness for storing > cluster brightness? We could probably drop this altogether as I think you pointed out before. > >> +} >> + >> +void led_mc_get_cluster_brightness(struct led_classdev_mc *mcled_cdev, >> + int brightness_val[]) >> +{ >> + struct led_classdev_mc_data *data = mcled_cdev->data; >> + struct led_classdev_mc_priv *priv; >> + int i = 0; >> + >> + list_for_each_entry(priv, &data->color_list, list) { >> + brightness_val[i] = priv->intensity; >> + i++; >> + } >> +} >> + >> +static ssize_t color_index_show(struct device *dev, >> + struct device_attribute *color_index_attr, >> + char *buf) >> +{ >> + struct led_classdev_mc_priv *priv = container_of(color_index_attr, >> + struct led_classdev_mc_priv, >> + color_index_attr); >> + >> + return sprintf(buf, "%d\n", priv->led_color_id); >> +} >> + >> +static ssize_t color_mix_store(struct device *dev, >> + struct device_attribute *color_mix_attr, >> + const char *buf, size_t size) >> +{ >> + struct led_classdev_mc_data *data = container_of(color_mix_attr, >> + struct led_classdev_mc_data, >> + color_mix_attr); >> + struct led_classdev_mc *mcled_cdev = data->mcled_cdev; >> + struct led_classdev_mc_priv *priv; >> + unsigned int value[LED_COLOR_ID_MAX]; >> + int nrchars, offset = 0; >> + unsigned int i; >> + int ret; >> + >> + for (i = 0; i < mcled_cdev->num_leds; i++) { >> + ret = sscanf(buf + offset, "%i%n", &value[i], &nrchars); >> + if (ret != 1) >> + break; >> + >> + offset += nrchars; >> + } >> + >> + if (i != mcled_cdev->num_leds) { >> + dev_err(dev, "Wrong number of LEDs defined %i, need %i\n", >> + i, mcled_cdev->num_leds); >> + return -EINVAL; >> + } >> + >> + list_for_each_entry(priv, &data->color_list, list) { >> + priv->intensity = value[priv->color_seq_pos]; >> + if (mcled_cdev->ops) { >> + ret = mcled_cdev->ops->set_color_brightness(mcled_cdev, >> + priv->led_color_id, >> + priv->intensity); >> + if (ret) >> + goto out; >> + } >> + } >> +out: >> + return size; >> +} >> + >> +static ssize_t intensity_store(struct device *dev, >> + struct device_attribute *intensity_attr, >> + const char *buf, size_t size) >> +{ >> + struct led_classdev_mc_priv *priv = container_of(intensity_attr, >> + struct led_classdev_mc_priv, >> + intensity_attr); >> + struct led_classdev_mc_data *data = priv->mcled_cdev->data; >> + struct led_classdev_mc *mcled_cdev = data->mcled_cdev; >> + struct led_classdev *led_cdev = priv->mcled_cdev->led_cdev; >> + unsigned long value; >> + ssize_t ret; >> + >> + mutex_lock(&led_cdev->led_access); >> + >> + ret = kstrtoul(buf, 10, &value); >> + if (ret) >> + goto unlock; >> + >> + if (value > priv->max_intensity) { >> + ret = -EINVAL; >> + goto unlock; >> + } >> + >> + priv->intensity = value; >> + >> + if (mcled_cdev->ops) { >> + ret = mcled_cdev->ops->set_color_brightness(mcled_cdev, >> + priv->led_color_id, >> + priv->intensity); >> + if (ret) >> + goto unlock; >> + } >> + >> + ret = size; >> + >> +unlock: >> + mutex_unlock(&led_cdev->led_access); >> + return ret; >> +} >> + >> +static ssize_t intensity_show(struct device *dev, >> + struct device_attribute *intensity_attr, >> + char *buf) >> +{ >> + struct led_classdev_mc_priv *priv = container_of(intensity_attr, >> + struct led_classdev_mc_priv, >> + intensity_attr); >> + const struct led_multicolor_ops *ops = priv->mcled_cdev->ops; >> + int value = 0; >> + >> + if (ops->get_color_brightness) { >> + value = ops->get_color_brightness(priv->mcled_cdev, >> + priv->led_color_id); >> + priv->intensity = value; >> + } else { >> + value = priv->intensity; >> + } >> + >> + return sprintf(buf, "%d\n", value); >> +} >> + >> +static ssize_t max_intensity_show(struct device *dev, >> + struct device_attribute *max_intensity_attr, >> + char *buf) >> +{ >> + struct led_classdev_mc_priv *priv = container_of(max_intensity_attr, >> + struct led_classdev_mc_priv, >> + max_intensity_attr); >> + >> + return sprintf(buf, "%d\n", priv->max_intensity); >> +} >> + >> +static int led_multicolor_init_color(struct led_classdev_mc_data *data, >> + struct led_classdev_mc *mcled_cdev, >> + int color_id, int color_index) >> +{ >> + struct led_classdev *led_cdev = mcled_cdev->led_cdev; >> + struct led_classdev_mc_priv *mc_priv; >> + int ret; >> + >> + mc_priv = devm_kzalloc(led_cdev->dev, sizeof(*mc_priv), GFP_KERNEL); >> + if (!mc_priv) >> + return -ENOMEM; >> + >> + mc_priv->led_color_id = color_id; >> + mc_priv->mcled_cdev = mcled_cdev; >> + >> + data->led_kobj = kobject_create_and_add(led_colors[color_id], >> + data->color_kobj); > No change here since previous version? What prevents you from following > what has been done for drivers/usb/core/ledtrig-usbport.c? > > Use sysfs_create_group() for creating color dir > and sysfs_add_file_to_group() for adding files to it. Yet another change I missed. I am hoping we can actually nail this down for 5.5. So many changes and versions to this. Dan > > >> + if (!data->led_kobj) >> + return -EINVAL; >> + >> + sysfs_attr_init(&mc_priv->intensity_attr.attr); >> + mc_priv->intensity_attr.attr.name = "intensity"; >> + mc_priv->intensity_attr.attr.mode = S_IRUGO | S_IWUGO; >> + mc_priv->intensity_attr.store = intensity_store; >> + mc_priv->intensity_attr.show = intensity_show; >> + ret = sysfs_create_file(data->led_kobj, >> + &mc_priv->intensity_attr.attr); >> + if (ret) >> + goto err_out; >> + >> + sysfs_attr_init(&mc_priv->max_intensity_attr.attr); >> + mc_priv->max_intensity_attr.attr.name = "max_intensity"; >> + mc_priv->max_intensity_attr.attr.mode = S_IRUGO; >> + mc_priv->max_intensity_attr.show = max_intensity_show; >> + ret = sysfs_create_file(data->led_kobj, >> + &mc_priv->max_intensity_attr.attr); >> + if (ret) >> + goto err_out; >> + >> + sysfs_attr_init(&mc_priv->color_index_attr.attr); >> + mc_priv->color_index_attr.attr.name = "color_id"; >> + mc_priv->color_index_attr.attr.mode = S_IRUGO; >> + mc_priv->color_index_attr.show = color_index_show; >> + ret = sysfs_create_file(data->led_kobj, >> + &mc_priv->color_index_attr.attr); >> + if (ret) >> + goto err_out; >> + >> + mc_priv->max_intensity = LED_FULL; >> + mc_priv->color_seq_pos = color_index; >> + list_add_tail(&mc_priv->list, &data->color_list); >> + >> +err_out: >> + return ret; >> +} >> + >> +static int led_multicolor_init_color_dir(struct led_classdev_mc_data *data, >> + struct led_classdev_mc *mcled_cdev) >> +{ >> + struct led_classdev *led_cdev = mcled_cdev->led_cdev; >> + u32 color_id; >> + int ret; >> + int i, j = 0; >> + >> + data->color_kobj = kobject_create_and_add("colors", >> + &led_cdev->dev->kobj); > Again: use sysfs_create_group(). > >> + if (!data->color_kobj) >> + return -EINVAL; >> + >> + data->mcled_cdev = mcled_cdev; >> + >> + for (i = 0; i < LED_COLOR_ID_MAX; i++) { >> + color_id = (mcled_cdev->available_colors & (1 << i)); >> + if (color_id) { >> + ret = led_multicolor_init_color(data, mcled_cdev, i, j); >> + if (ret) >> + break; >> + >> + j++; >> + } >> + } >> + >> + sysfs_attr_init(&data->color_mix_attr.attr); >> + data->color_mix_attr.attr.name = "color_mix"; >> + data->color_mix_attr.attr.mode = S_IRUGO | S_IWUGO; >> + data->color_mix_attr.store = color_mix_store; >> + ret = sysfs_create_file(data->color_kobj, >> + &data->color_mix_attr.attr); >> + >> + return ret; >> +} >> + >> +int led_classdev_multicolor_register_ext(struct device *parent, >> + struct led_classdev_mc *mcled_cdev, >> + struct led_init_data *init_data) >> +{ >> + struct led_classdev *led_cdev; >> + struct led_classdev_mc_data *data; >> + int ret; >> + >> + if (!mcled_cdev) >> + return -EINVAL; >> + >> + data = kzalloc(sizeof(*data), GFP_KERNEL); >> + if (!data) >> + return -ENOMEM; >> + >> + mcled_cdev->data = data; >> + led_cdev = mcled_cdev->led_cdev; >> + INIT_LIST_HEAD(&data->color_list); >> + >> + /* Register led class device */ >> + ret = led_classdev_register_ext(parent, led_cdev, init_data); >> + if (ret) >> + return ret; >> + >> + return led_multicolor_init_color_dir(data, mcled_cdev); >> +} >> +EXPORT_SYMBOL_GPL(led_classdev_multicolor_register_ext); >> + >> +void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) >> +{ >> + if (!mcled_cdev) >> + return; >> + >> + led_classdev_unregister(mcled_cdev->led_cdev); >> +} >> +EXPORT_SYMBOL_GPL(led_classdev_multicolor_unregister); >> + >> +static void devm_led_classdev_multicolor_release(struct device *dev, void *res) >> +{ >> + led_classdev_multicolor_unregister(*(struct led_classdev_mc **)res); >> +} >> + >> +/** >> + * devm_of_led_classdev_register - resource managed led_classdev_register() >> + * >> + * @parent: parent of LED device >> + * @led_cdev: the led_classdev structure for this device. >> + */ >> +int devm_led_classdev_multicolor_register(struct device *parent, >> + struct led_classdev_mc *mcled_cdev) >> +{ >> + struct led_classdev_mc **dr; >> + int ret; >> + >> + dr = devres_alloc(devm_led_classdev_multicolor_release, >> + sizeof(*dr), GFP_KERNEL); >> + if (!dr) >> + return -ENOMEM; >> + >> + ret = led_classdev_multicolor_register(parent, mcled_cdev); >> + if (ret) { >> + devres_free(dr); >> + return ret; >> + } >> + >> + *dr = mcled_cdev; >> + devres_add(parent, dr); >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(devm_led_classdev_multicolor_register); >> + >> +static int devm_led_classdev_multicolor_match(struct device *dev, >> + void *res, void *data) >> +{ >> + struct mcled_cdev **p = res; >> + >> + if (WARN_ON(!p || !*p)) >> + return 0; >> + >> + return *p == data; >> +} >> + >> +/** >> + * devm_led_classdev_multicolor_unregister() - resource managed >> + * led_classdev_multicolor_unregister() >> + * @parent: The device to unregister. >> + * @mcled_cdev: the led_classdev_mc structure for this device. >> + */ >> +void devm_led_classdev_multicolor_unregister(struct device *dev, >> + struct led_classdev_mc *mcled_cdev) >> +{ >> + WARN_ON(devres_release(dev, >> + devm_led_classdev_multicolor_release, >> + devm_led_classdev_multicolor_match, mcled_cdev)); >> +} >> +EXPORT_SYMBOL_GPL(devm_led_classdev_multicolor_unregister); >> + >> +MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); >> +MODULE_DESCRIPTION("Multi Color LED class interface"); >> +MODULE_LICENSE("GPL v2"); >> diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h >> new file mode 100644 >> index 000000000000..193ba0e46042 >> --- /dev/null >> +++ b/include/linux/led-class-multicolor.h >> @@ -0,0 +1,96 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +/* LED Multicolor class interface >> + * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ >> + */ >> + >> +#ifndef __LINUX_MULTICOLOR_LEDS_H_INCLUDED >> +#define __LINUX_MULTICOLOR_LEDS_H_INCLUDED >> + >> +#include <linux/leds.h> >> +#include <dt-bindings/leds/common.h> >> + >> +struct led_classdev_mc; >> + >> +struct led_classdev_mc_data { >> + struct led_classdev_mc *mcled_cdev; >> + >> + struct kobject *color_kobj; >> + struct kobject *led_kobj; >> + >> + struct device_attribute color_mix_attr; >> + >> + struct list_head color_list; >> + >> + enum led_brightness cluster_brightness; >> +}; >> + >> +struct led_multicolor_ops { >> + /* Set brightness for a specific color id */ >> + int (*set_color_brightness)(struct led_classdev_mc *mcled_cdev, >> + int color_id, int value); >> + /* Read current color setting */ >> + int (*get_color_brightness)(struct led_classdev_mc *mcled_cdev, >> + int color_id); >> +}; >> + >> +struct led_classdev_mc { >> + /* led class device */ >> + struct led_classdev *led_cdev; >> + >> + /* multicolor led specific ops */ >> + struct led_multicolor_ops *ops; >> + >> + struct led_classdev_mc_data *data; >> + >> + unsigned long available_colors; >> + int num_leds; >> +}; >> + >> +static inline struct led_classdev_mc *lcdev_to_mccdev( >> + struct led_classdev *lcdev) >> +{ >> + return container_of(lcdev, struct led_classdev_mc, led_cdev); >> +} >> + >> +/** >> + * led_classdev_multicolor_register_ext - register a new object of led_classdev >> + * class with support for multicolor LEDs >> + * @parent: the multicolor LED to register >> + * @mcled_cdev: the led_classdev_mc structure for this device >> + * @init_data: the LED class Multi color device initialization data >> + * >> + * Returns: 0 on success or negative error value on failure >> + */ >> +extern int led_classdev_multicolor_register_ext(struct device *parent, >> + struct led_classdev_mc *mcled_cdev, >> + struct led_init_data *init_data); >> + >> +#define led_classdev_multicolor_register(parent, mcled_cdev) \ >> + led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL) >> + >> +/** >> + * led_classdev_multicolor_unregister - unregisters an object of led_classdev >> + * class with support for multicolor LEDs >> + * @mcled_cdev: the multicolor LED to unregister >> + * >> + * Unregister a previously registered via led_classdev_multicolor_register >> + * object >> + */ >> +extern void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev); >> + >> +extern int devm_led_classdev_multicolor_register(struct device *parent, >> + struct led_classdev_mc *mcled_cdev); >> + >> +extern void devm_led_classdev_multicolor_unregister(struct device *parent, >> + struct led_classdev_mc *mcled_cdev); >> + >> +/* Set brightness for the monochrome LED cluster */ >> +extern void led_mc_set_cluster_brightness(struct led_classdev_mc *mcled_cdev, >> + enum led_brightness brightness, >> + int adj_value[]); >> + >> +/* Read current cluster brightness */ >> +extern void led_mc_get_cluster_brightness(struct led_classdev_mc *mcled_cdev, >> + int brightness_val[]); >> + >> +#endif /* __LINUX_MULTICOLOR_LEDS_H_INCLUDED */ >> ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition 2019-09-15 16:20 ` Jacek Anaszewski 2019-09-16 14:04 ` Dan Murphy @ 2019-09-16 18:34 ` Dan Murphy 2019-09-16 20:18 ` Jacek Anaszewski 1 sibling, 1 reply; 24+ messages in thread From: Dan Murphy @ 2019-09-16 18:34 UTC (permalink / raw) To: Jacek Anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel Jacek On 9/15/19 11:20 AM, Jacek Anaszewski wrote: > >> + >> +static int led_multicolor_init_color(struct led_classdev_mc_data *data, >> + struct led_classdev_mc *mcled_cdev, >> + int color_id, int color_index) >> +{ >> + struct led_classdev *led_cdev = mcled_cdev->led_cdev; >> + struct led_classdev_mc_priv *mc_priv; >> + int ret; >> + >> + mc_priv = devm_kzalloc(led_cdev->dev, sizeof(*mc_priv), GFP_KERNEL); >> + if (!mc_priv) >> + return -ENOMEM; >> + >> + mc_priv->led_color_id = color_id; >> + mc_priv->mcled_cdev = mcled_cdev; >> + >> + data->led_kobj = kobject_create_and_add(led_colors[color_id], >> + data->color_kobj); > No change here since previous version? What prevents you from following > what has been done for drivers/usb/core/ledtrig-usbport.c? > > Use sysfs_create_group() for creating color dir > and sysfs_add_file_to_group() for adding files to it. We have nested directories here. colors is a directory and then the LED color is a directory. So I am not sure how to create a group under another group without the colors directory kobj. Wondering if you know of any examples? Dan ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition 2019-09-16 18:34 ` Dan Murphy @ 2019-09-16 20:18 ` Jacek Anaszewski 0 siblings, 0 replies; 24+ messages in thread From: Jacek Anaszewski @ 2019-09-16 20:18 UTC (permalink / raw) To: Dan Murphy, pavel; +Cc: robh+dt, linux-leds, linux-kernel On 9/16/19 8:34 PM, Dan Murphy wrote: > Jacek > > On 9/15/19 11:20 AM, Jacek Anaszewski wrote: >> >>> + >>> +static int led_multicolor_init_color(struct led_classdev_mc_data *data, >>> + struct led_classdev_mc *mcled_cdev, >>> + int color_id, int color_index) >>> +{ >>> + struct led_classdev *led_cdev = mcled_cdev->led_cdev; >>> + struct led_classdev_mc_priv *mc_priv; >>> + int ret; >>> + >>> + mc_priv = devm_kzalloc(led_cdev->dev, sizeof(*mc_priv), >>> GFP_KERNEL); >>> + if (!mc_priv) >>> + return -ENOMEM; >>> + >>> + mc_priv->led_color_id = color_id; >>> + mc_priv->mcled_cdev = mcled_cdev; >>> + >>> + data->led_kobj = kobject_create_and_add(led_colors[color_id], >>> + data->color_kobj); >> No change here since previous version? What prevents you from following >> what has been done for drivers/usb/core/ledtrig-usbport.c? >> >> Use sysfs_create_group() for creating color dir >> and sysfs_add_file_to_group() for adding files to it. > > We have nested directories here. colors is a directory and then the LED > color is a directory. > > So I am not sure how to create a group under another group without the > colors directory kobj. > > Wondering if you know of any examples? Hmm, that indeed seems not to be allowed. kobject_create_and_add() seems to be the only solution to achieve nested directories. Nonetheless we will have to first justify the need for that to Greg. -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v5 7/9] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy ` (5 preceding siblings ...) 2019-09-11 18:01 ` [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-11 18:01 ` [PATCH v5 8/9] leds: lp50xx: Add the LP50XX family of the RGB LED driver Dan Murphy 2019-09-11 18:01 ` [PATCH v5 9/9] leds: Update the lp55xx to use the multi color framework Dan Murphy 8 siblings, 0 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Introduce the bindings for the Texas Instruments LP5036, LP5030, LP5024, LP5018, LP5012 and LP5009 RGB LED device driver. The LP5036/30/24/18/12/9 can control RGB LEDs individually or as part of a control bank group. These devices have the ability to adjust the mixing control for the RGB LEDs to obtain different colors independent of the overall brightness of the LED grouping. Datasheet: http://www.ti.com/lit/ds/symlink/lp5012.pdf http://www.ti.com/lit/ds/symlink/lp5024.pdf http://www.ti.com/lit/ds/symlink/lp5036.pdf Signed-off-by: Dan Murphy <dmurphy@ti.com> --- .../devicetree/bindings/leds/leds-lp50xx.txt | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-lp50xx.txt diff --git a/Documentation/devicetree/bindings/leds/leds-lp50xx.txt b/Documentation/devicetree/bindings/leds/leds-lp50xx.txt new file mode 100644 index 000000000000..9d05f43042e0 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-lp50xx.txt @@ -0,0 +1,148 @@ +* Texas Instruments - LP5009/12/18/24/30/36 RGB LED driver + +The LP50XX is multi-channel, I2C RGB LED Drivers that can group RGB LEDs into +a LED group or control them individually. + +The difference in these RGB LED drivers is the number of supported RGB modules. + +Required parent properties: + - compatible: + "ti,lp5009" + "ti,lp5012" + "ti,lp5018" + "ti,lp5024" + "ti,lp5030" + "ti,lp5036" + - reg : I2C slave address + lp5009/12 - 0x28 + lp5018/24 - 0x28 + lp5030/36 - 0x30 + - #address-cells : 1 + - #size-cells : 0 + +Optional parent properties: + - enable-gpios : gpio pin to enable/disable the device. + - vled-supply : LED supply + +Required child properties: + - #address-cells : 1 + - #size-cells : 0 + - reg : This is the LED module number. + - color : see Documentation/devicetree/bindings/leds/common.txt + - function : see Documentation/devicetree/bindings/leds/common.txt + +Required child properties only is LED modules will be banked: + - ti,led-bank : This property denotes the LED module numbers that will + be controlled as a single RGB cluster. Each LED module + number will be controlled by a single LED class instance. + There can only be one instance of the ti,led-bank + property for each device node. + +Required grandchildren properties: + - reg : A single entry denoting the LED module that controls + the RGB cluster. + - color : see Documentation/devicetree/bindings/leds/leds-multicolor.txt + - led-sources : see Documentation/devicetree/bindings/leds/common.txt + +The LED outputs associated with the LED modules are defined in Table 1 of the +corresponding data sheets. + +LP5009 - 2 Total RGB cluster LED outputs 0-1 +LP5012 - 4 Total RGB cluster LED outputs 0-3 +LP5018 - 6 Total RGB cluster LED outputs 0-5 +LP5024 - 8 Total RGB cluster LED outputs 0-7 +LP5030 - 10 Total RGB cluster LED outputs 0-9 +LP5036 - 12 Total RGB cluster LED outputs 0-11 + +Optional child properties: + - label : see Documentation/devicetree/bindings/leds/common.txt + - linux,default-trigger : + see Documentation/devicetree/bindings/leds/common.txt + +Examples: +led-controller@29 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "ti,lp5024"; + reg = <0x29>; + enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + vled-supply = <&vmmcsd_fixed>; + + multi-led@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + color = <LED_COLOR_ID_MULTI>; + function = LED_FUNCTION_STATUS; + + led@3 { + reg = <3>; + color = <LED_COLOR_ID_RED>; + }; + + led@4 { + reg = <4>; + color = <LED_COLOR_ID_GREEN>; + }; + + led@5 { + reg = <5>; + color = <LED_COLOR_ID_BLUE>; + }; + }; + + multi-led@2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + color = <LED_COLOR_ID_MULTI>; + function = LED_FUNCTION_STANDBY; + ti,led-bank = <2 3 5>; + + led@6 { + reg = <0x6>; + color = <LED_COLOR_ID_RED>; + led-sources = <6 9 15>; + }; + + led@7 { + reg = <0x7>; + color = <LED_COLOR_ID_GREEN>; + led-sources = <7 10 16>; + }; + + led@8 { + reg = <0x8>; + color = <LED_COLOR_ID_BLUE>; + led-sources = <8 11 17>; + }; + }; + + multi-led@4 { + #address-cells = <1>; + #size-cells = <0>; + reg = <4>; + color = <LED_COLOR_ID_MULTI>; + function = LED_FUNCTION_ACTIVITY; + + led@12 { + reg = <12>; + color = <LED_COLOR_ID_RED>; + }; + + led@13 { + reg = <13>; + color = <LED_COLOR_ID_GREEN>; + }; + + led@14 { + reg = <14>; + color = <LED_COLOR_ID_BLUE>; + }; + }; +}; + +For more product information please see the link below: +http://www.ti.com/lit/ds/symlink/lp5012.pdf +http://www.ti.com/lit/ds/symlink/lp5024.pdf +http://www.ti.com/lit/ds/symlink/lp5036.pdf -- 2.22.0.214.g8dca754b1e ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 8/9] leds: lp50xx: Add the LP50XX family of the RGB LED driver 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy ` (6 preceding siblings ...) 2019-09-11 18:01 ` [PATCH v5 7/9] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-11 18:01 ` [PATCH v5 9/9] leds: Update the lp55xx to use the multi color framework Dan Murphy 8 siblings, 0 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Introduce the LP5036/30/24/18/12/9 RGB LED driver. The difference in these parts are the number of LED outputs where the: LP5036 can control 36 LEDs LP5030 can control 30 LEDs LP5024 can control 24 LEDs LP5018 can control 18 LEDs LP5012 can control 12 LEDs LP509 can control 9 LEDs The device has the ability to group LED output into control banks so that multiple LED banks can be controlled with the same mixing and brightness. Inversely the LEDs can also be controlled independently. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- drivers/leds/Kconfig | 7 + drivers/leds/Makefile | 1 + drivers/leds/leds-lp50xx.c | 807 +++++++++++++++++++++++++++++++++++++ 3 files changed, 815 insertions(+) create mode 100644 drivers/leds/leds-lp50xx.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 71e7fd4f6f15..1041dfe8e354 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -350,6 +350,13 @@ config LEDS_LP3952 To compile this driver as a module, choose M here: the module will be called leds-lp3952. +config LEDS_LP50XX + tristate "LED Support for TI LP5036/30/24/18 LED driver chip" + depends on LEDS_CLASS && REGMAP_I2C + help + If you say yes here you get support for the Texas Instruments + LP5036, LP5030, LP5024 and LP5018 LED driver. + config LEDS_LP55XX_COMMON tristate "Common Driver for TI/National LP5521/5523/55231/5562/8501" depends on LEDS_LP5521 || LEDS_LP5523 || LEDS_LP5562 || LEDS_LP8501 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 897b810257dd..438a5499f3ee 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o obj-$(CONFIG_LEDS_LP3952) += leds-lp3952.o +obj-$(CONFIG_LEDS_LP50XX) += leds-lp50xx.o obj-$(CONFIG_LEDS_LP55XX_COMMON) += leds-lp55xx-common.o obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o obj-$(CONFIG_LEDS_LP5523) += leds-lp5523.o diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c new file mode 100644 index 000000000000..8a6cb559112f --- /dev/null +++ b/drivers/leds/leds-lp50xx.c @@ -0,0 +1,807 @@ +// SPDX-License-Identifier: GPL-2.0 +// TI LP50XX LED chip family driver +// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/ + +#include <linux/gpio/consumer.h> +#include <linux/i2c.h> +#include <linux/init.h> +#include <linux/leds.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/of_gpio.h> +#include <linux/regmap.h> +#include <linux/regulator/consumer.h> +#include <linux/slab.h> +#include <uapi/linux/uleds.h> + +#include <linux/led-class-multicolor.h> + +#define LP50XX_DEV_CFG0 0x00 +#define LP50XX_DEV_CFG1 0x01 +#define LP50XX_LED_CFG0 0x02 + +/* LP5009 and LP5012 registers */ +#define LP5012_BNK_BRT 0x03 +#define LP5012_BNKA_CLR 0x04 +#define LP5012_BNKB_CLR 0x05 +#define LP5012_BNKC_CLR 0x06 +#define LP5012_LED0_BRT 0x07 +#define LP5012_LED1_BRT 0x08 +#define LP5012_LED2_BRT 0x09 +#define LP5012_LED3_BRT 0x0a +#define LP5012_OUT0_CLR 0x0b +#define LP5012_OUT1_CLR 0x0c +#define LP5012_OUT2_CLR 0x0d +#define LP5012_OUT3_CLR 0x0e +#define LP5012_OUT4_CLR 0x0f +#define LP5012_OUT5_CLR 0x10 +#define LP5012_OUT6_CLR 0x11 +#define LP5012_OUT7_CLR 0x12 +#define LP5012_OUT8_CLR 0x13 +#define LP5012_OUT9_CLR 0x14 +#define LP5012_OUT10_CLR 0x15 +#define LP5012_OUT11_CLR 0x16 +#define LP5012_RESET 0x17 + +/* LP5018 and LP5024 registers */ +#define LP5024_BNK_BRT 0x03 +#define LP5024_BNKA_CLR 0x04 +#define LP5024_BNKB_CLR 0x05 +#define LP5024_BNKC_CLR 0x06 +#define LP5024_LED0_BRT 0x07 +#define LP5024_LED1_BRT 0x08 +#define LP5024_LED2_BRT 0x09 +#define LP5024_LED3_BRT 0x0a +#define LP5024_LED4_BRT 0x0b +#define LP5024_LED5_BRT 0x0c +#define LP5024_LED6_BRT 0x0d +#define LP5024_LED7_BRT 0x0e + +#define LP5024_OUT0_CLR 0x0f +#define LP5024_OUT1_CLR 0x10 +#define LP5024_OUT2_CLR 0x11 +#define LP5024_OUT3_CLR 0x12 +#define LP5024_OUT4_CLR 0x13 +#define LP5024_OUT5_CLR 0x14 +#define LP5024_OUT6_CLR 0x15 +#define LP5024_OUT7_CLR 0x16 +#define LP5024_OUT8_CLR 0x17 +#define LP5024_OUT9_CLR 0x18 +#define LP5024_OUT10_CLR 0x19 +#define LP5024_OUT11_CLR 0x1a +#define LP5024_OUT12_CLR 0x1b +#define LP5024_OUT13_CLR 0x1c +#define LP5024_OUT14_CLR 0x1d +#define LP5024_OUT15_CLR 0x1e +#define LP5024_OUT16_CLR 0x1f +#define LP5024_OUT17_CLR 0x20 +#define LP5024_OUT18_CLR 0x21 +#define LP5024_OUT19_CLR 0x22 +#define LP5024_OUT20_CLR 0x23 +#define LP5024_OUT21_CLR 0x24 +#define LP5024_OUT22_CLR 0x25 +#define LP5024_OUT23_CLR 0x26 +#define LP5024_RESET 0x27 + +/* LP5030 and LP5036 registers */ +#define LP5036_LED_CFG1 0x03 +#define LP5036_BNK_BRT 0x04 +#define LP5036_BNKA_CLR 0x05 +#define LP5036_BNKB_CLR 0x06 +#define LP5036_BNKC_CLR 0x07 +#define LP5036_LED0_BRT 0x08 +#define LP5036_LED1_BRT 0x09 +#define LP5036_LED2_BRT 0x0a +#define LP5036_LED3_BRT 0x0b +#define LP5036_LED4_BRT 0x0c +#define LP5036_LED5_BRT 0x0d +#define LP5036_LED6_BRT 0x0e +#define LP5036_LED7_BRT 0x0f +#define LP5036_LED8_BRT 0x10 +#define LP5036_LED9_BRT 0x11 +#define LP5036_LED10_BRT 0x12 +#define LP5036_LED11_BRT 0x13 + +#define LP5036_OUT0_CLR 0x14 +#define LP5036_OUT1_CLR 0x15 +#define LP5036_OUT2_CLR 0x16 +#define LP5036_OUT3_CLR 0x17 +#define LP5036_OUT4_CLR 0x18 +#define LP5036_OUT5_CLR 0x19 +#define LP5036_OUT6_CLR 0x1a +#define LP5036_OUT7_CLR 0x1b +#define LP5036_OUT8_CLR 0x1c +#define LP5036_OUT9_CLR 0x1d +#define LP5036_OUT10_CLR 0x1e +#define LP5036_OUT11_CLR 0x1f +#define LP5036_OUT12_CLR 0x20 +#define LP5036_OUT13_CLR 0x21 +#define LP5036_OUT14_CLR 0x22 +#define LP5036_OUT15_CLR 0x23 +#define LP5036_OUT16_CLR 0x24 +#define LP5036_OUT17_CLR 0x25 +#define LP5036_OUT18_CLR 0x26 +#define LP5036_OUT19_CLR 0x27 +#define LP5036_OUT20_CLR 0x28 +#define LP5036_OUT21_CLR 0x29 +#define LP5036_OUT22_CLR 0x2a +#define LP5036_OUT23_CLR 0x2b +#define LP5036_OUT24_CLR 0x2c +#define LP5036_OUT25_CLR 0x2d +#define LP5036_OUT26_CLR 0x2e +#define LP5036_OUT27_CLR 0x2f +#define LP5036_OUT28_CLR 0x30 +#define LP5036_OUT29_CLR 0x31 +#define LP5036_OUT30_CLR 0x32 +#define LP5036_OUT31_CLR 0x33 +#define LP5036_OUT32_CLR 0x34 +#define LP5036_OUT33_CLR 0x35 +#define LP5036_OUT34_CLR 0x36 +#define LP5036_OUT35_CLR 0x37 +#define LP5036_RESET 0x38 + +#define LP50XX_SW_RESET 0xff +#define LP50XX_CHIP_EN BIT(6) + +#define LP5009_MAX_LED_MODULES 2 +#define LP5012_MAX_LED_MODULES 4 +#define LP5018_MAX_LED_MODULES 6 +#define LP5024_MAX_LED_MODULES 8 +#define LP5030_MAX_LED_MODULES 10 +#define LP5036_MAX_LED_MODULES 12 + +struct lp50xx_led { + struct led_classdev led_dev; + struct led_classdev_mc mc_cdev; + struct lp50xx *priv; + unsigned long bank_modules; + char label[LED_MAX_NAME_SIZE]; + u8 ctrl_bank_enabled; + u32 available_leds; + int led_number; +}; + +/** + * struct lp50xx - + * @enable_gpio: Hardware enable gpio + * @regulator: LED supply regulator pointer + * @client: Pointer to the I2C client + * @regmap: Devices register map + * @dev: Pointer to the devices device struct + * @lock: Lock for reading/writing the device + * @chip_info: chip specific information (ie num_leds) + * @num_of_banked_leds: holds the number of banked LEDs + * @leds: Array of LED strings + */ +struct lp50xx { + struct gpio_desc *enable_gpio; + struct regulator *regulator; + struct i2c_client *client; + struct regmap *regmap; + struct device *dev; + struct mutex lock; + const struct lp50xx_chip_info *chip_info; + int num_of_banked_leds; + + /* This needs to be at the end of the struct */ + struct lp50xx_led leds[]; +}; + +static const struct reg_default lp5012_reg_defs[] = { + {LP50XX_DEV_CFG0, 0x0}, + {LP50XX_DEV_CFG1, 0x3c}, + {LP50XX_LED_CFG0, 0x0}, + {LP5012_BNK_BRT, 0xff}, + {LP5012_BNKA_CLR, 0x0f}, + {LP5012_BNKB_CLR, 0x0f}, + {LP5012_BNKC_CLR, 0x0f}, + {LP5012_LED0_BRT, 0x0f}, + {LP5012_LED1_BRT, 0xff}, + {LP5012_LED2_BRT, 0xff}, + {LP5012_LED3_BRT, 0xff}, + {LP5012_OUT0_CLR, 0x0f}, + {LP5012_OUT1_CLR, 0x00}, + {LP5012_OUT2_CLR, 0x00}, + {LP5012_OUT3_CLR, 0x00}, + {LP5012_OUT4_CLR, 0x00}, + {LP5012_OUT5_CLR, 0x00}, + {LP5012_OUT6_CLR, 0x00}, + {LP5012_OUT7_CLR, 0x00}, + {LP5012_OUT8_CLR, 0x00}, + {LP5012_OUT9_CLR, 0x00}, + {LP5012_OUT10_CLR, 0x00}, + {LP5012_OUT11_CLR, 0x00}, + {LP5012_RESET, 0x00} +}; + +static const struct reg_default lp5024_reg_defs[] = { + {LP50XX_DEV_CFG0, 0x0}, + {LP50XX_DEV_CFG1, 0x3c}, + {LP50XX_LED_CFG0, 0x0}, + {LP5024_BNK_BRT, 0xff}, + {LP5024_BNKA_CLR, 0x0f}, + {LP5024_BNKB_CLR, 0x0f}, + {LP5024_BNKC_CLR, 0x0f}, + {LP5024_LED0_BRT, 0x0f}, + {LP5024_LED1_BRT, 0xff}, + {LP5024_LED2_BRT, 0xff}, + {LP5024_LED3_BRT, 0xff}, + {LP5024_LED4_BRT, 0xff}, + {LP5024_LED5_BRT, 0xff}, + {LP5024_LED6_BRT, 0xff}, + {LP5024_LED7_BRT, 0xff}, + {LP5024_OUT0_CLR, 0x0f}, + {LP5024_OUT1_CLR, 0x00}, + {LP5024_OUT2_CLR, 0x00}, + {LP5024_OUT3_CLR, 0x00}, + {LP5024_OUT4_CLR, 0x00}, + {LP5024_OUT5_CLR, 0x00}, + {LP5024_OUT6_CLR, 0x00}, + {LP5024_OUT7_CLR, 0x00}, + {LP5024_OUT8_CLR, 0x00}, + {LP5024_OUT9_CLR, 0x00}, + {LP5024_OUT10_CLR, 0x00}, + {LP5024_OUT11_CLR, 0x00}, + {LP5024_OUT12_CLR, 0x00}, + {LP5024_OUT13_CLR, 0x00}, + {LP5024_OUT14_CLR, 0x00}, + {LP5024_OUT15_CLR, 0x00}, + {LP5024_OUT16_CLR, 0x00}, + {LP5024_OUT17_CLR, 0x00}, + {LP5024_OUT18_CLR, 0x00}, + {LP5024_OUT19_CLR, 0x00}, + {LP5024_OUT20_CLR, 0x00}, + {LP5024_OUT21_CLR, 0x00}, + {LP5024_OUT22_CLR, 0x00}, + {LP5024_OUT23_CLR, 0x00}, + {LP5024_RESET, 0x00} +}; + +static const struct reg_default lp5036_reg_defs[] = { + {LP50XX_DEV_CFG0, 0x0}, + {LP50XX_DEV_CFG1, 0x3c}, + {LP50XX_LED_CFG0, 0x0}, + {LP5036_LED_CFG1, 0x0}, + {LP5036_BNK_BRT, 0xff}, + {LP5036_BNKA_CLR, 0x0f}, + {LP5036_BNKB_CLR, 0x0f}, + {LP5036_BNKC_CLR, 0x0f}, + {LP5036_LED0_BRT, 0x0f}, + {LP5036_LED1_BRT, 0xff}, + {LP5036_LED2_BRT, 0xff}, + {LP5036_LED3_BRT, 0xff}, + {LP5036_LED4_BRT, 0xff}, + {LP5036_LED5_BRT, 0xff}, + {LP5036_LED6_BRT, 0xff}, + {LP5036_LED7_BRT, 0xff}, + {LP5036_OUT0_CLR, 0x0f}, + {LP5036_OUT1_CLR, 0x00}, + {LP5036_OUT2_CLR, 0x00}, + {LP5036_OUT3_CLR, 0x00}, + {LP5036_OUT4_CLR, 0x00}, + {LP5036_OUT5_CLR, 0x00}, + {LP5036_OUT6_CLR, 0x00}, + {LP5036_OUT7_CLR, 0x00}, + {LP5036_OUT8_CLR, 0x00}, + {LP5036_OUT9_CLR, 0x00}, + {LP5036_OUT10_CLR, 0x00}, + {LP5036_OUT11_CLR, 0x00}, + {LP5036_OUT12_CLR, 0x00}, + {LP5036_OUT13_CLR, 0x00}, + {LP5036_OUT14_CLR, 0x00}, + {LP5036_OUT15_CLR, 0x00}, + {LP5036_OUT16_CLR, 0x00}, + {LP5036_OUT17_CLR, 0x00}, + {LP5036_OUT18_CLR, 0x00}, + {LP5036_OUT19_CLR, 0x00}, + {LP5036_OUT20_CLR, 0x00}, + {LP5036_OUT21_CLR, 0x00}, + {LP5036_OUT22_CLR, 0x00}, + {LP5036_OUT23_CLR, 0x00}, + {LP5036_OUT24_CLR, 0x00}, + {LP5036_OUT25_CLR, 0x00}, + {LP5036_OUT26_CLR, 0x00}, + {LP5036_OUT27_CLR, 0x00}, + {LP5036_OUT28_CLR, 0x00}, + {LP5036_OUT29_CLR, 0x00}, + {LP5036_OUT30_CLR, 0x00}, + {LP5036_OUT31_CLR, 0x00}, + {LP5036_OUT32_CLR, 0x00}, + {LP5036_OUT33_CLR, 0x00}, + {LP5036_OUT34_CLR, 0x00}, + {LP5036_OUT35_CLR, 0x00}, + {LP5036_RESET, 0x00} +}; + +static const struct regmap_config lp5012_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LP5012_RESET, + .reg_defaults = lp5012_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lp5012_reg_defs), + .cache_type = REGCACHE_RBTREE, +}; + +static const struct regmap_config lp5024_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LP5024_RESET, + .reg_defaults = lp5024_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lp5024_reg_defs), + .cache_type = REGCACHE_RBTREE, +}; + +static const struct regmap_config lp5036_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = LP5036_RESET, + .reg_defaults = lp5036_reg_defs, + .num_reg_defaults = ARRAY_SIZE(lp5036_reg_defs), + .cache_type = REGCACHE_RBTREE, +}; + +enum lp50xx_model { + LP5009, + LP5012, + LP5018, + LP5024, + LP5030, + LP5036, +}; + +/* + * struct lp50xx_chip_info - + * @num_leds: number of LED outputs available on the device + * @led_brightness0_reg: first brightness register of the device + * @mix_out0_reg: first color mix register of the device + * @bank_brt_reg: bank brightness register + * @bank_mix_reg: color mix register + * @reset_reg: devices reset register + */ +struct lp50xx_chip_info { + struct regmap_config lp50xx_regmap_config; + u8 num_leds; + u8 led_brightness0_reg; + u8 mix_out0_reg; + u8 bank_brt_reg; + u8 bank_mix_reg; + u8 reset_reg; +}; + +static const struct lp50xx_chip_info lp50xx_chip_info_tbl[] = { + [LP5009] = { + .num_leds = LP5009_MAX_LED_MODULES, + .led_brightness0_reg = LP5012_LED0_BRT, + .mix_out0_reg = LP5012_OUT0_CLR, + .bank_brt_reg = LP5012_BNK_BRT, + .bank_mix_reg = LP5012_BNKA_CLR, + .reset_reg = LP5012_RESET, + .lp50xx_regmap_config = lp5012_regmap_config, + }, + [LP5012] = { + .num_leds = LP5012_MAX_LED_MODULES, + .led_brightness0_reg = LP5012_LED0_BRT, + .mix_out0_reg = LP5012_OUT0_CLR, + .bank_brt_reg = LP5012_BNK_BRT, + .bank_mix_reg = LP5012_BNKA_CLR, + .reset_reg = LP5012_RESET, + .lp50xx_regmap_config = lp5012_regmap_config, + }, + [LP5018] = { + .num_leds = LP5018_MAX_LED_MODULES, + .led_brightness0_reg = LP5024_LED0_BRT, + .mix_out0_reg = LP5024_OUT0_CLR, + .bank_brt_reg = LP5024_BNK_BRT, + .bank_mix_reg = LP5024_BNKA_CLR, + .reset_reg = LP5024_RESET, + .lp50xx_regmap_config = lp5024_regmap_config, + }, + [LP5024] = { + .num_leds = LP5024_MAX_LED_MODULES, + .led_brightness0_reg = LP5024_LED0_BRT, + .mix_out0_reg = LP5024_OUT0_CLR, + .bank_brt_reg = LP5024_BNK_BRT, + .bank_mix_reg = LP5024_BNKA_CLR, + .reset_reg = LP5024_RESET, + .lp50xx_regmap_config = lp5024_regmap_config, + }, + [LP5030] = { + .num_leds = LP5030_MAX_LED_MODULES, + .led_brightness0_reg = LP5036_LED0_BRT, + .mix_out0_reg = LP5036_OUT0_CLR, + .bank_brt_reg = LP5036_BNK_BRT, + .bank_mix_reg = LP5036_BNKA_CLR, + .reset_reg = LP5036_RESET, + .lp50xx_regmap_config = lp5036_regmap_config, + }, + [LP5036] = { + .num_leds = LP5036_MAX_LED_MODULES, + .led_brightness0_reg = LP5036_LED0_BRT, + .mix_out0_reg = LP5036_OUT0_CLR, + .bank_brt_reg = LP5036_BNK_BRT, + .bank_mix_reg = LP5036_BNKA_CLR, + .reset_reg = LP5036_RESET, + .lp50xx_regmap_config = lp5036_regmap_config, + }, +}; + +static struct lp50xx_led *mcled_cdev_to_led(struct led_classdev_mc *mcled_cdev) +{ + return container_of(mcled_cdev, struct lp50xx_led, mc_cdev); +} + +static int lp50xx_brightness_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct lp50xx_led *led = container_of(cdev, struct lp50xx_led, led_dev); + int ret = 0; + u8 reg_val; + + mutex_lock(&led->priv->lock); + + if (led->ctrl_bank_enabled) + reg_val = led->priv->chip_info->bank_brt_reg; + else + reg_val = led->priv->chip_info->led_brightness0_reg + + led->led_number; + + ret = regmap_write(led->priv->regmap, reg_val, brightness); + + mutex_unlock(&led->priv->lock); + + return ret; +} + +static enum led_brightness lp50xx_brightness_get(struct led_classdev *cdev) +{ + struct lp50xx_led *led = container_of(cdev, struct lp50xx_led, led_dev); + unsigned int brt_val; + u8 reg_val; + int ret; + + mutex_lock(&led->priv->lock); + + if (led->ctrl_bank_enabled) + reg_val = led->priv->chip_info->bank_brt_reg; + else + reg_val = led->priv->chip_info->led_brightness0_reg + led->led_number; + + ret = regmap_read(led->priv->regmap, reg_val, &brt_val); + + mutex_unlock(&led->priv->lock); + + return brt_val; +} + +static int lp50xx_get_color(struct led_classdev_mc *mcled_cdev, int color) +{ + struct lp50xx_led *led = mcled_cdev_to_led(mcled_cdev); + struct lp50xx *priv = led->priv; + u8 led_offset, reg_number, reg_color_off; + unsigned int value; + int ret; + + if (color == LED_COLOR_ID_RED) + reg_color_off = 0; + else if (color == LED_COLOR_ID_GREEN) + reg_color_off = 1; + else if (color == LED_COLOR_ID_BLUE) + reg_color_off = 2; + else + goto out; + + if (led->ctrl_bank_enabled) { + reg_number = priv->chip_info->bank_mix_reg + reg_color_off; + } else { + led_offset = (led->led_number * 3) + reg_color_off; + reg_number = priv->chip_info->mix_out0_reg + led_offset; + } + + ret = regmap_read(led->priv->regmap, reg_number, &value); + if (ret) { + dev_err(&priv->client->dev, "Cannot write LED value\n"); + goto out; + } +out: + return value; +} + +static int lp50xx_set_color(struct led_classdev_mc *mcled_cdev, + int color, int value) +{ + struct lp50xx_led *led = mcled_cdev_to_led(mcled_cdev); + struct lp50xx *priv = led->priv; + u8 led_offset, reg_number, reg_color_off; + int ret = -EINVAL; + + if (color == LED_COLOR_ID_RED) + reg_color_off = 0; + else if (color == LED_COLOR_ID_GREEN) + reg_color_off = 1; + else if (color == LED_COLOR_ID_BLUE) + reg_color_off = 2; + else + goto out; + + if (led->ctrl_bank_enabled) { + reg_number = priv->chip_info->bank_mix_reg + reg_color_off; + } else { + led_offset = (led->led_number * 3) + reg_color_off; + reg_number = priv->chip_info->mix_out0_reg + led_offset; + } + + ret = regmap_write(priv->regmap, reg_number, value); + if (ret) { + dev_err(&priv->client->dev, "Cannot write LED value\n"); + goto out; + } +out: + return ret; +} + +static struct led_multicolor_ops lp50xx_mc_ops = { + .set_color_brightness = lp50xx_set_color, + .get_color_brightness = lp50xx_get_color, +}; + +static int lp50xx_set_banks(struct lp50xx *priv, u32 led_strings[]) +{ + u8 led_ctrl_enable = 0; + u8 led1_ctrl_enable = 0; + u8 ctrl_ext = 0; + int ret; + int j; + + for (j = 0; j <= priv->chip_info->num_leds - 1; j++) { + if (led_strings[j] > (LP5024_MAX_LED_MODULES - 1)) { + ctrl_ext = led_strings[j] - LP5024_MAX_LED_MODULES; + led1_ctrl_enable |= (1 << ctrl_ext); + } else { + led_ctrl_enable |= (1 << led_strings[j]); + } + } + + ret = regmap_write(priv->regmap, LP50XX_LED_CFG0, led_ctrl_enable); + + if (led1_ctrl_enable) + ret = regmap_write(priv->regmap, LP5036_LED_CFG1, + led1_ctrl_enable); + + return ret; +} + +static int lp50xx_reset(struct lp50xx *priv) +{ + if (priv->enable_gpio) + return gpiod_direction_output(priv->enable_gpio, 1); + else + return regmap_write(priv->regmap, priv->chip_info->reset_reg, + LP50XX_SW_RESET); +} + +static int lp50xx_enable_disable(struct lp50xx *priv, u8 enable_disable) +{ + return regmap_write(priv->regmap, LP50XX_DEV_CFG0, enable_disable); +} + +static int lp50xx_probe_dt(struct lp50xx *priv) +{ + u32 led_strings[LP5036_MAX_LED_MODULES]; + struct fwnode_handle *child = NULL; + struct fwnode_handle *led_node = NULL; + struct led_init_data init_data; + struct lp50xx_led *led; + int num_colors; + u32 color_id; + int led_number; + size_t i = 0; + int ret; + + priv->enable_gpio = devm_gpiod_get_optional(&priv->client->dev, + "enable", GPIOD_OUT_LOW); + if (IS_ERR(priv->enable_gpio)) { + ret = PTR_ERR(priv->enable_gpio); + dev_err(&priv->client->dev, "Failed to get enable gpio: %d\n", + ret); + return ret; + } + + priv->regulator = devm_regulator_get(&priv->client->dev, "vled"); + if (IS_ERR(priv->regulator)) + priv->regulator = NULL; + + device_for_each_child_node(&priv->client->dev, child) { + led = &priv->leds[i]; + if (fwnode_property_present(child, "ti,led-bank")) { + ret = fwnode_property_read_u32_array(child, + "ti,led-bank", + NULL, 0); + ret = fwnode_property_read_u32_array(child, + "ti,led-bank", + led_strings, + ret); + + priv->num_of_banked_leds = ARRAY_SIZE(led_strings); + + ret = lp50xx_set_banks(priv, led_strings); + if (ret) { + dev_err(&priv->client->dev, + "Cannot setup banked LEDs\n"); + fwnode_handle_put(child); + goto child_out; + } + led->ctrl_bank_enabled = 1; + + } else { + ret = fwnode_property_read_u32(child, "reg", + &led_number); + + led->led_number = led_number; + } + if (ret) { + dev_err(&priv->client->dev, + "led sourcing property missing\n"); + fwnode_handle_put(child); + goto child_out; + } + + if (led_number > priv->chip_info->num_leds) { + dev_err(&priv->client->dev, + "led-sources property is invalid\n"); + ret = -EINVAL; + fwnode_handle_put(child); + goto child_out; + } + + init_data.fwnode = child; + init_data.devicename = priv->client->name; + init_data.default_label = ":"; + + fwnode_property_read_string(child, "linux,default-trigger", + &led->led_dev.default_trigger); + num_colors = 0; + + fwnode_for_each_child_node(child, led_node) { + ret = fwnode_property_read_u32(led_node, "color", + &color_id); + if (ret) + dev_err(&priv->client->dev, + "Cannot read color\n"); + + set_bit(color_id, &led->mc_cdev.available_colors); + num_colors++; + + } + + led->priv = priv; + led->mc_cdev.ops = &lp50xx_mc_ops; + led->mc_cdev.num_leds = num_colors; + led->mc_cdev.led_cdev = &led->led_dev; + led->led_dev.brightness_set_blocking = lp50xx_brightness_set; + led->led_dev.brightness_get = lp50xx_brightness_get; + ret = led_classdev_multicolor_register_ext(&priv->client->dev, + &led->mc_cdev, + &init_data); + if (ret) { + dev_err(&priv->client->dev, "led register err: %d\n", + ret); + fwnode_handle_put(child); + goto child_out; + } + i++; + } + +child_out: + return ret; +} + +static int lp50xx_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct lp50xx *led; + int count; + int ret; + + count = device_get_child_node_count(&client->dev); + if (!count) { + dev_err(&client->dev, "LEDs are not defined in device tree!"); + return -ENODEV; + } + + led = devm_kzalloc(&client->dev, struct_size(led, leds, count), + GFP_KERNEL); + if (!led) + return -ENOMEM; + + mutex_init(&led->lock); + led->client = client; + led->dev = &client->dev; + led->chip_info = &lp50xx_chip_info_tbl[id->driver_data]; + i2c_set_clientdata(client, led); + + led->regmap = devm_regmap_init_i2c(client, + &led->chip_info->lp50xx_regmap_config); + if (IS_ERR(led->regmap)) { + ret = PTR_ERR(led->regmap); + dev_err(&client->dev, "Failed to allocate register map: %d\n", + ret); + return ret; + } + + ret = lp50xx_reset(led); + if (ret) + return ret; + + ret = lp50xx_probe_dt(led); + if (ret) + return ret; + + return lp50xx_enable_disable(led, LP50XX_CHIP_EN); +} + +static int lp50xx_remove(struct i2c_client *client) +{ + struct lp50xx *led = i2c_get_clientdata(client); + int ret; + + ret = lp50xx_enable_disable(led, LP50XX_CHIP_EN); + if (ret) { + dev_err(&led->client->dev, "Failed to disable regulator\n"); + return ret; + } + + if (led->enable_gpio) + gpiod_direction_output(led->enable_gpio, 0); + + if (led->regulator) { + ret = regulator_disable(led->regulator); + if (ret) + dev_err(&led->client->dev, + "Failed to disable regulator\n"); + } + + mutex_destroy(&led->lock); + + return 0; +} + +static const struct i2c_device_id lp50xx_id[] = { + { "lp5009", LP5009 }, + { "lp5012", LP5012 }, + { "lp5018", LP5018 }, + { "lp5024", LP5024 }, + { "lp5030", LP5030 }, + { "lp5036", LP5036 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, lp50xx_id); + +static const struct of_device_id of_lp50xx_leds_match[] = { + { .compatible = "ti,lp5009", .data = (void *)LP5009 }, + { .compatible = "ti,lp5012", .data = (void *)LP5012 }, + { .compatible = "ti,lp5018", .data = (void *)LP5018 }, + { .compatible = "ti,lp5024", .data = (void *)LP5024 }, + { .compatible = "ti,lp5030", .data = (void *)LP5030 }, + { .compatible = "ti,lp5036", .data = (void *)LP5036 }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_lp50xx_leds_match); + +static struct i2c_driver lp50xx_driver = { + .driver = { + .name = "lp50xx", + .of_match_table = of_lp50xx_leds_match, + }, + .probe = lp50xx_probe, + .remove = lp50xx_remove, + .id_table = lp50xx_id, +}; +module_i2c_driver(lp50xx_driver); + +MODULE_DESCRIPTION("Texas Instruments LP50XX LED driver"); +MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); +MODULE_LICENSE("GPL v2"); -- 2.22.0.214.g8dca754b1e ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH v5 9/9] leds: Update the lp55xx to use the multi color framework 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy ` (7 preceding siblings ...) 2019-09-11 18:01 ` [PATCH v5 8/9] leds: lp50xx: Add the LP50XX family of the RGB LED driver Dan Murphy @ 2019-09-11 18:01 ` Dan Murphy 2019-09-15 16:28 ` Jacek Anaszewski 8 siblings, 1 reply; 24+ messages in thread From: Dan Murphy @ 2019-09-11 18:01 UTC (permalink / raw) To: jacek.anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel, Dan Murphy Update the lp5523 to use the multi color framework. Signed-off-by: Dan Murphy <dmurphy@ti.com> --- drivers/leds/leds-lp5523.c | 13 +++ drivers/leds/leds-lp55xx-common.c | 131 ++++++++++++++++++---- drivers/leds/leds-lp55xx-common.h | 9 ++ include/linux/platform_data/leds-lp55xx.h | 6 + modules.builtin.modinfo | Bin 0 -> 43550 bytes 5 files changed, 137 insertions(+), 22 deletions(-) create mode 100644 modules.builtin.modinfo diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index d0b931a136b9..8b2cdb98fed6 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -791,6 +791,18 @@ static ssize_t store_master_fader_leds(struct device *dev, return ret; } +static int lp5523_led_intensity(struct lp55xx_led *led, int chan_num) +{ + struct lp55xx_chip *chip = led->chip; + int ret; + + mutex_lock(&chip->lock); + ret = lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + chan_num, + led->brightness); + mutex_unlock(&chip->lock); + return ret; +} + static int lp5523_led_brightness(struct lp55xx_led *led) { struct lp55xx_chip *chip = led->chip; @@ -857,6 +869,7 @@ static struct lp55xx_device_config lp5523_cfg = { .max_channel = LP5523_MAX_LEDS, .post_init_device = lp5523_post_init_device, .brightness_fn = lp5523_led_brightness, + .color_intensity_fn = lp5523_led_intensity, .set_led_current = lp5523_set_led_current, .firmware_cb = lp5523_firmware_loaded, .run_engine = lp5523_run_engine, diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 44ced02b49f9..8408d625f8da 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -136,9 +136,26 @@ static int lp55xx_set_brightness(struct led_classdev *cdev, { struct lp55xx_led *led = cdev_to_lp55xx_led(cdev); struct lp55xx_device_config *cfg = led->chip->cfg; + int adj_value[LED_COLOR_ID_MAX]; + int ret; + int i; + + if (led->mc_cdev.num_leds > 1) { + led_mc_set_cluster_brightness(&led->mc_cdev, + brightness, adj_value); + for (i = 0; i < led->mc_cdev.num_leds; i++) { + led->brightness = adj_value[i]; + ret = cfg->color_intensity_fn(led, + led->grouped_channels[i]); + if (ret) + break; + } + } else { + led->brightness = (u8)brightness; + ret = cfg->brightness_fn(led); + } - led->brightness = (u8)brightness; - return cfg->brightness_fn(led); + return ret; } static int lp55xx_init_led(struct lp55xx_led *led, @@ -147,9 +164,9 @@ static int lp55xx_init_led(struct lp55xx_led *led, struct lp55xx_platform_data *pdata = chip->pdata; struct lp55xx_device_config *cfg = chip->cfg; struct device *dev = &chip->cl->dev; + int max_channel = cfg->max_channel; char name[32]; int ret; - int max_channel = cfg->max_channel; if (chan >= max_channel) { dev_err(dev, "invalid channel: %d / %d\n", chan, max_channel); @@ -159,10 +176,35 @@ static int lp55xx_init_led(struct lp55xx_led *led, if (pdata->led_config[chan].led_current == 0) return 0; + if (pdata->led_config[chan].name) { + led->cdev.name = pdata->led_config[chan].name; + } else { + snprintf(name, sizeof(name), "%s:channel%d", + pdata->label ? : chip->cl->name, chan); + led->cdev.name = name; + } + + if (pdata->led_config[chan].num_colors > 1) { + led->mc_cdev.led_cdev = &led->cdev; + led->cdev.brightness_set_blocking = lp55xx_set_brightness; + led->cdev.groups = lp55xx_led_groups; + led->mc_cdev.num_leds = pdata->led_config[chan].num_colors; + led->mc_cdev.available_colors = pdata->led_config[chan].available_colors; + memcpy(led->channel_color, + pdata->led_config[chan].channel_color, + sizeof(led->channel_color)); + memcpy(led->grouped_channels, + pdata->led_config[chan].grouped_channels, + sizeof(led->grouped_channels)); + } else { + + led->cdev.default_trigger = pdata->led_config[chan].default_trigger; + led->cdev.brightness_set_blocking = lp55xx_set_brightness; + } led->cdev.groups = lp55xx_led_groups; + led->led_current = pdata->led_config[chan].led_current; led->max_current = pdata->led_config[chan].max_current; led->chan_nr = pdata->led_config[chan].chan_nr; - led->cdev.default_trigger = pdata->led_config[chan].default_trigger; if (led->chan_nr >= max_channel) { dev_err(dev, "Use channel numbers between 0 and %d\n", @@ -170,18 +212,11 @@ static int lp55xx_init_led(struct lp55xx_led *led, return -EINVAL; } - led->cdev.brightness_set_blocking = lp55xx_set_brightness; - led->cdev.groups = lp55xx_led_groups; + if (pdata->led_config[chan].num_colors > 1) + ret = led_classdev_multicolor_register(dev, &led->mc_cdev); + else + ret = led_classdev_register(dev, &led->cdev); - if (pdata->led_config[chan].name) { - led->cdev.name = pdata->led_config[chan].name; - } else { - snprintf(name, sizeof(name), "%s:channel%d", - pdata->label ? : chip->cl->name, chan); - led->cdev.name = name; - } - - ret = led_classdev_register(dev, &led->cdev); if (ret) { dev_err(dev, "led register err: %d\n", ret); return ret; @@ -466,7 +501,6 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) dev_err(&chip->cl->dev, "empty brightness configuration\n"); return -EINVAL; } - for (i = 0; i < num_channels; i++) { /* do not initialize channels that are not connected */ @@ -538,6 +572,38 @@ void lp55xx_unregister_sysfs(struct lp55xx_chip *chip) } EXPORT_SYMBOL_GPL(lp55xx_unregister_sysfs); +static int lp5xx_parse_channel_child(struct device_node *np, + struct lp55xx_led_config *cfg, + int chan_num) +{ + struct device_node *child; + int num_colors = 0; + u32 color_id; + u32 led_number; + int ret; + + cfg[chan_num].default_trigger = + of_get_property(np, "linux,default-trigger", NULL); + + for_each_child_of_node(np, child) { + of_property_read_string(child, "chan-name", + &cfg[chan_num].name); + of_property_read_u8(child, "led-cur", + &cfg[chan_num].led_current); + of_property_read_u8(child, "max-cur", + &cfg[chan_num].max_current); + of_property_read_u32(child, "color", &color_id); + cfg[chan_num].channel_color[num_colors] = color_id; + set_bit(color_id, &cfg[chan_num].available_colors); + ret = of_property_read_u32(child, "reg", &led_number); + cfg[chan_num].grouped_channels[num_colors] = led_number; + num_colors++; + } + cfg[chan_num].num_colors = num_colors; + + return 0; +} + struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, struct device_node *np) { @@ -545,7 +611,10 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, struct lp55xx_platform_data *pdata; struct lp55xx_led_config *cfg; int num_channels; + int channel_color; + u32 led_number; int i = 0; + int ret; pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) @@ -565,13 +634,31 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, pdata->num_channels = num_channels; for_each_child_of_node(np, child) { - cfg[i].chan_nr = i; + ret = of_property_read_u32(child, "color", &channel_color); + if (ret) { + dev_err(dev,"Missing color property setting white\n"); + channel_color = LED_COLOR_ID_WHITE; + } - of_property_read_string(child, "chan-name", &cfg[i].name); - of_property_read_u8(child, "led-cur", &cfg[i].led_current); - of_property_read_u8(child, "max-cur", &cfg[i].max_current); - cfg[i].default_trigger = - of_get_property(child, "linux,default-trigger", NULL); + if (channel_color == LED_COLOR_ID_MULTI) + lp5xx_parse_channel_child(child, cfg, i); + else { + of_property_read_string(child, "chan-name", + &cfg[i].name); + of_property_read_u8(child, "led-cur", + &cfg[i].led_current); + of_property_read_u8(child, "max-cur", + &cfg[i].max_current); + cfg[i].default_trigger = + of_get_property(child, "linux,default-trigger", + NULL); + of_property_read_u32(child, "reg", &led_number); + + if (led_number < 0 || led_number > 6) + return ERR_PTR(EINVAL); + + cfg[i].chan_nr = led_number; + } i++; } diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h index 783ed5103ce5..d9c114259dcb 100644 --- a/drivers/leds/leds-lp55xx-common.h +++ b/drivers/leds/leds-lp55xx-common.h @@ -12,6 +12,8 @@ #ifndef _LEDS_LP55XX_COMMON_H #define _LEDS_LP55XX_COMMON_H +#include <linux/led-class-multicolor.h> + enum lp55xx_engine_index { LP55XX_ENGINE_INVALID, LP55XX_ENGINE_1, @@ -109,6 +111,9 @@ struct lp55xx_device_config { /* access brightness register */ int (*brightness_fn)(struct lp55xx_led *led); + /* access specific brightness register */ + int (*color_intensity_fn)(struct lp55xx_led *led, int chan_num); + /* current setting function */ void (*set_led_current) (struct lp55xx_led *led, u8 led_current); @@ -159,6 +164,7 @@ struct lp55xx_chip { * struct lp55xx_led * @chan_nr : Channel number * @cdev : LED class device + * @mc_cdev : Multi color class device * @led_current : Current setting at each led channel * @max_current : Maximun current at each led channel * @brightness : Brightness value @@ -167,9 +173,12 @@ struct lp55xx_chip { struct lp55xx_led { int chan_nr; struct led_classdev cdev; + struct led_classdev_mc mc_cdev; u8 led_current; u8 max_current; u8 brightness; + int channel_color[LED_COLOR_ID_MAX]; + int grouped_channels[LED_COLOR_ID_MAX]; struct lp55xx_chip *chip; }; diff --git a/include/linux/platform_data/leds-lp55xx.h b/include/linux/platform_data/leds-lp55xx.h index 96a787100fda..0ac29f537ab6 100644 --- a/include/linux/platform_data/leds-lp55xx.h +++ b/include/linux/platform_data/leds-lp55xx.h @@ -12,6 +12,8 @@ #ifndef _LEDS_LP55XX_H #define _LEDS_LP55XX_H +#include <linux/led-class-multicolor.h> + /* Clock configuration */ #define LP55XX_CLOCK_AUTO 0 #define LP55XX_CLOCK_INT 1 @@ -23,6 +25,10 @@ struct lp55xx_led_config { u8 chan_nr; u8 led_current; /* mA x10, 0 if led is not connected */ u8 max_current; + int num_colors; + unsigned long available_colors; + u32 channel_color[LED_COLOR_ID_MAX]; + int grouped_channels[LED_COLOR_ID_MAX]; }; struct lp55xx_predef_pattern { diff --git a/modules.builtin.modinfo b/modules.builtin.modinfo new file mode 100644 index 0000000000000000000000000000000000000000..e528d8f57796621b6cfef52ad0da44551a482481 GIT binary patch literal 43550 zcmcJ2?Q+|=(x(2ta}}twKjNIV<j*)6t(~$X+ldo9*0G$-%sF+IMNyQ*NF)`K@<-~u zoV|v<f%nGt=>|YGNXqfd?pCE75g*+RpaC?x8;w!ycl>2BO|zrh@WId3MUofUG7gi1 zeg~})3e2M*O!DyPegBfbM`0dh(V~db<mme9q^|~l3~tY^)aliUI=#90dUn&gPqW$g zWw;DG3qOmC$3=KF3Wv*yH%_x4^s>wg7R&B1P3KKT7wLVNdEs~*1raD&TW%EP{%{_8 z$ujnJp?sMy!eqo)j~204gn8kO!nyz0{k)8aVW!ft%EKT{M!70db?--o8it@MR9ToW z<0zS^ahAr)KvD#uCBbrIT+quXDO!sRe`l-q`ty7LG52P1KJiA&c%catrH(*Fo`QS> zy=zgLbTwK6<fNp;Pey7Qp$&;&geqNxnNLHI*DzP%ayJXa+=3#C!#YXPBtchr^K>!~ z@4|Uke=GZqt}6<nX@kM#%Ae2G3>1ZP6^D85PeSh2Vj3z##mgFbRUAxSzCdHsW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messages in thread
* Re: [PATCH v5 9/9] leds: Update the lp55xx to use the multi color framework 2019-09-11 18:01 ` [PATCH v5 9/9] leds: Update the lp55xx to use the multi color framework Dan Murphy @ 2019-09-15 16:28 ` Jacek Anaszewski 2019-09-16 14:03 ` Dan Murphy 0 siblings, 1 reply; 24+ messages in thread From: Jacek Anaszewski @ 2019-09-15 16:28 UTC (permalink / raw) To: Dan Murphy, pavel; +Cc: robh+dt, linux-leds, linux-kernel Hi Dan, On 9/11/19 8:01 PM, Dan Murphy wrote: > Update the lp5523 to use the multi color framework. > > Signed-off-by: Dan Murphy <dmurphy@ti.com> > --- > drivers/leds/leds-lp5523.c | 13 +++ > drivers/leds/leds-lp55xx-common.c | 131 ++++++++++++++++++---- > drivers/leds/leds-lp55xx-common.h | 9 ++ > include/linux/platform_data/leds-lp55xx.h | 6 + > modules.builtin.modinfo | Bin 0 -> 43550 bytes > 5 files changed, 137 insertions(+), 22 deletions(-) > create mode 100644 modules.builtin.modinfo > > diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c > index d0b931a136b9..8b2cdb98fed6 100644 > --- a/drivers/leds/leds-lp5523.c > +++ b/drivers/leds/leds-lp5523.c > @@ -791,6 +791,18 @@ static ssize_t store_master_fader_leds(struct device *dev, > return ret; > } [...] > struct lp55xx_predef_pattern { Below file seems to have been added to the index by mistake. > diff --git a/modules.builtin.modinfo b/modules.builtin.modinfo > new file mode 100644 > index 0000000000000000000000000000000000000000..e528d8f57796621b6cfef52ad0da44551a482481 > GIT binary patch > literal 43550 > zcmcJ2?Q+|=(x(2ta}}twKjNIV<j*)6t(~$X+ldo9*0G$-%sF+IMNyQ*NF)`K@<-~u > zoV|v<f%nGt=>|YGNXqfd?pCE75g*+RpaC?x8;w!ycl>2BO|zrh@WId3MUofUG7gi1 > zeg~})3e2M*O!DyPegBfbM`0dh(V~db<mme9q^|~l3~tY^)aliUI=#90dUn&gPqW$g > zWw;DG3qOmC$3=KF3Wv*yH%_x4^s>wg7R&B1P3KKT7wLVNdEs~*1raD&TW%EP{%{_8 [...] -- Best regards, Jacek Anaszewski ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH v5 9/9] leds: Update the lp55xx to use the multi color framework 2019-09-15 16:28 ` Jacek Anaszewski @ 2019-09-16 14:03 ` Dan Murphy 0 siblings, 0 replies; 24+ messages in thread From: Dan Murphy @ 2019-09-16 14:03 UTC (permalink / raw) To: Jacek Anaszewski, pavel; +Cc: robh+dt, linux-leds, linux-kernel On 9/15/19 11:28 AM, Jacek Anaszewski wrote: > Hi Dan, > > On 9/11/19 8:01 PM, Dan Murphy wrote: >> Update the lp5523 to use the multi color framework. >> >> Signed-off-by: Dan Murphy <dmurphy@ti.com> >> --- >> drivers/leds/leds-lp5523.c | 13 +++ >> drivers/leds/leds-lp55xx-common.c | 131 ++++++++++++++++++---- >> drivers/leds/leds-lp55xx-common.h | 9 ++ >> include/linux/platform_data/leds-lp55xx.h | 6 + >> modules.builtin.modinfo | Bin 0 -> 43550 bytes >> 5 files changed, 137 insertions(+), 22 deletions(-) >> create mode 100644 modules.builtin.modinfo >> >> diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c >> index d0b931a136b9..8b2cdb98fed6 100644 >> --- a/drivers/leds/leds-lp5523.c >> +++ b/drivers/leds/leds-lp5523.c >> @@ -791,6 +791,18 @@ static ssize_t store_master_fader_leds(struct device *dev, >> return ret; >> } > [...] >> struct lp55xx_predef_pattern { > Below file seems to have been added to the index by mistake. > I will remove it Dan >> diff --git a/modules.builtin.modinfo b/modules.builtin.modinfo >> new file mode 100644 >> index 0000000000000000000000000000000000000000..e528d8f57796621b6cfef52ad0da44551a482481 >> GIT binary patch >> literal 43550 >> zcmcJ2?Q+|=(x(2ta}}twKjNIV<j*)6t(~$X+ldo9*0G$-%sF+IMNyQ*NF)`K@<-~u >> zoV|v<f%nGt=>|YGNXqfd?pCE75g*+RpaC?x8;w!ycl>2BO|zrh@WId3MUofUG7gi1 >> zeg~})3e2M*O!DyPegBfbM`0dh(V~db<mme9q^|~l3~tY^)aliUI=#90dUn&gPqW$g >> zWw;DG3qOmC$3=KF3Wv*yH%_x4^s>wg7R&B1P3KKT7wLVNdEs~*1raD&TW%EP{%{_8 > [...] > ^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2019-09-16 20:18 UTC | newest] Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-09-11 18:01 [PATCH v5 0/9] Multicolor FW update Dan Murphy 2019-09-11 18:01 ` [PATCH v5 1/9] leds: multicolor: Add sysfs interface definition Dan Murphy 2019-09-15 13:57 ` Jacek Anaszewski 2019-09-16 13:56 ` Dan Murphy 2019-09-16 18:31 ` Jacek Anaszewski 2019-09-11 18:01 ` [PATCH v5 2/9] documention: leds: Add multicolor class documentation Dan Murphy 2019-09-12 20:55 ` Pavel Machek 2019-09-13 2:09 ` Dan Murphy 2019-09-15 12:45 ` Jacek Anaszewski 2019-09-11 18:01 ` [PATCH v5 3/9] dt: bindings: Add multicolor class dt bindings documention Dan Murphy 2019-09-15 14:01 ` Jacek Anaszewski 2019-09-16 13:58 ` Dan Murphy 2019-09-11 18:01 ` [PATCH v5 4/9] dt-bindings: leds: Add multicolor ID to the color ID list Dan Murphy 2019-09-11 18:01 ` [PATCH v5 5/9] " Dan Murphy 2019-09-11 18:01 ` [PATCH v5 6/9] leds: multicolor: Introduce a multicolor class definition Dan Murphy 2019-09-15 16:20 ` Jacek Anaszewski 2019-09-16 14:04 ` Dan Murphy 2019-09-16 18:34 ` Dan Murphy 2019-09-16 20:18 ` Jacek Anaszewski 2019-09-11 18:01 ` [PATCH v5 7/9] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Dan Murphy 2019-09-11 18:01 ` [PATCH v5 8/9] leds: lp50xx: Add the LP50XX family of the RGB LED driver Dan Murphy 2019-09-11 18:01 ` [PATCH v5 9/9] leds: Update the lp55xx to use the multi color framework Dan Murphy 2019-09-15 16:28 ` Jacek Anaszewski 2019-09-16 14:03 ` Dan Murphy
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).