From patchwork Mon Apr 13 17:36:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saravanan sekar X-Patchwork-Id: 11486081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAED414DD for ; Mon, 13 Apr 2020 17:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B22452076A for ; Mon, 13 Apr 2020 17:37:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fDIcoNZg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732866AbgDMRhJ (ORCPT ); Mon, 13 Apr 2020 13:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732864AbgDMRhH (ORCPT ); Mon, 13 Apr 2020 13:37:07 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E90DC0A3BDC; Mon, 13 Apr 2020 10:37:07 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id d27so1778724wra.1; Mon, 13 Apr 2020 10:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kaq0gyVDK71RemoPPD/qDBGyBcEjT8bXtwKNY1omfRQ=; b=fDIcoNZgVygOPRmNWeOwfJnxxU3kALx/SKQZvXWXOpsxNz3mnVkjGmjToWC+sc4ZEC NpIxAcNks+b8au4DkwXgIOyk0IM+WvQYu+3xo5xgLC5ugTCxRN3QL8XpSUvfpAng6g1p GIvZu/DnQAVzG8tuQ5Xkw4xj55uGAWtPYGlM/CYWP7Kmqlfbhe0r4iJyT74UtoTYqKiS 2mbQi0q8a37wDWyVjGMwKtLkkpEBy+qlMM4H4786KHATyJhW6n7Q+V0jIh6VwarRWGEg vsKyqQtzAFybdjbDQ+lufu7i8ZoHSMcN65UJgsg8NWvAW/e3M/m+5GV4lvxdczW5HR0I HBoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kaq0gyVDK71RemoPPD/qDBGyBcEjT8bXtwKNY1omfRQ=; b=qMedG7hLKKUR+ONTTcuxbAik+08XZqYyLDbQ+G77u6UpswAtCJ3b+GTNgFmTW602aM 8yWO1Wwn4IhNvGkW4MdCBVaAbL4C0m/JjVCDOIuA1XRfxDUWWKUZyhmrtVkH1bufTq9f oWld8AKjJw+DgE0SsSlq6BJG2Ydo9mUf2cKJjgFlLQ89lj8QGuM/9RfBzkkyOR3MCooS j9reJ+3BULlgofUoWPFd2UDnYRO9vg6ln+4PF2Qo9IZyXFfCLjBMegFkJ4huAbKpccfX c9dIDOpGZ2T5lxO7eSMDan+AtDKbbt2AFkMKF/1B3plmYZnWgfYkabPnVlouaAucueD+ VPvg== X-Gm-Message-State: AGi0Puat+OuuMDpP/TnKE/HnuUiG1a0kssGKSEsrWrOekTbaUsfJH3qP YZiSgI/81fuIieS1/rKNvec= X-Google-Smtp-Source: APiQypLUshspgNvpGiRKxHzyNuEL/PyESgSOmIqJqqQYJgFY2XZ9o8RUBgYg5ezzds4EUkh7cO0X4Q== X-Received: by 2002:adf:92c2:: with SMTP id 60mr15916660wrn.379.1586799426135; Mon, 13 Apr 2020 10:37:06 -0700 (PDT) Received: from localhost.localdomain (p5B3F6AD5.dip0.t-ipconnect.de. [91.63.106.213]) by smtp.gmail.com with ESMTPSA id a205sm11141465wmh.29.2020.04.13.10.37.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 10:37:05 -0700 (PDT) From: Saravanan Sekar To: lee.jones@linaro.org, andy.shevchenko@gmail.com, robh+dt@kernel.org, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, sre@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, Saravanan Sekar Subject: [PATCH v8 1/6] dt-bindings: mfd: add document bindings for mp2629 Date: Mon, 13 Apr 2020 19:36:51 +0200 Message-Id: <20200413173656.28522-2-sravanhome@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413173656.28522-1-sravanhome@gmail.com> References: <20200413173656.28522-1-sravanhome@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add device tree binding information for mp2629 mfd driver. Signed-off-by: Saravanan Sekar --- .../devicetree/bindings/mfd/mps,mp2629.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mps,mp2629.yaml diff --git a/Documentation/devicetree/bindings/mfd/mps,mp2629.yaml b/Documentation/devicetree/bindings/mfd/mps,mp2629.yaml new file mode 100644 index 000000000000..e71c554802a8 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/mps,mp2629.yaml @@ -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 + +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 + #include + 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>; + }; + }; From patchwork Mon Apr 13 17:36:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saravanan sekar X-Patchwork-Id: 11486095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D39F14DD for ; Mon, 13 Apr 2020 17:37:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42E0A20768 for ; Mon, 13 Apr 2020 17:37:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pDeIvzFk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732922AbgDMRhf (ORCPT ); Mon, 13 Apr 2020 13:37:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732835AbgDMRhJ (ORCPT ); Mon, 13 Apr 2020 13:37:09 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBD2FC0A3BE2; Mon, 13 Apr 2020 10:37:08 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id i10so10962756wrv.10; Mon, 13 Apr 2020 10:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6JHVvWyjCIClbMe3qA+hwkoKr1pqM/u0MjtagCuJzWg=; b=pDeIvzFkC+edHtL6nrNPZUQP8DuCvUkjux5H2DWhKdnGEBQ2DJUxKj/GAhYu466RgS LurkfR8zouIpDlvIdPue5Womg7fZVMoywEe5QUCEsvlCpesjO0EE6tWEdOKPL8lmkK/W z734gWeZpDctD5Hmk2+dxB66M4NrJv/k+f8X7b3w6mOtm7GmJuXUElbFfrAPajxACJM/ BKg4cMfKVbGjl3On/Z8CTC3w5VRpHK3reavN0T1WLPmcLrqdFLKnXP9OfXudfr/P0h8f itj2rEAzuNDeNBSHCMwp7JD7pAfwU0egOJjY6enzzrXwFE94lspwQHBhr5GozAIbwxud Sj+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6JHVvWyjCIClbMe3qA+hwkoKr1pqM/u0MjtagCuJzWg=; b=fLBVmHQS5Hzu9s+FdgKoKmi448pGO7MwOkZioXgJCmZKzEvqOOwEeCdNPOt9ujbn4h r6Gz2EC43QjC3PDrJhtR/6hrGClC+i/ceeZbErFyor4vnrz9KTCPi9Xt8agzceZt9MOt kLH/4/Xyfoeq3PKP3VZX/iFh+wcx67hbW//wqgrq9OAuL6sl6zlbtXQnCkjR439TmOtG 6otX3xfJmoLlwld87OV3Wtrt4w2k96XBvN4Nj5z2KoSozL1RlOlvgyGJi0ICKm1PkP8d +b+lS2aScuQbZmd+BhK3cYV+bzJcRLANXONe7JD4HvgbgZTDxJQ7dRzpM41+pOECQIOb eIeg== X-Gm-Message-State: AGi0PuaPGuJNrFXWUCYFdHx2KGhCsr2aDZTUiOOp+730bd1jIwSSeGgu TarCMzc0ajNhUwYtl/QwlU5cDUcIJKs= X-Google-Smtp-Source: APiQypJC1mPkPBQn+w2s+bie1OUPDO63/ukUS2fQ27KDLUPum+RtXkvkIyqfLovN7bn+tr8qSFAVLw== X-Received: by 2002:a5d:6342:: with SMTP id b2mr6497613wrw.111.1586799427499; Mon, 13 Apr 2020 10:37:07 -0700 (PDT) Received: from localhost.localdomain (p5B3F6AD5.dip0.t-ipconnect.de. [91.63.106.213]) by smtp.gmail.com with ESMTPSA id a205sm11141465wmh.29.2020.04.13.10.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 10:37:06 -0700 (PDT) From: Saravanan Sekar To: lee.jones@linaro.org, andy.shevchenko@gmail.com, robh+dt@kernel.org, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, sre@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, Saravanan Sekar Subject: [PATCH v8 2/6] mfd: mp2629: Add support for mps battery charger Date: Mon, 13 Apr 2020 19:36:52 +0200 Message-Id: <20200413173656.28522-3-sravanhome@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413173656.28522-1-sravanhome@gmail.com> References: <20200413173656.28522-1-sravanhome@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 Signed-off-by: Saravanan Sekar --- 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 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 3c547ed575e6..85be799795aa 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -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 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index f935d10cbf0f..d6c210f96d02 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -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 diff --git a/drivers/mfd/mp2629.c b/drivers/mfd/mp2629.c new file mode 100644 index 000000000000..46242b1cdf24 --- /dev/null +++ b/drivers/mfd/mp2629.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * MP2629 parent driver for ADC and battery charger + * + * Copyright 2020 Monolithic Power Systems, Inc + * + * Author: Saravanan Sekar + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MP2629_MFD_ADC, + MP2629_MFD_CHARGER, + MP2629_MFD_MAX +}; + +static const struct mfd_cell mp2629mfd[] = { + [MP2629_MFD_ADC] = { + .name = "mp2629_adc", + .of_compatible = "mps,mp2629_adc", + }, + [MP2629_MFD_CHARGER] = { + .name = "mp2629_charger", + .of_compatible = "mps,mp2629_charger", + } +}; + +static const struct regmap_config mp2629_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 0x17, +}; + +static int mp2629_probe(struct i2c_client *client) +{ + struct mp2629_info *ddata; + int ret; + + ddata = devm_kzalloc(&client->dev, sizeof(*ddata), GFP_KERNEL); + if (!ddata) + return -ENOMEM; + + ddata->dev = &client->dev; + i2c_set_clientdata(client, ddata); + + ddata->regmap = devm_regmap_init_i2c(client, &mp2629_regmap_config); + if (IS_ERR(ddata->regmap)) { + dev_err(ddata->dev, "Failed to allocate regmap!\n"); + return PTR_ERR(ddata->regmap); + } + + ret = devm_mfd_add_devices(ddata->dev, PLATFORM_DEVID_NONE, mp2629mfd, + ARRAY_SIZE(mp2629mfd), NULL, + 0, NULL); + if (ret) + dev_err(ddata->dev, "Failed to register sub-devices %d\n", ret); + + return ret; +} + +static const struct of_device_id mp2629_of_match[] = { + { .compatible = "mps,mp2629"}, + { } +}; +MODULE_DEVICE_TABLE(of, mp2629_of_match); + +static struct i2c_driver mp2629_driver = { + .driver = { + .name = "mp2629", + .of_match_table = mp2629_of_match, + }, + .probe_new = mp2629_probe, +}; +module_i2c_driver(mp2629_driver); + +MODULE_AUTHOR("Saravanan Sekar "); +MODULE_DESCRIPTION("MP2629 Battery charger parent driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/mp2629.h b/include/linux/mfd/mp2629.h new file mode 100644 index 000000000000..06985e41fc6f --- /dev/null +++ b/include/linux/mfd/mp2629.h @@ -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 +#include + +struct mp2629_info { + struct device *dev; + struct regmap *regmap; +}; + +#endif From patchwork Mon Apr 13 17:36:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saravanan sekar X-Patchwork-Id: 11486083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A51014DD for ; Mon, 13 Apr 2020 17:37:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E0CF2076A for ; Mon, 13 Apr 2020 17:37:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hy7G4xjW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732878AbgDMRhN (ORCPT ); Mon, 13 Apr 2020 13:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732872AbgDMRhK (ORCPT ); Mon, 13 Apr 2020 13:37:10 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D736C0A3BDC; Mon, 13 Apr 2020 10:37:10 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id a81so10757784wmf.5; Mon, 13 Apr 2020 10:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BO8j8+pI9zWfHd4m+N2P9+Cu+wuRfUjALFzaXkqSsKs=; b=hy7G4xjWFAoDNa+zi76sYpqg+BRy8Hj/px8I40l/1J+piWfc2mYCUuSmEtTe0Phnfr uwVQI5TxZOHiI9MX6dsyKc3eovt+0epWWJDZQQwT2c6+bFp6LM7QTdrb/wsGdk7o92JT XW3miIyfOvKTAzK3SrP43x0IeyGc9slgLqTzPbU5pTeSGQPsT01LH1dDzKhrNGqLP9rS x7F5NUMwNimVdYO8oS6EpJf7JtrHkzW5KGENNYMVC0d/wbD7SvZaZz+4La06dx0I8f0M d+TjDurBWsUpM153SKIW4c1PpHlzZwu/F206tHoP99Q5U42QqWN0fnZOzBmp/3TDvW5S /foA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BO8j8+pI9zWfHd4m+N2P9+Cu+wuRfUjALFzaXkqSsKs=; b=Dfrdz734yXSvbzQqiYAr0aIDd9lkVAJwOHK9PuA0fqgTn5rwS5fMLSByrV4Dk6JRGM XbAIAyNyfD58VUvdgoQdMxE75TaRab4+piBnHZL9acoB9l1YRtUGxhhmn6+ZY2/rP7p1 bhIPm0VSiUdynE1EVfOXd16SV7+K59dw3Uil63sXyC5E/OOqolCb3kWl1GhL4Wf7LSMW FovmyT18LOlHKs0D600cPrPCpkYYAqyY4HApKW0QbYBN0oDjpHIlb/sAOrciG+LXwT+w 4WvqflkkF0QVq7jEs9LYd9LMToXFWxiGahqA/vMf0GBTEqyBZNxINzIC4YCjtsoimx6D XORQ== X-Gm-Message-State: AGi0PubKumar35lD7/+bGj9rRAHAFbN58g1PQX/0q6Oi9Px1d+ZbVak8 niU16oXa8Slw3zDDv3UuKro= X-Google-Smtp-Source: APiQypLzFR6DUlUhHaTp+fT1GiuoTnAy3w2Zj8lPGAimmu1p198uZDn4ws5SKX61XvWHzwaKO1GNyQ== X-Received: by 2002:a1c:9a96:: with SMTP id c144mr19678718wme.84.1586799428849; Mon, 13 Apr 2020 10:37:08 -0700 (PDT) Received: from localhost.localdomain (p5B3F6AD5.dip0.t-ipconnect.de. [91.63.106.213]) by smtp.gmail.com with ESMTPSA id a205sm11141465wmh.29.2020.04.13.10.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 10:37:08 -0700 (PDT) From: Saravanan Sekar To: lee.jones@linaro.org, andy.shevchenko@gmail.com, robh+dt@kernel.org, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, sre@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, Saravanan Sekar Subject: [PATCH v8 3/6] iio: adc: mp2629: Add support for mp2629 ADC driver Date: Mon, 13 Apr 2020 19:36:53 +0200 Message-Id: <20200413173656.28522-4-sravanhome@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413173656.28522-1-sravanhome@gmail.com> References: <20200413173656.28522-1-sravanhome@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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. Signed-off-by: Saravanan Sekar --- 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 diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 82e33082958c..ef0c0cd31855 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -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 diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 919228900df9..f14416c245a6 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -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 diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c new file mode 100644 index 000000000000..faf389f32729 --- /dev/null +++ b/drivers/iio/adc/mp2629_adc.c @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * MP2629 Driver for ADC + * + * Copyright 2020 Monolithic Power Systems, Inc + * + * Author: Saravanan Sekar + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MP2629_REG_ADC_CTRL 0x03 +#define MP2629_REG_BATT_VOLT 0x0e +#define MP2629_REG_SYSTEM_VOLT 0x0f +#define MP2629_REG_INPUT_VOLT 0x11 +#define MP2629_REG_BATT_CURRENT 0x12 +#define MP2629_REG_INPUT_CURRENT 0x13 + +#define MP2629_ADC_START BIT(7) +#define MP2629_ADC_CONTINUOUS BIT(6) + +#define MP2629_MAP(_mp, _mpc) IIO_MAP(#_mp, "mp2629_charger", "mp2629-"_mpc) + +#define MP2629_ADC_CHAN(_ch, _type) { \ + .type = _type, \ + .indexed = 1, \ + .datasheet_name = #_ch, \ + .channel = MP2629_ ## _ch, \ + .address = MP2629_REG_ ## _ch, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +} + +struct mp2629_adc { + struct regmap *regmap; + struct device *dev; +}; + +static struct iio_chan_spec mp2629_channels[] = { + MP2629_ADC_CHAN(BATT_VOLT, IIO_VOLTAGE), + MP2629_ADC_CHAN(SYSTEM_VOLT, IIO_VOLTAGE), + MP2629_ADC_CHAN(INPUT_VOLT, IIO_VOLTAGE), + MP2629_ADC_CHAN(BATT_CURRENT, IIO_CURRENT), + MP2629_ADC_CHAN(INPUT_CURRENT, IIO_CURRENT) +}; + +static struct iio_map mp2629_adc_maps[] = { + MP2629_MAP(BATT_VOLT, "batt-volt"), + MP2629_MAP(SYSTEM_VOLT, "system-volt"), + MP2629_MAP(INPUT_VOLT, "input-volt"), + MP2629_MAP(BATT_CURRENT, "batt-current"), + MP2629_MAP(INPUT_CURRENT, "input-current") +}; + +static int mp2629_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct mp2629_adc *info = iio_priv(indio_dev); + unsigned int rval; + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = regmap_read(info->regmap, chan->address, &rval); + if (ret) + return ret; + + if (chan->address == MP2629_INPUT_VOLT) + rval &= GENMASK(6, 0); + *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: + *val = 133; + *val2 = 10; + return IIO_VAL_FRACTIONAL; + + default: + return -EINVAL; + } + + default: + return -EINVAL; + } +} + +static const struct iio_info mp2629_adc_info = { + .read_raw = &mp2629_read_raw, +}; + +static int mp2629_adc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mp2629_info *ddata = dev_get_drvdata(dev->parent); + struct mp2629_adc *info; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*info)); + if (!indio_dev) + return -ENOMEM; + + info = iio_priv(indio_dev); + info->regmap = ddata->regmap; + info->dev = dev; + platform_set_drvdata(pdev, indio_dev); + + ret = regmap_update_bits(ddata->regmap, MP2629_REG_ADC_CTRL, + MP2629_ADC_START | MP2629_ADC_CONTINUOUS, + MP2629_ADC_START | MP2629_ADC_CONTINUOUS); + if (ret) { + dev_err(dev, "adc enable fail: %d\n", ret); + return ret; + } + + ret = iio_map_array_register(indio_dev, mp2629_adc_maps); + if (ret) { + dev_err(dev, "IIO maps register fail: %d\n", ret); + goto fail_disable; + } + + indio_dev->name = "mp2629-adc"; + indio_dev->dev.parent = dev; + indio_dev->channels = mp2629_channels; + indio_dev->num_channels = ARRAY_SIZE(mp2629_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &mp2629_adc_info; + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(dev, "IIO device register fail: %d\n", ret); + goto fail_map_unregister; + } + + return 0; + +fail_map_unregister: + iio_map_array_unregister(indio_dev); + +fail_disable: + regmap_update_bits(ddata->regmap, MP2629_REG_ADC_CTRL, + MP2629_ADC_CONTINUOUS, 0); + regmap_update_bits(ddata->regmap, MP2629_REG_ADC_CTRL, + MP2629_ADC_START, 0); + + return ret; +} + +static int mp2629_adc_remove(struct platform_device *pdev) +{ + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct mp2629_adc *info = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + iio_map_array_unregister(indio_dev); + + regmap_update_bits(info->regmap, MP2629_REG_ADC_CTRL, + MP2629_ADC_CONTINUOUS, 0); + regmap_update_bits(info->regmap, MP2629_REG_ADC_CTRL, + MP2629_ADC_START, 0); + + return 0; +} + +static const struct of_device_id mp2629_adc_of_match[] = { + { .compatible = "mps,mp2629_adc"}, + {} +}; +MODULE_DEVICE_TABLE(of, mp2629_adc_of_match); + +static struct platform_driver mp2629_adc_driver = { + .driver = { + .name = "mp2629_adc", + .of_match_table = mp2629_adc_of_match, + }, + .probe = mp2629_adc_probe, + .remove = mp2629_adc_remove, +}; +module_platform_driver(mp2629_adc_driver); + +MODULE_AUTHOR("Saravanan Sekar "); +MODULE_DESCRIPTION("MP2629 ADC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/mp2629.h b/include/linux/mfd/mp2629.h index 06985e41fc6f..83ebfab41691 100644 --- a/include/linux/mfd/mp2629.h +++ b/include/linux/mfd/mp2629.h @@ -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 From patchwork Mon Apr 13 17:36:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saravanan sekar X-Patchwork-Id: 11486091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34103912 for ; Mon, 13 Apr 2020 17:37:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0845A20768 for ; Mon, 13 Apr 2020 17:37:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p9ddU1fe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732888AbgDMRhR (ORCPT ); Mon, 13 Apr 2020 13:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732880AbgDMRhN (ORCPT ); Mon, 13 Apr 2020 13:37:13 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E7DC008748; Mon, 13 Apr 2020 10:37:11 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id s8so10973393wrt.7; Mon, 13 Apr 2020 10:37:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XqcgzYs41Pt6ZEtI+pxqWzuWv5T+y9a7P5MK34lJ43g=; b=p9ddU1fe9eO82sdjhlMQae5ounkpkD8h5TCKBjVXr1p+IjeQVO1SBFEpryHrNi7796 AARkYbb+FbO/omxw3Yzk+Becp5tGNApK3bRcHD0iDx99VitSfuCCvFfAWybTL6WVvORz H7QxVfHWIDk60XwF4Lj92x6A1VhvHfF4UmIBqxXR5LXj3GzQVgb6DDNwHqqpnkztswKQ FaFxmTqeWxznrLtvXFAz7bHrxgSvF74v7nBz0dza8DqIvgdgTI59uhPfHUM/Y5oVsvPK iaWHZHaDdrCLiyIOk7Kgr1qPu33v9QmM/9hCfbL/PQcFO6Mm5/KaE5jLkgC1Hb6lYcnt dvig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XqcgzYs41Pt6ZEtI+pxqWzuWv5T+y9a7P5MK34lJ43g=; b=CVdXaZCJMKtsi7Zy5QftrhFojDdb0hTtMlLKj5ugOdYHGXpJkHfCICPIHGfyvXSSuR Y0KAkcM8ELW7CH5grOaE/b1LkofVS2ZdgqI9zwGUY325D4dURtovjKuBfFF1QFvajdD3 DzsYfUmalEBdr8fJtFLB0hAHDraqOZlPEyFxNR7l+t0SJM14N38n6yWWlUfTFWyR6FIE 3QU0xhbHrNcjNXbnKP/Td3wYoULDCiqKFyVOguViZEoJJSLgrPixlMdaoGECA9rjxIK+ Zd9JKj0Z6d/Je00ZWreWS+Vdelbj6xx6j9m6PP6oD0q29csW0ew/78AeeCoQB+Llf1Ja ntWw== X-Gm-Message-State: AGi0PuZUbRso/jAz/P/t14QzjX4eCHbUHDRMaad/702mTx1NnHHbTVz0 vGGys6ugeM/NQb/U9tPlJAs= X-Google-Smtp-Source: APiQypKCfF/lGtfZ8TnSAvjUIGttD/Kn5ChDjBE3z4G+9b8qcJPxqpgd0iE/iNI6bzUSI2F11uaInQ== X-Received: by 2002:adf:fc92:: with SMTP id g18mr10439373wrr.10.1586799430296; Mon, 13 Apr 2020 10:37:10 -0700 (PDT) Received: from localhost.localdomain (p5B3F6AD5.dip0.t-ipconnect.de. [91.63.106.213]) by smtp.gmail.com with ESMTPSA id a205sm11141465wmh.29.2020.04.13.10.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 10:37:09 -0700 (PDT) From: Saravanan Sekar To: lee.jones@linaro.org, andy.shevchenko@gmail.com, robh+dt@kernel.org, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, sre@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, Saravanan Sekar Subject: [PATCH v8 4/6] power: supply: Add support for mps mp2629 battery charger Date: Mon, 13 Apr 2020 19:36:54 +0200 Message-Id: <20200413173656.28522-5-sravanhome@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413173656.28522-1-sravanhome@gmail.com> References: <20200413173656.28522-1-sravanhome@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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. Signed-off-by: Saravanan Sekar --- 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 diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index f3424fdce341..05b3f66946ad 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -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 diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index 6c7da920ea83..41cb64f09e49 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -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 diff --git a/drivers/power/supply/mp2629_charger.c b/drivers/power/supply/mp2629_charger.c new file mode 100644 index 000000000000..279edfe383ee --- /dev/null +++ b/drivers/power/supply/mp2629_charger.c @@ -0,0 +1,687 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * MP2629 battery charger driver + * + * Copyright 2020 Monolithic Power Systems, Inc + * + * Author: Saravanan Sekar + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MP2629_REG_INPUT_ILIM 0x00 +#define MP2629_REG_INPUT_VLIM 0x01 +#define MP2629_REG_CHARGE_CTRL 0x04 +#define MP2629_REG_CHARGE_ILIM 0x05 +#define MP2629_REG_PRECHARGE 0x06 +#define MP2629_REG_TERM_CURRENT 0x06 +#define MP2629_REG_CHARGE_VLIM 0x07 +#define MP2629_REG_TIMER_CTRL 0x08 +#define MP2629_REG_IMPEDANCE_COMP 0x09 +#define MP2629_REG_INTERRUPT 0x0b +#define MP2629_REG_STATUS 0x0c +#define MP2629_REG_FAULT 0x0d + +#define MP2629_MASK_INPUT_TYPE GENMASK(7, 5) +#define MP2629_MASK_CHARGE_TYPE GENMASK(4, 3) +#define MP2629_MASK_CHARGE_CTRL GENMASK(5, 4) +#define MP2629_MASK_WDOG_CTRL GENMASK(5, 4) +#define MP2629_MASK_IMPEDANCE GENMASK(7, 4) + +#define MP2629_INPUTSOURCE_CHANGE GENMASK(7, 5) +#define MP2629_CHARGING_CHANGE GENMASK(4, 3) +#define MP2629_FAULT_BATTERY BIT(3) +#define MP2629_FAULT_THERMAL BIT(4) +#define MP2629_FAULT_INPUT BIT(5) +#define MP2629_FAULT_OTG BIT(6) + +#define MP2629_MAX_BATT_CAPACITY 100 + +#define MP2629_PROPS(_idx, _min, _max, _step) \ + [_idx] = { \ + .min = _min, \ + .max = _max, \ + .step = _step, \ +} + +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, +}; + +enum mp2629_field { + INPUT_ILIM, + INPUT_VLIM, + CHARGE_ILIM, + CHARGE_VLIM, + PRECHARGE, + TERM_CURRENT, + MP2629_MAX_FIELD +}; + +struct mp2629_charger { + struct device *dev; + struct work_struct charger_work; + int status; + int fault; + + struct regmap *regmap; + struct regmap_field *regmap_fields[MP2629_MAX_FIELD]; + struct mutex lock; + struct power_supply *usb; + struct power_supply *battery; + struct iio_channel *iiochan[MP2629_ADC_CHAN_END]; +}; + +struct mp2629_prop { + int reg; + int mask; + int min; + int max; + int step; + int shift; +}; + +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 +}; + +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, +}; + +static enum power_supply_property mp2629_charger_bat_props[] = { + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_PROP_CHARGE_TYPE, + 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, +}; + +static struct mp2629_prop props[] = { + MP2629_PROPS(INPUT_ILIM, 100000, 3250000, 50000), + MP2629_PROPS(INPUT_VLIM, 3800000, 5300000, 100000), + MP2629_PROPS(CHARGE_ILIM, 320000, 4520000, 40000), + MP2629_PROPS(CHARGE_VLIM, 3400000, 4670000, 10000), + MP2629_PROPS(PRECHARGE, 120000, 720000, 40000), + MP2629_PROPS(TERM_CURRENT, 80000, 680000, 40000), +}; + +static const struct reg_field mp2629_reg_fields[] = { + [INPUT_ILIM] = REG_FIELD(MP2629_REG_INPUT_ILIM, 0, 5), + [INPUT_VLIM] = REG_FIELD(MP2629_REG_INPUT_VLIM, 0, 3), + [CHARGE_ILIM] = REG_FIELD(MP2629_REG_CHARGE_ILIM, 0, 6), + [CHARGE_VLIM] = REG_FIELD(MP2629_REG_CHARGE_VLIM, 1, 7), + [PRECHARGE] = REG_FIELD(MP2629_REG_PRECHARGE, 4, 7), + [TERM_CURRENT] = REG_FIELD(MP2629_REG_TERM_CURRENT, 0, 3), +}; + +static char *adc_chan_name[] = { + "mp2629-batt-volt", + "mp2629-system-volt", + "mp2629-input-volt", + "mp2629-batt-current", + "mp2629-input-current", +}; + +static int mp2629_read_adc(struct mp2629_charger *charger, + enum mp2629_adc_chan ch, + union power_supply_propval *val) +{ + int ret; + int chval; + + ret = iio_read_channel_processed(charger->iiochan[ch], &chval); + if (ret) + return ret; + + val->intval = chval * 1000; + + return 0; +} + +static int mp2629_get_prop(struct mp2629_charger *charger, + enum mp2629_field fld, + union power_supply_propval *val) +{ + int ret; + unsigned int rval; + + ret = regmap_field_read(charger->regmap_fields[fld], &rval); + if (ret) + return ret; + + val->intval = rval * props[fld].step + props[fld].min; + + return 0; +} + +static int mp2629_set_prop(struct mp2629_charger *charger, + enum mp2629_field fld, + const union power_supply_propval *val) +{ + unsigned int rval; + + if (val->intval < props[fld].min || val->intval > props[fld].max) + return -EINVAL; + + rval = (val->intval - props[fld].min) / props[fld].step; + return regmap_field_write(charger->regmap_fields[fld], rval); +} + +static int mp2629_get_battery_capacity(struct mp2629_charger *charger, + union power_supply_propval *val) +{ + union power_supply_propval vnow, vlim; + int ret; + + ret = mp2629_read_adc(charger, MP2629_BATT_VOLT, &vnow); + if (ret) + return ret; + + ret = mp2629_get_prop(charger, CHARGE_VLIM, &vlim); + if (ret) + return ret; + + val->intval = (vnow.intval * 100) / vlim.intval; + val->intval = min(val->intval, MP2629_MAX_BATT_CAPACITY); + + return 0; +} + +static int mp2629_charger_battery_get_prop(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); + unsigned int rval; + int ret = 0; + + switch (psp) { + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + ret = mp2629_read_adc(charger, MP2629_BATT_VOLT, val); + break; + + case POWER_SUPPLY_PROP_CURRENT_NOW: + ret = mp2629_read_adc(charger, MP2629_BATT_CURRENT, val); + break; + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: + val->intval = 4520000; + break; + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: + val->intval = 4670000; + break; + + case POWER_SUPPLY_PROP_CAPACITY: + ret = mp2629_get_battery_capacity(charger, val); + break; + + case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: + ret = mp2629_get_prop(charger, TERM_CURRENT, val); + break; + + case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: + ret = mp2629_get_prop(charger, PRECHARGE, val); + break; + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + ret = mp2629_get_prop(charger, CHARGE_VLIM, val); + break; + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + ret = mp2629_get_prop(charger, CHARGE_ILIM, val); + break; + + case POWER_SUPPLY_PROP_HEALTH: + if (!charger->fault) + val->intval = POWER_SUPPLY_HEALTH_GOOD; + if (MP2629_FAULT_BATTERY & charger->fault) + val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + else if (MP2629_FAULT_THERMAL & charger->fault) + val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; + else if (MP2629_FAULT_INPUT & charger->fault) + val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + + case POWER_SUPPLY_PROP_STATUS: + ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); + if (ret) + break; + + rval = (rval & MP2629_MASK_CHARGE_TYPE) >> 3; + switch (rval) { + case 0x00: + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; + break; + case 0x01: + case 0x10: + val->intval = POWER_SUPPLY_STATUS_CHARGING; + break; + case 0x11: + val->intval = POWER_SUPPLY_STATUS_FULL; + } + break; + + case POWER_SUPPLY_PROP_CHARGE_TYPE: + ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); + if (ret) + break; + + rval = (rval & MP2629_MASK_CHARGE_TYPE) >> 3; + switch (rval) { + case 0x00: + val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; + break; + case 0x01: + val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; + break; + case 0x10: + val->intval = POWER_SUPPLY_CHARGE_TYPE_STANDARD; + break; + default: + val->intval = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; + } + break; + + default: + return -EINVAL; + } + + return ret; +} + +static int mp2629_charger_battery_set_prop(struct power_supply *psy, + enum power_supply_property psp, + const union power_supply_propval *val) +{ + struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); + + switch (psp) { + case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: + return mp2629_set_prop(charger, TERM_CURRENT, val); + + case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: + return mp2629_set_prop(charger, PRECHARGE, val); + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + return mp2629_set_prop(charger, CHARGE_VLIM, val); + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + return mp2629_set_prop(charger, CHARGE_ILIM, val); + + default: + return -EINVAL; + } +} + +static int mp2629_charger_usb_get_prop(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); + unsigned int rval; + int ret; + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); + if (ret) + break; + + val->intval = !!(rval & MP2629_MASK_INPUT_TYPE); + break; + + case POWER_SUPPLY_PROP_USB_TYPE: + ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); + if (ret) + break; + + rval = (rval & MP2629_MASK_INPUT_TYPE) >> 5; + switch (rval) { + case MP2629_SOURCE_TYPE_SDP: + val->intval = POWER_SUPPLY_USB_TYPE_SDP; + break; + case MP2629_SOURCE_TYPE_CDP: + val->intval = POWER_SUPPLY_USB_TYPE_CDP; + break; + case MP2629_SOURCE_TYPE_DCP: + val->intval = POWER_SUPPLY_USB_TYPE_DCP; + break; + case MP2629_SOURCE_TYPE_OTG: + val->intval = POWER_SUPPLY_USB_TYPE_PD_DRP; + break; + default: + val->intval = POWER_SUPPLY_USB_TYPE_UNKNOWN; + break; + } + break; + + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + ret = mp2629_read_adc(charger, MP2629_INPUT_VOLT, val); + break; + + case POWER_SUPPLY_PROP_CURRENT_NOW: + ret = mp2629_read_adc(charger, MP2629_INPUT_CURRENT, val); + break; + + case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT: + ret = mp2629_get_prop(charger, INPUT_VLIM, val); + break; + + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + ret = mp2629_get_prop(charger, INPUT_ILIM, val); + break; + + default: + return -EINVAL; + } + + return ret; +} + +static int mp2629_charger_usb_set_prop(struct power_supply *psy, + enum power_supply_property psp, + const union power_supply_propval *val) +{ + struct mp2629_charger *charger = dev_get_drvdata(psy->dev.parent); + + switch (psp) { + case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT: + return mp2629_set_prop(charger, INPUT_VLIM, val); + + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + return mp2629_set_prop(charger, INPUT_ILIM, val); + + default: + return -EINVAL; + } +} + +static int mp2629_charger_battery_prop_writeable(struct power_supply *psy, + enum power_supply_property psp) +{ + 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); +} + +static int mp2629_charger_usb_prop_writeable(struct power_supply *psy, + enum power_supply_property psp) +{ + return (psp == POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT) || + (psp == POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT); +} + +static void mp2629_charger_work(struct work_struct *work) +{ + struct mp2629_charger *charger; + unsigned int rval; + int ret; + + charger = container_of(work, struct mp2629_charger, charger_work); + + mutex_lock(&charger->lock); + + ret = regmap_read(charger->regmap, MP2629_REG_FAULT, &rval); + if (ret) + goto unlock; + + if (rval) { + charger->fault = rval; + if (MP2629_FAULT_BATTERY & rval) + dev_err(charger->dev, "Battery fault OVP"); + else if (MP2629_FAULT_THERMAL & rval) + dev_err(charger->dev, "Thermal shutdown fault"); + else if (MP2629_FAULT_INPUT & rval) + dev_err(charger->dev, "no input or input OVP"); + else if (MP2629_FAULT_OTG & rval) + dev_err(charger->dev, "VIN overloaded"); + + goto unlock; + } + + ret = regmap_read(charger->regmap, MP2629_REG_STATUS, &rval); + if (ret) + goto unlock; + + if (rval & MP2629_INPUTSOURCE_CHANGE) + power_supply_changed(charger->usb); + else if (rval & MP2629_CHARGING_CHANGE) + power_supply_changed(charger->battery); + +unlock: + mutex_unlock(&charger->lock); +} + +static irqreturn_t mp2629_irq_handler(int irq, void *dev_id) +{ + struct mp2629_charger *charger = dev_id; + + schedule_work(&charger->charger_work); + return IRQ_HANDLED; +} + +static const struct power_supply_desc mp2629_usb_desc = { + .name = "mp2629_usb", + .type = POWER_SUPPLY_TYPE_USB, + .usb_types = mp2629_usb_types, + .num_usb_types = ARRAY_SIZE(mp2629_usb_types), + .properties = mp2629_charger_usb_props, + .num_properties = ARRAY_SIZE(mp2629_charger_usb_props), + .get_property = mp2629_charger_usb_get_prop, + .set_property = mp2629_charger_usb_set_prop, + .property_is_writeable = mp2629_charger_usb_prop_writeable, +}; + +static const struct power_supply_desc mp2629_battery_desc = { + .name = "mp2629_battery", + .type = POWER_SUPPLY_TYPE_BATTERY, + .properties = mp2629_charger_bat_props, + .num_properties = ARRAY_SIZE(mp2629_charger_bat_props), + .get_property = mp2629_charger_battery_get_prop, + .set_property = mp2629_charger_battery_set_prop, + .property_is_writeable = mp2629_charger_battery_prop_writeable, +}; + +static ssize_t batt_impedance_compensation_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct mp2629_charger *charger = dev_get_drvdata(dev->parent); + unsigned int rval; + int ret; + + ret = regmap_read(charger->regmap, MP2629_REG_IMPEDANCE_COMP, &rval); + if (ret) + return ret; + + rval = (rval >> 4) * 10; + return sprintf(buf, "%d mohm\n", rval); +} + +static ssize_t batt_impedance_compensation_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t count) +{ + struct mp2629_charger *charger = dev_get_drvdata(dev->parent); + unsigned int val; + int ret; + + ret = kstrtouint(buf, 10, &val); + if (ret) + return ret; + + if (val > 140) + return -ERANGE; + + /* multiples of 10 mohm so round off */ + val = val / 10; + ret = regmap_update_bits(charger->regmap, MP2629_REG_IMPEDANCE_COMP, + MP2629_MASK_IMPEDANCE, val << 4); + if (ret) + return ret; + + return count; +} + +static DEVICE_ATTR_RW(batt_impedance_compensation); + +static struct attribute *mp2629_charger_sysfs_attrs[] = { + &dev_attr_batt_impedance_compensation.attr, + NULL +}; +ATTRIBUTE_GROUPS(mp2629_charger_sysfs); + +static int mp2629_charger_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mp2629_info *ddata = dev_get_drvdata(dev->parent); + struct mp2629_charger *charger; + struct power_supply_config psy_cfg = {}; + int ret, i, irq; + + charger = devm_kzalloc(dev, sizeof(*charger), GFP_KERNEL); + if (!charger) + return -ENOMEM; + + charger->regmap = ddata->regmap; + charger->dev = dev; + platform_set_drvdata(pdev, charger); + + for (i = 0; i < MP2629_MAX_FIELD; i++) { + charger->regmap_fields[i] = devm_regmap_field_alloc(dev, + charger->regmap, mp2629_reg_fields[i]); + if (IS_ERR(charger->regmap_fields[i])) { + dev_err(dev, "regmap field alloc fail %d\n", i); + return PTR_ERR(charger->regmap_fields[i]); + } + } + + 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; + } + } + + charger->usb = devm_power_supply_register(dev, &mp2629_usb_desc, NULL); + if (IS_ERR(charger->usb)) { + ret = PTR_ERR(charger->usb); + goto iio_fail; + } + + psy_cfg.drv_data = charger; + psy_cfg.attr_grp = mp2629_charger_sysfs_groups; + charger->battery = devm_power_supply_register(dev, + &mp2629_battery_desc, &psy_cfg); + if (IS_ERR(charger->battery)) { + ret = PTR_ERR(charger->battery); + goto iio_fail; + } + + ret = regmap_update_bits(charger->regmap, MP2629_REG_CHARGE_CTRL, + MP2629_MASK_CHARGE_CTRL, BIT(4)); + if (ret) { + dev_err(dev, "enable charge fail: %d\n", ret); + goto iio_fail; + } + + regmap_update_bits(charger->regmap, MP2629_REG_TIMER_CTRL, + MP2629_MASK_WDOG_CTRL, 0); + + INIT_WORK(&charger->charger_work, mp2629_charger_work); + mutex_init(&charger->lock); + + irq = platform_get_irq(to_platform_device(pdev->dev.parent), 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; + } + } + + regmap_update_bits(charger->regmap, MP2629_REG_INTERRUPT, + GENMASK(6, 5), BIT(6) | BIT(5)); + + return 0; + +iio_fail: + while (i--) + iio_channel_release(charger->iiochan[i]); + + dev_err(dev, "driver register fail: %d\n", ret); + return ret; +} + +static int mp2629_charger_remove(struct platform_device *pdev) +{ + struct mp2629_charger *charger = platform_get_drvdata(pdev); + int i; + + cancel_work_sync(&charger->charger_work); + + for (i = 0; i < MP2629_ADC_CHAN_END; i++) + iio_channel_release(charger->iiochan[i]); + + regmap_update_bits(charger->regmap, MP2629_REG_CHARGE_CTRL, + MP2629_MASK_CHARGE_CTRL, 0); + return 0; +} + +static const struct of_device_id mp2629_charger_of_match[] = { + { .compatible = "mps,mp2629_charger"}, + {} +}; +MODULE_DEVICE_TABLE(of, mp2629_charger_of_match); + +static struct platform_driver mp2629_charger_driver = { + .driver = { + .name = "mp2629_charger", + .of_match_table = mp2629_charger_of_match, + }, + .probe = mp2629_charger_probe, + .remove = mp2629_charger_remove, +}; +module_platform_driver(mp2629_charger_driver); + +MODULE_AUTHOR("Saravanan Sekar "); +MODULE_DESCRIPTION("MP2629 Charger driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Apr 13 17:36:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saravanan sekar X-Patchwork-Id: 11486085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22931912 for ; Mon, 13 Apr 2020 17:37:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0997820737 for ; Mon, 13 Apr 2020 17:37:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PgWv9D4E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732886AbgDMRhQ (ORCPT ); Mon, 13 Apr 2020 13:37:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732876AbgDMRhN (ORCPT ); Mon, 13 Apr 2020 13:37:13 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA7BC0A3BDC; Mon, 13 Apr 2020 10:37:12 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id x25so10055794wmc.0; Mon, 13 Apr 2020 10:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RJvsfKsMnt/X9Nzxg++jYAolf7LD+g/Z1b76iH73i3U=; b=PgWv9D4ExGDMpPseahRf3wQBBneUgnagl8ib7Au1jBonjNWWeQYRa9rvuBjmY5773T +AWCD4yUY5JogNkwgCK5zoq8ZA948YmtUq/+9pBqy33uNWdFZeUEPHLPQTKpNT2OFb+5 WQDYZfd/LwX6coTmog3RvV/xwe2MOQaF81pGeMJI7xskRyJQwMqB9sYZ6Zd3kEHH88fw FUY3Kt3DrxvJOTO5GJBy5rDfDMvZSaptj+7jJtQtNT19XoJOFsMbXMQBXq43gRnrqyW6 mCabi7S7R1LbvlzW7rm/5qz5URSFlQADee6o55A4q++X9S4zWizP7fkp0jpaXRUFztdm Q/Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RJvsfKsMnt/X9Nzxg++jYAolf7LD+g/Z1b76iH73i3U=; b=UluiBoquM1mWEEdqrqIcLurCFKatJmX/OjYuSvSn/qGft4hCL6dvD+U3fbaYhefkPC RKI5wHqFxw3+rwXXV6FPg2D3bCicZKI7Fke0Q9LVARJL0/iM4D5EyJn5MbQa9rJNFnx5 Mt8SPOrJJdrp8eWndgCrXpayWbda4zIyfZnYLKzEtfXYoSemqbOLgyFsVs+D40Q1LPut f3Pi1xrMTs+bLmItxqRQSYI7u/QozTt+4K+PODBIBNlXcERB3lydb3ex0LBzEE9EMpfW 5WWhB/zmrLT6Vc94JIqUgshzbhY5u0WsDr1T59kXKb5em9QTVwgSIJPmLDt47bfNOSf+ z02w== X-Gm-Message-State: AGi0PuYqwaL9xEc2DZ90uDmVax6moeFtxDMGK3DE4siFoxVvCxcI8vWc yVV1thk/u9P+yA3+cdsObxA= X-Google-Smtp-Source: APiQypILyrh7qXLb2k9CC4tX3cyTdg/9b2XUdW3iGtIm0qwRBy1+ocTtQxm5GzEsfW97jEbvmLIzsg== X-Received: by 2002:a05:600c:14d4:: with SMTP id i20mr8653509wmh.118.1586799431406; Mon, 13 Apr 2020 10:37:11 -0700 (PDT) Received: from localhost.localdomain (p5B3F6AD5.dip0.t-ipconnect.de. [91.63.106.213]) by smtp.gmail.com with ESMTPSA id a205sm11141465wmh.29.2020.04.13.10.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 10:37:10 -0700 (PDT) From: Saravanan Sekar To: lee.jones@linaro.org, andy.shevchenko@gmail.com, robh+dt@kernel.org, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, sre@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, Saravanan Sekar Subject: [PATCH v8 5/6] power: supply: mp2629: Add impedance compenstation config Date: Mon, 13 Apr 2020 19:36:55 +0200 Message-Id: <20200413173656.28522-6-sravanhome@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413173656.28522-1-sravanhome@gmail.com> References: <20200413173656.28522-1-sravanhome@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Allows the user to compensate the intrinsic resistance of the battery to accelerate the charging cycle. Signed-off-by: Saravanan Sekar --- Documentation/ABI/testing/sysfs-class-power-mp2629 | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-mp2629 diff --git a/Documentation/ABI/testing/sysfs-class-power-mp2629 b/Documentation/ABI/testing/sysfs-class-power-mp2629 new file mode 100644 index 000000000000..7b7c0e7a7c45 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-power-mp2629 @@ -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]. From patchwork Mon Apr 13 17:36:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saravanan sekar X-Patchwork-Id: 11486101 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74EF0912 for ; Mon, 13 Apr 2020 17:37:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B8622076D for ; Mon, 13 Apr 2020 17:37:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FyRQ4O4t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732916AbgDMRhe (ORCPT ); Mon, 13 Apr 2020 13:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732882AbgDMRhO (ORCPT ); Mon, 13 Apr 2020 13:37:14 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2497C0A3BE2; Mon, 13 Apr 2020 10:37:13 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id o81so4465427wmo.2; Mon, 13 Apr 2020 10:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6QvXfJZlpggMK4ANi6m9pBKzrWALkcbq78l8N8OifPg=; b=FyRQ4O4tvTTJTitTz9W28h/1N/LB+saR96VqV/dHtuDmuCaOoLZajiaIyEYWqlSNFK /nUN0Gvbw7+sIXhJT9QmCSA1tPmI5xuMEiUTsDUwdD7TJig99iJiIZQgB83msgwLRda5 tDUu2UruS3Pm3yjAmmSOGAc1msp8foDihyQrUwaU4P4ajkZlgFBlD8flj7mgd6y5S6uO SRAw08Shw5dtKBlpGdMeshBj61gNkGGRPiIrm8G23pAHxwtW0JcMRqxszwty0+lmJ4eB KZ1cQRQUqeKtGPvo5Ynm1+Df16dqyhngf4HL7pRHuSTyFBwht1OQtazm73b8e+NRiZU0 Y+Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6QvXfJZlpggMK4ANi6m9pBKzrWALkcbq78l8N8OifPg=; b=kro5dDHDW6vtCzhS20NVOG1fXZinU86PGF8zvfIKN0f4nuyHiSIb607B9plJkYYJEZ RlTBuO4PKNUFcgCZH/v4+hH9Ik17QCOhuw1vOiAANW+kOZ4PYOySpenPJd1Q/mfOWgi1 vuYSn5lfgXVCQRP9OdAFOnlCiDGk1f30dAjscqca+cd53IRePp3YshuJ459lA71WysL7 OYuGJkgmiLZ/+W8bSImQwT4EoHzzze4Z25pRb6Mmuj7cUME2pg795ygl9RFD8gE9NRHM bEsKumXU/ZkgrObkcHVgt+2z6lhotxz9P5U3FylxksNrsSuCtkBGgcoEdO2OvSmeVn1e QHDg== X-Gm-Message-State: AGi0Pub3rV4dvtCn1vxhf3jWrXuatrji4KRPtVRN7Nh6RUdYmonbRbU7 bco09TyrBZQccV3rWuloxuDuRy96Ckw= X-Google-Smtp-Source: APiQypLoFKiIymQKv4j12LxYH1Zb7462vvWxWlSn3xUcZq8EdPqS5Vh6LZWjzgYDMQin8f3MxLZQgg== X-Received: by 2002:a05:600c:2196:: with SMTP id e22mr6836810wme.105.1586799432693; Mon, 13 Apr 2020 10:37:12 -0700 (PDT) Received: from localhost.localdomain (p5B3F6AD5.dip0.t-ipconnect.de. [91.63.106.213]) by smtp.gmail.com with ESMTPSA id a205sm11141465wmh.29.2020.04.13.10.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 10:37:11 -0700 (PDT) From: Saravanan Sekar To: lee.jones@linaro.org, andy.shevchenko@gmail.com, robh+dt@kernel.org, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, sre@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, Saravanan Sekar Subject: [PATCH v8 6/6] MAINTAINERS: Add entry for mp2629 Battery Charger driver Date: Mon, 13 Apr 2020 19:36:56 +0200 Message-Id: <20200413173656.28522-7-sravanhome@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413173656.28522-1-sravanhome@gmail.com> References: <20200413173656.28522-1-sravanhome@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Add MAINTAINERS entry for Monolithic Power Systems mp2629 Charger driver. Signed-off-by: Saravanan Sekar --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 32a95d162f06..0f82d5a7a614 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11358,10 +11358,15 @@ F: drivers/tty/mxser.* MONOLITHIC POWER SYSTEM PMIC DRIVER M: Saravanan Sekar 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