Re: [RESEND 12/14] leds: mt6370: Add Mediatek MT6370 Indicator support

2022-06-06 Thread kernel test robot
Hi ChiaEn,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on pavel-leds/for-next]
[also build test ERROR on lee-mfd/for-mfd-next lee-backlight/for-backlight-next 
v5.19-rc1 next-20220606]
[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/intel-lab-lkp/linux/commits/ChiaEn-Wu/Add-Mediatek-MT6370-PMIC-support/20220531-211432
base:   git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git 
for-next
config: nios2-allyesconfig 
(https://download.01.org/0day-ci/archive/20220606/202206062207.q0s8wxpj-...@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.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/intel-lab-lkp/linux/commit/4de9e5ff11aeade155aa744bcaf9efca82b3d4ee
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
ChiaEn-Wu/Add-Mediatek-MT6370-PMIC-support/20220531-211432
git checkout 4de9e5ff11aeade155aa744bcaf9efca82b3d4ee
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 
O=build_dir ARCH=nios2 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   drivers/leds/leds-mt6370.c: In function 'mt6370_check_vendor_info':
>> drivers/leds/leds-mt6370.c:873:15: error: implicit declaration of function 
>> 'FIELD_GET'; did you mean 'FOLL_GET'? [-Werror=implicit-function-declaration]
 873 | vid = FIELD_GET(MT6370_VENID_MASK, devinfo);
 |   ^
 |   FOLL_GET
   cc1: some warnings being treated as errors


vim +873 drivers/leds/leds-mt6370.c

   863  
   864  static int mt6370_check_vendor_info(struct mt6370_priv *priv)
   865  {
   866  unsigned int devinfo, vid;
   867  int ret;
   868  
   869  ret = regmap_read(priv->regmap, MT6370_REG_DEV_INFO, );
   870  if (ret)
   871  return ret;
   872  
 > 873  vid = FIELD_GET(MT6370_VENID_MASK, devinfo);
   874  if (vid == 0x9 || vid == 0xb) {
   875  priv->reg_fields = mt6372_reg_fields;
   876  priv->ranges = mt6372_led_ranges;
   877  priv->is_mt6372 = true;
   878  } else {
   879  priv->reg_fields = common_reg_fields;
   880  priv->ranges = common_led_ranges;
   881  }
   882  
   883  return 0;
   884  }
   885  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


[RESEND 12/14] leds: mt6370: Add Mediatek MT6370 Indicator support

2022-05-31 Thread ChiaEn Wu
From: Alice Chen 

Add Mediatek MT6370 Indicator support

Signed-off-by: Alice Chen 
---
 drivers/leds/Kconfig   |  11 +
 drivers/leds/Makefile  |   1 +
 drivers/leds/leds-mt6370.c | 994 +
 3 files changed, 1006 insertions(+)
 create mode 100644 drivers/leds/leds-mt6370.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 6090e647daee..0cb2294b3431 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -244,6 +244,17 @@ config LEDS_MT6323
  This option enables support for on-chip LED drivers found on
  Mediatek MT6323 PMIC.
 
+config LEDS_MT6370_RGB
+   tristate "LED Support for Mediatek MT6370 PMIC"
+   depends on LEDS_CLASS
+   depends on MFD_MT6370
+   select LINEAR_RANGE
+   help
+ Support 4 channels and reg/pwm/breath mode.
+ Isink4 can also use as a CHG_VIN power good Indicator.
+ Say Y here to enable support for
+ MT6370_RGB_LED device.
+
 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 e58ecb36360f..b641fd83f49a 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -62,6 +62,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_MT6370_RGB)  += leds-mt6370.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-mt6370.c b/drivers/leds/leds-mt6370.c
new file mode 100644
index ..54f654d4f4fc
--- /dev/null
+++ b/drivers/leds/leds-mt6370.c
@@ -0,0 +1,994 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+enum {
+   MT6370_LED_ISNK1 = 0,
+   MT6370_LED_ISNK2,
+   MT6370_LED_ISNK3,
+   MT6370_LED_ISNK4,
+   MT6370_MAX_LEDS
+};
+
+enum mt6370_led_mode {
+   MT6370_LED_PWM_MODE = 0,
+   MT6370_LED_BREATH_MODE,
+   MT6370_LED_REG_MODE,
+   MT6370_LED_MAX_MODE
+};
+
+enum mt6370_led_field {
+   F_RGB_EN = 0,
+   F_CHGIND_EN,
+   F_LED1_CURR,
+   F_LED2_CURR,
+   F_LED3_CURR,
+   F_LED4_CURR,
+   F_LED1_MODE,
+   F_LED2_MODE,
+   F_LED3_MODE,
+   F_LED4_MODE,
+   F_LED1_DUTY,
+   F_LED2_DUTY,
+   F_LED3_DUTY,
+   F_LED4_DUTY,
+   F_LED1_FREQ,
+   F_LED2_FREQ,
+   F_LED3_FREQ,
+   F_LED4_FREQ,
+   F_MAX_FIELDS
+};
+
+enum mt6370_led_ranges {
+   R_LED123_CURR = 0,
+   R_LED4_CURR,
+   R_LED_TRFON,
+   R_LED_TOFF,
+   R_MAX_RANGES,
+};
+
+enum mt6370_pattern {
+   P_LED_TR1 = 0,
+   P_LED_TR2,
+   P_LED_TF1,
+   P_LED_TF2,
+   P_LED_TON,
+   P_LED_TOFF,
+   P_MAX_PATTERNS
+};
+
+#define MT6370_REG_DEV_INFO0x100
+#define MT6370_REG_RGB1_DIM0x182
+#define MT6370_REG_RGB2_DIM0x183
+#define MT6370_REG_RGB3_DIM0x184
+#define MT6370_REG_RGB_EN  0x185
+#define MT6370_REG_RGB1_ISNK   0x186
+#define MT6370_REG_RGB2_ISNK   0x187
+#define MT6370_REG_RGB3_ISNK   0x188
+#define MT6370_REG_RGB1_TR 0x189
+#define MT6370_REG_RGB_CHRIND_DIM  0x192
+#define MT6370_REG_RGB_CHRIND_CTRL 0x193
+#define MT6370_REG_RGB_CHRIND_TR   0x194
+
+#define MT6372_REG_RGB_EN  0x182
+#define MT6372_REG_RGB1_ISNK   0x183
+#define MT6372_REG_RGB2_ISNK   0x184
+#define MT6372_REG_RGB3_ISNK   0x185
+#define MT6372_REG_RGB4_ISNK   0x186
+#define MT6372_REG_RGB1_DIM0x187
+#define MT6372_REG_RGB2_DIM0x188
+#define MT6372_REG_RGB3_DIM0x189
+#define MT6372_REG_RGB4_DIM0x18A
+#define MT6372_REG_RGB12_FREQ  0x18B
+#define MT6372_REG_RGB34_FREQ  0x18C
+#define MT6372_REG_RGB1_TR 0x18D
+
+#define MT6370_VENID_MASK  GENMASK(7, 4)
+#define MT6370_CHEN_BIT(id)BIT(MT6370_LED_ISNK4 - id)
+#define MT6370_VIRTUAL_MULTICOLOR  5
+#define MC_CHANNEL_NUM 3
+#define MT6370_PWM_DUTY31
+#define MT6372_PMW_DUTY255
+
+#define STATE_OFF  0
+#define STATE_KEEP 1
+#define STATE_ON   2
+
+struct mt6370_led {
+   union {
+