Add battery charger driver support for MP2629
Subsystems (5)
Saravanan Sekar
maintainercover Add battery charger driver support for MP2629
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 (5):
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
MAINTAINERS: Add entry for mp2629 Battery Charger driver
.../devicetree/bindings/mfd/mps,mp2629.yaml | 62 ++ MAINTAINERS | 5 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mp2629_adc.c | 211 ++++++ drivers/mfd/Kconfig | 43 +- drivers/mfd/Makefile | 4 +- drivers/mfd/mp2629.c | 109 +++ drivers/power/supply/Kconfig | 14 +- drivers/power/supply/Makefile | 1 + drivers/power/supply/mp2629_charger.c | 709 ++++++++++++++++++ include/linux/mfd/mp2629.h | 34 + 12 files changed, 1169 insertions(+), 34 deletions(-) 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 1/5 dt-bindings: mfd: add document bindings for mp2629
Add device tree binding information for mp2629 mfd driver.
--- .../devicetree/bindings/mfd/mps,mp2629.yaml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mps,mp2629.yaml
Documentation/devicetree/bindings/mfd/mps,mp2629.yaml new file +62 -0
@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: GPL-2.0 +%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 an PMIC providing battery charging and power supply for smartphones, + Wireless camera and portable devices. Chip is contrlled over I2C. + + The MFD device handles battery charger controller and ADC IIO device for + battery, system voltage + +properties: + compatible: + const: mps,mp2629 + + reg: + description: + I2C device address. + 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 { + #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 2/5 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 | 43 +++++---------- drivers/mfd/Makefile | 4 +- drivers/mfd/mp2629.c | 109 +++++++++++++++++++++++++++++++++++++ include/linux/mfd/mp2629.h | 34 ++++++++++++ 4 files changed, 158 insertions(+), 32 deletions(-) create mode 100644 drivers/mfd/mp2629.c create mode 100644 include/linux/mfd/mp2629.h
drivers/mfd/Kconfig +13 -30
@@ -434,6 +434,15 @@ config MFD_MC13XXX_I2C help Select this if your MC13xxx is connected via an I2C bus. +config MFD_MP2629 + bool "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
@@ -642,19 +651,6 @@ config MFD_IPAQ_MICRO AT90LS8535 microcontroller flashed with a special iPAQ firmware using the custom protocol implemented in this driver. -config MFD_IQS62X - tristate "Azoteq IQS620A/621/622/624/625 core support" - depends on I2C - select MFD_CORE - select REGMAP_I2C - help - Say Y here if you want to build core support for the Azoteq IQS620A, - IQS621, IQS622, IQS624 and IQS625 multi-function sensors. Additional - options must be selected to enable device-specific functions. - - To compile this driver as a module, choose M here: the module will - be called iqs62x. - config MFD_JANZ_CMODIO tristate "Janz CMOD-IO PCI MODULbus Carrier Board" select MFD_CORE
@@ -906,7 +902,6 @@ config MFD_CPCAP tristate "Support for Motorola CPCAP" depends on SPI depends on OF || COMPILE_TEST - select MFD_CORE select REGMAP_SPI select REGMAP_IRQ help
@@ -1215,7 +1210,7 @@ config AB8500_CORE chip. This connects to U8500 either on the SSP/SPI bus (deprecated since hardware version v1.0) or the I2C bus via PRCMU. It also adds the irq_chip parts for handling the Mixed Signal chip events. - This chip embeds various other multimedia functionalities as well. + This chip embeds various other multimedia funtionalities as well. config AB8500_DEBUG bool "Enable debug info via debugfs"
@@ -1865,7 +1860,7 @@ config MFD_WM8994 has on board GPIO and regulator functionality which is supported via the relevant subsystems. This driver provides core support for the WM8994, in order to use the actual - functionality of the device other drivers must be enabled. + functionaltiy of the device other drivers must be enabled. config MFD_WM97xx tristate "Wolfson Microelectronics WM97xx"
@@ -1878,7 +1873,7 @@ config MFD_WM97xx designed for smartphone applications. As well as audio functionality it has on board GPIO and a touchscreen functionality which is supported via the relevant subsystems. This driver provides core - support for the WM97xx, in order to use the actual functionality of + support for the WM97xx, in order to use the actual functionaltiy of the device other drivers must be enabled. config MFD_STW481X
@@ -1971,7 +1966,7 @@ config MFD_STPMIC1 Support for ST Microelectronics STPMIC1 PMIC. STPMIC1 has power on key, watchdog and regulator functionalities which are supported via the relevant subsystems. This driver provides core support for the - STPMIC1. In order to use the actual functionality of the device other + STPMIC1. In order to use the actual functionaltiy of the device other drivers must be enabled. To compile this driver as a module, choose M here: the
@@ -1990,18 +1985,6 @@ config MFD_STMFX additional drivers must be enabled in order to use the functionality of the device. -config MFD_WCD934X - tristate "Support for WCD9340/WCD9341 Codec" - depends on SLIMBUS - select REGMAP - select REGMAP_SLIMBUS - select REGMAP_IRQ - select MFD_CORE - help - Support for the Qualcomm WCD9340/WCD9341 Codec. - This driver provides common support WCD934x audio codec and its - associated Pin Controller, Soundwire Controller and Audio codec. - menu "Multimedia Capabilities Port drivers" depends on ARCH_SA1100
drivers/mfd/Makefile +2 -2
@@ -58,7 +58,6 @@ endif ifeq ($(CONFIG_MFD_CS47L24),y) obj-$(CONFIG_MFD_ARIZONA) += cs47l24-tables.o endif -obj-$(CONFIG_MFD_WCD934X) += wcd934x.o obj-$(CONFIG_MFD_WM8400) += wm8400-core.o wm831x-objs := wm831x-core.o wm831x-irq.o wm831x-otp.o wm831x-objs += wm831x-auxadc.o
@@ -170,6 +169,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
@@ -226,7 +227,6 @@ obj-$(CONFIG_MFD_AS3711) += as3711.o obj-$(CONFIG_MFD_AS3722) += as3722.o obj-$(CONFIG_MFD_STW481X) += stw481x.o obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o -obj-$(CONFIG_MFD_IQS62X) += iqs62x.o obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o obj-$(CONFIG_MFD_HI655X_PMIC) += hi655x-pmic.o
drivers/mfd/mp2629.c new file +109 -0
109 lines not on this page · raw message
include/linux/mfd/mp2629.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* mp2629.h - register definitions for mp2629 charger +* +* Copyright 2020 Monolithic Power Systems, Inc +* +*/ + +#ifndef __MP2629_H__ +#define __MP2629_H__ + +#include <linux/platform_device.h> +#include <linux/i2c.h> +#include <linux/regmap.h> + +struct mp2629_info { +struct device *dev; +struct regmap *regmap; +int irq; +}; + +enum mp2629_adc_chan { +MP2629_BATT_VOLT , +MP2629_SYSTEM_VOLT , +MP2629_INPUT_VOLT , +MP2629_BATT_CURRENT , +MP2629_INPUT_CURRENT , +MP2629_ADC_CHAN_END +}; + +int mp2629_set_value (struct regmap *map,u8 reg,u8 mask,unsigned int val); +int mp2629_get_value (struct regmap *map,u8 reg,unsigned int *val); + +#endif
Signature · 1 line
2.17.1
Re: [PATCH 2/5] mfd: mp2629: Add support for mps battery charger
Quoted 5 lines · Saravanan Sekar
mp2629 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
...
Quoted 1 line
drivers/mfd/Kconfig | 43 +++++----------
Why do you have unrelated changes here?
...
drivers/mfd/mp2629.c line 54
Quoted 11 lines
drivers/mfd/mp2629.c new file +11
-0+int mp2629_set_value (struct regmap *map,u8 reg,u8 mask,unsigned int val) +{ +return regmap_update_bits (map, reg, mask, val); +} +EXPORT_SYMBOL (mp2629_set_value); + +int mp2629_get_value (struct regmap *map,u8 reg,unsigned int *val) +{ +return regmap_read (map, reg, val); +} +EXPORT_SYMBOL (mp2629_get_value);
I'm wondering why a child can get access to parent's regmap? I.o.w. why is this being exported?
...
drivers/mfd/mp2629.c line 62
Quoted 8 lines
drivers/mfd/mp2629.c new file +7
-0+static int mp2629_probe (struct i2c_client *client) +{ +struct mp2629_info *info; +int ret; + + info =devm_kzalloc (&client->dev,sizeof (struct mp2629_info ), +GFP_KERNEL );
info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
will be shorter.
drivers/mfd/mp2629.c line 78
Quoted 7 lines
drivers/mfd/mp2629.c new file +5
-0+if (!info) +return -ENOMEM ; + ret =devm_mfd_add_devices (info->dev,-1 , mp2629mfd, +ARRAY_SIZE (mp2629mfd),NULL , +0 ,NULL );
-1 has a defined name in this case.
Quoted 5 lines
drivers/mfd/mp2629.c new file +5
-0+if (ret) +dev_err (info->dev,"Failed to add mfd %d\n" , ret); + +return ret; +}
...
drivers/mfd/mp2629.c line 87
Quoted 4 lines
drivers/mfd/mp2629.c new file +3
-0+static const struct of_device_id mp2629_of_match[] = { + { .compatible ="mps,mp2629" }, + {},
Terminator line doesn't require comma.
Quoted 1 line
+};
...
drivers/mfd/mp2629.c line 93
Quoted 4 lines
drivers/mfd/mp2629.c new file +3
-0+static const struct i2c_device_id mp2629_id[] = { + {"mp2629" , }, + { },
Ditto.
Quoted 2 lines
(quoted diff) +2
-0+}; +MODULE_DEVICE_TABLE(i2c, mp2629_id);
...
drivers/mfd/mp2629.c line 100
Quoted 1 line
drivers/mfd/mp2629.c new file +1
-0+ .of_match_table = of_match_ptr(mp2629_of_match),
of_match_ptr() is redundant and even might provoke compiler warning...
drivers/mfd/mp2629.c line 102
Quoted 1 line
drivers/mfd/mp2629.c new file +1
-0+ .probe_new = mp2629_probe,
...especially taking into consideration ->probe_new().
...
Quoted 1 line
+#include <
linux/platform_device.h>
No user here. (Hint: Use forward declaration of struct device instead)
Quoted 1 line
+#include <
linux/i2c.h>
Ditto.
Quoted 1 line
+#include <
linux/regmap.h>
Ditto. (Hint: Use forward declaration of struct regmap instead)
But linux/types.h is actually missed.
Quoted 2 lines
include/linux/mfd/mp2629.h new file +2
-0+int mp2629_set_value (struct regmap *map,u8 reg,u8 mask,unsigned int val); +int mp2629_get_value (struct regmap *map,u8 reg,unsigned int *val);
Signature · 2 lines
With Best Regards, Andy Shevchenko
Saravanan Sekar
maintainerPATCH 3/5 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 | 211 +++++++++++++++++++++++++++++++++++ 3 files changed, 222 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 +211 -0
211 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 3/5] iio: adc: mp2629: Add support for mp2629 ADC driver
Quoted 3 lines · Saravanan Sekar
Add support for 8-bit resolution ADC readings for input power supply and battery charging measurement. Provides voltage, current readings to mp2629 power supply driver.
...
Quoted 32 lines
drivers/iio/adc/mp2629_adc.c new file +32
-0+struct mp2629_info *info = adc_info->info; +unsigned int rval; +int ret; + +switch (mask) { +case IIO_CHAN_INFO_RAW : + ret =mp2629_get_value (info->regmap, chan->address, &rval); +if (ret <0 ) +return ret; + +if (chan->address ==MP2629_INPUT_VOLT ) + rval &=0x7f ; + *val = rval; +return IIO_VAL_INT ; + +case IIO_CHAN_INFO_SCALE : +switch (chan->channel) { +case MP2629_BATT_VOLT : +case MP2629_SYSTEM_VOLT : + *val =20 ; +return IIO_VAL_INT ; + +case MP2629_INPUT_VOLT : + *val =60 ; +return IIO_VAL_INT ; + +case MP2629_BATT_CURRENT : + *val =175 ; + *val2 =10 ; +return IIO_VAL_FRACTIONAL ; + +case MP2629_INPUT_CURRENT :
drivers/iio/adc/mp2629_adc.c line 114
Quoted 10 lines
drivers/iio/adc/mp2629_adc.c new file +9
-0+ *val =133 ; + *val2 =10 ; +return IIO_VAL_FRACTIONAL ; + } +break ; + +default : + ret = -EINVAL ; +break ;
return -EINVAL;
drivers/iio/adc/mp2629_adc.c line 82
Quoted 4 lines
drivers/iio/adc/mp2629_adc.c new file +3
-0+ } + +return ret;
return 0;
?
What is default case for wrong channel in INFO_SCALE?
Quoted 1 line
+}
...
drivers/iio/adc/mp2629_adc.c line 195
Quoted 4 lines
drivers/iio/adc/mp2629_adc.c new file +3
-0+static const struct of_device_id mp2629_adc_of_match[] = { + { .compatible ="mps,mp2629_adc" }, + {},
No comma needed.
Quoted 1 line
+};
Signature · 2 lines
With Best Regards, Andy Shevchenko
Saravanan Sekar
maintainerPATCH 4/5 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 | 14 +- drivers/power/supply/Makefile | 1 + drivers/power/supply/mp2629_charger.c | 709 ++++++++++++++++++++++++++ 3 files changed, 722 insertions(+), 2 deletions(-) create mode 100644 drivers/power/supply/mp2629_charger.c
drivers/power/supply/Kconfig +12 -2
@@ -480,7 +480,7 @@ config CHARGER_GPIO called gpio-charger. config CHARGER_MANAGER - tristate "Battery charger manager for multiple chargers" + bool "Battery charger manager for multiple chargers" depends on REGULATOR select EXTCON help
@@ -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 + bool "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
@@ -659,7 +669,7 @@ config CHARGER_RT9455 config CHARGER_CROS_USBPD tristate "ChromeOS EC based USBPD charger" - depends on CROS_USBPD_NOTIFY + depends on CROS_EC default n help Say Y here to enable ChromeOS EC based USBPD charger
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 +709 -0
709 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH 4/5] power: supply: Add support for mps mp2629 battery charger
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 1 line
drivers/power/supply/Kconfig | 14 +-
Why unrelated changes here?
...
Quoted 5 lines
drivers/power/supply/mp2629_charger.c new file +5
-0+#include <linux/kernel.h> +#include <linux/kthread.h> +#include <linux/device.h> +#include <linux/module.h> +#include <linux/platform_device.h>
drivers/power/supply/mp2629_charger.c line 24
Quoted 10 lines
drivers/power/supply/mp2629_charger.c new file +10
-0+#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/slab.h> +#include <linux/err.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/iio/consumer.h> +#include <linux/iio/types.h> +#include <linux/power_supply.h> +#include <linux/workqueue.h>
All of them are needed?
...
drivers/power/supply/mp2629_charger.c line 79
Quoted 7 lines
drivers/power/supply/mp2629_charger.c new file +7
-0+enum mp2629_source_type { +MP2629_SOURCE_TYPE_NO_INPUT , +MP2629_SOURCE_TYPE_NON_STD , +MP2629_SOURCE_TYPE_SDP , +MP2629_SOURCE_TYPE_CDP , +MP2629_SOURCE_TYPE_DCP , +MP2629_SOURCE_TYPE_OTG =7
+ comma? (It is not obvious there will be no extension in the future)
drivers/power/supply/mp2629_charger.c line 88
Quoted 10 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+}; + +enum { +INPUT_ILIM , +INPUT_VLIM , +CHARGE_ILIM , +CHARGE_VLIM , +PRECHARGE , +TERM_CURRENT
Ditto.
Quoted 1 line
+};
...
drivers/power/supply/mp2629_charger.c line 118
Quoted 7 lines
drivers/power/supply/mp2629_charger.c new file +6
-0+static enum power_supply_usb_type mp2629_usb_types[] = { +POWER_SUPPLY_USB_TYPE_SDP , +POWER_SUPPLY_USB_TYPE_DCP , +POWER_SUPPLY_USB_TYPE_CDP , +POWER_SUPPLY_USB_TYPE_PD_DRP , +POWER_SUPPLY_USB_TYPE_UNKNOWN ,
Here it seems other way around, i.e. no comma.
drivers/power/supply/mp2629_charger.c line 127
Quoted 10 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+}; + +static enum power_supply_property mp2629_charger_usb_props[] = { +POWER_SUPPLY_PROP_ONLINE , +POWER_SUPPLY_PROP_USB_TYPE , +POWER_SUPPLY_PROP_VOLTAGE_NOW , +POWER_SUPPLY_PROP_CURRENT_NOW , +POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT , +POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT
...but here again, it can be extended.
Quoted 6 lines
drivers/power/supply/mp2629_charger.c new file +6
-0+}; + +static enum power_supply_property mp2629_charger_bat_props[] = { +POWER_SUPPLY_PROP_STATUS , +POWER_SUPPLY_PROP_HEALTH , +POWER_SUPPLY_PROP_CHARGE_TYPE ,
drivers/power/supply/mp2629_charger.c line 142
Quoted 10 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+POWER_SUPPLY_PROP_VOLTAGE_NOW , +POWER_SUPPLY_PROP_CURRENT_NOW , +POWER_SUPPLY_PROP_CAPACITY , +POWER_SUPPLY_PROP_PRECHARGE_CURRENT , +POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT , +POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT , +POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE , +POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX , +POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX
Ditto.
drivers/power/supply/mp2629_charger.c line 151
Quoted 10 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+}; + +static struct mp2629_prop props[] = { +MP2629_PROPS (INPUT_ILIM ,100000 ,3250000 ,50000 ,0 ), +MP2629_PROPS (INPUT_VLIM ,3800000 ,5300000 ,100000 ,0 ), +MP2629_PROPS (CHARGE_ILIM ,320000 ,4520000 ,40000 ,0 ), +MP2629_PROPS (CHARGE_VLIM ,3400000 ,4670000 ,10000 ,1 ), +MP2629_PROPS (PRECHARGE ,120000 ,720000 ,40000 ,4 ), +MP2629_PROPS (TERM_CURRENT ,80000 ,680000 ,40000 ,0 )
Ditto.
Quoted 1 line
+};
...
drivers/power/supply/mp2629_charger.c line 156
Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+static char *adc_chan_name[] = {"mp2629-batt-volt" ,"mp2629-system-volt" , +"mp2629-input-volt" ,"mp2629-batt-current" , +"mp2629-input-current" };
One item per line, please. And comma in the last, new compatible hw might have more channels.
drivers/power/supply/mp2629_charger.c line 184
Quoted 5 lines
drivers/power/supply/mp2629_charger.c new file +5
-0+ ret =mp2629_get_value (map, prop->reg, &rval); +if (!ret) { + rval = (rval & prop->mask) >> prop->shift; + val->intval = (rval * prop->step) + prop->min; + }
Sounds like regmap field operation...
Ditto for similar code.
Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+ +return ret; +}
...
drivers/power/supply/mp2629_charger.c line 324
Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+default : + ret = -EINVAL ; +break ;
return -EINVAL;
...
drivers/power/supply/mp2629_charger.c line 324
Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+default : + ret = -EINVAL ; +break ;
Ditto.
...
drivers/power/supply/mp2629_charger.c line 324
Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+default : + ret = -EINVAL ; +break ;
Ditto.
...
drivers/power/supply/mp2629_charger.c line 459
Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +4
-0+return (psp ==POWER_SUPPLY_PROP_PRECHARGE_CURRENT || + psp ==POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT || + psp ==POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT || + psp ==POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE );
Too many parentheses.
...
drivers/power/supply/mp2629_charger.c line 466
Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2
-0+return (psp ==POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT || + psp ==POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT );
Ditto.
...
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (kstrtol(buf, 10, &val) < 0) + return -EINVAL;
Don't shadow the actual error code.
drivers/power/supply/mp2629_charger.c line 574
Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+ +if (val <0 && val >140 ) +return -EINVAL ;
ERANGE is better.
...
drivers/power/supply/mp2629_charger.c line 587
Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2
-0+static DEVICE_ATTR(batt_impedance_compensation, 0644, + mp2629_sysfs_impedance_show, mp2629_sysfs_impedance_store);
DEVICE_ATTR_RW()
drivers/power/supply/mp2629_charger.c line 591
Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+static struct attribute *mp2629_charger_sysfs_attrs[] = { + &dev_attr_batt_impedance_compensation.attr, +NULL ,
No comma.
Quoted 1 line
+};
...
drivers/power/supply/mp2629_charger.c line 608
Quoted 11 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+static int mp2629_charger_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct mp2629_charger *charger; +struct mp2629_info *info; +struct power_supply_config psy_cfg = {0 }; +int ret, i; +platform_set_drvdata (pdev, charger); + info =dev_get_drvdata (dev->parent);
Could be assigned in definition block above.
Quoted 9 lines
drivers/power/supply/mp2629_charger.c new file +9
-0+ charger->info = info; + charger->dev = dev; + +for (i =0 ; i <MP2629_ADC_CHAN_END ; i++) { + charger->iiochan[i] =iio_channel_get (dev, adc_chan_name[i]); +if (IS_ERR (charger->iiochan[i])) { + ret =PTR_ERR (charger->iiochan[i]); + goto iio_fail; + }
drivers/power/supply/mp2629_charger.c line 667
Quoted 10 lines
drivers/power/supply/mp2629_charger.c new file +8
-0+ } +return 0 ; + +iio_fail: +for (i =0 ; i <MP2629_ADC_CHAN_END ; i++) { +if (charger->iiochan[i] && !(IS_ERR (charger->iiochan[i]))) +iio_channel_release (charger->iiochan[i]); + }
while (i--) iio_channel_release(charger->iiochan[i]);
Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +4
-0+ +dev_err (dev,"driver register fail: %d\n" , ret); +return ret; +}
...
drivers/power/supply/mp2629_charger.c line 682
Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +2
-0+for (i =0 ; i <MP2629_ADC_CHAN_END ; i++) { +if (charger->iiochan[i])
When this is possible?
And shouldn't iio_channel_release() take care of NULL pointer? If it doesn't, fix it in preparatory patch.
Quoted 2 lines
(quoted diff) +2
-0+ iio_channel_release(charger->iiochan[i]); + }
...
drivers/power/supply/mp2629_charger.c line 693
Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +3
-0+static const struct of_device_id mp2629_charger_of_match[] = { + { .compatible ="mps,mp2629_charger" }, + {},
No comma.
Quoted 1 line
+};
Signature · 2 lines
With Best Regards, Andy Shevchenko
Saravanan Sekar
maintainerPATCH 5/5 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
@@ -11352,10 +11352,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
Quoted 3 lines · Saravanan Sekar
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.
For the future, hint:
scripts/get_maintainer.pl --git --git-min-percent=67 ...
but since I reviewed this, don't forget to include reviewers in your next version.
Quoted 33 lines
Thanks,
SaravananSaravanan Sekar (5):
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
MAINTAINERS: Add entry for mp2629 Battery Charger driver.../devicetree/bindings/mfd/mps,mp2629.yaml | 62 ++ MAINTAINERS | 5 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mp2629_adc.c | 211 ++++++ drivers/mfd/Kconfig | 43 +- drivers/mfd/Makefile | 4 +- drivers/mfd/mp2629.c | 109 +++ drivers/power/supply/Kconfig | 14 +- drivers/power/supply/Makefile | 1 + drivers/power/supply/mp2629_charger.c | 709 ++++++++++++++++++ include/linux/mfd/mp2629.h | 34 + 12 files changed, 1169 insertions(+), 34 deletions(-) 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.hSignature · 1 line
2.17.1
Signature · 2 lines
With Best Regards, Andy Shevchenko