Re: [PATCH v12 5/5] leds: mt6360: Add LED driver for MT6360
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 robh/for-next linus/master v5.10 next-20201215] [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/20201210-140617 base: git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next config: x86_64-randconfig-m001-20201215 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot smatch warnings: drivers/leds/leds-mt6360.c:778 mt6360_led_probe() warn: always true condition '(reg >= 0) => (0-u32max >= 0)' vim +778 drivers/leds/leds-mt6360.c 714 715 static int mt6360_led_probe(struct platform_device *pdev) 716 { 717 struct mt6360_priv *priv; 718 struct fwnode_handle *child; 719 size_t count; 720 int i = 0, ret; 721 722 count = device_get_child_node_count(>dev); 723 if (!count || count > MT6360_MAX_LEDS) { 724 dev_err(>dev, "No child node or node count over max led number %lu\n", count); 725 return -EINVAL; 726 } 727 728 priv = devm_kzalloc(>dev, struct_size(priv, leds, count), GFP_KERNEL); 729 if (!priv) 730 return -ENOMEM; 731 732 priv->leds_count = count; 733 priv->dev = >dev; 734 mutex_init(>lock); 735 736 priv->regmap = dev_get_regmap(pdev->dev.parent, NULL); 737 if (!priv->regmap) { 738 dev_err(>dev, "Failed to get parent regmap\n"); 739 return -ENODEV; 740 } 741 742 device_for_each_child_node(>dev, child) { 743 struct mt6360_led *led = priv->leds + i; 744 struct led_init_data init_data = { .fwnode = child, }; 745 u32 reg, led_color; 746 747 ret = fwnode_property_read_u32(child, "color", _color); 748 if (ret) 749 goto out_flash_release; 750 751 if (led_color == LED_COLOR_ID_RGB || led_color == LED_COLOR_ID_MULTI) 752 reg = MT6360_VIRTUAL_MULTICOLOR; 753 else { 754 ret = fwnode_property_read_u32(child, "reg", ); 755 if (ret) 756 goto out_flash_release; 757 758 if (reg >= MT6360_MAX_LEDS) { 759 ret = -EINVAL; 760 goto out_flash_release; 761 } 762 } 763 764 if (priv->leds_active & BIT(reg)) { 765 ret = -EINVAL; 766 goto out_flash_release; 767 } 768 priv->leds_active |= BIT(reg); 769 770 led->led_no = reg; 771 led->priv = priv; 772 773 ret = mt6360_init_common_properties(led, _data); 774 if (ret) 775 goto out_flash_release; 776 777 if (reg == MT6360_VIRTUAL_MULTICOLOR || > 778 (reg >= MT6360_LED_ISNK1 && reg <= > MT6360_LED_ISNKML)) 779 ret = mt6360_init_isnk_properties(led, _data); 780 else 781 ret = mt6360_init_flash_properties(led, _data); 782 783 if (ret) 784 goto out_flash_release; 785 786 ret = mt6360_led_register(>dev, led, _data); 787 if (ret) 788 goto out_flash_release; 789 790 i++; 791 } 792 793 platform_set_drvdata(pdev, priv); 794 return 0; 795 796 out_flash_release: 797 mt6360_v4l2_flash_release(priv); 798 return ret; 799 } 800 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
[PATCH v12 5/5] leds: mt6360: Add LED driver for MT6360
From: Gene Chen 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 --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 827 + 3 files changed, 841 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1c181df..4f533bc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ 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 && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !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 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c2c7d7a..5596427 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -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 diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..42d18a8 --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,827 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_MAX_LEDS +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +/* Virtual definition for multicolor */ +#define MT6360_VIRTUAL_MULTICOLOR (MT6360_MAX_LEDS + 1) +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; + struct led_classdev_mc