leds: mt6360: Add LED driver for MT6360
Subsystems (3)
v5 cover leds: mt6360: Add LED driver for MT6360
This patch series add MT6360 LED support contains driver and binding document
Gene Chen (2)
dt-bindings: leds: Add bindings for MT6360 LED
leds: mt6360: Add LED driver for MT6360
Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 95 + drivers/leds/Kconfig | 12 drivers/leds/Makefile | 1 drivers/leds/leds-mt6360.c | 783 ++++++++++++++++ 4 files changed, 891 insertions(+)
changelogs between v1 & v2
- add led driver with mfd
changelogs between v2 & v3
- independent add led driver
- add dt-binding document
- refactor macros definition for easy to debug
- parse device tree by fwnode
- use devm*ext to register led class device
changelogs between v3 & v4
- fix binding document description
- use GENMASK and add unit postfix to definition
- isink register led class device
changelogs between v4 & v5
- change rgb isink to multicolor control
- add binding reference to mfd yaml
PATCH v5 1/2 dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen <[email protected]>
Add bindings document for LED support on MT6360 PMIC
--- .../devicetree/bindings/leds/leds-mt6360.yaml | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml
Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file +95 -0
@@ -0,0 +1,95 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen <[email protected]> + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: + const: mediatek,mt6360-led + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[0-3]$": + type: object + $ref: common.yaml# + description: + Properties for a single LED. + + properties: + reg: + description: Index of the LED. + enum: + - 0 # LED output INDICATOR1_RGB + - 1 # LED output INDICATOR2 + - 2 # LED output FLED1 + - 3 # LED output FLED2 + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/leds/common.h> + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = <LED_COLOR_ID_RGB>; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = <LED_COLOR_ID_AMBER>; + default-state = "off"; + led-max-microamp = <150000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_FLASH; + color = <LED_COLOR_ID_WHITE>; + function-enumerator = <1>; + default-state = "off"; + led-max-microamp = <200000>; + flash-max-microamp = <500000>; + flash-max-timeout-us = <1024000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_FLASH; + color = <LED_COLOR_ID_WHITE>; + function-enumerator = <2>; + default-state = "off"; + led-max-microamp = <200000>; + flash-max-microamp = <500000>; + flash-max-timeout-us = <1024000>; + }; + }; +...
Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH v5 1/2] dt-bindings: leds: Add bindings for MT6360 LED
Quoted 10 lines · Gene Chen
From: Gene Chen <[email protected]>
Add bindings document for LED support on MT6360 PMIC
Signed-off-by Gene Chen <[email protected]>--- .../devicetree/bindings/leds/leds-mt6360.yaml | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml
My bot found errors running 'make dt_binding_check' on your patch:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-mt6360.example.dt.yaml: led-controller: led@0:color:0:0: 9 is greater than the maximum of 8
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-mt6360.yaml
See https://patchwork.ozlabs.org/patch/1377747
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:
pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade
Please check and re-submit.
Re: [PATCH v5 1/2] dt-bindings: leds: Add bindings for MT6360 LED
In reply to Gene ChenHi Gene,
Thanks for the update.
Quoted 72 lines · Gene Chen
From: Gene Chen <[email protected]>
Add bindings document for LED support on MT6360 PMIC
Signed-off-by Gene Chen <[email protected]>--- .../devicetree/bindings/leds/leds-mt6360.yaml | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+)create mode 100644
Documentation/devicetree/bindings/leds/leds-mt6360.yamlDocumentation/devicetree/bindings/leds/leds-mt6360.yaml new file +56
-0@@ -0,0 +1,95 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen <[email protected]> + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: + const: mediatek,mt6360-led + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[0-3]$": + type: object + $ref: common.yaml# + description: + Properties for a single LED. + + properties: + reg: + description: Index of the LED. + enum: + - 0 # LED output INDICATOR1_RGB + - 1 # LED output INDICATOR2 + - 2 # LED output FLED1 + - 3 # LED output FLED2 + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/leds/common.h> + led-controller {
Documentation/devicetree/bindings/leds/leds-mt6360.yaml line 66
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file +10
-0+ compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = <LED_COLOR_ID_RGB>; + led-max-microamp = <24000>; + };
This should be multi-led node. See [0] for a reference.
Documentation/devicetree/bindings/leds/leds-mt6360.yaml line 69
Quoted 3 lines
Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file +3
-0+ led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR;
Maybe add LED_FUNCTION_MOONLIGHT ?
Quoted 17 lines
Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file +16
-0+ color = <LED_COLOR_ID_AMBER>; + default-state = "off"; + led-max-microamp = <150000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_FLASH; + color = <LED_COLOR_ID_WHITE>; + function-enumerator = <1>; + default-state = "off"; + led-max-microamp = <200000>; + flash-max-microamp = <500000>; + flash-max-timeout-us = <1024000>; + }; + led@3 { + reg = <3>;
Documentation/devicetree/bindings/leds/leds-mt6360.yaml line 95
Quoted 10 lines
Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file +10
-0+ function = LED_FUNCTION_FLASH; + color = <LED_COLOR_ID_WHITE>; + function-enumerator = <2>; + default-state = "off"; + led-max-microamp = <200000>; + flash-max-microamp = <500000>; + flash-max-timeout-us = <1024000>; + }; + }; +...
Signature · 2 lines
Best regards, Jacek Anaszewski
PATCH v5 2/2 leds: mt6360: Add LED driver for MT6360
In reply to Gene ChenFrom: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c
drivers/leds/Kconfig +12 -0
@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -66,6 +66,7 @@ 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_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o
drivers/leds/leds-mt6360.c new file +783 -0
783 lines not on this page · raw message
Signature · 1 line
2.7.4
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Gene,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on pavel-linux-leds/for-next]
[also build test WARNING on v5.9-rc8 next-20201006]
[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]
url: https://github.com/0day-ci/linux/commits/Gene-Chen/leds-mt6360-Add-LED-driver-for-MT6360/20201007-094408 base: git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next config: alpha-allyesconfig (attached as .config) compiler: alpha-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/cdafaffefe3568d483b764206c6cea243203b370
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gene-Chen/leds-mt6360-Add-LED-driver-for-MT6360/20201007-094408 git checkout cdafaffefe3568d483b764206c6cea243203b370
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=alpha
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from include/linux/leds.h:12,
from include/linux/led-class-flash.h:11,
from drivers/leds/leds-mt6360.c:7:
drivers/leds/leds-mt6360.c: In function 'mt6360_led_probe':
>> drivers/leds/leds-mt6360.c:696:23: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]
696 | dev_err(&pdev->dev, "No child node or node count over max led number %d\n", count);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
19 | #define dev_fmt(fmt) fmt
| ^~~
drivers/leds/leds-mt6360.c:696:3: note: in expansion of macro 'dev_err'
696 | dev_err(&pdev->dev, "No child node or node count over max led number %d\n", count);
| ^~~~~~~
drivers/leds/leds-mt6360.c:696:73: note: format string is defined here
696 | dev_err(&pdev->dev, "No child node or node count over max led number %d\n", count);
| ~^
| |
| int
| %ldvim +696 drivers/leds/leds-mt6360.c
686
687 static int mt6360_led_probe(struct platform_device *pdev)
688 {
689 struct mt6360_priv *priv;
690 struct fwnode_handle *child;
691 size_t count;
692 int i = 0, ret;
693
694 count = device_get_child_node_count(&pdev->dev);
695 if (!count || count > MT6360_MAX_LEDS) {
> 696 dev_err(&pdev->dev, "No child node or node count over max led number %d\n", count);
697 return -EINVAL;
698 }
699
700 priv = devm_kzalloc(&pdev->dev, struct_size(priv, leds, count), GFP_KERNEL);
701 if (!priv)
702 return -ENOMEM;
703
704 priv->leds_count = count;
705 priv->dev = &pdev->dev;
706 mutex_init(&priv->lock);
707
708 priv->regmap = dev_get_regmap(pdev->dev.parent, NULL);
709 if (!priv->regmap) {
710 dev_err(&pdev->dev, "Failed to get parent regmap\n");
711 return -ENODEV;
712 }
713
714 device_for_each_child_node(&pdev->dev, child) {
715 struct mt6360_led *led = priv->leds + i;
716 struct led_init_data init_data = { .fwnode = child, };
717 u32 reg;
718
719 ret = fwnode_property_read_u32(child, "reg", ®);
720 if (ret)
721 goto out_flash_release;
722
723 if (reg >= MT6360_MAX_LEDS || priv->leds_active & BIT(reg))
724 return -EINVAL;
725 priv->leds_active |= BIT(reg);
726
727 led->led_no = reg;
728 led->priv = priv;
729
730 ret = mt6360_init_common_properties(led, &init_data);
731 if (ret)
732 goto out_flash_release;
733
734 if (reg == MT6360_LED_ISNKRGB || reg == MT6360_LED_ISNKML)
735 ret = mt6360_init_isnk_properties(led, &init_data);
736 else
737 ret = mt6360_init_flash_properties(led, &init_data);
738
739 if (ret)
740 goto out_flash_release;
741
742 ret = mt6360_led_register(&pdev->dev, led, &init_data);
743 if (ret)
744 goto out_flash_release;
745
746 i++;
747 }
748
749 platform_set_drvdata(pdev, priv);
750 return 0;
751
752 out_flash_release:
753 mt6360_v4l2_flash_release(priv);
754 return ret;
755 }
756
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+)create mode 100644
drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0
drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLOR
Since CONFIG_LED_CLASS_MULTICOLOR can be turned off you need to have below instead:
depends on LEDS_CLASS_MULTICOLOR || !!LEDS_CLASS_MULTICOLOR
Unless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
Quoted 8 lines
drivers/leds/Kconfig +8
-0+ depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. +
Signature · 2 lines
Best regards, Jacek Anaszewski
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 34 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+)create mode 100644
drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:
Quoted 5 lines
depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORUnless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
May I change to "select LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.
Quoted 12 lines
drivers/leds/Kconfig config LEDS_MT6323 · line 285
Quoted 8 lines
drivers/leds/Kconfig +8
-0+ depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. +--
Best regards,
Jacek Anaszewski
Quoted 35 lines · Gene Chen
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 34 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+)create mode 100644
drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:
Quoted 8 lines
Quoted 5 lines
depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORUnless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
May I change to "select
LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.
You will also have moonlight LED that will not need multicolor framework. Is it somehow troublesome to keep "depends on"?
Signature · 2 lines
Best regards, Jacek Anaszewski
Jacek Anaszewski <[email protected]> 於 2020年10月21日 週三 上午5:47寫道:
Quoted 43 lines · Gene Chen
Quoted 41 lines
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 39 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+)create mode 100644
drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORUnless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
Quoted 6 lines
Quoted 2 lines
May I change to "select
LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.You will also have moonlight LED that will not need multicolor framework. Is it somehow troublesome to keep "depends on"?
If only use ML LED and FLED, DTSI will only define ML LED and FLED. Therefore, the drivers probe will not register rgb multicolor device. I will remove "depends", use "select" instead.
Quoted 3 lines
--
Best regards,
Jacek Anaszewski
Quoted 39 lines · Gene Chen
Jacek Anaszewski <[email protected]> 於 2020年10月21日 週三 上午5:47寫道:
Quoted 38 lines · Gene Chen
Quoted 36 lines
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 35 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+) create mode 100644 drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLOR
My typo here, should be one "!":
depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR
And you should also have
depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH
But to make it work correctly you would have to add registration stubs to include/linux/led-class-flash.h similarly to LED mc stubs in include/linux/led-class-multicolor.h.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Unless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
May I change to "select
LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.
Quoted 6 lines
Quoted 3 lines
You will also have moonlight LED that will not need multicolor framework. Is it somehow troublesome to keep "depends on"?
If only use ML LED and FLED, DTSI will only define ML LED and FLED. Therefore, the drivers probe will not register rgb multicolor device.
Please test your use case again with my fixed "depends on".
In case when there is only ML LED and FLED in the DT it should register both devices if LEDS_CLASS_FLASH is turned on. Multicolor framework has nothing to do in this case.
But if you additionally had MC LED node, then it should be registered only if LEDS_CLASS_MULTICOLOR is enabled.
Similarly, when FLED node is present, but LEDS_CLASS_FLASH is off, and LEDS_CLASS_MULTICOLOR is on, the driver should still compile, but register only LED MC device (if its node is present).
Possible should be also the case when both LEDS_CLASS_FLASH and LEDS_CLASS_MULTICOLOR are off. Then only LED class device for ML LED will be registered (provided there is ML DT node). But to make it possible you should have also "depends on LEDS_CLASS" in the Kconfig entry.
Quoted 1 line
I will remove "depends", use "select" instead.
Signature · 2 lines
Best regards, Jacek Anaszewski
Jacek Anaszewski <[email protected]> 於 2020年10月28日 週三 上午1:28寫道:
Quoted 75 lines · Gene Chen
Quoted 39 lines
Jacek Anaszewski <[email protected]> 於 2020年10月21日 週三 上午5:47寫道:
Quoted 38 lines · Gene Chen
Quoted 36 lines
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 35 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+) create mode 100644 drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORMy typo here, should be one "!":
depends on
LEDS_CLASS_MULTICOLOR|| !LEDS_CLASS_MULTICOLORAnd you should also have
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASHBut to make it work correctly you would have to add registration stubs to
include/linux/led-class-flash.hsimilarly to LED mc stubs ininclude/linux/led-class-multicolor.h.Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Unless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
May I change to "select
LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.Quoted 6 lines
Quoted 3 lines
You will also have moonlight LED that will not need multicolor framework. Is it somehow troublesome to keep "depends on"?
If only use ML LED and FLED, DTSI will only define ML LED and FLED. Therefore, the drivers probe will not register rgb multicolor device.
Please test your use case again with my fixed "depends on".
In case when there is only ML LED and FLED in the DT it should register both devices if
LEDS_CLASS_FLASHis turned on. Multicolor framework has nothing to do in this case.
Quoted 7 lines
But if you additionally had MC LED node, then it should be registered only if
LEDS_CLASS_MULTICOLORis enabled.Similarly, when FLED node is present, but
LEDS_CLASS_FLASHis off, andLEDS_CLASS_MULTICOLORis on, the driver should still compile, but register only LED MC device (if its node is present).
I think this case only register LED device, not LED "MC" device. Because our FLASH is not a multicolor device.
Quoted 6 lines
Possible should be also the case when both
LEDS_CLASS_FLASHandLEDS_CLASS_MULTICOLORare off. Then only LED class device for ML LED will be registered (provided there is ML DT node). But to make it possible you should have also "depends onLEDS_CLASS" in theKconfigentry.
According to your suggestion,
depends on LED_CLASS && LEDS_CLASS_FLASH && OF depends on LEDS_CLASS_MULTICOLOR || !!LEDS_CLASS_MULTICOLOR depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH depends on MFD_MT6360
and source code add constraint
#if IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR)
ret = devm_led_classdev_multicolor_register_ext(parent, &led->rgb,init_data);
#endif
#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH)
ret = devm_led_classdev_flash_register_ext(parent, &led->flash, init_data);#endif
=============
Or Should I seperate two drivers?
one for RGB LED, one for ML LED and FLED
Quoted 5 lines
Quoted 1 line
I will remove "depends", use "select" instead.
--
Best regards,
Jacek Anaszewski
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 79 lines · Gene Chen
Jacek Anaszewski <[email protected]> 於 2020年10月28日 週三 上午1:28寫道:
Quoted 78 lines · Gene Chen
Quoted 39 lines
Jacek Anaszewski <[email protected]> 於 2020年10月21日 週三 上午5:47寫道:
Quoted 38 lines · Gene Chen
Quoted 36 lines
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 35 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+) create mode 100644 drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORMy typo here, should be one "!":
depends on
LEDS_CLASS_MULTICOLOR|| !LEDS_CLASS_MULTICOLORAnd you should also have
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASHBut to make it work correctly you would have to add registration stubs to
include/linux/led-class-flash.hsimilarly to LED mc stubs ininclude/linux/led-class-multicolor.h.Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Unless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
May I change to "select
LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.Quoted 6 lines
Quoted 3 lines
You will also have moonlight LED that will not need multicolor framework. Is it somehow troublesome to keep "depends on"?
If only use ML LED and FLED, DTSI will only define ML LED and FLED. Therefore, the drivers probe will not register rgb multicolor device.
Please test your use case again with my fixed "depends on".
In case when there is only ML LED and FLED in the DT it should register both devices if
LEDS_CLASS_FLASHis turned on. Multicolor framework has nothing to do in this case.But if you additionally had MC LED node, then it should be registered only if
LEDS_CLASS_MULTICOLORis enabled.
Quoted 7 lines
Quoted 4 lines
Similarly, when FLED node is present, but
LEDS_CLASS_FLASHis off, andLEDS_CLASS_MULTICOLORis on, the driver should still compile, but register only LED MC device (if its node is present).I think this case only register LED device, not LED "MC" device. Because our FLASH is not a multicolor device.
No, here I was describing following setup:
- DT FLED node is present, CONFIG_LEDS_CLASS_FLASH is off
- DT MC node is present, CONFIG_LEDS_CLASS_MULTICOLOR is on
ML LED presence in DT is irrelevant in this case.
It should be always registered if there is corresponding DT node and LEDS_CLASS is on.
Quoted 10 lines
Quoted 7 lines
Possible should be also the case when both
LEDS_CLASS_FLASHandLEDS_CLASS_MULTICOLORare off. Then only LED class device for ML LED will be registered (provided there is ML DT node). But to make it possible you should have also "depends onLEDS_CLASS" in theKconfigentry.According to your suggestion,
depends onLED_CLASS&&LEDS_CLASS_FLASH&& OF
s/LED_CLASS/LEDS_CLASS/
And you have to remove LEDS_CLASS_FLASH from above line.
Quoted 1 line
depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLOR
s/!!LEDS_CLASS_MULTICOLOR/!LEDS_CLASS_MULTICOLOR/
Quoted 2 lines
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASH
depends onMFD_MT6360
You will need V4L2_FLASH_LED_CLASS dependency as well, to avoid build break, when it is set to 'm'.
To recap, following block of dependencies is required:
depends on LEDS_CLASS && OF
depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS depends on MFD_MT6360
Quoted 11 lines
and source code add constraint
#if IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) ret = devm_led_classdev_multicolor_register_ext(parent, &led->rgb,
init_data);
#endif#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) ret = devm_led_classdev_flash_register_ext(parent, &led->flash, init_data);#endif
No, the guards should be in headers. That's why I recommended adding no ops for LED flash class registration functions in previous email.
Please compare include/linux/led-class-multicolor.h and do similar changes in include/linux/led-class-flash.h.
Quoted 4 lines
=============
Or Should I seperate two drivers?
one for RGB LED, one for ML LED and FLED
This would incur unnecessary code duplication.
Signature · 2 lines
Best regards, Jacek Anaszewski
Jacek Anaszewski <[email protected]> 於 2020年10月31日 週六 上午6:34寫道:
Quoted 89 lines · Gene Chen
Quoted 79 lines
Jacek Anaszewski <[email protected]> 於 2020年10月28日 週三 上午1:28寫道:
Quoted 78 lines · Gene Chen
Quoted 39 lines
Jacek Anaszewski <[email protected]> 於 2020年10月21日 週三 上午5:47寫道:
Quoted 38 lines · Gene Chen
Quoted 36 lines
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 35 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+) create mode 100644 drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORMy typo here, should be one "!":
depends on
LEDS_CLASS_MULTICOLOR|| !LEDS_CLASS_MULTICOLORAnd you should also have
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASHBut to make it work correctly you would have to add registration stubs to
include/linux/led-class-flash.hsimilarly to LED mc stubs ininclude/linux/led-class-multicolor.h.Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Unless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
May I change to "select
LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.Quoted 6 lines
Quoted 3 lines
You will also have moonlight LED that will not need multicolor framework. Is it somehow troublesome to keep "depends on"?
If only use ML LED and FLED, DTSI will only define ML LED and FLED. Therefore, the drivers probe will not register rgb multicolor device.
Please test your use case again with my fixed "depends on".
In case when there is only ML LED and FLED in the DT it should register both devices if
LEDS_CLASS_FLASHis turned on. Multicolor framework has nothing to do in this case.But if you additionally had MC LED node, then it should be registered only if
LEDS_CLASS_MULTICOLORis enabled.Quoted 7 lines
Quoted 4 lines
Similarly, when FLED node is present, but
LEDS_CLASS_FLASHis off, andLEDS_CLASS_MULTICOLORis on, the driver should still compile, but register only LED MC device (if its node is present).I think this case only register LED device, not LED "MC" device. Because our FLASH is not a multicolor device.
Quoted 9 lines
No, here I was describing following setup:
- DT FLED node is present,
CONFIG_LEDS_CLASS_FLASHis off
- DT MC node is present,CONFIG_LEDS_CLASS_MULTICOLORis onML LED presence in DT is irrelevant in this case.
It should be always registered if there is corresponding DT node andLEDS_CLASSis on.
As a long time discussion, we conclude some rules about MT6360 LED driver. FLED is necessary, so Kconfig depends on LED_CLASS_FLASH
ML LED is optional, which is registered as led class device. RGB LED can be either simple led class device or multicolor device, which is decided in DT node
If Multicolor LED DT node is exist, it should be register multicolor device success.
Maybe it is more specific to send a new patch?
Sample DT as below
LED "red" is simple led class device, LED "green&blue" is multicolor devices.
led@0 {
reg = <0>;
function = LED_FUNCTION_INDICATOR;
color = <LED_COLOR_ID_RED>;
led-max-microamp = <24000>;
};
led@6 {
reg = <6>;
function = LED_FUNCTION_INDICATOR;
color = <LED_COLOR_ID_MULTI>;
led@1 {
reg = <1>;
function = LED_FUNCTION_INDICATOR;
color = <LED_COLOR_ID_GREEN>;
led-max-microamp = <24000>;
};
led@2 {
reg = <2>;
function = LED_FUNCTION_INDICATOR;
color = <LED_COLOR_ID_BLUE>;
led-max-microamp = <24000>;
};
};Quoted 25 lines
Quoted 10 lines
Quoted 7 lines
Possible should be also the case when both
LEDS_CLASS_FLASHandLEDS_CLASS_MULTICOLORare off. Then only LED class device for ML LED will be registered (provided there is ML DT node). But to make it possible you should have also "depends onLEDS_CLASS" in theKconfigentry.According to your suggestion,
depends onLED_CLASS&&LEDS_CLASS_FLASH&& OFs/LED_CLASS/LEDS_CLASS/
And you have to remove
LEDS_CLASS_FLASHfrom above line.Quoted 1 line
depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORs/!!LEDS_CLASS_MULTICOLOR/!LEDS_CLASS_MULTICOLOR/
Quoted 2 lines
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASH
depends onMFD_MT6360You will need
V4L2_FLASH_LED_CLASSdependency as well, to avoid build break, when it is set to 'm'.
Quoted 8 lines
To recap, following block of dependencies is required:
depends on
LEDS_CLASS&& OF
depends onLEDS_CLASS_MULTICOLOR|| !LEDS_CLASS_MULTICOLOR depends onLEDS_CLASS_FLASH|| !LEDS_CLASS_FLASH depends onV4L2_FLASH_LED_CLASS|| !V4L2_FLASH_LED_CLASS depends onMFD_MT6360
LEDS_MT6360 depends on LEDS_CLASS_FLASH, and LEDS_CLASS_FLASH depends on LEDS_CLASS
Is "depends on LEDS_CLASS" still needed?
Quoted 12 lines
Quoted 11 lines
and source code add constraint
#if IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) ret = devm_led_classdev_multicolor_register_ext(parent, &led->rgb,
init_data);
#endif#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) ret = devm_led_classdev_flash_register_ext(parent, &led->flash, init_data);#endif
Quoted 6 lines
No, the guards should be in headers. That's why I recommended adding no ops for LED flash class registration functions in previous email.
Please compare
include/linux/led-class-multicolor.hand do similar changes ininclude/linux/led-class-flash.h.
ACK, I will submit a fixed patch about leds-class-flash.h.
By the way, if CONFIG_LED_CLASS_MULTICOLOR is not enabled and we don't use #if IS_ENABLED,
according to led-class-multicolor.h return -EINVAL,
we will register multicolor device fail and cause probe fail.
Quoted 10 lines
Quoted 4 lines
=============
Or Should I seperate two drivers?
one for RGB LED, one for ML LED and FLEDThis would incur unnecessary code duplication.
--
Best regards,
Jacek Anaszewski
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Quoted 95 lines · Gene Chen
Jacek Anaszewski <[email protected]> 於 2020年10月31日 週六 上午6:34寫道:
Quoted 94 lines · Gene Chen
Quoted 79 lines
Jacek Anaszewski <[email protected]> 於 2020年10月28日 週三 上午1:28寫道:
Quoted 78 lines · Gene Chen
Quoted 39 lines
Jacek Anaszewski <[email protected]> 於 2020年10月21日 週三 上午5:47寫道:
Quoted 38 lines · Gene Chen
Quoted 36 lines
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 35 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+) create mode 100644 drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORMy typo here, should be one "!":
depends on
LEDS_CLASS_MULTICOLOR|| !LEDS_CLASS_MULTICOLORAnd you should also have
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASHBut to make it work correctly you would have to add registration stubs to
include/linux/led-class-flash.hsimilarly to LED mc stubs ininclude/linux/led-class-multicolor.h.Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Unless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
May I change to "select
LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.Quoted 6 lines
Quoted 3 lines
You will also have moonlight LED that will not need multicolor framework. Is it somehow troublesome to keep "depends on"?
If only use ML LED and FLED, DTSI will only define ML LED and FLED. Therefore, the drivers probe will not register rgb multicolor device.
Please test your use case again with my fixed "depends on".
In case when there is only ML LED and FLED in the DT it should register both devices if
LEDS_CLASS_FLASHis turned on. Multicolor framework has nothing to do in this case.But if you additionally had MC LED node, then it should be registered only if
LEDS_CLASS_MULTICOLORis enabled.Quoted 7 lines
Quoted 4 lines
Similarly, when FLED node is present, but
LEDS_CLASS_FLASHis off, andLEDS_CLASS_MULTICOLORis on, the driver should still compile, but register only LED MC device (if its node is present).I think this case only register LED device, not LED "MC" device. Because our FLASH is not a multicolor device.
No, here I was describing following setup:
- DT FLED node is present,
CONFIG_LEDS_CLASS_FLASHis off
- DT MC node is present,CONFIG_LEDS_CLASS_MULTICOLORis on
Quoted 7 lines
Quoted 4 lines
ML LED presence in DT is irrelevant in this case.
It should be always registered if there is corresponding DT node andLEDS_CLASSis on.As a long time discussion, we conclude some rules about MT6360 LED driver. FLED is necessary, so
Kconfigdepends onLED_CLASS_FLASH
Maybe it is necessary in your use case, but probably it is possible to use the device without FLED. If so, then you should allow users disabling it. Therefore you should have:
depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH
Quoted 5 lines
ML LED is optional, which is registered as led class device. RGB LED can be either simple led class device or multicolor device, which is decided in DT node
If Multicolor LED DT node is exist, it should be register multicolor device success.
But only if CONFIG_LEDS_CLASS_MULTICOLOR is enabled.
Quoted 20 lines
Maybe it is more specific to send a new patch?
Sample DT as below
LED "red" is simple led class device, LED "green&blue" is multicolor devices.led@0 { reg = <0>; function = LED_FUNCTION_INDICATOR; color = <LED_COLOR_ID_RED>; led-max-microamp = <24000>; }; led@6 { reg = <6>; function = LED_FUNCTION_INDICATOR; color = <LED_COLOR_ID_MULTI>; led@1 { reg = <1>; function = LED_FUNCTION_INDICATOR; color = <LED_COLOR_ID_GREEN>; led-max-microamp = <24000>;
Quoted 8 lines
};
led@2 {
reg = <2>;
function = LED_FUNCTION_INDICATOR;
color = <LED_COLOR_ID_BLUE>;
led-max-microamp = <24000>;
};
};It looks OK.
Quoted 33 lines
Quoted 24 lines
Quoted 9 lines
Quoted 6 lines
Possible should be also the case when both
LEDS_CLASS_FLASHandLEDS_CLASS_MULTICOLORare off. Then only LED class device for ML LED will be registered (provided there is ML DT node). But to make it possible you should have also "depends onLEDS_CLASS" in theKconfigentry.According to your suggestion,
depends onLED_CLASS&&LEDS_CLASS_FLASH&& OFs/LED_CLASS/LEDS_CLASS/
And you have to remove
LEDS_CLASS_FLASHfrom above line.Quoted 1 line
depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORs/!!LEDS_CLASS_MULTICOLOR/!LEDS_CLASS_MULTICOLOR/
Quoted 2 lines
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASH
depends onMFD_MT6360You will need
V4L2_FLASH_LED_CLASSdependency as well, to avoid build break, when it is set to 'm'.Quoted 8 lines
To recap, following block of dependencies is required:
depends on
LEDS_CLASS&& OF
depends onLEDS_CLASS_MULTICOLOR|| !LEDS_CLASS_MULTICOLOR depends onLEDS_CLASS_FLASH|| !LEDS_CLASS_FLASH depends onV4L2_FLASH_LED_CLASS|| !V4L2_FLASH_LED_CLASS depends onMFD_MT6360
Quoted 3 lines
LEDS_MT6360depends onLEDS_CLASS_FLASH, andLEDS_CLASS_FLASHdepends onLEDS_CLASS
Is "depends onLEDS_CLASS" still needed?
Yes, because you should allow disabling CONFIG_LEDS_CLASS_FLASH. In such a case driver should still compile and register ML LED class device when it has corresponding DT node.
Quoted 18 lines
Quoted 11 lines
Quoted 10 lines
and source code add constraint
#if IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) ret = devm_led_classdev_multicolor_register_ext(parent, &led->rgb,
init_data);
#endif#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) ret = devm_led_classdev_flash_register_ext(parent, &led->flash, init_data);#endif
Quoted 6 lines
No, the guards should be in headers. That's why I recommended adding no ops for LED flash class registration functions in previous email.
Please compare
include/linux/led-class-multicolor.hand do similar changes ininclude/linux/led-class-flash.h.
Quoted 6 lines
ACK, I will submit a fixed patch about
leds-class-flash.h.By the way, if
CONFIG_LED_CLASS_MULTICOLORis not enabled and we don't use #ifIS_ENABLED,
according toled-class-multicolor.hreturn-EINVAL,
we will register multicolor device fail and cause probe fail.
Good point. So led-class-multicolor.h no-ops need to be fixed to return 0 instead of -EINVAL.
And no-ops in include/linux/led-class-flash.h should also return 0.
Signature · 2 lines
Best regards, Jacek Anaszewski
Jacek Anaszewski <[email protected]> 於 2020年11月17日 週二 上午2:25寫道:
Quoted 102 lines · Gene Chen
Quoted 100 lines
Jacek Anaszewski <[email protected]> 於 2020年10月31日 週六 上午6:34寫道:
Quoted 98 lines · Gene Chen
Quoted 79 lines
Jacek Anaszewski <[email protected]> 於 2020年10月28日 週三 上午1:28寫道:
Quoted 78 lines · Gene Chen
Quoted 39 lines
Jacek Anaszewski <[email protected]> 於 2020年10月21日 週三 上午5:47寫道:
Quoted 38 lines · Gene Chen
Quoted 36 lines
Jacek Anaszewski <[email protected]> 於 2020年10月9日 週五 上午5:51寫道:
Quoted 35 lines
Hi Gene,
Quoted 19 lines · Gene Chen
From: Gene Chen <[email protected]>
Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED.
Signed-off-by Gene Chen <[email protected]>--- drivers/leds/Kconfig | 12 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 783 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 796 insertions(+) create mode 100644 drivers/leds/leds-mt6360.cdrivers/leds/Kconfig +0
-0drivers/leds/Kconfig config LEDS_MT6323 · line 277
Quoted 7 lines
drivers/leds/Kconfig +4
-0@@ -271,6 +271,18 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on LEDS_CLASS_MULTICOLORSince
CONFIG_LED_CLASS_MULTICOLORcan be turned off you need to have below instead:depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORMy typo here, should be one "!":
depends on
LEDS_CLASS_MULTICOLOR|| !LEDS_CLASS_MULTICOLORAnd you should also have
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASHBut to make it work correctly you would have to add registration stubs to
include/linux/led-class-flash.hsimilarly to LED mc stubs ininclude/linux/led-class-multicolor.h.Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Unless you want to prevent enabling the driver without RGB LED, but that does not seem to be reasonable at first glance.
May I change to "select
LEDS_CLASS_MULTICOLOR"?
I suppose RGB always use multicolor mode.Quoted 6 lines
Quoted 3 lines
You will also have moonlight LED that will not need multicolor framework. Is it somehow troublesome to keep "depends on"?
If only use ML LED and FLED, DTSI will only define ML LED and FLED. Therefore, the drivers probe will not register rgb multicolor device.
Please test your use case again with my fixed "depends on".
In case when there is only ML LED and FLED in the DT it should register both devices if
LEDS_CLASS_FLASHis turned on. Multicolor framework has nothing to do in this case.But if you additionally had MC LED node, then it should be registered only if
LEDS_CLASS_MULTICOLORis enabled.Quoted 7 lines
Quoted 4 lines
Similarly, when FLED node is present, but
LEDS_CLASS_FLASHis off, andLEDS_CLASS_MULTICOLORis on, the driver should still compile, but register only LED MC device (if its node is present).I think this case only register LED device, not LED "MC" device. Because our FLASH is not a multicolor device.
No, here I was describing following setup:
- DT FLED node is present,
CONFIG_LEDS_CLASS_FLASHis off
- DT MC node is present,CONFIG_LEDS_CLASS_MULTICOLORis onML LED presence in DT is irrelevant in this case.
It should be always registered if there is corresponding DT node andLEDS_CLASSis on.
Quoted 9 lines
Quoted 2 lines
As a long time discussion, we conclude some rules about MT6360 LED driver. FLED is necessary, so
Kconfigdepends onLED_CLASS_FLASHMaybe it is necessary in your use case, but probably it is possible to use the device without FLED. If so, then you should allow users disabling it. Therefore you should have:
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASH
ACK
Quoted 72 lines
Quoted 5 lines
ML LED is optional, which is registered as led class device. RGB LED can be either simple led class device or multicolor device, which is decided in DT node
If Multicolor LED DT node is exist, it should be register multicolor device success.But only if
CONFIG_LEDS_CLASS_MULTICOLORis enabled.Quoted 20 lines
Maybe it is more specific to send a new patch?
Sample DT as below
LED "red" is simple led class device, LED "green&blue" is multicolor devices.led@0 { reg = <0>; function = LED_FUNCTION_INDICATOR; color = <LED_COLOR_ID_RED>; led-max-microamp = <24000>; }; led@6 { reg = <6>; function = LED_FUNCTION_INDICATOR; color = <LED_COLOR_ID_MULTI>; led@1 { reg = <1>; function = LED_FUNCTION_INDICATOR; color = <LED_COLOR_ID_GREEN>; led-max-microamp = <24000>;Quoted 8 lines
}; led@2 { reg = <2>; function = LED_FUNCTION_INDICATOR; color = <LED_COLOR_ID_BLUE>; led-max-microamp = <24000>; }; };It looks OK.
Quoted 33 lines
Quoted 32 lines
Quoted 9 lines
Quoted 6 lines
Possible should be also the case when both
LEDS_CLASS_FLASHandLEDS_CLASS_MULTICOLORare off. Then only LED class device for ML LED will be registered (provided there is ML DT node). But to make it possible you should have also "depends onLEDS_CLASS" in theKconfigentry.According to your suggestion,
depends onLED_CLASS&&LEDS_CLASS_FLASH&& OFs/LED_CLASS/LEDS_CLASS/
And you have to remove
LEDS_CLASS_FLASHfrom above line.Quoted 1 line
depends on
LEDS_CLASS_MULTICOLOR|| !!LEDS_CLASS_MULTICOLORs/!!LEDS_CLASS_MULTICOLOR/!LEDS_CLASS_MULTICOLOR/
Quoted 2 lines
depends on
LEDS_CLASS_FLASH|| !LEDS_CLASS_FLASH
depends onMFD_MT6360You will need
V4L2_FLASH_LED_CLASSdependency as well, to avoid build break, when it is set to 'm'.To recap, following block of dependencies is required:
depends on
LEDS_CLASS&& OF
depends onLEDS_CLASS_MULTICOLOR|| !LEDS_CLASS_MULTICOLOR depends onLEDS_CLASS_FLASH|| !LEDS_CLASS_FLASH depends onV4L2_FLASH_LED_CLASS|| !V4L2_FLASH_LED_CLASS depends onMFD_MT6360
Quoted 8 lines
Quoted 3 lines
LEDS_MT6360depends onLEDS_CLASS_FLASH, andLEDS_CLASS_FLASHdepends onLEDS_CLASS
Is "depends onLEDS_CLASS" still needed?Yes, because you should allow disabling
CONFIG_LEDS_CLASS_FLASH. In such a case driver should still compile and register ML LED class device when it has corresponding DT node.
ACK
Quoted 25 lines
Quoted 18 lines
Quoted 11 lines
Quoted 10 lines
and source code add constraint
#if IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) ret = devm_led_classdev_multicolor_register_ext(parent, &led->rgb,
init_data);
#endif#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) ret = devm_led_classdev_flash_register_ext(parent, &led->flash, init_data);#endif
Quoted 6 lines
No, the guards should be in headers. That's why I recommended adding no ops for LED flash class registration functions in previous email.
Please compare
include/linux/led-class-multicolor.hand do similar changes ininclude/linux/led-class-flash.h.Quoted 6 lines
ACK, I will submit a fixed patch about
leds-class-flash.h.By the way, if
CONFIG_LED_CLASS_MULTICOLORis not enabled and we don't use #ifIS_ENABLED,
according toled-class-multicolor.hreturn-EINVAL,
we will register multicolor device fail and cause probe fail.
Quoted 4 lines
Good point. So
led-class-multicolor.hno-ops need to be fixed to return 0 instead of-EINVAL.And no-ops in
include/linux/led-class-flash.hshould also return 0.
DT node is first priority to decide how leds work.
If RGB LED use multicolor form in DT, CONFIG_LEDS_CLASS_FLASH should be defined. Otherwise It is right action to probe fail.
Quoted 4 lines
--
Best regards,
Jacek Anaszewski
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek