add support for MCP16502 PMIC
Subsystems (3)
v2 cover add support for MCP16502 PMIC
MCP16502 is a Power Management IC from Microchip.
It has 4 Buck outputs and 2 LDOs. The buck regulators can be used in two modes: normal(FPWM) and low-power(Auto PFM).
This patch series adds support for the MCP16502 PMIC.
v2:
- use lpm-gpios instead of lpm-gpio in devicetree bindings documentation
- describe the regulators present on the PMIC in the devicetree bindings documentation
- add SPDX license inside a C++ comment
- prefix macro
- remove mcp16502_update_regulator and mcp16502_read
- replace ?: with if-else
- change some if-else with switch statements for legibility
- use regmap helpers for regultor settings during runtime
- make mcp16502_get_status read the status from the PMIC STS registers
- use module_i2c_driver
- use the PMIC's Hibernate registers for suspend-to-mem, the PMIC's Low-power registers for standby and the PMIC's Active registers for normal runtime
Note about mcp16502_suspend:
- mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_HIB) has now been changed to mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_LPM) for legibility.
Note that the function call only sets the LPM pin of the PMIC to high. This puts the PMIC in Low-power operating mode. Hibernate operating mode is reached when the MPU sets the PWRHLD line to zero (typically when entering suspend-to-ram).
Andrei Stefanescu (3):
regulator: dt-bindings: add MCP16502 regulator bindings
MAINTAINERS: add maintainer for MCP16502 PMIC driver
regulator: mcp16502: add regulator driver for MCP16502
.../bindings/regulator/mcp16502-regulator.txt | 143 ++++++ MAINTAINERS | 7 + drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/mcp16502.c | 542 +++++++++++++++++++++ 5 files changed, 702 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/mcp16502-regulator.txt create mode 100644 drivers/regulator/mcp16502.c
Signature · 1 line
2.7.4
PATCH v2 1/3 regulator: dt-bindings: add MCP16502 regulator bindings
This patch describes the compatible and the device tree bindings necessary for the MCP16502 PMIC.
--- .../bindings/regulator/mcp16502-regulator.txt | 143 +++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/mcp16502-regulator.txt
Documentation/devicetree/bindings/regulator/mcp16502-regulator.txt new file +143 -0
@@ -0,0 +1,143 @@ +MCP16502 PMIC + +Required properties: +- compatible: "microchip,mcp16502" +- reg: I2C slave address +- lpm-gpios: GPIO for LPM pin. Note that this GPIO *must* remain high during + suspend-to-ram, keeping the PMIC into HIBERNATE mode. +- regulators: A node that houses a sub-node for each regulator within + the device. Each sub-node is identified using the node's + name. The content of each sub-node is defined by the + standard binding for regulators; see regulator.txt. + +Regualtors of MCP16502 PMIC: +1) VDD_IO - Buck (1.2 - 3.7 V) +2) VDD_DDR - Buck (0.6 - 1.85 V) +3) VDD_CORE - Buck (0.6 - 1.85 V) +4) VDD_OTHER - BUCK (0.6 - 1.85 V) +5) LDO1 - LDO (1.2 - 3.7 V) +6) LDO2 - LDO (1.2 - 3.7 V) + +Regulator modes: +2 - FPWM: higher precision, higher consumption +4 - AutoPFM: lower precision, lower consumption + +Each regulator is defined using the standard binding for regulators. + +Example: + +mcp16502 at 5b { + compatible = "microchip,mcp16502"; + reg = <0x5b>; + status = "okay"; + lpm-gpios = <&pioBU 7 GPIO_ACTIVE_HIGH>; + + regulators { + VDD_IO { + regulator-name = "VDD_IO"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <3700000>; + regulator-initial-mode = <2>; + regulator-allowed-modes = <2>, <4>; + regulator-always-on; + + regulator-state-standby { + regulator-on-in-suspend; + regulator-mode = <4>; + }; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-mode = <4>; + }; + }; + + VDD_DDR { + regulator-name = "VDD_DDR"; + regulator-min-microvolt = <600000>; + regulator-max-microvolt = <1850000>; + regulator-initial-mode = <2>; + regulator-allowed-modes = <2>, <4>; + regulator-always-on; + + regulator-state-standby { + regulator-on-in-suspend; + regulator-mode = <4>; + }; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-mode = <4>; + }; + }; + + VDD_CORE { + regulator-name = "VDD_CORE"; + regulator-min-microvolt = <600000>; + regulator-max-microvolt = <1850000>; + regulator-initial-mode = <2>; + regulator-allowed-modes = <2>, <4>; + regulator-always-on; + + regulator-state-standby { + regulator-on-in-suspend; + regulator-mode = <4>; + }; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-mode = <4>; + }; + }; + + VDD_OTHER { + regulator-name = "VDD_OTHER"; + regulator-min-microvolt = <600000>; + regulator-max-microvolt = <1850000>; + regulator-initial-mode = <2>; + regulator-allowed-modes = <2>, <4>; + regulator-always-on; + + regulator-state-standby { + regulator-on-in-suspend; + regulator-mode = <4>; + }; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-mode = <4>; + }; + }; + + LDO1 { + regulator-name = "LDO1"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <3700000>; + regulator-always-on; + + regulator-state-standby { + regulator-on-in-suspend; + }; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + LDO2 { + regulator-name = "LDO2"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <3700000>; + regulator-always-on; + + regulator-state-standby { + regulator-on-in-suspend; + }; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + }; +};
Signature · 1 line
2.7.4
PATCH v2 2/3 MAINTAINERS: add maintainer for MCP16502 PMIC driver
In reply to [email protected]This patch adds a maintainer for the MCP16502 PMIC driver.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -9730,6 +9730,13 @@ M: Ludovic Desroches <[email protected]> S: Maintained F: drivers/mmc/host/atmel-mci.c +MICROCHIP MCP16502 PMIC DRIVER +M: Andrei Stefanescu <[email protected]> +L: linux-arm-kernel at lists.infradead.org (moderated for non-subscribers) +S: Maintained +F: Documentation/devicetree/bindings/regulator/mcp16502-regulator.txt +F: drivers/regulator/mcp16502.c + MICROCHIP MCP3911 ADC DRIVER M: Marcus Folkesson <[email protected]> M: Kent Gustavsson <[email protected]>
Signature · 1 line
2.7.4
PATCH v2 3/3 regulator: mcp16502: add regulator driver for MCP16502
In reply to [email protected]This patch adds a regulator driver for the MCP16502 PMIC. This drivers supports basic operations through the regulator interface such as:
- setting/reading voltage
- setting/reading operating mode
- reading current status
- transitioning to/from suspend-to-ram and standby power states
--- drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/mcp16502.c | 542 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 552 insertions(+) create mode 100644 drivers/regulator/mcp16502.c
drivers/regulator/Kconfig +9 -0
@@ -567,6 +567,15 @@ config REGULATOR_MC13892 Say y here to support the regulators found on the Freescale MC13892 PMIC. +config REGULATOR_MCP16502 + tristate "Microchip MCP16502 PMIC" + depends on I2C && OF + help + Say y here to support the MCP16502 PMIC. This driver supports + basic operations (get/set voltage, get/set operating mode) + through the regulator interface. In addition it enables + suspend-to-ram/standby transition. + config REGULATOR_MT6311 tristate "MediaTek MT6311 PMIC" depends on I2C
drivers/regulator/Makefile +1 -0
@@ -74,6 +74,7 @@ obj-$(CONFIG_REGULATOR_MAX77802) += max77802-regulator.o obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o +obj-$(CONFIG_REGULATOR_MCP16502) += mcp16502.o obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o
drivers/regulator/mcp16502.c new file +542 -0
542 lines not on this page · raw message
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH v2 3/3] regulator: mcp16502: add regulator driver for MCP16502
Thank you for the patch! Yet something to improve:
Hi Andrei.Stefanescu,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on regulator/for-next]
[also build test ERROR on v4.20-rc4 next-20181127]
[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/Andrei-Stefanescu-microchip-com/add-support-for-MCP16502-PMIC/20181128-041809 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next config: sh-allyesconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.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.2.0 make.cross ARCH=sh
All error/warnings (new ones prefixed by >>):
drivers//regulator/mcp16502.c: In function 'mcp16502_suspend_get_target_reg':
>> drivers//regulator/mcp16502.c:273:10: error: 'pm_suspend_target_state' undeclared (first use in this function); did you mean 'pm_suspended_storage'?
switch (pm_suspend_target_state) {
^~~~~~~~~~~~~~~~~~~~~~~
pm_suspended_storage
drivers//regulator/mcp16502.c:273:10: note: each undeclared identifier is reported only once for each function it appears in
drivers//regulator/mcp16502.c: In function 'mcp16502_set_suspend_mode':
drivers//regulator/mcp16502.c:310:10: error: 'pm_suspend_target_state' undeclared (first use in this function); did you mean 'pm_suspended_storage'?
switch (pm_suspend_target_state) {
^~~~~~~~~~~~~~~~~~~~~~~
pm_suspended_storage
drivers//regulator/mcp16502.c: In function 'mcp16502_suspend_get_target_reg':
>> drivers//regulator/mcp16502.c:284:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
drivers//regulator/mcp16502.c: In function 'mcp16502_set_suspend_mode':
drivers//regulator/mcp16502.c:321:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^vim +273 drivers//regulator/mcp16502.c
266
267 /*
268 * mcp16502_suspend_get_target_reg() - get the reg of the target suspend PMIC
269 * mode
270 */
271 static int mcp16502_suspend_get_target_reg(struct regulator_dev *rdev)
272 {
> 273 switch (pm_suspend_target_state) {
274 case PM_SUSPEND_STANDBY:
275 return mcp16502_get_reg(rdev, MCP16502_OPMODE_LPM);
276 case PM_SUSPEND_ON:
277 case PM_SUSPEND_MEM:
278 return mcp16502_get_reg(rdev, MCP16502_OPMODE_HIB);
279 default:
280 dev_err(&rdev->dev, "invalid suspend target: %d\n",
281 pm_suspend_target_state);
282 return -EINVAL;
283 }
> 284 }285
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 50575 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181128/5945d017/attachment-0001.gz>
kbuild test robot
build bot[PATCH] regulator: mcp16502: fix platform_no_drv_owner.cocci warnings
In reply to [email protected]drivers/regulator/mcp16502.c:530:3-8: No need to set .owner here. The core will do it.
From: kbuild test robot <[email protected]>
drivers/regulator/mcp16502.c:530:3-8: No need to set .owner here. The core will do it.
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci
---
url: https://github.com/0day-ci/linux/commits/Andrei-Stefanescu-microchip-com/add-support-for-MCP16502-PMIC/20181128-041809 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
mcp16502.c | 1 - 1 file changed, 1 deletion(-)
drivers/regulator/mcp16502.c +0 -1
@@ -527,7 +527,6 @@ static struct i2c_driver mcp16502_drv = .probe = mcp16502_probe, .driver = { .name = "mcp16502-regulator", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(mcp16502_ids), .pm = &mcp16502_pm_ops, },
kbuild test robot
build botRe: [PATCH v2 3/3] regulator: mcp16502: add regulator driver for MCP16502
In reply to [email protected]Thank you for the patch! Perhaps something to improve:
Hi Andrei.Stefanescu,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on regulator/for-next]
[also build test WARNING on v4.20-rc4 next-20181127]
[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/Andrei-Stefanescu-microchip-com/add-support-for-MCP16502-PMIC/20181128-041809 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
coccinelle warnings: (new ones prefixed by >>)
>> drivers/regulator/mcp16502.c:530:3-8: No need to set .owner here. The core will do it.
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation