Skip to contentSkip to conversation

Add Support for Hi6220 PMIC Hi6553 MFD Core

PATCH Superseded Chen Feng 4 participants 13 messages Jan 4, 2016 – Jan 11, 2016

Subsystems (4)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Chen Feng

author
#0 lore raw

v4 cover Add Support for Hi6220 PMIC Hi6553 MFD Core

The patch sets add support for Hi6220 PMIC Hi655x MFD core and its regulator driver.
Current testing and support board is Hikey which is one of 96boards.
It is an arm64 open source board. For more information about this board, please access https://www.96boards.org.

This is hardware layout for access PMIC Hi655x from AP SoC Hi6220. Between PMIC Hi655x and Hi6220, the physical signal channel is SSI. We can use memory-mapped I/O to communicate.

+----------------+             +-------------+
|                |             |             |
|    Hi6220      |   SSI bus   |   Hi655x    |
|                |-------------|             |
|                |(REGMAP_MMIO)|             |
+----------------+             +-------------+

V2: Code refactoring of regulator.

V3: Drop mtcmos from this patch and use regmap-irq.

V4: Move the vset-table to driver code and donot open code for it.

Chen Feng (5):
doc: bindings: Add document for mfd hi665x PMIC
doc: bindings: Document for hi655x regulator driver
mfd: hi655x: Add hi665x pmic driver
regulator: add regulator driver of hi655x pmic hisilicon/dts: Add hi655x pmic dts node

 .../devicetree/bindings/mfd/hisilicon,hi655x.txt   |  17 ++
 .../regulator/hisilicon,hi655x-regulator.txt       |  24 +++
 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts     |   5 +
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |  99 +++++++++
 drivers/mfd/Kconfig                                |  10 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/hi655x-pmic.c                          | 160 ++++++++++++++
 drivers/regulator/Kconfig                          |   8 +
 drivers/regulator/Makefile                         |   1 +
 drivers/regulator/hi655x-regulator.c               | 232 +++++++++++++++++++++
 include/linux/mfd/hi655x-pmic.h                    |  56 +++++
 11 files changed, 613 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/hisilicon,hi655x.txt
 create mode 100644 Documentation/devicetree/bindings/regulator/hisilicon,hi655x-regulator.txt
 create mode 100644 drivers/mfd/hi655x-pmic.c
 create mode 100644 drivers/regulator/hi655x-regulator.c
 create mode 100644 include/linux/mfd/hi655x-pmic.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v4 1/5 doc: bindings: Add document for mfd hi665x PMIC

Add document for mfd driver hi655x pmic driver

---
 .../devicetree/bindings/mfd/hisilicon,hi655x.txt        | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/hisilicon,hi655x.txt
Documentation/devicetree/bindings/mfd/hisilicon,hi655x.txt new file +17 -0
new file mode 100644
index 0000000..9479619
@@ -0,0 +1,17 @@
+Hisilicon hi655x Power Management Integrated Circuit (PMIC)
+
+Required properties:
+- compatible: Should be "hisilicon,hi655x-pmic"
+- reg: Base address of PMIC on hi6220 soc
+- interrupt-controller: Hi655x has internal IRQs (has own IRQ domain).
+- pmic-gpios: The gpio used by pmic irq.
+
+Example:
+	pmic: pmic@f8000000 {
+		compatible = "hisilicon,hi655x-pmic-driver";
+		reg = <0x0 0xf8000000 0x0 0x1000>;
+		#interrupt-cells = <2>;
+		interrupt-controller;
+		pmic-gpios = <&gpio1 2 0>;
+		status = "disabled";
+	}
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH v4 2/5 doc: bindings: Document for hi655x regulator driver

In reply to Chen Feng

Add Document for hi655x pmic regulator driver

---
 .../regulator/hisilicon,hi655x-regulator.txt       | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regulator/hisilicon,hi655x-regulator.txt
Documentation/devicetree/bindings/regulator/hisilicon,hi655x-regulator.txt new file +24 -0
new file mode 100644
index 0000000..1cf71a0
@@ -0,0 +1,24 @@
+Hisilicon Hi655x Voltage regulators
+
+Note:
+The hi655x regulator control is managed by hi655x Power IC.
+So the node of this regulator must be child node of hi655x
+pmic node.
+
+The driver uses the regulator core framework, so please also
+take the bindings of regulator.txt for reference.
+
+Example:
+        pmic: pmic@f8000000 {
+                compatible = "hisilicon,hi655x-pmic";
+		...
+		ldo2: ldo2@a21 {
+			compatible = "hisilicon,hi655x-regulator";
+			regulator-name = "ldo2";
+			regulator-min-microvolt = <2500000>;
+			regulator-max-microvolt = <3200000>;
+			regulator-valid-modes-mask = <0x02>;
+			regulator-enable-ramp-delay = <120>;
+		};
+		...
+	}
Signature · 1 line
1.9.1
maintainer
#3 lore raw

Re: [PATCH v4 2/5] doc: bindings: Document for hi655x regulator driver

Quoted 1 line · Chen Feng

Add Document for hi655x pmic regulator driver

As indicated in the driver review this seems to be a bit of an unusual binding that I think needs reworking, also it needs a bit more detail - for example, listing which regulator names are valid.

Please also use subject lines reflecting the normal style for the subsystem.

author
#4 lore raw

Re: [PATCH v4 2/5] doc: bindings: Document for hi655x regulator driver

Quoted 10 lines · Mark Brown
Quoted 1 line · Chen Feng

Add Document for hi655x pmic regulator driver

As indicated in the driver review this seems to be a bit of an unusual binding that I think needs reworking, also it needs a bit more detail - for example, listing which regulator names are valid.

Please also use subject lines reflecting the normal style for the subsystem.

OK,Thanks.

author
#5 lore raw

PATCH v4 3/5 mfd: hi655x: Add hi665x pmic driver

In reply to Chen Feng

Add pmic mfd driver to support hisilicon hi665x.

---
 drivers/mfd/Kconfig             |  10 +++
 drivers/mfd/Makefile            |   1 +
 drivers/mfd/hi655x-pmic.c       | 160 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/hi655x-pmic.h |  56 ++++++++++++++
 4 files changed, 227 insertions(+)
 create mode 100644 drivers/mfd/hi655x-pmic.c
 create mode 100644 include/linux/mfd/hi655x-pmic.h
drivers/mfd/Kconfig +10 -0
index 4d92df6..0c84186 100644
@@ -284,6 +284,16 @@ config MFD_HI6421_PMIC
 	  menus in order to enable them.
 	  We communicate with the Hi6421 via memory-mapped I/O.
 
+config MFD_HI655X_PMIC
+	tristate "HiSilicon Hi655X series PMU/Codec IC"
+	depends on ARCH_HISI || COMPILE_TEST
+	depends on OF
+	select MFD_CORE
+	select REGMAP_MMIO
+	select REGMAP_IRQ
+	help
+	  Select this option to enable Hisilicon hi655x series pmic driver.
+
 config HTC_EGPIO
 	bool "HTC EGPIO support"
 	depends on GPIOLIB && ARM
drivers/mfd/Makefile +1 -0
index a8b76b8..6a7b0e1 100644
@@ -186,6 +186,7 @@ obj-$(CONFIG_MFD_STW481X)	+= stw481x.o
 obj-$(CONFIG_MFD_IPAQ_MICRO)	+= ipaq-micro.o
 obj-$(CONFIG_MFD_MENF21BMC)	+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)	+= hi6421-pmic-core.o
+obj-$(CONFIG_MFD_HI655X_PMIC)   += hi655x-pmic.o
 obj-$(CONFIG_MFD_DLN2)		+= dln2.o
 obj-$(CONFIG_MFD_RT5033)	+= rt5033.o
 obj-$(CONFIG_MFD_SKY81452)	+= sky81452.o
drivers/mfd/hi655x-pmic.c new file +160 -0

160 lines not on this page · raw message

include/linux/mfd/hi655x-pmic.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH v4 3/5] mfd: hi655x: Add hi665x pmic driver

reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Chen,

[auto build test ERROR on v4.4-rc8]
[also build test ERROR on next-20160104]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Chen-Feng/Add-Support-for-Hi6220-PMIC-Hi6553-MFD-Core/20160104-203635
config: tile-allmodconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=tile

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

>> drivers/mfd/hi655x-pmic.c:156:1: warning: data definition has no type or storage class [enabled by default]
>> drivers/mfd/hi655x-pmic.c:156:1: error: type defaults to 'int' in declaration of 'module_init'
>> drivers/mfd/hi655x-pmic.c:156:1: warning: parameter names (without types) in function declaration [enabled by default]
>> drivers/mfd/hi655x-pmic.c:156:1: warning: data definition has no type or storage class [enabled by default]
>> drivers/mfd/hi655x-pmic.c:156:1: error: type defaults to 'int' in declaration of 'module_exit'
>> drivers/mfd/hi655x-pmic.c:156:1: warning: parameter names (without types) in function declaration [enabled by default]
>> drivers/mfd/hi655x-pmic.c:158:15: error: expected declaration specifiers or '...' before string constant

drivers/mfd/hi655x-pmic.c:159:20: error: expected declaration specifiers or '...' before string constant drivers/mfd/hi655x-pmic.c:160:16: error: expected declaration specifiers or '...' before string constant drivers/mfd/hi655x-pmic.c:156:1: warning: 'hi655x_pmic_driver_init' defined but not used drivers/mfd/hi655x-pmic.c:156:1: warning: 'hi655x_pmic_driver_exit' defined but not used
cc1: some warnings being treated as errors

vim +156 drivers/mfd/hi655x-pmic.c

150 .driver = {
151 .name = "hi655x-pmic",
152 .of_match_table = of_hi655x_pmic_match_tbl,
153 },
154 .probe = hi655x_pmic_probe,
155 };

 > 156	module_platform_driver(hi655x_pmic_driver);
   157	
 > 158	MODULE_AUTHOR("Chen Feng <[email protected]>");

159 MODULE_DESCRIPTION("Hisi hi655x pmic driver");
160 MODULE_LICENSE("GPL v2");

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

#7 lore raw

Re: [PATCH v4 3/5] mfd: hi655x: Add hi665x pmic driver

In reply to Chen Feng
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Chen,

[auto build test WARNING on v4.4-rc8]
[also build test WARNING on next-20160104]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Chen-Feng/Add-Support-for-Hi6220-PMIC-Hi6553-MFD-Core/20160104-203635
config: parisc-allmodconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=parisc

All warnings (new ones prefixed by >>):

In file included from include/linux/platform_device.h:14:0,

                    from drivers/mfd/hi655x-pmic.c:19:
   include/linux/device.h:1329:1: warning: data definition has no type or storage class
    module_init(__driver##_init); \
    ^
   include/linux/platform_device.h:222:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(hi655x_pmic_driver);
    ^
   include/linux/device.h:1329:1: error: type defaults to 'int' in declaration of 'module_init' [-Werror=implicit-int]
    module_init(__driver##_init); \
    ^
   include/linux/platform_device.h:222:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(hi655x_pmic_driver);
    ^
   drivers/mfd/hi655x-pmic.c:156:1: warning: parameter names (without types) in function declaration
   In file included from include/linux/platform_device.h:14:0,
                    from drivers/mfd/hi655x-pmic.c:19:
   include/linux/device.h:1334:1: warning: data definition has no type or storage class
    module_exit(__driver##_exit);
    ^
   include/linux/platform_device.h:222:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(hi655x_pmic_driver);
    ^
   include/linux/device.h:1334:1: error: type defaults to 'int' in declaration of 'module_exit' [-Werror=implicit-int]
    module_exit(__driver##_exit);
    ^
   include/linux/platform_device.h:222:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
>> drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(hi655x_pmic_driver);
    ^
   drivers/mfd/hi655x-pmic.c:156:1: warning: parameter names (without types) in function declaration
   drivers/mfd/hi655x-pmic.c:158:15: error: expected declaration specifiers or '...' before string constant
    MODULE_AUTHOR("Chen Feng <[email protected]>");
                  ^
   drivers/mfd/hi655x-pmic.c:159:20: error: expected declaration specifiers or '...' before string constant
    MODULE_DESCRIPTION("Hisi hi655x pmic driver");
                       ^
   drivers/mfd/hi655x-pmic.c:160:16: error: expected declaration specifiers or '...' before string constant
    MODULE_LICENSE("GPL v2");
                   ^
   In file included from include/linux/platform_device.h:14:0,
                    from drivers/mfd/hi655x-pmic.c:19:
   drivers/mfd/hi655x-pmic.c:156:24: warning: 'hi655x_pmic_driver_init' defined but not used [-Wunused-function]
    module_platform_driver(hi655x_pmic_driver);
                           ^
   include/linux/device.h:1325:19: note: in definition of macro 'module_driver'
    static int __init __driver##_init(void) \
                      ^
>> drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(hi655x_pmic_driver);
    ^
   drivers/mfd/hi655x-pmic.c:156:24: warning: 'hi655x_pmic_driver_exit' defined but not used [-Wunused-function]
    module_platform_driver(hi655x_pmic_driver);
                           ^
   include/linux/device.h:1330:20: note: in definition of macro 'module_driver'
    static void __exit __driver##_exit(void) \
                       ^
>> drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'
    module_platform_driver(hi655x_pmic_driver);
    ^

cc1: some warnings being treated as errors

vim +/module_platform_driver +156 drivers/mfd/hi655x-pmic.c

    13	
    14	#include <linux/io.h>
    15	#include <linux/interrupt.h>
    16	#include <linux/init.h>
    17	#include <linux/gpio.h>
    18	#include <linux/of_gpio.h>
  > 19	#include <linux/platform_device.h>
    20	#include <linux/of_platform.h>
    21	#include <linux/mfd/hi655x-pmic.h>
    22	#include <linux/regmap.h>
    23	
    24	static const struct of_device_id of_hi655x_pmic_child_match_tbl[] = {
    25		{ .compatible = "hisilicon,hi655x-regulator", },
    26		{},
    27	};
    28	
    29	static const struct of_device_id of_hi655x_pmic_match_tbl[] = {
    30		{ .compatible = "hisilicon,hi655x-pmic", },
    31		{},
    32	};
    33	
    34	static const struct regmap_irq hi655x_irqs[] = {
    35		{ .reg_offset = 0, .mask = OTMP_D1R_INT },
    36		{ .reg_offset = 0, .mask = VSYS_2P5_R_INT },
    37		{ .reg_offset = 0, .mask = VSYS_UV_D3R_INT },
    38		{ .reg_offset = 0, .mask = VSYS_6P0_D200UR_INT },
    39		{ .reg_offset = 0, .mask = PWRON_D4SR_INT },
    40		{ .reg_offset = 0, .mask = PWRON_D20F_INT },
    41		{ .reg_offset = 0, .mask = PWRON_D20R_INT },
    42		{ .reg_offset = 0, .mask = RESERVE_INT },
    43	};
    44	
    45	static const struct regmap_irq_chip hi655x_irq_chip = {
    46		.name = "hi655x-pmic",
    47		.irqs = hi655x_irqs,
    48		.num_regs = 1,
    49		.num_irqs = ARRAY_SIZE(hi655x_irqs),
    50		.status_base = HI655X_IRQ_STAT_BASE,
    51		.mask_base = HI655X_IRQ_MASK_BASE,
    52	};
    53	
    54	static unsigned int hi655x_pmic_get_version(struct hi655x_pmic *pmic)
    55	{
    56		u32 val;
    57	
    58		regmap_read(pmic->regmap,
    59			    HI655X_BUS_ADDR(HI655X_VER_REG), &val);
    60	
    61		return val;
    62	}
    63	
    64	static struct regmap_config hi655x_regmap_config = {
    65		.reg_bits = 32,
    66		.reg_stride = HI655X_STRIDE,
    67		.val_bits = 8,
    68		.max_register = HI655X_BUS_ADDR(0xFFF),
    69	};
    70	
    71	static void hi655x_local_irq_clear(struct regmap *map)
    72	{
    73		int i;
    74	
    75		regmap_write(map, HI655X_ANA_IRQM_BASE, HI655X_IRQ_CLR);
    76		for (i = 0; i < HI655X_IRQ_ARRAY; i++) {
    77			regmap_write(map, HI655X_IRQ_STAT_BASE + i * HI655X_STRIDE,
    78				     HI655X_IRQ_CLR);
    79		}
    80	}
    81	
    82	static int hi655x_pmic_probe(struct platform_device *pdev)
    83	{
    84		int ret;
    85		struct hi655x_pmic *pmic;
    86		struct device *dev = &pdev->dev;
    87		struct device_node *np = dev->of_node;
    88		void __iomem *base;
    89	
    90		pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
    91		pmic->dev = dev;
    92	
    93		pmic->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    94		if (!pmic->res) {
    95			dev_err(dev, "platform_get_resource err\n");
    96			return -ENOENT;
    97		}
    98		base = devm_ioremap_resource(dev, pmic->res);
    99		if (!base) {
   100			dev_err(dev, "cannot map register memory\n");
   101			return -ENOMEM;
   102		}
   103		pmic->regmap = devm_regmap_init_mmio_clk(dev, NULL, base,
   104							 &hi655x_regmap_config);
   105	
   106		pmic->ver = hi655x_pmic_get_version(pmic);
   107		if ((pmic->ver < PMU_VER_START) || (pmic->ver > PMU_VER_END)) {
   108			dev_warn(dev, "it is wrong pmu version\n");
   109			return -EINVAL;
   110		}
   111	
   112		hi655x_local_irq_clear(pmic->regmap);
   113	
   114		pmic->gpio = of_get_named_gpio(np, "pmic-gpios", 0);
   115		if (!gpio_is_valid(pmic->gpio)) {
   116			dev_err(dev, "cannot get the pmic-gpios\n");
   117			return -ENODEV;
   118		}
   119	
   120		ret = devm_gpio_request_one(dev, pmic->gpio, GPIOF_IN, "hi655x_pmic_irq");
   121		if (ret < 0) {
   122			dev_err(dev, "failed to request gpio %d  ret = %d\n",
   123				pmic->gpio, ret);
   124			return ret;
   125		}
   126	
   127		ret = regmap_add_irq_chip(pmic->regmap, gpio_to_irq(pmic->gpio),
   128					  IRQF_TRIGGER_LOW | IRQF_NO_SUSPEND, 0,
   129					  &hi655x_irq_chip, &pmic->irq_data);
   130		if (ret) {
   131			dev_err(dev, "add pmic irq chip error! ret %d\n", ret);
   132			return ret;
   133		}
   134	
   135		/* bind pmic to device */
   136		platform_set_drvdata(pdev, pmic);
   137	
   138		/* populate sub nodes */
   139		ret = of_platform_populate(np, of_hi655x_pmic_child_match_tbl,
   140					   NULL, dev);
   141		if (ret) {
   142			regmap_del_irq_chip(pmic->irq, pmic->irq_data);
   143			return ret;
   144		}
   145	
   146		return 0;
   147	}
   148	
   149	static struct platform_driver hi655x_pmic_driver = {
   150		.driver	= {
   151			.name =	"hi655x-pmic",
   152			.of_match_table = of_hi655x_pmic_match_tbl,
   153		},
   154		.probe  = hi655x_pmic_probe,
   155	};
 > 156	module_platform_driver(hi655x_pmic_driver);

157
158 MODULE_AUTHOR("Chen Feng <[email protected]>");
159 MODULE_DESCRIPTION("Hisi hi655x pmic driver");

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

#8 lore raw

Re: [PATCH v4 3/5] mfd: hi655x: Add hi665x pmic driver

Obviously I am unable to accept (or even review) this patch until these issues are resolved. Please fix and resubmit the set.

Quoted 240 lines · kbuild test robot

[auto build test WARNING on v4.4-rc8]
[also build test WARNING on next-20160104]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Chen-Feng/Add-Support-for-Hi6220-PMIC-Hi6553-MFD-Core/20160104-203635
config: parisc-allmodconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=parisc

All warnings (new ones prefixed by >>):

   In file included from include/linux/platform_device.h:14:0,
                    from drivers/mfd/hi655x-pmic.c:19:
   include/linux/device.h:1329:1: warning: data definition has no type or storage class
    module_init(__driver##_init); \
    ^
   include/linux/platform_device.h:222:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
Quoted 1 line
Quoted 1 line

drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'

    module_platform_driver(hi655x_pmic_driver);
    ^
   include/linux/device.h:1329:1: error: type defaults to 'int' in declaration of 'module_init' [-Werror=implicit-int]
    module_init(__driver##_init); \
    ^
   include/linux/platform_device.h:222:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
Quoted 1 line
Quoted 1 line

drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'

    module_platform_driver(hi655x_pmic_driver);
    ^
   drivers/mfd/hi655x-pmic.c:156:1: warning: parameter names (without types) in function declaration
   In file included from include/linux/platform_device.h:14:0,
                    from drivers/mfd/hi655x-pmic.c:19:
   include/linux/device.h:1334:1: warning: data definition has no type or storage class
    module_exit(__driver##_exit);
    ^
   include/linux/platform_device.h:222:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
Quoted 1 line
Quoted 1 line

drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'

    module_platform_driver(hi655x_pmic_driver);
    ^
   include/linux/device.h:1334:1: error: type defaults to 'int' in declaration of 'module_exit' [-Werror=implicit-int]
    module_exit(__driver##_exit);
    ^
   include/linux/platform_device.h:222:2: note: in expansion of macro 'module_driver'
     module_driver(__platform_driver, platform_driver_register, \
     ^
Quoted 1 line
Quoted 1 line

drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'

    module_platform_driver(hi655x_pmic_driver);
    ^
   drivers/mfd/hi655x-pmic.c:156:1: warning: parameter names (without types) in function declaration
   drivers/mfd/hi655x-pmic.c:158:15: error: expected declaration specifiers or '...' before string constant
    MODULE_AUTHOR("Chen Feng <[email protected]>");
                  ^
   drivers/mfd/hi655x-pmic.c:159:20: error: expected declaration specifiers or '...' before string constant
    MODULE_DESCRIPTION("Hisi hi655x pmic driver");
                       ^
   drivers/mfd/hi655x-pmic.c:160:16: error: expected declaration specifiers or '...' before string constant
    MODULE_LICENSE("GPL v2");
                   ^
   In file included from include/linux/platform_device.h:14:0,
                    from drivers/mfd/hi655x-pmic.c:19:
   drivers/mfd/hi655x-pmic.c:156:24: warning: 'hi655x_pmic_driver_init' defined but not used [-Wunused-function]
    module_platform_driver(hi655x_pmic_driver);
                           ^
   include/linux/device.h:1325:19: note: in definition of macro 'module_driver'
    static int __init __driver##_init(void) \
                      ^
Quoted 1 line
Quoted 1 line

drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'

    module_platform_driver(hi655x_pmic_driver);
    ^
   drivers/mfd/hi655x-pmic.c:156:24: warning: 'hi655x_pmic_driver_exit' defined but not used [-Wunused-function]
    module_platform_driver(hi655x_pmic_driver);
                           ^
   include/linux/device.h:1330:20: note: in definition of macro 'module_driver'
    static void __exit __driver##_exit(void) \
                       ^
Quoted 1 line
Quoted 1 line

drivers/mfd/hi655x-pmic.c:156:1: note: in expansion of macro 'module_platform_driver'

    module_platform_driver(hi655x_pmic_driver);
    ^

cc1: some warnings being treated as errors

vim +/module_platform_driver +156 drivers/mfd/hi655x-pmic.c

    13	
    14	#include <linux/io.h>
    15	#include <linux/interrupt.h>
    16	#include <linux/init.h>
    17	#include <linux/gpio.h>
    18	#include <linux/of_gpio.h>
Quoted 1 line

19 #include <linux/platform_device.h>

    20	#include <linux/of_platform.h>
    21	#include <linux/mfd/hi655x-pmic.h>
    22	#include <linux/regmap.h>
    23	
    24	static const struct of_device_id of_hi655x_pmic_child_match_tbl[] = {
    25		{ .compatible = "hisilicon,hi655x-regulator", },
    26		{},
    27	};
    28	
    29	static const struct of_device_id of_hi655x_pmic_match_tbl[] = {
    30		{ .compatible = "hisilicon,hi655x-pmic", },
    31		{},
    32	};
    33	
    34	static const struct regmap_irq hi655x_irqs[] = {
    35		{ .reg_offset = 0, .mask = OTMP_D1R_INT },
    36		{ .reg_offset = 0, .mask = VSYS_2P5_R_INT },
    37		{ .reg_offset = 0, .mask = VSYS_UV_D3R_INT },
    38		{ .reg_offset = 0, .mask = VSYS_6P0_D200UR_INT },
    39		{ .reg_offset = 0, .mask = PWRON_D4SR_INT },
    40		{ .reg_offset = 0, .mask = PWRON_D20F_INT },
    41		{ .reg_offset = 0, .mask = PWRON_D20R_INT },
    42		{ .reg_offset = 0, .mask = RESERVE_INT },
    43	};
    44	
    45	static const struct regmap_irq_chip hi655x_irq_chip = {
    46		.name = "hi655x-pmic",
    47		.irqs = hi655x_irqs,
    48		.num_regs = 1,
    49		.num_irqs = ARRAY_SIZE(hi655x_irqs),
    50		.status_base = HI655X_IRQ_STAT_BASE,
    51		.mask_base = HI655X_IRQ_MASK_BASE,
    52	};
    53	
    54	static unsigned int hi655x_pmic_get_version(struct hi655x_pmic *pmic)
    55	{
    56		u32 val;
    57	
    58		regmap_read(pmic->regmap,
    59			    HI655X_BUS_ADDR(HI655X_VER_REG), &val);
    60	
    61		return val;
    62	}
    63	
    64	static struct regmap_config hi655x_regmap_config = {
    65		.reg_bits = 32,
    66		.reg_stride = HI655X_STRIDE,
    67		.val_bits = 8,
    68		.max_register = HI655X_BUS_ADDR(0xFFF),
    69	};
    70	
    71	static void hi655x_local_irq_clear(struct regmap *map)
    72	{
    73		int i;
    74	
    75		regmap_write(map, HI655X_ANA_IRQM_BASE, HI655X_IRQ_CLR);
    76		for (i = 0; i < HI655X_IRQ_ARRAY; i++) {
    77			regmap_write(map, HI655X_IRQ_STAT_BASE + i * HI655X_STRIDE,
    78				     HI655X_IRQ_CLR);
    79		}
    80	}
    81	
    82	static int hi655x_pmic_probe(struct platform_device *pdev)
    83	{
    84		int ret;
    85		struct hi655x_pmic *pmic;
    86		struct device *dev = &pdev->dev;
    87		struct device_node *np = dev->of_node;
    88		void __iomem *base;
    89	
    90		pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
    91		pmic->dev = dev;
    92	
    93		pmic->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    94		if (!pmic->res) {
    95			dev_err(dev, "platform_get_resource err\n");
    96			return -ENOENT;
    97		}
    98		base = devm_ioremap_resource(dev, pmic->res);
    99		if (!base) {
   100			dev_err(dev, "cannot map register memory\n");
   101			return -ENOMEM;
   102		}
   103		pmic->regmap = devm_regmap_init_mmio_clk(dev, NULL, base,
   104							 &hi655x_regmap_config);
   105	
   106		pmic->ver = hi655x_pmic_get_version(pmic);
   107		if ((pmic->ver < PMU_VER_START) || (pmic->ver > PMU_VER_END)) {
   108			dev_warn(dev, "it is wrong pmu version\n");
   109			return -EINVAL;
   110		}
   111	
   112		hi655x_local_irq_clear(pmic->regmap);
   113	
   114		pmic->gpio = of_get_named_gpio(np, "pmic-gpios", 0);
   115		if (!gpio_is_valid(pmic->gpio)) {
   116			dev_err(dev, "cannot get the pmic-gpios\n");
   117			return -ENODEV;
   118		}
   119	
   120		ret = devm_gpio_request_one(dev, pmic->gpio, GPIOF_IN, "hi655x_pmic_irq");
   121		if (ret < 0) {
   122			dev_err(dev, "failed to request gpio %d  ret = %d\n",
   123				pmic->gpio, ret);
   124			return ret;
   125		}
   126	
   127		ret = regmap_add_irq_chip(pmic->regmap, gpio_to_irq(pmic->gpio),
   128					  IRQF_TRIGGER_LOW | IRQF_NO_SUSPEND, 0,
   129					  &hi655x_irq_chip, &pmic->irq_data);
   130		if (ret) {
   131			dev_err(dev, "add pmic irq chip error! ret %d\n", ret);
   132			return ret;
   133		}
   134	
   135		/* bind pmic to device */
   136		platform_set_drvdata(pdev, pmic);
   137	
   138		/* populate sub nodes */
   139		ret = of_platform_populate(np, of_hi655x_pmic_child_match_tbl,
   140					   NULL, dev);
   141		if (ret) {
   142			regmap_del_irq_chip(pmic->irq, pmic->irq_data);
   143			return ret;
   144		}
   145	
   146		return 0;
   147	}
   148	
   149	static struct platform_driver hi655x_pmic_driver = {
   150		.driver	= {
   151			.name =	"hi655x-pmic",
   152			.of_match_table = of_hi655x_pmic_match_tbl,
   153		},
   154		.probe  = hi655x_pmic_probe,
   155	};
Quoted 1 line

156 module_platform_driver(hi655x_pmic_driver);

157

   158	MODULE_AUTHOR("Chen Feng <[email protected]>");
   159	MODULE_DESCRIPTION("Hisi hi655x pmic driver");

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

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#9 lore raw

PATCH v4 4/5 regulator: add regulator driver of hi655x pmic

In reply to Chen Feng

Add regulator support for hi655x pmic

---
 drivers/regulator/Kconfig            |   8 ++
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/hi655x-regulator.c | 232 +++++++++++++++++++++++++++++++++++
 3 files changed, 241 insertions(+)
 create mode 100644 drivers/regulator/hi655x-regulator.c
drivers/regulator/Kconfig +8 -0
index 8df0b0e..2e9eaa7 100644
@@ -261,6 +261,14 @@ config REGULATOR_HI6421
 	  21 general purpose LDOs, 3 dedicated LDOs, and 5 BUCKs. All
 	  of them come with support to either ECO (idle) or sleep mode.
 
+config REGULATOR_HI655X
+	tristate "Hisilicon HI655X PMIC regulators support"
+	depends on ARCH_HISI || COMPILE_TEST
+	depends on MFD_HI655X_PMIC && OF
+	help
+	  This driver provides support for the voltage regulators of the
+	  Hisilicon Hi655x PMIC device.
+
 config REGULATOR_ISL9305
 	tristate "Intersil ISL9305 regulator"
 	depends on I2C
drivers/regulator/Makefile +1 -0
index 0f81749..8e4db96 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
 obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
 obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
 obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o
+obj-$(CONFIG_REGULATOR_HI655X) += hi655x-regulator.o
 obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
 obj-$(CONFIG_REGULATOR_ISL9305) += isl9305.o
 obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
drivers/regulator/hi655x-regulator.c new file +232 -0

232 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#10 lore raw

Re: [PATCH v4 4/5] regulator: add regulator driver of hi655x pmic

Quoted 1 line · Chen Feng

+/*LDO 2 & LDO 14*/

Please use the normal kernel coding style for comments, I'm surprised checkpatch didn't warn you about this.

drivers/regulator/hi655x-regulator.c line 37

Quoted 3 lines
drivers/regulator/hi655x-regulator.c new file +3 -0
+static const unsigned int ldo2_voltages[] = {
+	2500000, 2600000, 2700000, 2800000,
+	2900000, 3000000, 3100000, 3200000,

This looks like a linear range from 2.5V in steps of 100mV? A linear range is better than a table since values can be mapped directly without having to scan a table.

drivers/regulator/hi655x-regulator.c line 43

Quoted 4 lines
drivers/regulator/hi655x-regulator.c new file +4 -0
+/*LDO7 & LDO10*/
+static const unsigned int ldo7_voltages[] = {
+	1800000, 1850000, 2850000, 2900000,
+	3000000, 3100000, 3200000, 3300000,

This is the sort of thing a voltage table is for where the voltages aren't evenly spaced and don't map onto a formula.

drivers/regulator/hi655x-regulator.c line 166

Quoted 6 lines
drivers/regulator/hi655x-regulator.c new file +6 -0
+static const struct of_device_id of_hi655x_regulator_match_tbl[] = {
+	{
+		.compatible = "hisilicon,hi655x-regulator",
+	},
+};
+MODULE_DEVICE_TABLE(of, of_hi655x_regulator_match_tbl);

A couple of problems here. One is that the compatible strings should be for specific devices, not use a wildcard. The other is that since this is part of a PMIC and we already have a compatible string for the PMIC so this is really just a set of properties for that device rather than a totally separate device - we're not achieving any real reuse over multiple devices or anything.

Quoted 5 lines
drivers/regulator/hi655x-regulator.c new file +5 -0
+	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
+		if (!of_node_cmp(np->name, regulators[i].rdesc.name))
+			break;
+	}
+

drivers/regulator/hi655x-regulator.c line 203

Quoted 10 lines
drivers/regulator/hi655x-regulator.c new file +10 -0
+	if (i == ARRAY_SIZE(regulators)) {
+		dev_err(dev, "error regulator %s int dts\n", np->name);
+		return -ENODEV;
+	}
+
+	regulator = &regulators[i];
+	init_data = of_get_regulator_init_data(dev, np,
+					       &regulator->rdesc);
+	if (!init_data)
+		return -EINVAL;

Don't open code this, use the standard support with of_match and regulators_node.

drivers/regulator/hi655x-regulator.c line 214

Quoted 10 lines
drivers/regulator/hi655x-regulator.c new file +9 -0
+	config.dev = dev;
+	config.init_data = init_data;
+	config.driver_data = regulator;
+	config.regmap = pmic->regmap;
+	config.of_node = pdev->dev.of_node;
 
+	rdev = devm_regulator_register(dev, &regulator->rdesc,
+				       &config);
+	if (IS_ERR(rdev))
+		return PTR_ERR(rdev);

Though this looks like it's trying to have a device per regulator which is an unusual pattern and if we are doing that then relying on the node name to figure out which device this is a bit broken.

author
#11 lore raw

Re: [PATCH v4 4/5] regulator: add regulator driver of hi655x pmic

Quoted 7 lines · Mark Brown
Quoted 1 line · Chen Feng

+/*LDO 2 & LDO 14*/

Please use the normal kernel coding style for comments, I'm surprised checkpatch didn't warn you about this.

ok,thanks!

Quoted 8 lines

drivers/regulator/hi655x-regulator.c line 37

Quoted 3 lines
drivers/regulator/hi655x-regulator.c new file +3 -0
+static const unsigned int ldo2_voltages[] = {
+	2500000, 2600000, 2700000, 2800000,
+	2900000, 3000000, 3100000, 3200000,

This looks like a linear range from 2.5V in steps of 100mV? A linear range is better than a table since values can be mapped directly without having to scan a table.

Agree with you.

Quoted 8 lines

drivers/regulator/hi655x-regulator.c line 43

Quoted 4 lines
drivers/regulator/hi655x-regulator.c new file +4 -0
+/*LDO7 & LDO10*/
+static const unsigned int ldo7_voltages[] = {
+	1800000, 1850000, 2850000, 2900000,
+	3000000, 3100000, 3200000, 3300000,

This is the sort of thing a voltage table is for where the voltages aren't evenly spaced and don't map onto a formula.

Quoted 13 lines

drivers/regulator/hi655x-regulator.c line 166

Quoted 6 lines
drivers/regulator/hi655x-regulator.c new file +6 -0
+static const struct of_device_id of_hi655x_regulator_match_tbl[] = {
+	{
+		.compatible = "hisilicon,hi655x-regulator",
+	},
+};
+MODULE_DEVICE_TABLE(of, of_hi655x_regulator_match_tbl);

A couple of problems here. One is that the compatible strings should be for specific devices, not use a wildcard. The other is that since this is part of a PMIC and we already have a compatible string for the PMIC so this is really just a set of properties for that device rather than a totally separate device - we're not achieving any real reuse over multiple devices or anything.

ok.

Quoted 26 lines
Quoted 6 lines
drivers/regulator/hi655x-regulator.c new file +5 -0
+	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
+		if (!of_node_cmp(np->name, regulators[i].rdesc.name))
+			break;
+	}
+

drivers/regulator/hi655x-regulator.c line 203

Quoted 10 lines
drivers/regulator/hi655x-regulator.c new file +10 -0
+	if (i == ARRAY_SIZE(regulators)) {
+		dev_err(dev, "error regulator %s int dts\n", np->name);
+		return -ENODEV;
+	}
+
+	regulator = &regulators[i];
+	init_data = of_get_regulator_init_data(dev, np,
+					       &regulator->rdesc);
+	if (!init_data)
+		return -EINVAL;

Don't open code this, use the standard support with of_match and regulators_node.

Quoted 5 lines
drivers/regulator/hi655x-regulator.c new file +5 -0
+	config.dev = dev;
+	config.init_data = init_data;
+	config.driver_data = regulator;
+	config.regmap = pmic->regmap;
+	config.of_node = pdev->dev.of_node;
Quoted 9 lines

drivers/regulator/hi655x-regulator.c line 214

Quoted 4 lines
drivers/regulator/hi655x-regulator.c new file +4 -0
+	rdev = devm_regulator_register(dev, &regulator->rdesc,
+				       &config);
+	if (IS_ERR(rdev))
+		return PTR_ERR(rdev);

Though this looks like it's trying to have a device per regulator which is an unusual pattern and if we are doing that then relying on the node name to figure out which device this is a bit broken.

ok, I will fix the patch and resend it.

author
#12 lore raw

PATCH v4 5/5 hisilicon/dts: Add hi655x pmic dts node

In reply to Chen Feng

Add the mfd hi655x dts node and regulator support

---
 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts |  5 ++
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi      | 99 ++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts +5 -0
index 8d43a0f..f714ac7 100644
@@ -31,4 +31,9 @@
 		device_type = "memory";
 		reg = <0x0 0x0 0x0 0x40000000>;
 	};
+
+};
+
+&pmic {
+	status = "okay";
 };
arch/arm64/boot/dts/hisilicon/hi6220.dtsi +99 -0

104 lines not on this page · raw message

Signature · 1 line
1.9.1