[PATCH v2 1/3] adp5061: New driver for ADP5061 I2C battery charger
This patch adds basic support for Analog Devices I2C programmable linear battery charger. With this driver, some parameters can be read and configured such as: * trickle charge current level * trickle charge voltage threshold * weak charge threshold * constant current * constant charge voltage limit * battery full * input current limit * charger status * battery status * termination current Datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/ADP5061.pdf Signed-off-by: Stefan Popa--- Changes in v2: - Fixed typo in Kconfig file: build -> built .../devicetree/bindings/power/supply/adp5061.txt | 17 + MAINTAINERS| 8 + drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile | 1 + drivers/power/supply/adp5061.c | 745 + 5 files changed, 782 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/adp5061.txt create mode 100644 drivers/power/supply/adp5061.c diff --git a/Documentation/devicetree/bindings/power/supply/adp5061.txt b/Documentation/devicetree/bindings/power/supply/adp5061.txt new file mode 100644 index 000..7447446 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/adp5061.txt @@ -0,0 +1,17 @@ +Analog Devices ADP5061 Programmable Linear Battery Charger Driver + +Required properties: + - compatible:should be "adi,adp5061" + - reg: i2c address of the device + +The node for this driver must be a child node of a I2C controller, hence +all mandatory properties described in +Documentation/devicetree/bindings/i2c/i2c.txt +must be specified. + +Example: + + adp5061@14 { + compatible = "adi,adp5061"; + reg = <0x14>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 3bdc260..a9ca73b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -797,6 +797,14 @@ L: linux-me...@vger.kernel.org S: Maintained F: drivers/media/i2c/ad9389b* +ANALOG DEVICES INC ADP5061 DRIVER +M: Stefan Popa +L: linux...@vger.kernel.org +W: http://ez.analog.com/community/linux-device-drivers +S: Supported +F: Documentation/devicetree/bindings/power/supply/adp5061.txt +F: drivers/power/supply/adp5061.c + ANALOG DEVICES INC ADV7180 DRIVER M: Lars-Peter Clausen L: linux-me...@vger.kernel.org diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 428b426..4cc9aa9 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -75,6 +75,17 @@ config BATTERY_88PM860X help Say Y here to enable battery monitor for Marvell 88PM860x chip. +config CHARGER_ADP5061 + tristate "ADP5061 battery charger driver" + depends on I2C + select REGMAP_I2C + help + Say Y here to enable support for the ADP5061 standalone battery + charger. + + This driver can be built as a module. If so, the module will be + called adp5061. + config BATTERY_ACT8945A tristate "Active-semi ACT8945A charger driver" depends on MFD_ACT8945A || COMPILE_TEST diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index e83aa84..71b1398 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_WM8350_POWER)+= wm8350_power.o obj-$(CONFIG_TEST_POWER) += test_power.o obj-$(CONFIG_BATTERY_88PM860X) += 88pm860x_battery.o +obj-$(CONFIG_CHARGER_ADP5061) += adp5061.o obj-$(CONFIG_BATTERY_ACT8945A) += act8945a_charger.o obj-$(CONFIG_BATTERY_AXP20X) += axp20x_battery.o obj-$(CONFIG_CHARGER_AXP20X) += axp20x_ac_power.o diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c new file mode 100644 index 000..c00a02e --- /dev/null +++ b/drivers/power/supply/adp5061.c @@ -0,0 +1,745 @@ +/* + * ADP5061 I2C Programmable Linear Battery Charger + * + * Copyright 2018 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* ADP5061 registers definition */ +#define ADP5061_ID 0x00 +#define ADP5061_REV0x01 +#define ADP5061_VINX_SET 0x02 +#define ADP5061_TERM_SET 0x03 +#define ADP5061_CHG_CURR 0x04 +#define ADP5061_VOLTAGE_TH 0x05 +#define ADP5061_TIMER_SET 0x06 +#define ADP5061_FUNC_SET_1 0x07 +#define ADP5061_FUNC_SET_2 0x08 +#define ADP5061_INT_EN 0x09 +#define ADP5061_INT_ACT0x0A +#define ADP5061_CHG_STATUS_1 0x0B +#define ADP5061_CHG_STATUS_2 0x0C +#define ADP5061_FAULT 0x0D +#define ADP5061_BATTERY_SHORT 0x10
[PATCH v2 1/3] adp5061: New driver for ADP5061 I2C battery charger
This patch adds basic support for Analog Devices I2C programmable linear battery charger. With this driver, some parameters can be read and configured such as: * trickle charge current level * trickle charge voltage threshold * weak charge threshold * constant current * constant charge voltage limit * battery full * input current limit * charger status * battery status * termination current Datasheet: http://www.analog.com/media/en/technical-documentation/data-sheets/ADP5061.pdf Signed-off-by: Stefan Popa --- Changes in v2: - Fixed typo in Kconfig file: build -> built .../devicetree/bindings/power/supply/adp5061.txt | 17 + MAINTAINERS| 8 + drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile | 1 + drivers/power/supply/adp5061.c | 745 + 5 files changed, 782 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/adp5061.txt create mode 100644 drivers/power/supply/adp5061.c diff --git a/Documentation/devicetree/bindings/power/supply/adp5061.txt b/Documentation/devicetree/bindings/power/supply/adp5061.txt new file mode 100644 index 000..7447446 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/adp5061.txt @@ -0,0 +1,17 @@ +Analog Devices ADP5061 Programmable Linear Battery Charger Driver + +Required properties: + - compatible:should be "adi,adp5061" + - reg: i2c address of the device + +The node for this driver must be a child node of a I2C controller, hence +all mandatory properties described in +Documentation/devicetree/bindings/i2c/i2c.txt +must be specified. + +Example: + + adp5061@14 { + compatible = "adi,adp5061"; + reg = <0x14>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 3bdc260..a9ca73b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -797,6 +797,14 @@ L: linux-me...@vger.kernel.org S: Maintained F: drivers/media/i2c/ad9389b* +ANALOG DEVICES INC ADP5061 DRIVER +M: Stefan Popa +L: linux...@vger.kernel.org +W: http://ez.analog.com/community/linux-device-drivers +S: Supported +F: Documentation/devicetree/bindings/power/supply/adp5061.txt +F: drivers/power/supply/adp5061.c + ANALOG DEVICES INC ADV7180 DRIVER M: Lars-Peter Clausen L: linux-me...@vger.kernel.org diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 428b426..4cc9aa9 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -75,6 +75,17 @@ config BATTERY_88PM860X help Say Y here to enable battery monitor for Marvell 88PM860x chip. +config CHARGER_ADP5061 + tristate "ADP5061 battery charger driver" + depends on I2C + select REGMAP_I2C + help + Say Y here to enable support for the ADP5061 standalone battery + charger. + + This driver can be built as a module. If so, the module will be + called adp5061. + config BATTERY_ACT8945A tristate "Active-semi ACT8945A charger driver" depends on MFD_ACT8945A || COMPILE_TEST diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index e83aa84..71b1398 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_WM8350_POWER)+= wm8350_power.o obj-$(CONFIG_TEST_POWER) += test_power.o obj-$(CONFIG_BATTERY_88PM860X) += 88pm860x_battery.o +obj-$(CONFIG_CHARGER_ADP5061) += adp5061.o obj-$(CONFIG_BATTERY_ACT8945A) += act8945a_charger.o obj-$(CONFIG_BATTERY_AXP20X) += axp20x_battery.o obj-$(CONFIG_CHARGER_AXP20X) += axp20x_ac_power.o diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c new file mode 100644 index 000..c00a02e --- /dev/null +++ b/drivers/power/supply/adp5061.c @@ -0,0 +1,745 @@ +/* + * ADP5061 I2C Programmable Linear Battery Charger + * + * Copyright 2018 Analog Devices Inc. + * + * Licensed under the GPL-2. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* ADP5061 registers definition */ +#define ADP5061_ID 0x00 +#define ADP5061_REV0x01 +#define ADP5061_VINX_SET 0x02 +#define ADP5061_TERM_SET 0x03 +#define ADP5061_CHG_CURR 0x04 +#define ADP5061_VOLTAGE_TH 0x05 +#define ADP5061_TIMER_SET 0x06 +#define ADP5061_FUNC_SET_1 0x07 +#define ADP5061_FUNC_SET_2 0x08 +#define ADP5061_INT_EN 0x09 +#define ADP5061_INT_ACT0x0A +#define ADP5061_CHG_STATUS_1 0x0B +#define ADP5061_CHG_STATUS_2 0x0C +#define ADP5061_FAULT 0x0D +#define ADP5061_BATTERY_SHORT 0x10 +#define ADP5061_IEND 0x11 + +/* ADP5061_VINX_SET */