From patchwork Mon Oct 24 13:27:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 618062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 696FEFA373E for ; Mon, 24 Oct 2022 14:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235498AbiJXOxr (ORCPT ); Mon, 24 Oct 2022 10:53:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231956AbiJXOxU (ORCPT ); Mon, 24 Oct 2022 10:53:20 -0400 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 894B8D38C6; Mon, 24 Oct 2022 06:31:07 -0700 (PDT) Received: by mail-ed1-f45.google.com with SMTP id a67so31218851edf.12; Mon, 24 Oct 2022 06:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xkjjo7UhHr68UQkDQLmeDc/rzOhg5k2ugSo/6Bh7PsU=; b=T3b3FyGncjk4zPd1OhDQJliCp91vS+wwBy7+VfIBdISFNkro26NByxQAozweGKNYzg hUb0D9/qt7ikl+Aqa/j3O74PUV4KwOHirptzpd0KBAz5BsOXCWAReH8oE8cbiI8LVwrU 1f+OKPi3Lz+9Zm8UoTu7TwGhVECgERGMkq8dOGCyj9a/xV/4+zRC2eU6JLgw0iKP+pzV fBezP3yBvCfIF7ZKYJVZNK4r5DgCC7zEIhHKY2WMZ7g39ckpwRfb4pqSRv3fuZiFtIKB n16CIjE6DhzSkFz6PWc9xfAnwtn2sTSiBSG0avMOgquRYUuIXQ+R4unWYncm+3jIkovr sfZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xkjjo7UhHr68UQkDQLmeDc/rzOhg5k2ugSo/6Bh7PsU=; b=tIhFEgNlwqourBdmvO1xlVadn32Ow37ttk8GIhEeoMG+oG2uhcIwJdRGF+7vCS29lX GQRY0cbwHD0wTPs1sCkHQmELLuAotxZi/kUNoKj+7Hr/QK+YhBkJIHQ1hk6hIg3f+jOp YWw6X8eq7uTVgHem39QbIwpLwakjFJR17YdhR80eeEI2w8RVaBgVC0yaHhP33Ozl8vAv UUHdjmwAk6s/i+S2p2z2Wr3XYrNWyo18F1zaddAwBFtvgIfaB08s7JnisA0pichR2dR7 5e8N51F+hZz3wYEd5K5Aac8dlvApcfOViSmimvlDBLx1cpQQAgZamsROPv/I+KDKJ12b N2kg== X-Gm-Message-State: ACrzQf2IBbrDR9vA5BMcLco5aMnZpRG8GSZBYGPwDMTMlqrGdab8iu90 ZcqqVJwFDwAkBBywfMh7DgfVheJfx34= X-Google-Smtp-Source: AMsMyM6BW9Qwf1YKt0QJuHSrKBkpjQA+LWdiivjudPUUEZLBin7mbS4/9M7FDPOwmuf1TpopggBi6g== X-Received: by 2002:a05:6402:294a:b0:461:b661:d903 with SMTP id ed10-20020a056402294a00b00461b661d903mr6155562edb.407.1666618083184; Mon, 24 Oct 2022 06:28:03 -0700 (PDT) Received: from discovery.. (p5dcfeede.dip0.t-ipconnect.de. [93.207.238.222]) by smtp.gmail.com with ESMTPSA id l20-20020a056402231400b00457c5637578sm18243818eda.63.2022.10.24.06.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:28:02 -0700 (PDT) From: Saravanan Sekar To: sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Saravanan Sekar Subject: [PATCH v4 1/8] iio: adc: mp2629: fix wrong comparison of channel Date: Mon, 24 Oct 2022 15:27:50 +0200 Message-Id: <20221024132757.3345400-2-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221024132757.3345400-1-sravanhome@gmail.com> References: <20221024132757.3345400-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Input voltage channel enum is compared against iio address instead of the channel. Fixes: 7abd9fb64682 ("iio: adc: mp2629: Add support for mp2629 ADC driver") Signed-off-by: Saravanan Sekar Reviewed-by: Andy Shevchenko --- drivers/iio/adc/mp2629_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c index 30a31f185d08..f7af9af1665d 100644 --- a/drivers/iio/adc/mp2629_adc.c +++ b/drivers/iio/adc/mp2629_adc.c @@ -74,7 +74,7 @@ static int mp2629_read_raw(struct iio_dev *indio_dev, if (ret) return ret; - if (chan->address == MP2629_INPUT_VOLT) + if (chan->channel == MP2629_INPUT_VOLT) rval &= GENMASK(6, 0); *val = rval; return IIO_VAL_INT; From patchwork Mon Oct 24 13:27:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 618637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F92AFA373F for ; Mon, 24 Oct 2022 16:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbiJXQ4N (ORCPT ); Mon, 24 Oct 2022 12:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236098AbiJXQzi (ORCPT ); Mon, 24 Oct 2022 12:55:38 -0400 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDDFF20BD3; Mon, 24 Oct 2022 08:36:29 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id o12so17349407lfq.9; Mon, 24 Oct 2022 08:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+dEUdYH2IOK4Sv9uUCxei2ji2lQPqttekINckKjP4e8=; b=pKdY04PVa7KzU5j5KpYTQgyufQJqQQAqX0xxLZmGJ861xYsrflmL/WopHbWTcz4UAn N2vuNASVoKq7pnoedCv98RrECU5fmV3h5WQ0azO8g1K+4RX+GvROPZZ4AMVgM9C9ZW6R x2G14hZlamiKeezO2/C87M3lo6F0GZcVVn4V1e4nzxaMcCY38zBR7Gvc5BuyX7JQvkjt d+bJ1iubDj/lyUd+fsYoxSbYtVHGAMSV4KOvmJFIawcogmEljymppTCVekP3lo0Q8hVx 1ZDGWIvuqQd7NNt12+7MzCQ3snGFz7akKAJVS7rybKhRc+Xe7lpix735ZLRWKyeI5xY6 V33A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+dEUdYH2IOK4Sv9uUCxei2ji2lQPqttekINckKjP4e8=; b=IZE/Ua4M/t5ptwOVPv9x3AhV9kA7WDD+76B8+KJ2VVs228pejzbeByzsDYF9QS+aFT dFMq26rxydee6ZeLNu8BOAvqhY4Zbjmm6EKl4VLVuoIq9WmZ0MVGlukBh1CTr8wOoiZ4 ykn7JVDkLLnpBrmQJRJM0098HXlBacG+If00qmzcwn/TjzpXRYc5gMapJLNe3tO4Vahh blemC3+hZZ+GHZBMrd7xP4kUfN9R9D3FFwXeJEiD7ojGsBYiw3a0c4JzLHAJMv3StGjZ Jn/afhkdFEs2Qd4NDJN70pHt6fX/Yw6ruZtT2rvb3pQV0Oh8cr3r/ZWZUb9sT1L/1Z73 XRDw== X-Gm-Message-State: ACrzQf1TBB/3eycQUKGHZhvnArQE7IlsHb+PVSbJXtzhWYK0h25WSc7d q/Xbpk0pZMULegPx6Dd99+FID/625f0= X-Google-Smtp-Source: AMsMyM7M/0vyYZ6EerjqtAwEA7qKq+RAd7hMP2WFYVk+1+1oDCXgyAFn2yvL7zrF3OumgreOBLPoLw== X-Received: by 2002:a17:907:7e9e:b0:78d:f3b0:fc78 with SMTP id qb30-20020a1709077e9e00b0078df3b0fc78mr28125405ejc.478.1666618084008; Mon, 24 Oct 2022 06:28:04 -0700 (PDT) Received: from discovery.. (p5dcfeede.dip0.t-ipconnect.de. [93.207.238.222]) by smtp.gmail.com with ESMTPSA id l20-20020a056402231400b00457c5637578sm18243818eda.63.2022.10.24.06.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:28:03 -0700 (PDT) From: Saravanan Sekar To: sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Saravanan Sekar Subject: [PATCH v4 2/8] mfd: mp2629: Add support for mps mp2733 battery charger Date: Mon, 24 Oct 2022 15:27:51 +0200 Message-Id: <20221024132757.3345400-3-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221024132757.3345400-1-sravanhome@gmail.com> References: <20221024132757.3345400-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org mp2733 is updated version of mp2629 battery charge management device for single-cell Li-ion or Li-polymer battery. Additionally supports USB fast-charge and higher range of input voltage. Signed-off-by: Saravanan Sekar Reviewed-by: Andy Shevchenko --- drivers/mfd/mp2629.c | 5 ++++- include/linux/mfd/mp2629.h | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/mp2629.c b/drivers/mfd/mp2629.c index 16840ec5fd1c..f59c97e70f83 100644 --- a/drivers/mfd/mp2629.c +++ b/drivers/mfd/mp2629.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -43,6 +44,7 @@ static int mp2629_probe(struct i2c_client *client) return -ENOMEM; ddata->dev = &client->dev; + ddata->chip_id = (uintptr_t)device_get_match_data(&client->dev); i2c_set_clientdata(client, ddata); ddata->regmap = devm_regmap_init_i2c(client, &mp2629_regmap_config); @@ -60,7 +62,8 @@ static int mp2629_probe(struct i2c_client *client) } static const struct of_device_id mp2629_of_match[] = { - { .compatible = "mps,mp2629"}, + { .compatible = "mps,mp2629", .data = (void *)CHIP_ID_MP2629 }, + { .compatible = "mps,mp2733", .data = (void *)CHIP_ID_MP2733 }, { } }; MODULE_DEVICE_TABLE(of, mp2629_of_match); diff --git a/include/linux/mfd/mp2629.h b/include/linux/mfd/mp2629.h index 89b706900b57..ee0e65720c75 100644 --- a/include/linux/mfd/mp2629.h +++ b/include/linux/mfd/mp2629.h @@ -9,9 +9,15 @@ #include #include +enum mp2xx_chip_id { + CHIP_ID_MP2629, + CHIP_ID_MP2733, +}; + struct mp2629_data { struct device *dev; struct regmap *regmap; + enum mp2xx_chip_id chip_id; }; enum mp2629_adc_chan { From patchwork Mon Oct 24 13:27:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 618639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58C84ECAAA1 for ; Mon, 24 Oct 2022 14:53:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231939AbiJXOxF (ORCPT ); Mon, 24 Oct 2022 10:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232289AbiJXOwf (ORCPT ); Mon, 24 Oct 2022 10:52:35 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB299B85F; Mon, 24 Oct 2022 06:30:34 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id z97so31227603ede.8; Mon, 24 Oct 2022 06:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gTwWNDn2qdNJbRVw9L9jOeKIRCjIta4CaBA+HcX1eOI=; b=V17lr0h3FpW9kjI2vkyNoAG1BIIuwTrC1r3tH3a3LeHFAHee+isiudTIbWz79ZqNoI odLWavTFfLHYvyGRDGWd8ZbU4Xqxoujfk5TbzR8DZ+iC1s9zLik0AETTqbK62Pb3FKLQ RShfOIXH1rabvPyR9XT6mPJaWRQ9U585B6idhb/q1Byi9DmU4+a2y+Pp0qIPsrb2e7xc HiSutZmWDLk9satKX+6DifC31ADBejDiABipsWuCq52awmCeW/xwCsd4hAv98FILj2So DWcNOx0wRUiYMSKz9gq27gvgQHVpVhbG1J7ZQ7BmYJsvPnLqIjE9gMGZoSG2Vmy+gUGh fdhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gTwWNDn2qdNJbRVw9L9jOeKIRCjIta4CaBA+HcX1eOI=; b=rPrxWbVrc7MCd+heYMg6vLZ7jh0sjd00CqW68RaCnbiyWMjoQMo5ASkF0gleBvO7xi KFhPW1FaKK0V9yO+ZsWo0p/9lD8EPcU/KkdZRrFSrzEmQTEtA19R7SR4TnVxcHFOf7ke hxRDVPTdI+EZPBrP1gcERAjKzncCFJ/8vFVzDUqzhfB0GV/jvdZRCJ1yWHmSHfcVbgob i5OinmUcOELACBwHEz1+NN4HrNYaDOhMuG827Xcchzj1U5u8wo8I9ttT0cO/hlbRy5rB P02Uh/Gql3HK4wt6si6K+0NQ9Q4mc2he5pxCzy+B9MnNqxuWr3dhJc8QebsNm31tkh85 Tk+Q== X-Gm-Message-State: ACrzQf3FlnwWYU9nHZYPh0efEF49mwtaTbwkE1aq0j0ROGK2hK0wyGC0 eHYzlkPXEeuZuS2Q/VgTxGHBGuWY4yc= X-Google-Smtp-Source: AMsMyM4wuoEeSV6p6sCOVKCcYuUj083c9dZQhKjdqPnK6b7c+25sRkz071I2gCQiO64qQxU+P/ztIQ== X-Received: by 2002:a05:6402:2687:b0:45d:3a94:348f with SMTP id w7-20020a056402268700b0045d3a94348fmr30638576edd.48.1666618084665; Mon, 24 Oct 2022 06:28:04 -0700 (PDT) Received: from discovery.. (p5dcfeede.dip0.t-ipconnect.de. [93.207.238.222]) by smtp.gmail.com with ESMTPSA id l20-20020a056402231400b00457c5637578sm18243818eda.63.2022.10.24.06.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:28:04 -0700 (PDT) From: Saravanan Sekar To: sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Saravanan Sekar Subject: [PATCH v4 3/8] iio: adc: mp2629: restrict input voltage mask for mp2629 Date: Mon, 24 Oct 2022 15:27:52 +0200 Message-Id: <20221024132757.3345400-4-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221024132757.3345400-1-sravanhome@gmail.com> References: <20221024132757.3345400-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add support for mp2733 which is updated version of mp2629 with a higher range of input voltage. Signed-off-by: Saravanan Sekar Reviewed-by: Andy Shevchenko --- drivers/iio/adc/mp2629_adc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c index f7af9af1665d..0f297072b8aa 100644 --- a/drivers/iio/adc/mp2629_adc.c +++ b/drivers/iio/adc/mp2629_adc.c @@ -65,6 +65,7 @@ static int mp2629_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct mp2629_adc *info = iio_priv(indio_dev); + struct mp2629_data *ddata = dev_get_drvdata(info->dev); unsigned int rval; int ret; @@ -74,8 +75,10 @@ static int mp2629_read_raw(struct iio_dev *indio_dev, if (ret) return ret; - if (chan->channel == MP2629_INPUT_VOLT) + if (chan->channel == MP2629_INPUT_VOLT && + ddata->chip_id == CHIP_ID_MP2629) rval &= GENMASK(6, 0); + *val = rval; return IIO_VAL_INT; From patchwork Mon Oct 24 13:27:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 618059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5768FA3743 for ; Mon, 24 Oct 2022 15:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbiJXP7c (ORCPT ); Mon, 24 Oct 2022 11:59:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232628AbiJXP7L (ORCPT ); Mon, 24 Oct 2022 11:59:11 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71D424F183; Mon, 24 Oct 2022 07:54:09 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id g12so6623957lfh.3; Mon, 24 Oct 2022 07:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gXxXAz2jrV6T3R31kVjyCFmWzvSu0pT4CfRxjg0qzH8=; b=hVYMlWxxcbXVKQ1NbFDbER/iZVyN+wrE5ASu44/YMmt0SXdT71B3I7241ki1C3y00m vSbudiT9/VQBR2MeUvn2TjHlmRDLEXvNesUpvkOSEIJJh2sYsNQ2IDd3JxCvdhZ+t+9C t0d0dASKMc18zAZUJB5unbnw9+JPsjYdJvpdCdJT1TFm1gOX9IELVPpvNMbvOtZC1zo/ WNr6dQVKQ6NvW9ANdPB+Mgre++HOpUmXD+Wyp5AGfD3RaF+IOHZBT185t5NknxzLNrbM ePXRC1zhdyafQy9hL0jjRrqubeR0MX3bg20E+fABEbUNkSF4YT2kMtcChpyfoGPo2BKF qryQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gXxXAz2jrV6T3R31kVjyCFmWzvSu0pT4CfRxjg0qzH8=; b=59+KnGF3k+pHL5bvKQkxS8qmLePKRnIVCzhigqzO4b8q0znB1N496++Bq5oKgo9CFH 5xOA3ODzo8W9pSYfCCLjO8UZsfiMgGhdBz1lrduTrS4ucSU3xEXRmKMBBfww3Q27G95u UDPPz1dcDjgSyKBh645sSPyeQj3UnHTCBw5C6rHITK+zNl/8dXExLegnK6J5iyg5MfGf 6oeStKjxUOV/wku6HYqlXd1v4GfbgHKVD8+oaUOplhfMHF1dkdxau8Ah3Y72bkHFhIr/ AR+samhNDV1eMipVSljWJp5voLPQ9by46PzdvVfMT+MRWOf/Z0Ut6XfzkzZR7R1ZIwza pM5w== X-Gm-Message-State: ACrzQf39T+cLjvV3Xxv23r1ueYDJuQ45uGg67x/fHDHE9bKROR1K5+bf ZeD8ZGujPWxMaVt0+jOskgBJUnmiNjU= X-Google-Smtp-Source: AMsMyM4GWDnqN0QcwnUNL1WbROTlUrH6jTihbQTySeENB0syuxV6MoBZgw18xN6x7LsBk8pyVGijQA== X-Received: by 2002:a17:907:8693:b0:791:a37d:e9ac with SMTP id qa19-20020a170907869300b00791a37de9acmr26284475ejc.7.1666618085577; Mon, 24 Oct 2022 06:28:05 -0700 (PDT) Received: from discovery.. (p5dcfeede.dip0.t-ipconnect.de. [93.207.238.222]) by smtp.gmail.com with ESMTPSA id l20-20020a056402231400b00457c5637578sm18243818eda.63.2022.10.24.06.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:28:05 -0700 (PDT) From: Saravanan Sekar To: sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Saravanan Sekar Subject: [PATCH v4 4/8] power: supply: Add support for mp2733 battery charger Date: Mon, 24 Oct 2022 15:27:53 +0200 Message-Id: <20221024132757.3345400-5-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221024132757.3345400-1-sravanhome@gmail.com> References: <20221024132757.3345400-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org mp2733 is updated version of mp2629 battery charge management which supports USB fast-charge and higher range of input voltage. Signed-off-by: Saravanan Sekar Reviewed-by: Andy Shevchenko Acked-by: Sebastian Reichel --- drivers/power/supply/mp2629_charger.c | 223 ++++++++++++++++++++++---- 1 file changed, 192 insertions(+), 31 deletions(-) diff --git a/drivers/power/supply/mp2629_charger.c b/drivers/power/supply/mp2629_charger.c index bf9c27b463a8..9e4111aace4b 100644 --- a/drivers/power/supply/mp2629_charger.c +++ b/drivers/power/supply/mp2629_charger.c @@ -30,12 +30,15 @@ #define MP2629_REG_INTERRUPT 0x0b #define MP2629_REG_STATUS 0x0c #define MP2629_REG_FAULT 0x0d +#define MP2629_REG_FAST_CHARGE 0x17 #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 MP2733_MASK_FAST_CHARGE GENMASK(2, 1) +#define MP2733_MASK_FAST_CHARGE_RESET BIT(0) #define MP2629_INPUTSOURCE_CHANGE GENMASK(7, 5) #define MP2629_CHARGING_CHANGE GENMASK(4, 3) @@ -62,6 +65,17 @@ enum mp2629_source_type { MP2629_SOURCE_TYPE_OTG = 7, }; +enum mp2733_source_type { + MP2733_SOURCE_TYPE_NO_INPUT, + MP2733_SOURCE_TYPE_NON_STD, + MP2733_SOURCE_TYPE_APPLE_1p0, + MP2733_SOURCE_TYPE_APPLE_2p1, + MP2733_SOURCE_TYPE_APPLE_2p4, + MP2733_SOURCE_TYPE_SDP, + MP2733_SOURCE_TYPE_CDP, + MP2733_SOURCE_TYPE_DCP, +}; + enum mp2629_field { INPUT_ILIM, INPUT_VLIM, @@ -72,11 +86,30 @@ enum mp2629_field { MP2629_MAX_FIELD }; +struct mp2629_prop { + int reg; + int mask; + int min; + int max; + int step; + int shift; +}; + +struct mp2xx_chip_info { + const struct reg_field *rfields; + struct mp2629_prop *chip_props; + bool has_impedance; + bool has_fast_charge; + + int (*mp2xx_get_usb_type)(unsigned int rval); +}; + struct mp2629_charger { struct device *dev; int status; int fault; + const struct mp2xx_chip_info *chip_info; struct regmap *regmap; struct regmap_field *regmap_fields[MP2629_MAX_FIELD]; struct mutex lock; @@ -85,15 +118,6 @@ struct mp2629_charger { 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, @@ -126,7 +150,25 @@ static enum power_supply_property mp2629_charger_bat_props[] = { POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, }; -static struct mp2629_prop props[] = { +static struct mp2629_prop mp2733_chip_props[] = { + MP2629_PROPS(INPUT_ILIM, 100000, 3250000, 50000), + MP2629_PROPS(INPUT_VLIM, 3800000, 15200000, 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 mp2733_reg_fields[] = { + [INPUT_ILIM] = REG_FIELD(MP2629_REG_INPUT_ILIM, 0, 5), + [INPUT_VLIM] = REG_FIELD(MP2629_REG_INPUT_VLIM, 0, 6), + [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 struct mp2629_prop mp2629_chip_props[] = { MP2629_PROPS(INPUT_ILIM, 100000, 3250000, 50000), MP2629_PROPS(INPUT_VLIM, 3800000, 5300000, 100000), MP2629_PROPS(CHARGE_ILIM, 320000, 4520000, 40000), @@ -174,6 +216,7 @@ static int mp2629_get_prop(struct mp2629_charger *charger, { int ret; unsigned int rval; + struct mp2629_prop *props = charger->chip_info->chip_props; ret = regmap_field_read(charger->regmap_fields[fld], &rval); if (ret) @@ -189,6 +232,7 @@ static int mp2629_set_prop(struct mp2629_charger *charger, const union power_supply_propval *val) { unsigned int rval; + struct mp2629_prop *props = charger->chip_info->chip_props; if (val->intval < props[fld].min || val->intval > props[fld].max) return -EINVAL; @@ -311,6 +355,16 @@ static int mp2629_charger_battery_get_prop(struct power_supply *psy, default: val->intval = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN; } + + if (charger->chip_info->has_fast_charge) { + ret = regmap_read(charger->regmap, + MP2629_REG_FAST_CHARGE, &rval); + if (ret) + break; + + if (rval & BIT(6)) + val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; + } break; default: @@ -344,6 +398,40 @@ static int mp2629_charger_battery_set_prop(struct power_supply *psy, } } +static int mp2733_get_usb_type(unsigned int rval) +{ + switch (rval) { + case MP2733_SOURCE_TYPE_APPLE_1p0: + case MP2733_SOURCE_TYPE_APPLE_2p1: + case MP2733_SOURCE_TYPE_APPLE_2p4: + return POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID; + case MP2733_SOURCE_TYPE_SDP: + return POWER_SUPPLY_USB_TYPE_SDP; + case MP2733_SOURCE_TYPE_CDP: + return POWER_SUPPLY_USB_TYPE_CDP; + case MP2733_SOURCE_TYPE_DCP: + return POWER_SUPPLY_USB_TYPE_DCP; + default: + return POWER_SUPPLY_USB_TYPE_UNKNOWN; + } +} + +static int mp2629_get_usb_type(unsigned int rval) +{ + switch (rval) { + case MP2629_SOURCE_TYPE_SDP: + return POWER_SUPPLY_USB_TYPE_SDP; + case MP2629_SOURCE_TYPE_CDP: + return POWER_SUPPLY_USB_TYPE_CDP; + case MP2629_SOURCE_TYPE_DCP: + return POWER_SUPPLY_USB_TYPE_DCP; + case MP2629_SOURCE_TYPE_OTG: + return POWER_SUPPLY_USB_TYPE_PD_DRP; + default: + return POWER_SUPPLY_USB_TYPE_UNKNOWN; + } +} + static int mp2629_charger_usb_get_prop(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -367,23 +455,7 @@ static int mp2629_charger_usb_get_prop(struct power_supply *psy, 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; - } + val->intval = charger->chip_info->mp2xx_get_usb_type(rval); break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: @@ -550,11 +622,72 @@ static ssize_t batt_impedance_compensation_store(struct device *dev, static DEVICE_ATTR_RW(batt_impedance_compensation); -static struct attribute *mp2629_charger_sysfs_attrs[] = { +static struct attribute *mp2xx_batt_imp_sysfs_attrs[] = { + &dev_attr_batt_impedance_compensation.attr, + NULL +}; +ATTRIBUTE_GROUPS(mp2xx_batt_imp_sysfs); + +static ssize_t usb_fast_charge_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_INTERRUPT, &rval); + if (ret) + return ret; + + return sysfs_emit(buf, "USB DP %u:DM %u\n", !!(rval & BIT(2)), + !!(rval & BIT(1))); +} + +static ssize_t usb_fast_charge_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 > 3) + return -ERANGE; + + ret = regmap_update_bits(charger->regmap, MP2629_REG_INTERRUPT, + MP2733_MASK_FAST_CHARGE, val << 1); + if (ret) + return ret; + + ret = regmap_update_bits(charger->regmap, MP2629_REG_INTERRUPT, + MP2733_MASK_FAST_CHARGE_RESET, + MP2733_MASK_FAST_CHARGE_RESET); + if (ret) + return ret; + + return count; +} + +static DEVICE_ATTR_RW(usb_fast_charge); + +static struct attribute *mp2xx_fast_charge_sysfs_attrs[] = { + &dev_attr_usb_fast_charge.attr, + NULL +}; +ATTRIBUTE_GROUPS(mp2xx_fast_charge_sysfs); + +static struct attribute *mp2xx_all_sysfs_attrs[] = { + &dev_attr_usb_fast_charge.attr, &dev_attr_batt_impedance_compensation.attr, NULL }; -ATTRIBUTE_GROUPS(mp2629_charger_sysfs); +ATTRIBUTE_GROUPS(mp2xx_all_sysfs); static void mp2629_charger_disable(void *data) { @@ -564,6 +697,23 @@ static void mp2629_charger_disable(void *data) MP2629_MASK_CHARGE_CTRL, 0); } +static const struct mp2xx_chip_info mp2xx_chip_info_tbl[] = { + [CHIP_ID_MP2629] = { + .rfields = mp2629_reg_fields, + .chip_props = mp2629_chip_props, + .has_impedance = 1, + + .mp2xx_get_usb_type = mp2629_get_usb_type, + }, + [CHIP_ID_MP2733] = { + .rfields = mp2733_reg_fields, + .chip_props = mp2733_chip_props, + .has_fast_charge = 1, + + .mp2xx_get_usb_type = mp2733_get_usb_type, + }, +}; + static int mp2629_charger_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -578,6 +728,7 @@ static int mp2629_charger_probe(struct platform_device *pdev) charger->regmap = ddata->regmap; charger->dev = dev; + charger->chip_info = &mp2xx_chip_info_tbl[ddata->chip_id]; platform_set_drvdata(pdev, charger); irq = platform_get_irq(to_platform_device(dev->parent), 0); @@ -586,7 +737,8 @@ static int mp2629_charger_probe(struct platform_device *pdev) for (i = 0; i < MP2629_MAX_FIELD; i++) { charger->regmap_fields[i] = devm_regmap_field_alloc(dev, - charger->regmap, mp2629_reg_fields[i]); + charger->regmap, + charger->chip_info->rfields[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]); @@ -613,7 +765,16 @@ static int mp2629_charger_probe(struct platform_device *pdev) } psy_cfg.drv_data = charger; - psy_cfg.attr_grp = mp2629_charger_sysfs_groups; + + if (charger->chip_info->has_impedance && + charger->chip_info->has_fast_charge) { + psy_cfg.attr_grp = mp2xx_all_sysfs_groups; + } else if (charger->chip_info->has_impedance) { + psy_cfg.attr_grp = mp2xx_batt_imp_sysfs_groups; + } else if (charger->chip_info->has_fast_charge) { + psy_cfg.attr_grp = mp2xx_fast_charge_sysfs_groups; + } + charger->battery = devm_power_supply_register(dev, &mp2629_battery_desc, &psy_cfg); if (IS_ERR(charger->battery)) { From patchwork Mon Oct 24 13:27:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 618061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18BE0ECAAA1 for ; Mon, 24 Oct 2022 15:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbiJXPW4 (ORCPT ); Mon, 24 Oct 2022 11:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230187AbiJXPWj (ORCPT ); Mon, 24 Oct 2022 11:22:39 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4620F18F923; Mon, 24 Oct 2022 07:06:40 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id y12so11373255edc.9; Mon, 24 Oct 2022 07:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9UBEsDOtGvuqocb1tQphZqfQPO49fazm6XTep7E5qLU=; b=nDAwkhGpUseVldEa+nd6n9zF/tkqyQhZlEI9B4uy5NneWVkbJl1WuxqnMr3UT7mk82 BspUUfEUTcKa8mBe65Q3kL7B/2T8UENqq5LM0iTq/HEtj7cWLPts9qPIj+FAMeWjI8VA oUTSPRXOVimyRDgRTbQ8Kgsopaqrd6/Ma280044VHyYnJbY4hnpecHJdDrWNM1tAgu0y KsJxs9vq+5A3Euo3RHHUaTFQvh6vVYFP2cIUYEtAD0y0fB/drr3NUS44qgNJSqWWcrUl kYyVfkqEjeMRF01E0N8dfPwquasC/ka9GoShuPZ7XevSvAWv7TaEAISDlTFsLf2unKgO 9axQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9UBEsDOtGvuqocb1tQphZqfQPO49fazm6XTep7E5qLU=; b=KZY8hcA1qYxCRdyVLxi+ShPL3NUVwNBUyBLRggVNB5KeWv3wHMCcybeKXR/skt97we UWNS/hw63Ri2CYokkPA9bkTl2D6WD2ayn9z2yPx5oGa4e63ObbyOFtixYyMR/IJgs38q i7bseoEQ03BlbQPet9PJ2Pw8stp9Ddm2ELzbfVidyBkAO9evRnkGTJs93Zo3MbdgxLoh +qiaIi+J7nUNXSXLOKm1tn6ChvDE4Og/F1/oVVAZ5Jd4HewpqrsJ+jMf5e4X6KhLPHRa P2LYnpVepNbWlmhIgxqLu8beWQWUQM0ygPRVk8DLBxr3K5fAtOOBLC0mQaElazM3uefS JRhA== X-Gm-Message-State: ACrzQf3qtKnzJz+DP6c4dzx/aFC4Zw0aDonWhSp1gFBlvBTSNhPvcVpj UfhBd88KA4I+QT99m4H9uTV9Or5NMpM= X-Google-Smtp-Source: AMsMyM741Q0+KuGzBJqCT6ePEjtdpRdPVylZpUQ2x6R6r5bekAgiB5+Ns9qejo/ngiDM7t/TJvK10Q== X-Received: by 2002:a05:6402:3705:b0:454:e006:82 with SMTP id ek5-20020a056402370500b00454e0060082mr30580615edb.360.1666618086450; Mon, 24 Oct 2022 06:28:06 -0700 (PDT) Received: from discovery.. (p5dcfeede.dip0.t-ipconnect.de. [93.207.238.222]) by smtp.gmail.com with ESMTPSA id l20-20020a056402231400b00457c5637578sm18243818eda.63.2022.10.24.06.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:28:06 -0700 (PDT) From: Saravanan Sekar To: sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Saravanan Sekar Subject: [PATCH v4 5/8] power: supply: mp2629: Add USB fast charge settings Date: Mon, 24 Oct 2022 15:27:54 +0200 Message-Id: <20221024132757.3345400-6-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221024132757.3345400-1-sravanhome@gmail.com> References: <20221024132757.3345400-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Allows the user to change the USB device fast charge setting to advertise host on enumeration helps to accelerate the charging cycle. Altering this value resets USB existing connection. Signed-off-by: Saravanan Sekar Reviewed-by: Andy Shevchenko Acked-by: Sebastian Reichel --- .../ABI/testing/sysfs-class-power-mp2629 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-power-mp2629 b/Documentation/ABI/testing/sysfs-class-power-mp2629 index 914d67caac0d..b386d02cb010 100644 --- a/Documentation/ABI/testing/sysfs-class-power-mp2629 +++ b/Documentation/ABI/testing/sysfs-class-power-mp2629 @@ -1,3 +1,19 @@ +What: /sys/class/power_supply/mp2629_battery/usb_fast_charge +Date: June 2022 +KernelVersion: 5.20 +Description: + Represents a USB device fast charge settings.Altering this + value resets USB existing connection + USB DP:DM[0:0] 0.6V : Hi-Z + USB DP:DM[0:1] 3.3V : 0.6V + USB DP:DM[1:0] 0.6V : 0.6V + USB DP:DM[1:1] 0.6V : 3.3V + + Access: Read, Write + + Valid values: Represented in bit DP & DM setting. Valid + range is [0, 3]. + What: /sys/class/power_supply/mp2629_battery/batt_impedance_compen Date: April 2020 KernelVersion: 5.7 From patchwork Mon Oct 24 13:27:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 618638 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7988C38A2D for ; Mon, 24 Oct 2022 15:49:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbiJXPtj (ORCPT ); Mon, 24 Oct 2022 11:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbiJXPtV (ORCPT ); Mon, 24 Oct 2022 11:49:21 -0400 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E6FD2A968; Mon, 24 Oct 2022 07:42:55 -0700 (PDT) Received: by mail-ed1-f45.google.com with SMTP id a13so32180194edj.0; Mon, 24 Oct 2022 07:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VYDe+pPSD0vc7fcU9WurDQ2z2Lc918aKtSIZ7Rn8KXw=; b=iPiLBv6575MeL9d+q2zZB1Oe/sGJ3rPuJQad8fELE0DVeDXDgIzRyDMC+CoStYEpy8 z/mDAR2Vec+1BPqOaKUGtIo2GMVhyltj5zjo6E/Wo63C5qIHPhAPTEtv6nbmX74dv6II SkcTuoZkhvNOL33U2CxQEE77hIqv1e/kilbGi1Kd6ewYtipek8gH8v4+WgVwniEYXDlh ZTXgywMN8Nq58NbrFlNdZFKVRSSRGBZ//MQ4B42j34z9Km3PrHq9uRr2b7L4dwu0T/pr o/pk0YWkH9MgqJJWqMlQ8z/2/D3FQkyDDXZCHt11i+3dB09hhmP9DrRyxCdyrHTOR+5C PpPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VYDe+pPSD0vc7fcU9WurDQ2z2Lc918aKtSIZ7Rn8KXw=; b=OyHuSlbW0TuNGIBUlLuvMgwZaAA/iofhlJX+jX+NSbJro0h+UzSzGmYRSyKIQ5mj7o Jbikht8l4KzjSEFp1f3JF++/Ok73YcctNNyBdnfvyLfcmDVvi3I31A8/PWY5dw8XwzJb QaSUSHb0ntoby5h6VUFRW/3IwNPxl1MkxuEPZFUk5u3A1PqrUvj1xtUGIzmL2N2O4Yuy CocJfGdK/MtTJSfJghEEvDNpqu8ZwUGo67ag7L2q/tTLtPMMW66oRfiXZus4E3Lp5CZd INaNr7TVgA1v7tTalIG8wkha0NEXfH/yrPKdFZ125JbVJzJN580+bJSOYPiDTQ7w3pNT +gCw== X-Gm-Message-State: ACrzQf14j4B/lxxcPY4+TrD8I2FsijgPIntI4NeRwaYGWsNAT6NJuso7 CkfdwZ4t0Bmtl2vzfj5m4bkh3PJrRQ8= X-Google-Smtp-Source: AMsMyM7rW8i8eCkcbfpOCp3IRqDyjVQj3PEdLDUFEk4WffYh+K+tRiFC1TX13LHlUYZPJ9uASUMg5w== X-Received: by 2002:a17:906:65c6:b0:73c:8897:65b0 with SMTP id z6-20020a17090665c600b0073c889765b0mr27950016ejn.322.1666618087180; Mon, 24 Oct 2022 06:28:07 -0700 (PDT) Received: from discovery.. (p5dcfeede.dip0.t-ipconnect.de. [93.207.238.222]) by smtp.gmail.com with ESMTPSA id l20-20020a056402231400b00457c5637578sm18243818eda.63.2022.10.24.06.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:28:06 -0700 (PDT) From: Saravanan Sekar To: sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Saravanan Sekar Subject: [PATCH v4 6/8] power: supply: fix failed to get iio channel by device name Date: Mon, 24 Oct 2022 15:27:55 +0200 Message-Id: <20221024132757.3345400-7-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221024132757.3345400-1-sravanhome@gmail.com> References: <20221024132757.3345400-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The mfd cell devices name populated on sysfs entry is dynamically derived from an auto instance which introduced a regression. As a result mpc2629_charger driver failed to get adc channel because of iio consumer name mismatch with the sysfs. /sys/class/i2c-adapter/i2c-1/mp2629_adc.0.auto/ /sys/class/i2c-adapter/i2c-1/mp2629_charger.1.auto/ Fixes: 466a62d7642f(mfd: core: Make a best effort attempt to match devices) Signed-off-by: Saravanan Sekar --- drivers/mfd/mp2629.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/mp2629.c b/drivers/mfd/mp2629.c index f59c97e70f83..57db0f5009b9 100644 --- a/drivers/mfd/mp2629.c +++ b/drivers/mfd/mp2629.c @@ -53,7 +53,7 @@ static int mp2629_probe(struct i2c_client *client) return PTR_ERR(ddata->regmap); } - ret = devm_mfd_add_devices(ddata->dev, PLATFORM_DEVID_AUTO, mp2629_cell, + ret = devm_mfd_add_devices(ddata->dev, PLATFORM_DEVID_NONE, mp2629_cell, ARRAY_SIZE(mp2629_cell), NULL, 0, NULL); if (ret) dev_err(ddata->dev, "Failed to register sub-devices %d\n", ret); From patchwork Mon Oct 24 13:27:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 618057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19D10C67871 for ; Mon, 24 Oct 2022 21:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233264AbiJXVDf (ORCPT ); Mon, 24 Oct 2022 17:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232812AbiJXVDT (ORCPT ); Mon, 24 Oct 2022 17:03:19 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 846B72C5684; Mon, 24 Oct 2022 12:08:59 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id b2so18267074lfp.6; Mon, 24 Oct 2022 12:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PwL8/qx1/0F0Hrq3IMB5cdMrfq8hnyHJ0+oU5aJtiFo=; b=hJu80Hr9tWx4yHsXduGAuqtUGB6IrvpVnsc1taAXKITwr6UOest6JMpQe+OrjHD3ad aFOG3QKptelq11AzR0C5ldh2kjMtVx6U7CiknAIDKoPWfyETrjo+Nj+nXkqCj0XnQ+9h vq7wuHNQowYgbH4lSqPsACZvbP2xweM+UB9NAZL7o9LTXCtANE7RPF+ipOshTuHpG6EZ eIky0yzzS1yCvDzwsR3k8KBqcsFPG8/SPdsiBB2a9OO+K4jb4dorwxmVgajFEg5dSzWL cDYCTDP6v4pg8BvhemFU5crB5+dn/n+KAge4M8kn50ywJBmFnhMtEHx4U61d1GZ07MRo dTZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PwL8/qx1/0F0Hrq3IMB5cdMrfq8hnyHJ0+oU5aJtiFo=; b=Rd13/FD7+O0dYHPqSn9Z3TZ4B6m+0vq/bzD0oNlZq/GlPwGTrwuhjdrU15lXm74BP+ XisNNlXIAN6BBw0u2BCNtG0tSgW1ZET9e/foF1gEo/YTeGCY2160r+iuMyTadLGl+llT 320KxvsH0azztunRWssuNNyKoUjfQoNr6TckiVbrZ7llHsycVngsgyV9emHJyiovJs6+ s+m06Xm6yqSuY0lMs8zCoQRVUC9If4Yrdi2mv/2Hx1jI+yPuIK995DH/nEHVZ/lu5f+Y cbfjnoudC0md4/wHvMoYDahrYjaAv5C6FoPYmoUSa3gH2shIpdlYxwnhS9hWK7g2VpRb xUpQ== X-Gm-Message-State: ACrzQf3AcqaLE6wwyPvM5z6mub/fp7jFGrdzga7SQezSoj+uliXWTtEJ 9QT0pMGFJmxfF4NkWrfSIzIsU9HD8Uk= X-Google-Smtp-Source: AMsMyM4QQorvU7/sJtwzla1liZs/dJanTTjXhWgjZ6BdF4BKG+u2hgWU1L3QBk8NZOE7g3hFix2TsA== X-Received: by 2002:a17:907:5c2:b0:77e:def7:65d8 with SMTP id wg2-20020a17090705c200b0077edef765d8mr28009125ejb.487.1666618087998; Mon, 24 Oct 2022 06:28:07 -0700 (PDT) Received: from discovery.. (p5dcfeede.dip0.t-ipconnect.de. [93.207.238.222]) by smtp.gmail.com with ESMTPSA id l20-20020a056402231400b00457c5637578sm18243818eda.63.2022.10.24.06.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:28:07 -0700 (PDT) From: Saravanan Sekar To: sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Saravanan Sekar Subject: [PATCH v4 7/8] iio: adc: mp2629: fix potential array out of bound access Date: Mon, 24 Oct 2022 15:27:56 +0200 Message-Id: <20221024132757.3345400-8-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221024132757.3345400-1-sravanhome@gmail.com> References: <20221024132757.3345400-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add sentinel at end of maps to avoid potential array out of bound access in iio core. Fixes: 7abd9fb6468 ("iio: adc: mp2629: Add support for mp2629 ADC driver") Signed-off-by: Saravanan Sekar --- drivers/iio/adc/mp2629_adc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c index 0f297072b8aa..18290e176e1e 100644 --- a/drivers/iio/adc/mp2629_adc.c +++ b/drivers/iio/adc/mp2629_adc.c @@ -57,7 +57,8 @@ static struct iio_map mp2629_adc_maps[] = { MP2629_MAP(SYSTEM_VOLT, "system-volt"), MP2629_MAP(INPUT_VOLT, "input-volt"), MP2629_MAP(BATT_CURRENT, "batt-current"), - MP2629_MAP(INPUT_CURRENT, "input-current") + MP2629_MAP(INPUT_CURRENT, "input-current"), + { } }; static int mp2629_read_raw(struct iio_dev *indio_dev, From patchwork Mon Oct 24 13:27:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 618058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF4FFFA3740 for ; Mon, 24 Oct 2022 19:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233033AbiJXTJx (ORCPT ); Mon, 24 Oct 2022 15:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231901AbiJXTJW (ORCPT ); Mon, 24 Oct 2022 15:09:22 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27B9B580B0; Mon, 24 Oct 2022 10:48:37 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id r14so32876739edc.7; Mon, 24 Oct 2022 10:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lLLFhdOjQdZVRi4+dO3LV4A0SKwug3EMMGQt1+QKLJM=; b=ARxc6MtH2mx0X8Zz04iqbFY7gSCEE8pZ1qcWgY+bfnOASKVlGMS45z2/V8Sax4EHId K3k6exT3goUntttLvMxaBlZ8eJDnahocz0V+Shq16ED7zrIL3/taap1SKM23rgkoSSUc qA3w0Ko77XIG3QAnrU/tagZrSydiNnESWOSMmNcgGjPqWKWQ4x3NZ/QU8kQsvG7rCs8z PGC8Rhs7uVaHm4F60B1HPzxc3Ijvy+2+gBztS42FcjL9P6AArJryR3RAL0N5uPqIi23p Pw/I9mbF2nPXh+ry9PTsQzK3FqFBLb2h6oNc45Ip/yK3116ofyqtzRe/ct4XYXjDklLI ia7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lLLFhdOjQdZVRi4+dO3LV4A0SKwug3EMMGQt1+QKLJM=; b=FmMmrdQX9uulR/yhhfeHI8nh+kNistG/Zjx4XTN6Jcqkaa+rTVEDZBKgTzRVH2AzHq 2BALA3Lux8kyRN4Li57A5ERkgsLBplMXJnDoHAJHfgZSzFUQ3sSO0lrSaI7yGT7+7vYM FZGRf0bxCgr8EIKqsaUO7t1ppZ9TB5cFikJOexp/rUT5B82LvLsHE0TkUap7Jk8GmXhY 6BE8Uxwa944O+bNJyLpTZzplCAaVH5gnKHHjg2LsFIZVBun7x5sfVBRlrgA8VMFtOr3E O1Vq9nvuzljowZt6mlzfIG2IKR3u8kWsUgmhozgjItk4zlY4+uM7DFVt4NaXQZEJTZIb 2+2Q== X-Gm-Message-State: ACrzQf037Tss8HRHfkGNy/Znj9Vz+GMUvFLpHGaYr2XUOxLgQ4HvXojh D/AZBLqnTxXaeuWWVzAxQTOIetgy4s0= X-Google-Smtp-Source: AMsMyM5OZgGw0Zl5UJYWJ3Xrn6tNdg5QKfk1JM9oi8g1+WlLZjjnT0KJx1sRGwhdHIavjPlodQ/gQQ== X-Received: by 2002:a17:907:9717:b0:78d:9fb4:16dd with SMTP id jg23-20020a170907971700b0078d9fb416ddmr28304599ejc.720.1666618088834; Mon, 24 Oct 2022 06:28:08 -0700 (PDT) Received: from discovery.. (p5dcfeede.dip0.t-ipconnect.de. [93.207.238.222]) by smtp.gmail.com with ESMTPSA id l20-20020a056402231400b00457c5637578sm18243818eda.63.2022.10.24.06.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 06:28:08 -0700 (PDT) From: Saravanan Sekar To: sre@kernel.org, lee.jones@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Saravanan Sekar Subject: [PATCH v4 8/8] power: supply: fix wrong interpretation of register value Date: Mon, 24 Oct 2022 15:27:57 +0200 Message-Id: <20221024132757.3345400-9-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221024132757.3345400-1-sravanhome@gmail.com> References: <20221024132757.3345400-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org fix wrong interpretation of bitwise as hex Signed-off-by: Saravanan Sekar --- drivers/power/supply/mp2629_charger.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/mp2629_charger.c b/drivers/power/supply/mp2629_charger.c index 9e4111aace4b..2ff3729afc48 100644 --- a/drivers/power/supply/mp2629_charger.c +++ b/drivers/power/supply/mp2629_charger.c @@ -328,10 +328,10 @@ static int mp2629_charger_battery_get_prop(struct power_supply *psy, val->intval = POWER_SUPPLY_STATUS_DISCHARGING; break; case 0x01: - case 0x10: + case 0x02: val->intval = POWER_SUPPLY_STATUS_CHARGING; break; - case 0x11: + case 0x03: val->intval = POWER_SUPPLY_STATUS_FULL; } break; @@ -349,7 +349,7 @@ static int mp2629_charger_battery_get_prop(struct power_supply *psy, case 0x01: val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; break; - case 0x10: + case 0x02: val->intval = POWER_SUPPLY_CHARGE_TYPE_STANDARD; break; default: