Skip to contentSkip to conversation

mfd: mt6360: add pmic mt6360 driver

PATCH Superseded Gene Chen 3 participants 8 messages Sep 18, 2019 – Sep 24, 2019

Subsystems (2)

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Gene Chen

author
#0 lore raw

PATCH 1/1 mfd: mt6360: add pmic mt6360 driver

From: Gene Chen <[email protected]>

Add mfd driver for mt6360 pmic chip include
Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck

---
 drivers/mfd/Kconfig                |  12 +
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/mt6360-core.c          | 463 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mt6360-private.h | 279 ++++++++++++++++++++++
 include/linux/mfd/mt6360.h         |  33 +++
 5 files changed, 788 insertions(+)
 create mode 100644 drivers/mfd/mt6360-core.c
 create mode 100644 include/linux/mfd/mt6360-private.h
 create mode 100644 include/linux/mfd/mt6360.h
drivers/mfd/Kconfig +12 -0
index f129f96..a422c76 100644
@@ -862,6 +862,18 @@ config MFD_MAX8998
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_MT6360
+	tristate "Mediatek MT6360 SubPMIC"
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	depends on I2C
+	help
+	  Say Y here to enable MT6360 PMU/PMIC/LDO functional support.
+	  PMU part include charger, flashlight, rgb led
+	  PMIC part include 2-channel BUCKs and 2-channel LDOs
+	  LDO part include 4-channel LDOs
+
 config MFD_MT6397
 	tristate "MediaTek MT6397 PMIC Support"
 	select MFD_CORE
drivers/mfd/Makefile +1 -0
index f026ada..77a8f0b 100644
@@ -241,6 +241,7 @@ obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
 obj-$(CONFIG_INTEL_SOC_PMIC_BXTWC)	+= intel_soc_pmic_bxtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC)	+= intel_soc_pmic_chtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC_CHTDC_TI)	+= intel_soc_pmic_chtdc_ti.o
+obj-$(CONFIG_MFD_MT6360)	+= mt6360-core.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
drivers/mfd/mt6360-core.c new file +463 -0

463 lines not on this page · raw message

include/linux/mfd/mt6360-private.h new file +279 -0

279 lines not on this page · raw message

include/linux/mfd/mt6360.h new file +33 -0
new file mode 100644
index 0000000..ba2e80a
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019 MediaTek Inc.
+ */
+
+#ifndef __MT6360_H__
+#define __MT6360_H__
+
+#include <linux/regmap.h>
+
+enum {
+	MT6360_SLAVE_PMU = 0,
+	MT6360_SLAVE_PMIC,
+	MT6360_SLAVE_LDO,
+	MT6360_SLAVE_TCPC,
+	MT6360_SLAVE_MAX,
+};
+
+#define MT6360_PMU_SLAVEID	(0x34)
+#define MT6360_PMIC_SLAVEID	(0x1A)
+#define MT6360_LDO_SLAVEID	(0x64)
+#define MT6360_TCPC_SLAVEID	(0x4E)
+
+struct mt6360_pmu_info {
+	struct i2c_client *i2c[MT6360_SLAVE_MAX];
+	struct device *dev;
+	struct regmap *regmap;
+	struct regmap_irq_chip_data *irq_data;
+	struct regmap_irq_chip irq_chip;
+	unsigned int chip_rev;
+};
+
+#endif /* __MT6360_H__ */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · Gene Chen

From: Gene Chen <[email protected]>

Add mfd driver for mt6360 pmic chip include
Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck

---

This looks different from the one you sent before, but I don't see a version bump or any changelog in this space. Please re-submit with the differences noted.

Quoted 9 lines
 drivers/mfd/Kconfig                |  12 +
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/mt6360-core.c          | 463 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mt6360-private.h | 279 ++++++++++++++++++++++
 include/linux/mfd/mt6360.h         |  33 +++
 5 files changed, 788 insertions(+)
 create mode 100644 drivers/mfd/mt6360-core.c
 create mode 100644 include/linux/mfd/mt6360-private.h
 create mode 100644 include/linux/mfd/mt6360.h
Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#2 lore raw

Lee Jones <[email protected]> 於 2019年9月18日 週三 下午6:51寫道:

Quoted 8 lines · Gene Chen
Quoted 6 lines

From: Gene Chen <[email protected]>

Add mfd driver for mt6360 pmic chip include
Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck

Quoted 7 lines
Quoted 2 lines

---

This looks different from the one you sent before, but I don't see a version bump or any changelog in this space. Please re-submit with the differences noted.

the change is
1. add missing include file
2. modify commit message

this patch is regarded as version 1

Quoted 15 lines
Quoted 9 lines
 drivers/mfd/Kconfig                |  12 +
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/mt6360-core.c          | 463 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mt6360-private.h | 279 ++++++++++++++++++++++
 include/linux/mfd/mt6360.h         |  33 +++
 5 files changed, 788 insertions(+)
 create mode 100644 drivers/mfd/mt6360-core.c
 create mode 100644 include/linux/mfd/mt6360-private.h
 create mode 100644 include/linux/mfd/mt6360.h

--
Lee Jones [李琼斯]
Linaro Services Technical Lead

Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw
Quoted 17 lines · Gene Chen

Lee Jones <[email protected]> 於 2019年9月18日 週三 下午6:51寫道:

Quoted 8 lines · Gene Chen
Quoted 6 lines

From: Gene Chen <[email protected]>

Add mfd driver for mt6360 pmic chip include
Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck

Quoted 7 lines
Quoted 2 lines

---

This looks different from the one you sent before, but I don't see a version bump or any changelog in this space. Please re-submit with the differences noted.

Quoted 5 lines

the change is
1. add missing include file
2. modify commit message

this patch is regarded as version 1

It's different to the first one you sent to the list, so it needs a version bump and a change log. There also appears to still be issues with it, if the auto-builders are to be believed.

Do ensure you thoroughly test your patches before sending upstream.

Please fix the issues and resubmit your v3 with a nice changelog.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
 drivers/mfd/Kconfig                |  12 +
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/mt6360-core.c          | 463 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mt6360-private.h | 279 ++++++++++++++++++++++
 include/linux/mfd/mt6360.h         |  33 +++
 5 files changed, 788 insertions(+)
 create mode 100644 drivers/mfd/mt6360-core.c
 create mode 100644 include/linux/mfd/mt6360-private.h
 create mode 100644 include/linux/mfd/mt6360.h
Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#4 lore raw

2019-09-19 15:18 GMT+08:00, Lee Jones <[email protected]>:

Quoted 25 lines · Gene Chen
Quoted 18 lines

Lee Jones <[email protected]> 於 2019年9月18日 週三 下午6:51寫道:

Quoted 8 lines · Gene Chen
Quoted 6 lines

From: Gene Chen <[email protected]>

Add mfd driver for mt6360 pmic chip include
Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck

Quoted 7 lines
Quoted 2 lines

---

This looks different from the one you sent before, but I don't see a version bump or any changelog in this space. Please re-submit with the differences noted.

Quoted 5 lines

the change is
1. add missing include file
2. modify commit message

this patch is regarded as version 1

Quoted 8 lines

It's different to the first one you sent to the list, so it needs a version bump and a change log. There also appears to still be issues with it, if the auto-builders are to be believed.

Do ensure you thoroughly test your patches before sending upstream.

Please fix the issues and resubmit your v3 with a nice changelog.

thank you for suggestion
may i ask how to disable kbuild test reboot for s390/x86_64/ia64? we want support only cross compiler = aarch64-linux-gnu- and we have test build pass with our patch

Quoted 18 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
 drivers/mfd/Kconfig                |  12 +
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/mt6360-core.c          | 463
+++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mt6360-private.h | 279 ++++++++++++++++++++++
 include/linux/mfd/mt6360.h         |  33 +++
 5 files changed, 788 insertions(+)
 create mode 100644 drivers/mfd/mt6360-core.c
 create mode 100644 include/linux/mfd/mt6360-private.h
 create mode 100644 include/linux/mfd/mt6360.h

--
Lee Jones [李琼斯]
Linaro Services Technical Lead

Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw
Quoted 32 lines · Gene Chen

2019-09-19 15:18 GMT+08:00, Lee Jones <[email protected]>:

Quoted 31 lines · Gene Chen
Quoted 18 lines

Lee Jones <[email protected]> 於 2019年9月18日 週三 下午6:51寫道:

Quoted 8 lines · Gene Chen
Quoted 6 lines

From: Gene Chen <[email protected]>

Add mfd driver for mt6360 pmic chip include
Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck

Quoted 7 lines
Quoted 2 lines

---

This looks different from the one you sent before, but I don't see a version bump or any changelog in this space. Please re-submit with the differences noted.

Quoted 5 lines

the change is
1. add missing include file
2. modify commit message

this patch is regarded as version 1

It's different to the first one you sent to the list, so it needs a version bump and a change log. There also appears to still be issues with it, if the auto-builders are to be believed.

Do ensure you thoroughly test your patches before sending upstream.

Quoted 7 lines
Quoted 2 lines

Please fix the issues and resubmit your v3 with a nice changelog.

thank you for suggestion
may i ask how to disable kbuild test reboot for s390/x86_64/ia64? we want support only cross compiler = aarch64-linux-gnu- and we have test build pass with our patch

You can't and we wouldn't want to.

If this driver should only be built/tested for AArch64, you need to ensure the Kconfig represents that.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw
In reply to Gene Chen
Thank you for the patch! Yet something to improve:

Hi Gene,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3 next-20190917]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Gene-Chen/mfd-mt6360-add-pmic-mt6360-driver/20190918-181850
config: x86_64-randconfig-s0-201937 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-13) 7.4.0 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

In file included from <command-line>:0:0:

>> include/linux/mfd/mt6360-private.h:234:51: warning: 'struct device_node' declared inside parameter list will not be visible outside of this definition or declaration
    static inline void mt6360_dt_parser_helper(struct device_node *np, void *data,
                                                      ^~~~~~~~~~~
   include/linux/mfd/mt6360-private.h: In function 'mt6360_dt_parser_helper':
>> include/linux/mfd/mt6360-private.h:243:3: error: implicit declaration of function 'of_property_read_u32' [-Werror=implicit-function-declaration]
      of_property_read_u32(np, props[i].name, data + props[i].offset);
      ^~~~~~~~~~~~~~~~~~~~
   include/linux/mfd/mt6360-private.h: In function 'mt6360_pdata_apply_helper':
>> include/linux/mfd/mt6360-private.h:271:9: error: implicit declaration of function 'regmap_update_bits'; did you mean 'work_data_bits'? [-Werror=implicit-function-declaration]

ret = regmap_update_bits(context,
^~~~~~~~~~~~~~~~~~
work_data_bits
cc1: some warnings being treated as errors

vim +/of_property_read_u32 +243 include/linux/mfd/mt6360-private.h

233

 > 234	static inline void mt6360_dt_parser_helper(struct device_node *np, void *data,
   235						   const struct mt6360_val_prop *props,
   236						   int prop_cnt)
   237	{
   238		int i;
   239	
   240		for (i = 0; i < prop_cnt; i++) {
   241			if (unlikely(!props[i].name))
   242				continue;
 > 243			of_property_read_u32(np, props[i].name, data + props[i].offset);
   244		}
   245	}
   246	
   247	#define MT6360_PDATA_VALPROP(name, type, reg, shift, mask, func, base) \
   248				{offsetof(type, name), reg, shift, mask, func, base}
   249	
   250	struct mt6360_pdata_prop {
   251		size_t offset;
   252		u8 reg;
   253		u8 shift;
   254		u8 mask;
   255		u32 (*transform)(u32 val);
   256		u8 base;
   257	};
   258	
   259	static inline int mt6360_pdata_apply_helper(void *context, void *pdata,
   260						   const struct mt6360_pdata_prop *prop,
   261						   int prop_cnt)
   262	{
   263		int i, ret;
   264		u32 val;
   265	
   266		for (i = 0; i < prop_cnt; i++) {
   267			val = *(u32 *)(pdata + prop[i].offset);
   268			if (prop[i].transform)
   269				val = prop[i].transform(val);
   270			val += prop[i].base;
 > 271			ret = regmap_update_bits(context,

272 prop[i].reg, prop[i].mask, val << prop[i].shift);
273 if (ret < 0)
274 return ret;
275 }
276 return 0;
277 }
278

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#7 lore raw
In reply to Gene Chen
Thank you for the patch! Yet something to improve:

Hi Gene,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3 next-20190917]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Gene-Chen/mfd-mt6360-add-pmic-mt6360-driver/20190918-181850
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

In file included from <command-line>:0:0:
include/linux/mfd/mt6360-private.h: In function 'mt6360_dt_parser_helper':
include/linux/mfd/mt6360-private.h:243:3: error: implicit declaration of function 'of_property_read_u32' [-Werror=implicit-function-declaration]

      of_property_read_u32(np, props[i].name, data + props[i].offset);
      ^~~~~~~~~~~~~~~~~~~~
   include/linux/mfd/mt6360-private.h: In function 'mt6360_pdata_apply_helper':
>> include/linux/mfd/mt6360-private.h:271:9: error: implicit declaration of function 'regmap_update_bits'; did you mean 'file_update_time'? [-Werror=implicit-function-declaration]

ret = regmap_update_bits(context,
^~~~~~~~~~~~~~~~~~ file_update_time
cc1: some warnings being treated as errors

vim +271 include/linux/mfd/mt6360-private.h

233
234 static inline void mt6360_dt_parser_helper(struct device_node *np, void *data,
235 const struct mt6360_val_prop *props,
236 int prop_cnt)
237 {
238 int i;
239
240 for (i = 0; i < prop_cnt; i++) {
241 if (unlikely(!props[i].name))
242 continue;

 > 243			of_property_read_u32(np, props[i].name, data + props[i].offset);
   244		}
   245	}
   246	
   247	#define MT6360_PDATA_VALPROP(name, type, reg, shift, mask, func, base) \
   248				{offsetof(type, name), reg, shift, mask, func, base}
   249	
   250	struct mt6360_pdata_prop {
   251		size_t offset;
   252		u8 reg;
   253		u8 shift;
   254		u8 mask;
   255		u32 (*transform)(u32 val);
   256		u8 base;
   257	};
   258	
   259	static inline int mt6360_pdata_apply_helper(void *context, void *pdata,
   260						   const struct mt6360_pdata_prop *prop,
   261						   int prop_cnt)
   262	{
   263		int i, ret;
   264		u32 val;
   265	
   266		for (i = 0; i < prop_cnt; i++) {
   267			val = *(u32 *)(pdata + prop[i].offset);
   268			if (prop[i].transform)
   269				val = prop[i].transform(val);
   270			val += prop[i].base;
 > 271			ret = regmap_update_bits(context,

272 prop[i].reg, prop[i].mask, val << prop[i].shift);
273 if (ret < 0)
274 return ret;
275 }
276 return 0;
277 }
278

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

_______________________________________________
linux-arm-kernel mailing list [email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel