leds: Add a driver for MP3326
Subsystems (2)
cover leds: Add a driver for MP3326
Add the binding description and the corresponding driver for the MPS MP3326.
Yuxi Wang (2):
dt-bindings: leds: add mps mp3326 LED
leds: add mp3326 driver
.../devicetree/bindings/leds/mps,mp3326.yaml | 143 ++++ drivers/leds/Kconfig | 7 + drivers/leds/Makefile | 1 + drivers/leds/leds-mp3326.c | 622 ++++++++++++++++++ 4 files changed, 773 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mps,mp3326.yaml create mode 100644 drivers/leds/leds-mp3326.c
Signature · 1 line
2.25.1
PATCH 1/2 dt-bindings: leds: add mps mp3326 LED
Document mps mp3326 LED driver devicetree bindings.
--- .../devicetree/bindings/leds/mps,mp3326.yaml | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mps,mp3326.yaml
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +143 -0
@@ -0,0 +1,143 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/mps,mp3326.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MPS MP3326 RGB/White LED Driver + +maintainers: + - Yuxi Wang <[email protected]> + +description: | + The MP3326 is a RGB/White LED driver with I2C interface. + + For more product information please see the link below: + https://www.monolithicpower.com/en/products/mp3326.html + +properties: + compatible: + const: mps,mp3326 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + reg: + maxItems: 1 + + multi-led: + type: object + unevaluatedProperties: false + + properties: + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + color: + description: RGB module + + patternProperties: + "^led@[0-3]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: Index of the LED. + minimum: 1 + maximum: 16 + + required: + - reg + - color + + required: + - "#address-cells" + - "#size-cells" + - color + +patternProperties: + "^led@[0-9]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: Index of the LED. + minimum: 1 + maximum: 16 + + required: + - reg + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/leds/common.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + led-controller@30 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "mps,mp3326"; + reg = <0x30>; + multi-led { + #address-cells = <1>; + #size-cells = <0>; + color = <LED_COLOR_ID_RGB>; + + led@0 { + reg = <1>; + color = <LED_COLOR_ID_RED>; + }; + + led@1 { + reg = <2>; + color = <LED_COLOR_ID_GREEN>; + }; + + led@2 { + reg = <3>; + color = <LED_COLOR_ID_BLUE>; + }; + }; + }; + }; + + - | + #include <dt-bindings/leds/common.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + led-controller@30 { + compatible = "mps,mp3326"; + reg = <0x30>; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg= <5>; + color = <LED_COLOR_ID_WHITE>; + }; + }; + }; +...
Signature · 1 line
2.25.1
Re: [PATCH 1/2] dt-bindings: leds: add mps mp3326 LED
Quoted 36 lines · Yuxi Wang
Document mps mp3326 LED driver devicetree bindings.
Signed-off-by Yuxi Wang <[email protected]>--- .../devicetree/bindings/leds/mps,mp3326.yaml | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mps,mp3326.yamlDocumentation/devicetree/bindings/leds/mps,mp3326.yaml new file +22
-0@@ -0,0 +1,143 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/mps,mp3326.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MPS MP3326 RGB/White LED Driver + +maintainers: + - Yuxi Wang <[email protected]> + +description: | + The MP3326 is a RGB/White LED driver with I2C interface. + + For more product information please see the link below: + https://www.monolithicpower.com/en/products/mp3326.html + +properties: + compatible: + const: mps,mp3326 + + "#address-cells":
Documentation/devicetree/bindings/leds/mps,mp3326.yaml line 32
Quoted 10 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +10
-0+ const: 1 + + "#size-cells": + const: 0 + + reg: + maxItems: 1 + + multi-led: + type: object
Missing ref to multi-led class. Please open existing bindings with such node and take a look how it is done there.
Documentation/devicetree/bindings/leds/mps,mp3326.yaml line 43
Quoted 11 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +11
-0+ unevaluatedProperties: false + + properties: + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + color: + description: RGB module
Drop property
Documentation/devicetree/bindings/leds/mps,mp3326.yaml line 46
Quoted 3 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +3
-0+ + patternProperties: + "^led@[0-3]$":
This says 4...
Documentation/devicetree/bindings/leds/mps,mp3326.yaml line 55
Quoted 9 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +9
-0+ type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: Index of the LED. + minimum: 1 + maximum: 16
But this says 16.
Also reg does not match unit address. Minimum reg is 1, but unit address is 0.
Documentation/devicetree/bindings/leds/mps,mp3326.yaml line 64
Quoted 9 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +9
-0+ + required: + - reg + - color + + required: + - "#address-cells" + - "#size-cells" + - color
Drop color, it is coming with class-multicolor
Documentation/devicetree/bindings/leds/mps,mp3326.yaml line 67
Quoted 3 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +3
-0+ +patternProperties: + "^led@[0-9]$":
It's even weirded. Here you have 10 leds with indices 0-9
Documentation/devicetree/bindings/leds/mps,mp3326.yaml line 55
Quoted 9 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +9
-0+ type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: Index of the LED. + minimum: 1 + maximum: 16
bu there 16! With indices 1-16.
It's a mess.
Quoted 21 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +21
-0+ required: + - reg + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/leds/common.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + led-controller@30 { + #address-cells = <1>;
Documentation/devicetree/bindings/leds/mps,mp3326.yaml line 108
Quoted 10 lines
Documentation/devicetree/bindings/leds/mps,mp3326.yaml new file +10
-0+ #size-cells = <0>; + compatible = "mps,mp3326"; + reg = <0x30>; + multi-led { + #address-cells = <1>; + #size-cells = <0>; + color = <LED_COLOR_ID_RGB>; + + led@0 { + reg = <1>;
OK, you did not test it. Test your DTS before sending.
Also, messed indentation. Use 4 spaces.
Best regards,
Krzysztof
PATCH 2/2 leds: add mp3326 driver
In reply to Yuxi WangThis commit adds support for MPS MP3326 LED driver.
--- drivers/leds/Kconfig | 7 + drivers/leds/Makefile | 1 + drivers/leds/leds-mp3326.c | 622 +++++++++++++++++++++++++++++++++++++ 3 files changed, 630 insertions(+) create mode 100644 drivers/leds/leds-mp3326.c
drivers/leds/Kconfig +7 -0
@@ -262,6 +262,13 @@ config LEDS_MIKROTIK_RB532 This option enables support for the so called "User LED" of Mikrotik's Routerboard 532. +config LEDS_MP3326 + tristate "LED Support for MPS MP3326" + depends on LEDS_CLASS + help + This option enables support for on-chip LED drivers found on + MPS MP3326. + config LEDS_MT6323 tristate "LED Support for Mediatek MT6323 PMIC" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o +obj-$(CONFIG_LEDS_MP3326) += leds-mp3326.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
drivers/leds/leds-mp3326.c new file +622 -0
622 lines not on this page · raw message
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH 2/2] leds: add mp3326 driver
kernel test robot noticed the following build warnings:
Hi Yuxi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on lee-leds/for-leds-next]
[also build test WARNING on robh/for-next linus/master v6.7-rc2 next-20231124] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yuxi-Wang/dt-bindings-leds-add-mps-mp3326-LED/20231124-173610 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next patch link: https://lore.kernel.org/r/20231124093034.951-3-Yuxi.Wang%40monolithicpower.com patch subject: [PATCH 2/2] leds: add mp3326 driver config: openrisc-allyesconfig (https://download.01.org/0day-ci/archive/20231124/[email protected]/config) compiler: or1k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231124/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/leds/leds-mp3326.c: In function 'mp3326_parse_dt':
>> drivers/leds/leds-mp3326.c:543:13: warning: unused variable 'val' [-Wunused-variable]
543 | int val;
| ^~~
drivers/leds/leds-mp3326.c: At top level:
drivers/leds/leds-mp3326.c:611:10: error: 'struct i2c_driver' has no member named 'probe_new'
611 | .probe_new = mp3326_leds_probe,
| ^~~~~~~~~
drivers/leds/leds-mp3326.c:611:22: warning: initialization of 'unsigned int' from 'int (*)(struct i2c_client *)' makes integer from pointer without a cast [-Wint-conversion]
611 | .probe_new = mp3326_leds_probe,
| ^~~~~~~~~~~~~~~~~ drivers/leds/leds-mp3326.c:611:22: note: (near initialization for 'mp3326_driver.class')
vim +/val +543 drivers/leds/leds-mp3326.c
536
537 static int mp3326_parse_dt(struct mp3326 *chip)
538 {
539 struct device_node *np = dev_of_node(&chip->client->dev);
540 struct device_node *child;
541 int ret;
542 int i = 0;
> 543 int val;
544
545 for_each_available_child_of_node(np, child) {
546 ret = mp3326_add_led(chip, child, i);
547 if (ret)
548 return ret;
549 i++;
550 }
551
552 ret = regmap_write(chip->regmap, MP3326_PWM_CTRL_CHANNEL_9_16, 0);
553 if (ret)
554 return ret;
555 ret = regmap_write(chip->regmap, MP3326_PWM_CTRL_CHANNEL_1_8, 0);
556 if (ret)
557 return ret;
558 return 0;
559 }
560
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 2/2] leds: add mp3326 driver
In reply to Yuxi Wangkernel test robot noticed the following build errors:
Hi Yuxi,
kernel test robot noticed the following build errors:
[auto build test ERROR on lee-leds/for-leds-next]
[also build test ERROR on robh/for-next linus/master v6.7-rc2 next-20231124] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yuxi-Wang/dt-bindings-leds-add-mps-mp3326-LED/20231124-173610 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next patch link: https://lore.kernel.org/r/20231124093034.951-3-Yuxi.Wang%40monolithicpower.com patch subject: [PATCH 2/2] leds: add mp3326 driver config: i386-buildonly-randconfig-005-20231126 (https://download.01.org/0day-ci/archive/20231126/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231126/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/leds/leds-mp3326.c:543:6: warning: unused variable 'val' [-Wunused-variable]
int val;
^
drivers/leds/leds-mp3326.c:611:3: error: field designator 'probe_new' does not refer to any field in type 'struct i2c_driver'
.probe_new = mp3326_leds_probe,
^
>> drivers/leds/leds-mp3326.c:619:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
module_i2c_driver(mp3326_driver);
^
int
>> drivers/leds/leds-mp3326.c:619:19: error: a parameter list without types is only allowed in a function definition
module_i2c_driver(mp3326_driver);
^1 warning and 3 errors generated.
vim +/int +619 drivers/leds/leds-mp3326.c
618
> 619 module_i2c_driver(mp3326_driver);
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 2/2] leds: add mp3326 driver
In reply to Yuxi Wangkernel test robot noticed the following build warnings:
Hi Yuxi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on lee-leds/for-leds-next]
[also build test WARNING on robh/for-next linus/master v6.7-rc2 next-20231124] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yuxi-Wang/dt-bindings-leds-add-mps-mp3326-LED/20231124-173610 base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/leds.git for-leds-next patch link: https://lore.kernel.org/r/20231124093034.951-3-Yuxi.Wang%40monolithicpower.com patch subject: [PATCH 2/2] leds: add mp3326 driver config: x86_64-randconfig-123-20231126 (https://download.01.org/0day-ci/archive/20231126/[email protected]/config) compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231126/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/leds/leds-mp3326.c: In function 'mp3326_parse_dt':
drivers/leds/leds-mp3326.c:543:6: warning: unused variable 'val' [-Wunused-variable]
int val;
^~~
drivers/leds/leds-mp3326.c: At top level:
drivers/leds/leds-mp3326.c:611:3: error: 'struct i2c_driver' has no member named 'probe_new'; did you mean 'probe'?
.probe_new = mp3326_leds_probe,
^~~~~~~~~
probe
>> drivers/leds/leds-mp3326.c:611:15: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
.probe_new = mp3326_leds_probe,
^~~~~~~~~~~~~~~~~ drivers/leds/leds-mp3326.c:611:15: note: (near initialization for 'mp3326_driver.class') drivers/leds/leds-mp3326.c:611:15: error: initializer element is not computable at load time drivers/leds/leds-mp3326.c:611:15: note: (near initialization for 'mp3326_driver.class')
vim +611 drivers/leds/leds-mp3326.c
609
610 static struct i2c_driver mp3326_driver = {
> 611 .probe_new = mp3326_leds_probe,
612 .driver = {
613 .name = "mp3326_led",
614 .of_match_table = mp3326_of_match,
615 },
616 .id_table = mp3326_id,
617 };
618
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki