Add battery charger driver support for MP2629
Subsystems (5)
Saravanan Sekar
maintainerv8 cover Add battery charger driver support for MP2629
changes in v8:
- fixed order of call in probe/remove in iio adc
- add ABI documentation for mp2629 power supply
changes in v7:
- fixed probe/remove order, managed and unmanaged call mix use in adc.
- Documentation dual license, i2c node with controller address
changes in v6:
- removed includes types.h in mfd, of_device.h in adc.
- fixed review comments parentheses, err check, kstrtouint
changes in v5:
- removed platfrom data stored in mfd and directly accessed mfd struct in child
- fixed spell check and capitalization in mfd and documentation
changes in v4:
- fixed capitalization in mfg Kconfig and documentation
changes in v3:
- regmap for children passed using platform data and remove mfd driver info access directly from children
changes in v2:
- removed EXPORT_SYMBOL of register set/get helper
- regmap bit filed used, fixed other review comments
This patch series add support for Battery charger control driver for Monolithic Power System's MP2629 chipset, includes MFD driver for ADC battery & input power supply measurement and battery charger control driver.
Thanks,
Saravanan
Saravanan Sekar (6):
dt-bindings: mfd: add document bindings for mp2629
mfd: mp2629: Add support for mps battery charger
iio: adc: mp2629: Add support for mp2629 ADC driver
power: supply: Add support for mps mp2629 battery charger
power: supply: mp2629: Add impedance compenstation config
MAINTAINERS: Add entry for mp2629 Battery Charger driver
.../ABI/testing/sysfs-class-power-mp2629 | 8 + .../devicetree/bindings/mfd/mps,mp2629.yaml | 60 ++ MAINTAINERS | 5 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mp2629_adc.c | 208 ++++++ drivers/mfd/Kconfig | 9 + drivers/mfd/Makefile | 2 + drivers/mfd/mp2629.c | 86 +++ drivers/power/supply/Kconfig | 10 + drivers/power/supply/Makefile | 1 + drivers/power/supply/mp2629_charger.c | 687 ++++++++++++++++++ include/linux/mfd/mp2629.h | 28 + 13 files changed, 1115 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-mp2629 create mode 100644 Documentation/devicetree/bindings/mfd/mps,mp2629.yaml create mode 100644 drivers/iio/adc/mp2629_adc.c create mode 100644 drivers/mfd/mp2629.c create mode 100644 drivers/power/supply/mp2629_charger.c create mode 100644 include/linux/mfd/mp2629.h
Signature · 1 line
2.17.1
Saravanan Sekar
maintainerPATCH v8 1/6 dt-bindings: mfd: add document bindings for mp2629
Add device tree binding information for mp2629 mfd driver.
--- .../devicetree/bindings/mfd/mps,mp2629.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mps,mp2629.yaml
Documentation/devicetree/bindings/mfd/mps,mp2629.yaml new file +60 -0
@@ -0,0 +1,60 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/mps,mp2629.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MP2629 Battery Charger PMIC from Monolithic Power System. + +maintainers: + - Saravanan Sekar <[email protected]> + +description: | + MP2629 is a PMIC providing battery charging and power supply for smartphones, + wireless camera and portable devices. Chip is contrlled over I2C. + + The battery charge management device handles battery charger controller and + ADC IIO device for battery, system voltage + +properties: + compatible: + const: mps,mp2629 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": + const: 2 + description: + The first cell is the IRQ number, the second cell is the trigger type. + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - "#interrupt-cells" + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/input/linux-event-codes.h> + i2c@7e205000 { + #address-cells = <1>; + #size-cells = <0>; + + pmic@4b { + compatible = "mps,mp2629"; + reg = <0x4b>; + + interrupt-controller; + interrupt-parent = <&gpio2>; + #interrupt-cells = <2>; + interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; + }; + };
Signature · 1 line
2.17.1
Saravanan Sekar
maintainerPATCH v8 2/6 mfd: mp2629: Add support for mps battery charger
In reply to Saravanan Sekarmp2629 is a highly-integrated switching-mode battery charge management device for single-cell Li-ion or Li-polymer battery.
Add MFD core enables chip access for ADC driver for battery readings, and a power supply battery-charger driver
--- drivers/mfd/Kconfig | 9 ++++ drivers/mfd/Makefile | 2 + drivers/mfd/mp2629.c | 86 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/mp2629.h | 19 +++++++++ 4 files changed, 116 insertions(+) create mode 100644 drivers/mfd/mp2629.c create mode 100644 include/linux/mfd/mp2629.h
drivers/mfd/Kconfig +9 -0
@@ -434,6 +434,15 @@ config MFD_MC13XXX_I2C help Select this if your MC13xxx is connected via an I2C bus. +config MFD_MP2629 + tristate "Monolithic power system MP2629 ADC and Battery charger" + depends on I2C + select REGMAP_I2C + help + Select this option to enable support for monolithic power system + battery charger. This provides ADC, thermal, battery charger power + management functions on the systems. + config MFD_MXS_LRADC tristate "Freescale i.MX23/i.MX28 LRADC" depends on ARCH_MXS || COMPILE_TEST
drivers/mfd/Makefile +2 -0
@@ -170,6 +170,8 @@ obj-$(CONFIG_MFD_MAX8925) += max8925.o obj-$(CONFIG_MFD_MAX8997) += max8997.o max8997-irq.o obj-$(CONFIG_MFD_MAX8998) += max8998.o max8998-irq.o +obj-$(CONFIG_MFD_MP2629) += mp2629.o + pcf50633-objs := pcf50633-core.o pcf50633-irq.o obj-$(CONFIG_MFD_PCF50633) += pcf50633.o obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
drivers/mfd/mp2629.c new file +86 -0
86 lines not on this page · raw message
include/linux/mfd/mp2629.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* register definitions for MP2629 charger +* +* Copyright 2020 Monolithic Power Systems, Inc +*/ + +#ifndef __MP2629_H__ +#define __MP2629_H__ + +#include <linux/device.h> +#include <linux/regmap.h> + +struct mp2629_info { +struct device *dev; +struct regmap *regmap; +}; + +#endif
Signature · 1 line
2.17.1
Saravanan Sekar
maintainerPATCH v8 3/6 iio: adc: mp2629: Add support for mp2629 ADC driver
In reply to Saravanan SekarAdd support for 8-bit resolution ADC readings for input power supply and battery charging measurement. Provides voltage, current readings to mp2629 power supply driver.
--- drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mp2629_adc.c | 208 +++++++++++++++++++++++++++++++++++ include/linux/mfd/mp2629.h | 9 ++ 4 files changed, 228 insertions(+) create mode 100644 drivers/iio/adc/mp2629_adc.c
drivers/iio/adc/Kconfig +10 -0
@@ -680,6 +680,16 @@ config MESON_SARADC To compile this driver as a module, choose M here: the module will be called meson_saradc. +config MP2629_ADC + tristate "Monolithic MP2629 ADC driver" + depends on MFD_MP2629 + help + Say yes to have support for battery charger IC MP2629 ADC device + accessed over I2C. + + This driver provides ADC conversion of system, input power supply + and battery voltage & current information. + config NAU7802 tristate "Nuvoton NAU7802 ADC driver" depends on I2C
drivers/iio/adc/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_MCP3911) += mcp3911.o obj-$(CONFIG_MEDIATEK_MT6577_AUXADC) += mt6577_auxadc.o obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o obj-$(CONFIG_MESON_SARADC) += meson_saradc.o +obj-$(CONFIG_MP2629_ADC) += mp2629_adc.o obj-$(CONFIG_MXS_LRADC_ADC) += mxs-lradc-adc.o obj-$(CONFIG_NAU7802) += nau7802.o obj-$(CONFIG_NPCM_ADC) += npcm_adc.o
drivers/iio/adc/mp2629_adc.c new file +208 -0
208 lines not on this page · raw message
include/linux/mfd/mp2629.h +9 -0
@@ -16,4 +16,13 @@ struct mp2629_info { struct regmap *regmap; }; +enum mp2629_adc_chan { +MP2629_BATT_VOLT , +MP2629_SYSTEM_VOLT , +MP2629_INPUT_VOLT , +MP2629_BATT_CURRENT , +MP2629_INPUT_CURRENT , +MP2629_ADC_CHAN_END +}; +#endif
Signature · 1 line
2.17.1
Saravanan Sekar
maintainerPATCH v8 4/6 power: supply: Add support for mps mp2629 battery charger
In reply to Saravanan SekarThe mp2629 provides switching-mode battery charge management for single-cell Li-ion or Li-polymer battery. Driver supports the access/control input source and battery charging parameters.
--- drivers/power/supply/Kconfig | 10 + drivers/power/supply/Makefile | 1 + drivers/power/supply/mp2629_charger.c | 687 ++++++++++++++++++++++++++ 3 files changed, 698 insertions(+) create mode 100644 drivers/power/supply/mp2629_charger.c
drivers/power/supply/Kconfig +10 -0
@@ -541,6 +541,16 @@ config CHARGER_MAX8998 Say Y to enable support for the battery charger control sysfs and platform data of MAX8998/LP3974 PMICs. +config CHARGER_MP2629 + tristate "Monolithic power system MP2629 Battery charger" + depends on MFD_MP2629 + depends on MP2629_ADC + depends on IIO + help + Select this option to enable support for Monolithic power system + Battery charger. This driver provies Battery charger power management + functions on the systems. + config CHARGER_QCOM_SMBB tristate "Qualcomm Switch-Mode Battery Charger and Boost" depends on MFD_SPMI_PMIC || COMPILE_TEST
drivers/power/supply/Makefile +1 -0
@@ -75,6 +75,7 @@ obj-$(CONFIG_CHARGER_MAX77650) += max77650-charger.o obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o +obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o obj-$(CONFIG_CHARGER_QCOM_SMBB) += qcom_smbb.o obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o
drivers/power/supply/mp2629_charger.c new file +687 -0
687 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v8 4/6] power: supply: Add support for mps mp2629 battery charger
Quoted 4 lines · Saravanan Sekar
The mp2629 provides switching-mode battery charge management for single-cell Li-ion or Li-polymer battery. Driver supports the access/control input source and battery charging parameters.
...
drivers/power/supply/mp2629_charger.c line 630
Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+static int mp2629_charger_probe (struct platform_device *pdev) +{ + irq =platform_get_irq (to_platform_device (pdev->dev.parent),0 );
Why not to use temporary variable dev?
This should be platform_get_irq_optional().
Quoted 11 lines
drivers/power/supply/mp2629_charger.c new file +10
-0+if (irq) { + ret =devm_request_irq (dev, irq, mp2629_irq_handler, +IRQF_TRIGGER_RISING ,"mp2629-charger" , + charger); +if (ret) { +dev_err (dev,"failed to request gpio IRQ\n" ); + goto iio_fail; + } + } +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
saravanan sekar
maintainerRe: [PATCH v8 4/6] power: supply: Add support for mps mp2629 battery charger
Hi Andy,
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Saravanan Sekar
The mp2629 provides switching-mode battery charge management for single-cell Li-ion or Li-polymer battery. Driver supports the access/control input source and battery charging parameters.
Quoted 8 lines
...
drivers/power/supply/mp2629_charger.c line 630
Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+static int mp2629_charger_probe (struct platform_device *pdev) +{ + irq =platform_get_irq (to_platform_device (pdev->dev.parent),0 );Why not to use temporary variable dev?
This should be
platform_get_irq_optional().
Platform_get_irq in turn calls platform_get_irq_optional. It was suggested by Lee and is it mandatory to change it?
Quoted 10 lines
Quoted 10 lines
drivers/power/supply/mp2629_charger.c new file +10
-0+if (irq) { + ret =devm_request_irq (dev, irq, mp2629_irq_handler, +IRQF_TRIGGER_RISING ,"mp2629-charger" , + charger); +if (ret) { +dev_err (dev,"failed to request gpio IRQ\n" ); + goto iio_fail; + } + } +}
Re: [PATCH v8 4/6] power: supply: Add support for mps mp2629 battery charger
Hi,
Quoted 14 lines · saravanan sekar
Hi Andy,
Quoted 11 lines · Andy Shevchenko
Quoted 3 lines · Saravanan Sekar
The mp2629 provides switching-mode battery charge management for single-cell Li-ion or Li-polymer battery. Driver supports the access/control input source and battery charging parameters.
...
drivers/power/supply/mp2629_charger.c line 630
Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+static int mp2629_charger_probe (struct platform_device *pdev) +{ + irq =platform_get_irq (to_platform_device (pdev->dev.parent),0 );Why not to use temporary variable dev?
Quoted 4 lines
Quoted 1 line
This should be
platform_get_irq_optional().
Platform_get_irqin turn callsplatform_get_irq_optional. It was suggested by Lee and is it mandatory to change it?
platform_get_irq is fine.
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ if (irq) {
But this must be
if (irq > 0)
or you will also try to continue with error codes.
Quoted 9 lines
Quoted 9 lines
drivers/power/supply/mp2629_charger.c line 652
Quoted 9 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+ ret =devm_request_irq (dev, irq, mp2629_irq_handler, +IRQF_TRIGGER_RISING ,"mp2629-charger" , + charger); +if (ret) { +dev_err (dev,"failed to request gpio IRQ\n" ); + goto iio_fail; + } + } +}
-- Sebastian
Re: [PATCH v8 4/6] power: supply: Add support for mps mp2629 battery charger
Quoted 3 lines · Sebastian Reichel
Quoted 2 lines · saravanan sekar
Quoted 1 line · Andy Shevchenko
On Mon, Apr 13, 2020 at 8:37 PM Saravanan Sekar <[email protected]> wrote:
...
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+ irq =
platform_get_irq(to_platform_device(pdev->dev.parent), 0);Why not to use temporary variable dev?
This should be
platform_get_irq_optional().
Platform_get_irqin turn callsplatform_get_irq_optional. It was suggested by Lee and is it mandatory to change it?
platform_get_irqis fine.
I don't think so. It will spill an error in case there is no IRQ or error happened.
So, either is should be _optional, or below conditional simply wrong, should be
if (irq < 0)
return irq;
Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ if (irq) {
But this must be
if (irq > 0)
or you will also try to continue with error codes.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+ ret =devm_request_irq (dev, irq, mp2629_irq_handler, +IRQF_TRIGGER_RISING ,"mp2629-charger" , + charger); +if (ret) { +dev_err (dev,"failed to request gpio IRQ\n" ); + goto iio_fail; + } + } +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v8 4/6] power: supply: Add support for mps mp2629 battery charger
Hi,
Quoted 13 lines · Andy Shevchenko
Quoted 3 lines · Sebastian Reichel
Quoted 2 lines · saravanan sekar
Quoted 1 line · Andy Shevchenko
On Mon, Apr 13, 2020 at 8:37 PM Saravanan Sekar <[email protected]> wrote:
...
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
+ irq =
platform_get_irq(to_platform_device(pdev->dev.parent), 0);Why not to use temporary variable dev?
This should be
platform_get_irq_optional().
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Platform_get_irqin turn callsplatform_get_irq_optional. It was suggested by Lee and is it mandatory to change it?
platform_get_irqis fine.I don't think so. It will spill an error in case there is no IRQ or error happened.
I suppose even for an optional IRQ we want an error message when an error happens (i.e. IRQ is specified, but not used because $reason).
Quoted 3 lines
So, either is should be
_optional, or below conditional simply wrong, should be
if (irq < 0)return irq;
In other words: Making the irq mandatory. Sounds reasonable to me considering the driver code. Without IRQ userspace needs to poll to know about error states like thermal shutdown.
-- Sebastian
Quoted 22 lines
Quoted 18 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+ if (irq) {
But this must be
if (irq > 0)
or you will also try to continue with error codes.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+ ret =devm_request_irq (dev, irq, mp2629_irq_handler, +IRQF_TRIGGER_RISING ,"mp2629-charger" , + charger); +if (ret) { +dev_err (dev,"failed to request gpio IRQ\n" ); + goto iio_fail; + } + } +}Signature · 2 lines
With Best Regards, Andy Shevchenko
Saravanan Sekar
maintainerPATCH v8 5/6 power: supply: mp2629: Add impedance compenstation config
In reply to Saravanan SekarAllows the user to compensate the intrinsic resistance of the battery to accelerate the charging cycle.
--- Documentation/ABI/testing/sysfs-class-power-mp2629 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-mp2629
Documentation/ABI/testing/sysfs-class-power-mp2629 new file +8 -0
@@ -0,0 +1,8 @@ +What: /sys/class/power_supply/mp2629_battery/batt_impedance_compen +Date: April 2020 +KernelVersion: 5.7 +Description: + Represents a battery impedance compenstation to accelerate charging. + + Access: Read, Write + Valid values: Represented in milli-ohms. Valid range is [0, 140].
Signature · 1 line
2.17.1
Saravanan Sekar
maintainerPATCH v8 6/6 MAINTAINERS: Add entry for mp2629 Battery Charger driver
In reply to Saravanan SekarAdd MAINTAINERS entry for Monolithic Power Systems mp2629 Charger driver.
--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
@@ -11358,10 +11358,15 @@ F: drivers/tty/mxser.* MONOLITHIC POWER SYSTEM PMIC DRIVER M: Saravanan Sekar <[email protected]> S: Maintained +F: Documentation/devicetree/bindings/mfd/mps,mp2629.yaml F: Documentation/devicetree/bindings/regulator/mps,mp*.yaml +F: drivers/iio/adc/mp2629_adc.c +F: drivers/mfd/mp2629.c +F: drivers/power/supply/mp2629_charger.c F: drivers/regulator/mp5416.c F: drivers/regulator/mpq7920.c F: drivers/regulator/mpq7920.h +F: include/linux/mfd/mp2629.h MR800 AVERMEDIA USB FM RADIO DRIVER M: Alexey Klimov <[email protected]>
Signature · 1 line
2.17.1
On Mon, Apr 13, 2020 at 8:37 PM Saravanan Sekar <[email protected]> wrote:
When somebody gives you a tag, take care and add that tag to all patches where it applies (if you don't drastically change the code, it applies to all mentioned in the corresponding reply).
Quoted 66 lines
changes in v8:
- fixed order of call in probe/remove in iio adc
- add ABI documentation for mp2629 power supplychanges in v7:
- fixed probe/remove order, managed and unmanaged call mix use in adc.
- Documentation dual license, i2c node with controller addresschanges in v6:
- removed includestypes.hin mfd,of_device.hin adc.
- fixed review comments parentheses, err check, kstrtouintchanges in v5:
- removed platfrom data stored in mfd and directly accessed mfd struct in child
- fixed spell check and capitalization in mfd and documentationchanges in v4:
- fixed capitalization in mfgKconfigand documentationchanges in v3:
- regmap for children passed using platform data and remove mfd driver info access directly from childrenchanges in v2:
- removedEXPORT_SYMBOLof register set/get helper
- regmap bit filed used, fixed other review commentsThis patch series add support for Battery charger control driver for Monolithic Power System's MP2629 chipset, includes MFD driver for ADC battery & input power supply measurement and battery charger control driver.
Thanks,
SaravananSaravanan Sekar (6):
dt-bindings: mfd: add document bindings for mp2629
mfd: mp2629: Add support for mps battery charger
iio: adc: mp2629: Add support for mp2629 ADC driver
power: supply: Add support for mps mp2629 battery charger
power: supply: mp2629: Add impedance compenstation config
MAINTAINERS: Add entry for mp2629 Battery Charger driver.../ABI/testing/sysfs-class-power-mp2629 | 8 + .../devicetree/bindings/mfd/mps,mp2629.yaml | 60 ++ MAINTAINERS | 5 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mp2629_adc.c | 208 ++++++ drivers/mfd/Kconfig | 9 + drivers/mfd/Makefile | 2 + drivers/mfd/mp2629.c | 86 +++ drivers/power/supply/Kconfig | 10 + drivers/power/supply/Makefile | 1 + drivers/power/supply/mp2629_charger.c | 687 ++++++++++++++++++ include/linux/mfd/mp2629.h | 28 + 13 files changed, 1115 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-mp2629 create mode 100644 Documentation/devicetree/bindings/mfd/mps,mp2629.yaml create mode 100644 drivers/iio/adc/mp2629_adc.c create mode 100644 drivers/mfd/mp2629.c create mode 100644 drivers/power/supply/mp2629_charger.c create mode 100644 include/linux/mfd/mp2629.h--
2.17.1
Signature · 2 lines
With Best Regards, Andy Shevchenko