From patchwork Sat Oct 29 09:29: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: 619898 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 76D81C433FE for ; Sat, 29 Oct 2022 09:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229515AbiJ2JaJ (ORCPT ); Sat, 29 Oct 2022 05:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbiJ2JaI (ORCPT ); Sat, 29 Oct 2022 05:30:08 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 329D957BE2; Sat, 29 Oct 2022 02:30:06 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id y16so9389003wrt.12; Sat, 29 Oct 2022 02:30:06 -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=quUqf6BNp5UZzyhdM5eQZ4d0L+clKrLdmEM2GHHs+ljP/NUkaE9aqMDWfyYj8AMMBX u13V0EmOiGjmeWy0+rDgbYXLdNq98g4BwtPgn7Eg2EuRUCuu1KAxCuqFuO+//vyKZXcR 0MPFAn12KAoSgw1bmBAzVGLWeBnlwFe65RNuimv1PfBQYwxcF7vGAAtN/fnPqO2WYyDg F8IPZRvDsg25EnzLKxlLapcBQhjUtDBPci3w0GKVUsXQTXM4UmNXDTDwU2REFDLwWQmQ cNuk6IQVyZMpPg/tKYHLhHtQv0F+D2Xye54b8jhapzXIXcReZofOAIjaTI6shEji4hm/ 1ORA== 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=dhlNCX4GKYPS9O4+H9awhP4yRzIGSV7vw4saMh/jzI7NCrAg1cjVWcMQmyQke+uiRK P63v4+o+U7bEjvKL6AmiP1VxA3ywREcVPX+zKQm8lB0L9X+Rr4gQaoQ3tFiRNrlnc3R5 xNBBPKESy18SeTZElYIYDf/6YhP+t7K6GPoM1OaL7glwrK/aLpeHN3o2OJN0T+A8Obli xLuJh4IMSHGOF8BS+6dK731BsqI5aKljk/339szeUaiMqrMPUionMlfAwNI/xwEAMciF ZxQwlZ0efWhw4gtIL0nZKZj+FlCfUB12t9J+ycYAkbQyI5SlP2UuEzP/nY41X6ZpqGav 7PBw== X-Gm-Message-State: ACrzQf19KK4as4Djj2JJJrMaik//ewZZzlLOAYX/7Hg2QtjcbvfZmj4M A/qUtwE9FG/s14P8tV2FKGa6nQH32wqfmw== X-Google-Smtp-Source: AMsMyM5e6xOzMTR5x/GZs6j7ZXh31p17gFPI/5vbXO9YBLPcQuN3jfxvhA2NJA90nCfVseQTkkhM2w== X-Received: by 2002:a05:6000:1a85:b0:230:f67b:da03 with SMTP id f5-20020a0560001a8500b00230f67bda03mr2011312wry.296.1667035804661; Sat, 29 Oct 2022 02:30:04 -0700 (PDT) Received: from discovery.. (p5b3f76b5.dip0.t-ipconnect.de. [91.63.118.181]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0022e6178bd84sm1068187wrr.8.2022.10.29.02.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 02:30: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 v5 1/8] iio: adc: mp2629: fix wrong comparison of channel Date: Sat, 29 Oct 2022 11:29:53 +0200 Message-Id: <20221029093000.45451-2-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221029093000.45451-1-sravanhome@gmail.com> References: <20221029093000.45451-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 Sat Oct 29 09:29: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: 619897 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 B7BB2FA3745 for ; Sat, 29 Oct 2022 09:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbiJ2JaK (ORCPT ); Sat, 29 Oct 2022 05:30:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbiJ2JaI (ORCPT ); Sat, 29 Oct 2022 05:30:08 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F9435808A; Sat, 29 Oct 2022 02:30:07 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id l32so4465436wms.2; Sat, 29 Oct 2022 02:30: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=rW+UYRb2CSBuEpmSaGw7sQ/AAKDnWs/63BdEHUXF19Y=; b=Zp9rJbyx0urCnZGLvKGDNjhEfFoFfPH7kdDjdkEMANwoRordRSk/DUXX+PZtPSSGt+ o8xSAs/tqw7srio5+PqeiveCTsFp/B9O8zQA4obfcwLghIgXUxeDa8XeruhLe/p5G/4t drRX22IkUn273HrJDQ1fcOzAcoM36UrMA1Ovi8yj2db4J7KojhH7vwDBenhRF8MY8hRx fh9K3D8NlZuS1YeORjEu2k1Z6of0xvXByUAkJXSS0eXth1XztHUUkWAvYhMx0SmiANK+ lqpPOYKFQiNA4Lu5X3PMOPSXLbVnU9uT+WVN+sclvEb3QbUVwioQYImq/hN+yuL5Qq2c vRUQ== 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=rW+UYRb2CSBuEpmSaGw7sQ/AAKDnWs/63BdEHUXF19Y=; b=SoWWJTbzvqSy1Nnr1tn+5s3f1nLfy5BtwXoxmwOeQg7JeCnmTgOx+wDZj8N00dXtYg EIEZ9os5cVUKFmgMhfK0xW26B/VHWRe/mqyT+Aq6vsMqjgIBbMcFrkwYO8XShCzmsdaZ OMKi4oOVUZNumWamAhlAp/opwxy6ty6vAtToOvNoW4dCdJYImb24M1aFoPo9D00jVPQE s900IXDU+Pk2iIuU6dhqNvb4gcxP7POd+Xc4po+PLqqt+IqT175sC7lYEZ+EqjBOj2tO n+//ZR/9XGpDWj4U4mqLG63OaxmYg8y0OPFcz3lmVKrGqKdWiXj1jlZswI7JRBnTG9oI IYyQ== X-Gm-Message-State: ACrzQf0NG9NWol8xBizrYnli/s/Uigauo/22daCVFEwPfGN1pvGb/pi9 JfyHlEkybG0IDgTFj6/WYcs= X-Google-Smtp-Source: AMsMyM6COioCS4F6sVSJDC7QvwzHDVe6990k2yEiGXXYJ/DTBlJX+aQdhY2WgfKauRsbemOR5xbRBg== X-Received: by 2002:a05:600c:5127:b0:3c6:47ff:5d33 with SMTP id o39-20020a05600c512700b003c647ff5d33mr2065991wms.68.1667035805788; Sat, 29 Oct 2022 02:30:05 -0700 (PDT) Received: from discovery.. (p5b3f76b5.dip0.t-ipconnect.de. [91.63.118.181]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0022e6178bd84sm1068187wrr.8.2022.10.29.02.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 02:30: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 v5 2/8] mfd: mp2629: fix failed to get iio channel by device name Date: Sat, 29 Oct 2022 11:29:54 +0200 Message-Id: <20221029093000.45451-3-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221029093000.45451-1-sravanhome@gmail.com> References: <20221029093000.45451-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 16840ec5fd1c..f4c5aa06f38c 100644 --- a/drivers/mfd/mp2629.c +++ b/drivers/mfd/mp2629.c @@ -51,7 +51,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 Sat Oct 29 09:29: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: 619896 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 3EA21FA374B for ; Sat, 29 Oct 2022 09:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbiJ2JaN (ORCPT ); Sat, 29 Oct 2022 05:30:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229761AbiJ2JaK (ORCPT ); Sat, 29 Oct 2022 05:30:10 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D2E158169; Sat, 29 Oct 2022 02:30:08 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id bp11so9412882wrb.9; Sat, 29 Oct 2022 02:30: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=QpsqUmkgwpxZ/VajIIb/0zX7NJyKUT5sNbfK2Me1e70=; b=gBhyZYf4MEHBZbUCcbcAX5qPx+1ALqys/p/WikBYGuqVwCiNBh6Ha62Ayyp1kxFCGR V/IxcDIeHGJ8yp63Pg+4yqKNbDXx+kE0dgBCt/YreCij3Txpev9iCsFRfODtNjkZOuCZ /0oTrZK8GSVo/AT2FXKaghyXQDQB9bVgYlp0+bj4tYvdiY6Ygeh8U9DD7St4xDsAnWBe 22eI8v5lPk5zqF8ahcbM9YrXPUy6WSAddalWf1ZYMM7D8fXmTBfoMYD7rycQgElG8Xag HCYka6q5MOdA5sp30IJ29sx0iXCrTUJpM3tpNCJlxd8F05SX+RQu/DrKqZRTRI72kQiO jrLw== 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=QpsqUmkgwpxZ/VajIIb/0zX7NJyKUT5sNbfK2Me1e70=; b=3JYm3pX/yGe1Z627A8vYs7uInGaNUXCTHlPeCqlKvA/J4s6fqA9VCdMkhpM+uD75HP gbqYgW1ebLInSYdnWJfPmAonC/eDhe/xeugZGPPN2HNPiWtCZyAbtTfnxu8ESVMl3NX9 LRvxVI25Fhn5gxoDOgSVuE/JILb6tP3WRf5xRo/MVsrDSBt5LzbpZBtj2zz7LrCU4PCK EfmpZwkgUIGJ6fERhTxSkZvhDN0qduK2VyEbHqc5JJX7Zb40SN25Rc/Y58xnQKaehMz8 Q7xN88bh2YVIdktItx+s7qAxpDfmlfzl+8vEEPwZMM6d5tJg6ys4FBsZNpaooPesX+Y6 IsKA== X-Gm-Message-State: ACrzQf2zhkoMgzEvs44Vqo0bsdthshDYk2i8cLqcZ5AsRyMugYd0ylGo 0Afn77bcx1Mpc+9WgnMN+So= X-Google-Smtp-Source: AMsMyM5U4VXpUFXYQ7mnJB0yZC0RjNlWxY0OoI4rSzqmTtGHDrVYf17r5Jr8rrZq6DM4X0fCkjEsYg== X-Received: by 2002:a5d:6d89:0:b0:236:7d7d:1e79 with SMTP id l9-20020a5d6d89000000b002367d7d1e79mr1972329wrs.673.1667035806663; Sat, 29 Oct 2022 02:30:06 -0700 (PDT) Received: from discovery.. (p5b3f76b5.dip0.t-ipconnect.de. [91.63.118.181]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0022e6178bd84sm1068187wrr.8.2022.10.29.02.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 02:30: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 v5 3/8] iio: adc: mp2629: fix potential array out of bound access Date: Sat, 29 Oct 2022 11:29:55 +0200 Message-Id: <20221029093000.45451-4-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221029093000.45451-1-sravanhome@gmail.com> References: <20221029093000.45451-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 f7af9af1665d..88e947f300cf 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 Sat Oct 29 09:29: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: 620696 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 9F0A4FA3748 for ; Sat, 29 Oct 2022 09:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbiJ2JaM (ORCPT ); Sat, 29 Oct 2022 05:30:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbiJ2JaK (ORCPT ); Sat, 29 Oct 2022 05:30:10 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C57CC58E93; Sat, 29 Oct 2022 02:30:08 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id j15so9439266wrq.3; Sat, 29 Oct 2022 02:30: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=BRio8WmNPVIhI4AkJ7r8lq4Jznf7XL46j1qcLi92j54=; b=ioJ+TlykrU215ZM0MuzVa/D1SbosAfdtgAHWjyBwARVCv5zLlSI/GH9MfeHXnIVsna 3vD0nAVKPtJRU8Z7OI712Xi6fj0jo3/7+lc77eUN8D0n+SjhrC8bwOzvsa8E0LXIK/iK dnz462Qq0cMh/PLY8s5MEKOIrRKs21fhFgQAalrRCOVXcG66YUe1y5RgRiriMyAYKDjO k85p0TKVTm4+UXw1pjSLibeHfiii/8EJJnq4JkMCrXqRYNA0alqZa2xeoLbEK0W1FNi5 PvA8flqgFOq+Ol6xTdaKakHIWoOFsS/jYfSIzSxi7ZrR9BLuB0t8LCVV6uKzNN5n+hq5 Kejg== 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=BRio8WmNPVIhI4AkJ7r8lq4Jznf7XL46j1qcLi92j54=; b=sIPCKhyY0qsTmdwU0YTM545CzXtNCuD5vYjwQ0bVvNRvKSbvHJ+erNvnZRZ0s+TXAH o02dMhJBGkFW3P77KA1hKXImRoHxt25kfA8HugLXsVBqATw2aTClSZiwJw1eexCvYFhV +oAR+JX6jkrk6k808YBTjxDGBuD7Wm7IXoVaUxLAz3mNiYy9PADQ8lB8TuRKNYu2PPQd jxdJZrTGTcL9vrLKxoPtIt2MwIzvV3M5U4ZZhzsy0Jk0ypCiCUqrRdC5H9tYFTqo3k7j WBV5xnf322uS7Ooaveouw7ZjZBRTNstc+EtGaNfyPST4oCOcoE/LKjN+GYeTH/iDDNB/ zh6A== X-Gm-Message-State: ACrzQf0i6xUqpIMc8L7m28xF1Zqzmy1yFjFbl+87pVyUlISv2gu/TjtB QDKJ55UHj54d1Ivs2TJ+GpI= X-Google-Smtp-Source: AMsMyM6AO0fVfZ6Jve8NFte/cLX83aqhO0uCVCSTqEADjoeKr8BE2fj35W8F4VXSJqTiKNnIii1+cw== X-Received: by 2002:a5d:40d1:0:b0:236:786d:611e with SMTP id b17-20020a5d40d1000000b00236786d611emr1931557wrq.355.1667035807418; Sat, 29 Oct 2022 02:30:07 -0700 (PDT) Received: from discovery.. (p5b3f76b5.dip0.t-ipconnect.de. [91.63.118.181]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0022e6178bd84sm1068187wrr.8.2022.10.29.02.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 02:30: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 v5 4/8] power: supply: fix wrong interpretation of register value Date: Sat, 29 Oct 2022 11:29:56 +0200 Message-Id: <20221029093000.45451-5-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221029093000.45451-1-sravanhome@gmail.com> References: <20221029093000.45451-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org fix the switch cases to match the register value. 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 bf9c27b463a8..46d620bd23b9 100644 --- a/drivers/power/supply/mp2629_charger.c +++ b/drivers/power/supply/mp2629_charger.c @@ -284,10 +284,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; @@ -305,7 +305,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: From patchwork Sat Oct 29 09:29: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: 620695 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 01942FA3744 for ; Sat, 29 Oct 2022 09:30:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbiJ2JaO (ORCPT ); Sat, 29 Oct 2022 05:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbiJ2JaL (ORCPT ); Sat, 29 Oct 2022 05:30:11 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D165C59E95; Sat, 29 Oct 2022 02:30:09 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id t1so777431wmi.4; Sat, 29 Oct 2022 02:30:09 -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=3goYbsJDZwsx1DqCHZmmtgFkfTgwpdzB6nk55vcDFfg=; b=jBs97ucoqcakG2D5kdyfEMhnORwaVEPiplFRWhoi0pMNqJ40VPSKoG5gHifjC/Y31P gTNE3gzHVkNvOzaUCBHUpRy2RbT2vw1hb+jL1QwHCF2FdQyNWfkQDOzexmamvp2OUVYQ r0h5k3561u9xwRayDlgTl/WcEgYBZcyAfa85rKEeNKPtCc6fvNEEWP0XL/iCfurh78f3 Md7u2Tv2qkClNLYMheBvDOsal+LnE4jJOm+YXApgFeNyYYjjXyiINKM0avVqZdAQ5xGZ RQzFXTX4SKR78gDAjIwXcLdC0DdgjC+KOIIB3IQvubrUgbeBL7OEhHHIvamNndJl58Gd 2dKA== 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=3goYbsJDZwsx1DqCHZmmtgFkfTgwpdzB6nk55vcDFfg=; b=kFjAiXupUDWn/U7H1hB6JW138l0nE4xdE5yHNt+uX2UeFnx1OTMg/cNy0cT726hOdW 7TBlqzPGlPrY6gz9YIv4WITKgJN08DKqI8dzGl3yKZl9GtEA5lo2yvOe08nT63l6Iru7 mSCHqfYp7gkD4ifvI5k8JT4Hl4wjh15aNqa95zaVKvrGKrwjZPRVEFXWkbg+0FDjWZeA SlpJIoV41+cLnN3azCBpIQ3pjM8xGdyjuJhilJ3KtgOcXY2fgRrkocNxGM8YNh2njf9j UPG9GT2/bkk+0TmpXuMJ+bvyM8+7vtW5ZmkVqe2/W1CDegCS+47J+aw9v90IKQQvyJIv z1QA== X-Gm-Message-State: ACrzQf0mJWYsyWQfmI6kLKAZ+yHx1BiCTdF7jSSHX65OGsU1jW4ePxo5 ZQGnjhxn20fmR4TYsfobeJ4= X-Google-Smtp-Source: AMsMyM4QH4xVzn8ngRL3c6gJ1pn31cQeLg/S/ZE1z+mdZ+xGo2JXIfbkenWtKysM0m+kJBCqb4T0PA== X-Received: by 2002:a05:600c:1987:b0:3c6:fd37:7776 with SMTP id t7-20020a05600c198700b003c6fd377776mr12390070wmq.72.1667035808379; Sat, 29 Oct 2022 02:30:08 -0700 (PDT) Received: from discovery.. (p5b3f76b5.dip0.t-ipconnect.de. [91.63.118.181]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0022e6178bd84sm1068187wrr.8.2022.10.29.02.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 02:30: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 , Sebastian Reichel Subject: [PATCH v5 5/8] mfd: mp2629: Add support for mps mp2733 battery charger Date: Sat, 29 Oct 2022 11:29:57 +0200 Message-Id: <20221029093000.45451-6-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221029093000.45451-1-sravanhome@gmail.com> References: <20221029093000.45451-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 Acked-by: Sebastian Reichel --- 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 f4c5aa06f38c..57db0f5009b9 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 Sat Oct 29 09:29:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 619895 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 50476FA374D for ; Sat, 29 Oct 2022 09:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229828AbiJ2JaP (ORCPT ); Sat, 29 Oct 2022 05:30:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbiJ2JaM (ORCPT ); Sat, 29 Oct 2022 05:30:12 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB6B5B065; Sat, 29 Oct 2022 02:30:11 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id k8so9451790wrh.1; Sat, 29 Oct 2022 02:30:11 -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=9aX0cSt9m4+Cq/f1RJLWS1kmL6VQUel6+uX1gQMvMUk=; b=dmr+VZFxGybIUj2z2AntKwOIXFPJF+0kLb37xpb2ClxzIf4VbSzZd3yCrCD95ZHuhu LXhPOifD/LsBtJ3gWWVulxskurW4AljDMjSWxHICi2JVl651461JrsabhkHJu0uodJmY f8OggObxxrAh5zLGWTbaNfex1M0QHk1bDVJK/Kjg+Ehz2c5x4qPNhC1eUMpSIAnAEyz5 VHReQ7W24HxNblIkhGVlds4rylc/zU/kB0XqyHt0s/35Ov4FK1VXMzM4TUQ7du6lR0oW cQfG/vvZJesqYYWlbRGZZIFqVsWn3/6nQ3epLH+9gTjcW8frNF21Oi2tjEtaSswL2UkI ebkA== 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=9aX0cSt9m4+Cq/f1RJLWS1kmL6VQUel6+uX1gQMvMUk=; b=aKMUHxTdLpNuQURmnEUV5ug/5ze44qKtzUX0S6wceiUVTGZaZ4oCe7I7kDKJSfWSou 51hZVzzzo/xSCuoMBaCaNWwtfhCBpHTjCHr6PbYFWs71bueltZJGr9jAKFrQq6sfeFx3 ix9q9CfJdy6FiSsF5WeF2V/DtI+IcUaChjb9v0aRyhR1OAnylo/96lvi9TzRdDwD1h3H pinasmCTOw+Irj2CMWQTMX2SgQYItH2XvdpCnF4rhCxUZ2c/90qUrziTIMPmT1YhaDAs tIkbL6Cqh7E4wbPj/Nnjxo37UddMMsiDCLklmpmL585e7cWFVI+JpmYo7CR33yy6531B XWQA== X-Gm-Message-State: ACrzQf35Pvl0AAkmBDapZn25aw49jYbVqgCxuVbReiiU61jw8GONEwBp iS8Yg45MDqrW0F9ZUkY6xQg= X-Google-Smtp-Source: AMsMyM6B1H6rKpGvxcPczA+Ys/6D3oEasxUh7PBv4MEZ0Mo40/Bvl5vbvzL680lqsl4uP/I3q68Q2w== X-Received: by 2002:a5d:47ce:0:b0:236:76de:726c with SMTP id o14-20020a5d47ce000000b0023676de726cmr1978167wrc.510.1667035809542; Sat, 29 Oct 2022 02:30:09 -0700 (PDT) Received: from discovery.. (p5b3f76b5.dip0.t-ipconnect.de. [91.63.118.181]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0022e6178bd84sm1068187wrr.8.2022.10.29.02.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 02:30:09 -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 v5 6/8] iio: adc: mp2629: restrict input voltage mask for mp2629 Date: Sat, 29 Oct 2022 11:29:58 +0200 Message-Id: <20221029093000.45451-7-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221029093000.45451-1-sravanhome@gmail.com> References: <20221029093000.45451-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 Acked-by: Jonathan Cameron --- 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 88e947f300cf..18290e176e1e 100644 --- a/drivers/iio/adc/mp2629_adc.c +++ b/drivers/iio/adc/mp2629_adc.c @@ -66,6 +66,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; @@ -75,8 +76,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 Sat Oct 29 09:29:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 620694 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 3BA57C38A02 for ; Sat, 29 Oct 2022 09:30:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbiJ2JaQ (ORCPT ); Sat, 29 Oct 2022 05:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229817AbiJ2JaN (ORCPT ); Sat, 29 Oct 2022 05:30:13 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16B4D5B78A; Sat, 29 Oct 2022 02:30:12 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id g12so9410754wrs.10; Sat, 29 Oct 2022 02:30:11 -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=Gcpve3HUhoxjVitiFh1PFrKAWx8ahfBrWMl6ZoMh5jU=; b=NBbnrwh6N18QYGvl6b32J1is9vaFpcxqJefZIUyax+oiE4TEu1D0Iqa+CRsRq6ioi/ 7jMCJTswsxMwPgVm6t7b6Y9Oh0FPcbf5p2mDLflOU72vhB07Fy8pbk9ucoMX3qgWKgvH 1eRqimadhnafu2YOrFKeJ//xYuDHQXqCICMsyWHOCnQl3lcYV6OM2YIAocGmbwIptlt/ CS8bRPaqwuN+eK3rtVyM1pqp7WZP3gkpagerpHbAcR//JwqjoxGtabzcNseUuRboTGXG 5A/vLw8NixGleNMHYNxkzzniSZ1t0IX8XxXASE/458BeSh+Yiqlw1nVWFkLNxxba7XOY B9oA== 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=Gcpve3HUhoxjVitiFh1PFrKAWx8ahfBrWMl6ZoMh5jU=; b=MXD9p9YCa9wYI1DcgCcVCLCcGhqHro51LRLkwe63IpEmgrwFKvBvMEBAqOzuESwpc4 Zx7LEXKW2WtMpVsNJ+jPHdCSDuvBaLAIK063XuVQ1aq6JH4ahtmd3w2gQzOtmM3xnXEt vygWV93ETERvFkpeGzCost87oPRAzAQjQq3Rr4oTcAMUhcx5R/n3bpfzNqOK3PiANJtc 9XqihvAdgVLyZjSMjIIpkJglnANvV4pWf1iff9kNdagUxOsMWFf9/bZ0I9p2pGwDleUy MFn5Vx8qqav9EU85hZip70pkGDYYZnOHif0TyvJq5ZBhJEs1ssi08ZTrX1160oEMuwfr OLvg== X-Gm-Message-State: ACrzQf3AjU1rSxDRUkb7nBxoNxhLoB+c3f7zANgUgqL2Ri3wz4+srlwT tJtTpPUG1NDHDPLvdaVsAZo= X-Google-Smtp-Source: AMsMyM7Mk5BRzc60ghAqxCwgWlDnQ2nE28/FgDZkZcQWzEUMZRDmF0tKdN8L63HCrJTrlIcf840V9w== X-Received: by 2002:a5d:5270:0:b0:236:60c6:6e80 with SMTP id l16-20020a5d5270000000b0023660c66e80mr1845757wrc.140.1667035810478; Sat, 29 Oct 2022 02:30:10 -0700 (PDT) Received: from discovery.. (p5b3f76b5.dip0.t-ipconnect.de. [91.63.118.181]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0022e6178bd84sm1068187wrr.8.2022.10.29.02.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 02:30:10 -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 v5 7/8] power: supply: Add support for mp2733 battery charger Date: Sat, 29 Oct 2022 11:29:59 +0200 Message-Id: <20221029093000.45451-8-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221029093000.45451-1-sravanhome@gmail.com> References: <20221029093000.45451-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 --- 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 46d620bd23b9..2ff3729afc48 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 Sat Oct 29 09:30:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Sekar X-Patchwork-Id: 619894 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 07816FA374C for ; Sat, 29 Oct 2022 09:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229610AbiJ2JaR (ORCPT ); Sat, 29 Oct 2022 05:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbiJ2JaO (ORCPT ); Sat, 29 Oct 2022 05:30:14 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E5F75C961; Sat, 29 Oct 2022 02:30:12 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id h9so9475681wrt.0; Sat, 29 Oct 2022 02:30:12 -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=bkJrpxcP48TMk8lHsqey+h3jqmE5YwXV+ijLJdBnXvo=; b=HmwqAQG8Tk2v71b7VEjnQad2cz+Fk8YUMWxxRgn+QXvgJo1COCuAaQ62WwbZIAfVUE 5wrax/x9Rp8ADIzqWJOfiKob74lIeLPIg5OqRohmQBhyFVq5LDEM78nPZSO13e1AQtHo lhY8mStRWxuunE/f5kFZZ2tg8yq17oP+8Iql0HZPpSztVLv6VsnLLNqjKBQ7ii51ecva skLeXirsN6TUMQi+hv4xx/v4vHVSK3Kpw8K1Ic8+rkasZMQjbLzYXPycwWo7otctY9+Y /T8MiLiMgopDjP29VHzWvS6/k9lVw9i/BKI5ccGRNyi5t6onpmPHeKP71xTMtFzmzyPP rJCg== 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=bkJrpxcP48TMk8lHsqey+h3jqmE5YwXV+ijLJdBnXvo=; b=FHvqAMyUdXDHzSP1JnEMNNerA+kEG5VwwwDfDBmmyAWk3WYx3PeagnxOlYyQEJyIZb xGKrrnJqG5NBzPFATgx6E3nNm88OQklFjZ5MREV/V46xEY6uX9/9k1nqMVWhhQ8CP41X wk9WR+w3ZtS/Wrz51LI0xgXcFlNNV/DxQZe8iZrZhKT1NqqGAANu2zfO8quWfOFXpjEG gWWUNwhJH1H5U6vQsw3ygEiUWrrGOkl1ST4GZHfPurxl8G9kEpBonss0qVZMszhkMJsY KUeHzDfD5bpjVuDRcTb8qaXFwTNdMikZKkCyx9LXAfY29EesBe1rEtL2Pb1LU/C8/z2L 03xw== X-Gm-Message-State: ACrzQf2ieCLUOHrbvcYDCuujf+Jlqd5YhhFYdcNyo+ZnL+9URaINP14z rzeVNW6XLI9eopLHwQD3uPc= X-Google-Smtp-Source: AMsMyM4m0SgvZTbNuPJIGzE2zVDyx5FULFr7VqyeQN/rq6FUbBUwhynXpCEow9/e/64lsyj2yanGoA== X-Received: by 2002:a05:6000:887:b0:21e:24a0:f302 with SMTP id ca7-20020a056000088700b0021e24a0f302mr1844035wrb.466.1667035811519; Sat, 29 Oct 2022 02:30:11 -0700 (PDT) Received: from discovery.. (p5b3f76b5.dip0.t-ipconnect.de. [91.63.118.181]) by smtp.gmail.com with ESMTPSA id f7-20020adff987000000b0022e6178bd84sm1068187wrr.8.2022.10.29.02.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 02:30:11 -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 , Sebastian Reichel Subject: [PATCH v5 8/8] power: supply: mp2629: Add USB fast charge settings Date: Sat, 29 Oct 2022 11:30:00 +0200 Message-Id: <20221029093000.45451-9-sravanhome@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221029093000.45451-1-sravanhome@gmail.com> References: <20221029093000.45451-1-sravanhome@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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