From patchwork Sun Oct 16 23:43:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1192764wrs; Sun, 16 Oct 2022 16:43:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4zog/ycfdgm61Vt9/bybnli3WaF3GT62LQRDxR1JtaJYmzoVlqtC4SELWXQrhOXVKCydyC X-Received: by 2002:a05:6a00:21c8:b0:52e:3404:eba5 with SMTP id t8-20020a056a0021c800b0052e3404eba5mr9589038pfj.67.1665963781039; Sun, 16 Oct 2022 16:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963781; cv=none; d=google.com; s=arc-20160816; b=Nxu4jDTb8+s4KdFKBVM0rIkFJ3VhEwXK9+khnUzTPkXisM9nRSw7DmxDMdEnr7FkIi UwaG7FutRRCHUdPujDoTFUnfynKLDb8TYBQ6y0hFscjDHgCL0NSd0xd9nUj2E6XN1KRp LU2JFgrgkuAWbvKzZNShOzwC8GpsTMZH4JQ7EZ9aBtFibDkrjI0+1D8AdbCeL5gMMboi iC/iyU5ealCfDI2E3uZGuFac3nHlYIHMyd9iaIYGzVlPe2/TcKfKW5kmjgSpVE5yb15L VulalzDW2vqKPpcIiQ5krVqt+yeTPNINtMnGeKT26Vd2d5gH+/g6V3PCZb7H3C/oDPGO M0fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p8WgOnqzsVIcwM2hwBH1ea3tXcJUTMam+tnMayl18pQ=; b=d6bnfhWms7r390CyTfblk6Qm9r+j/6pqH7Y4MzabQlGND3t1o6O+3aH7H+IU1/Qmg7 R4MqLFBbDhPbU0c6h0tWDc3ZJ4CuzXCiuuX5HjRafgaZ8SbQSVykt8xVlmYZvNiyWvUl 5hxRqfJQ+tyoF2AGwS1M4JSrumqOXJkXe1VDai4qz2oaiIiwFYlSCE2aZ5zzRJ8ejNtE tvloDvyTsq9Vaudgse9nvdgkTUiPvnfb50YsOQUyr1ztxdxCzgKkkk4TygTB21LVrFkA CDgvBzxMKLX2sxO8bw6hj87sw7P23dTOAULpOdtpDpZ63qX6dOZVk1gPpITARLBuMogs rYxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=loCBswe7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020a17090a8d8100b001fde53d5d79si15976826pjo.5.2022.10.16.16.42.48; Sun, 16 Oct 2022 16:43:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=loCBswe7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbiJPXmV (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiJPXmS (ORCPT ); Sun, 16 Oct 2022 19:42:18 -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 88AAC13D68; Sun, 16 Oct 2022 16:42:17 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id i131-20020a1c3b89000000b003c6c154d528so4451762wma.4; Sun, 16 Oct 2022 16:42:17 -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=p8WgOnqzsVIcwM2hwBH1ea3tXcJUTMam+tnMayl18pQ=; b=loCBswe7W5OffBB4isgFvCHt5qA62IhRzDSaInfeKsrWfq3Q8wPL9j5TlLOSl4fcP8 HT+b3Fc9UMFDm+6HP6uC0aeitQx5VnCdBbJnstvpuHYxLdx8j0c4FMAf4ec+mrAnYusl RcRfVd8yyb9Qcw0f+ODXTFfMKFsWpsqfVWJTh4ulhU4cnqp41wtVFTSbbrlIcmTPLCcd VuvanJewga4E0gs3MDwt+++OOEBWR8981SJ7RBKacwVLCni9ZVyITghKUu1KGvvWEYMJ E+n+YLcPTv9Eu3ZP8IjQ9y4VrDDXqdt5ZhMpxL11CNXUcZT2H4mLUKJE/I+348XRhhkN 3g1w== 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=p8WgOnqzsVIcwM2hwBH1ea3tXcJUTMam+tnMayl18pQ=; b=IfHJKx57l+k4VyGq3n6y/2ME6cD9zohNx1nAfAjxhw4p91nYXX+0h+XnqnYNxZyJ6c cv53j3cC+tlXCUQS/mpv7rG1xsyw8oJp5BKg0+/HFLC7uCP7RKmDkIfXM3Fr1LJ05lHK UusyYm94rVuVIkQU4puMz5kCIljI9wK090cOlFZBst9rrkLct/Re5g8wIlHC4+h8d4fJ ntGd/9Gfyo6Y42VadiaIpvBci3ipt5yigYusbWeOPXoVXhJ5E1GDdvQ+OoF9SItnwChU 8IMwMvjEh7DKcSJHtsB4zJOUQrHlCkbKmy6ttRtMKVKOCrdATcPa8nuQmdyPMOm/lVc8 5u0g== X-Gm-Message-State: ACrzQf37DXQjGtaYbvCDRL5/p3jG/bFJVHTSweMl2PwqVU5BJGzrdc39 DDFvhuGoHvrq6i8ktvDz7vo= X-Received: by 2002:a05:600c:4e51:b0:3c0:55e0:7719 with SMTP id e17-20020a05600c4e5100b003c055e07719mr5569381wmq.3.1665963736070; Sun, 16 Oct 2022 16:42:16 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id bv20-20020a0560001f1400b00231a5fa1ae2sm6950749wrb.20.2022.10.16.16.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:15 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring Subject: [PATCH v6 01/13] dt-bindings: mfd: add bindings for AXP192 MFD device Date: Mon, 17 Oct 2022 00:43:23 +0100 Message-Id: <20221016234335.904212-2-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889637747537140?= X-GMAIL-MSGID: =?utf-8?q?1746889637747537140?= The AXP192 is another X-Powers PMIC similar to the existing ones. Acked-by: Rob Herring Acked-by: Chen-Yu Tsai Signed-off-by: Aidan MacDonald --- Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml index b7a8747d5fa0..db9845add060 100644 --- a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml +++ b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml @@ -84,6 +84,7 @@ properties: oneOf: - enum: - x-powers,axp152 + - x-powers,axp192 - x-powers,axp202 - x-powers,axp209 - x-powers,axp221 From patchwork Sun Oct 16 23:43:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1192771wrs; Sun, 16 Oct 2022 16:43:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4S5TAq30j9eyGWAFl1jId3h4YrVpRwp+0Xcqq4Fgqgx00iBB6FBYmv5MJMsEK+4kb1cBSI X-Received: by 2002:a17:90b:33ce:b0:20d:7450:6b49 with SMTP id lk14-20020a17090b33ce00b0020d74506b49mr10517640pjb.128.1665963782267; Sun, 16 Oct 2022 16:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963782; cv=none; d=google.com; s=arc-20160816; b=UAJkCTg2w6+pXVbYyM/JpZu5k88t1c1qZQmqXl+qim3PIPBNESn2NwOtzrA650geU/ DvJW0eFl3kGfk7T0AinbTxS4pNnYEYJqeWTkbUVzc+hdEu1S00/DqTR/iYaLJg6MqaFI 8rXYTO/B9T5icHX22ZSghd9rZDBTvb1SQz19LnHOBOMLreoDiZ1K5sA8U8gWdifVgRvo mgvKZS9w3/TI7gJECYOZPwOzdd31qxlsiZDa1ptMt2WF85tglB+GNsILBRDX22Exgegb KNUYDgi6cOuSPxCmb/iP37N2i3w3Q4WYV28o7ACJ/3+S3vXa/sVOSEL0VTbnMx0+7ygd D+hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=713k9A6cCfEIb7eNKGVtq1FKwXEY5zby7RrWVPQyY24=; b=opF6Way/Bymrrdjjza4W82wDy/uosDcbXH0CHthBLG/NXODpiTQp2081JwVsV3c6Ag hL6MYNhATG9sDCpKRnipp235Ny2co5CIaRRoQG0MO13DIiS52RDM+4QJkG2seXgcJy54 WMuLggU2nH6GgGEtPZj5UnibkAm+jDMnQDQZ7r3PGFd3TXD0kxPbpIFXTlq7TR1Aj89t 1pOwd/gt+YTwW8FcaVElL0keJQdhlIg9ltDkum/DkL/E+SWQLf3Ut/RUokQ0lZILim2q e5c8v8yvPD6mCC5g0uHSling/4Too2mzhBYrzGRdQNCKRYedggQ1920Ui+dDyP35Nb2c cQGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eyEdwym3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a17090ac68700b0020a74d5486esi14839547pjt.21.2022.10.16.16.42.49; Sun, 16 Oct 2022 16:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eyEdwym3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbiJPXmX (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbiJPXmU (ORCPT ); Sun, 16 Oct 2022 19:42:20 -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 2F3BB13D68; Sun, 16 Oct 2022 16:42:19 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id bg9-20020a05600c3c8900b003bf249616b0so8787292wmb.3; Sun, 16 Oct 2022 16:42:19 -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=713k9A6cCfEIb7eNKGVtq1FKwXEY5zby7RrWVPQyY24=; b=eyEdwym3MlKxaLg0tiz1H3ve/wbTs4RV4XzkFJNZJVv1fllfY8wrWlh0jYb0y3vu/l M+RLxXsdbJLQFmM//ovIlh0CdXukS2tK8NFtebCP4tuYKRWPkDZVXOOK51B+Dn4qPNQQ fYkVqUjYULqN6P9z9U8hs2wXmH5OFESfYiswlXEltv579j2KyRl20Om7SBLKf86ucJFa 5TCmOh72mIB3lqHqez1cNw2xPdPdFD8Cn0ivAQCIYruAqjpQj7axnqBBCD6+kOiOpUs3 ElBee8n0672BldpXi7tEESuaqXue0LbUdH8mp0kJWe1IbZoPt/2XU68p8WVoEx1+XpmB KDvA== 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=713k9A6cCfEIb7eNKGVtq1FKwXEY5zby7RrWVPQyY24=; b=wb8m9xZ8SxVvr310WdrrSCE2aZYpWl0Pj4ki/mG7FiyYMunXDrxvNxtqwlZjNJrA/W jYcwkDYOlfVtXVBmrM3AGlgt9lbuo9qiwcX4JmevJ1WDnq/9MnI3fxHuuFZ9x0ZBa3pw 52CAkDQLeF/YnXnoPCrjrLu1jXsVoGN9XiXSI1nU+BJtiQW9Q/tVJyktetPg3l3gFSeY punEfB2wE7Eyk1tYixVGtqWRXrbfOcDC+qvlev9Gfs4FbAsOniaNiDkZH3v545HhtdB+ 9DEA2PjeKUIOE9fCt4p4C84XmvamqTDYpfkB9W02YjQ6G/IVkeS05yQd/+K+yNu933OH vYuQ== X-Gm-Message-State: ACrzQf1OEbkzuaG7raqoMM6/XmX1o//TQCXUhfrgY608Wg0hDGtJApCJ /LlaO/J2uTT3dSM/t/x9uio= X-Received: by 2002:a05:600c:2f9a:b0:3b4:9bd5:1472 with SMTP id t26-20020a05600c2f9a00b003b49bd51472mr16858598wmn.171.1665963737658; Sun, 16 Oct 2022 16:42:17 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id n14-20020a05600c4f8e00b003b47b80cec3sm13781642wmq.42.2022.10.16.16.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:17 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring Subject: [PATCH v6 02/13] dt-bindings: iio: adc: axp209: Add AXP192 compatible Date: Mon, 17 Oct 2022 00:43:24 +0100 Message-Id: <20221016234335.904212-3-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889638921192366?= X-GMAIL-MSGID: =?utf-8?q?1746889638921192366?= The AXP192 is identical to the AXP20x, except for two additional GPIO ADC channels. Acked-by: Rob Herring Reviewed-by: Chen-Yu Tsai Signed-off-by: Aidan MacDonald --- .../bindings/iio/adc/x-powers,axp209-adc.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml b/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml index d6d3d8590171..1a68e650ac7d 100644 --- a/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml @@ -14,6 +14,23 @@ description: | Device is a child of an axp209 multifunction device ADC channels and their indexes per variant: + AXP192 + ------ + 0 | acin_v + 1 | acin_i + 2 | vbus_v + 3 | vbus_i + 4 | pmic_temp + 5 | gpio0_v + 6 | gpio1_v + 7 | gpio2_v + 8 | gpio3_v + 9 | ipsout_v + 10 | batt_v + 11 | batt_chrg_i + 12 | batt_dischrg_i + 13 | ts_v + AXP209 ------ 0 | acin_v @@ -50,6 +67,7 @@ description: | properties: compatible: oneOf: + - const: x-powers,axp192-adc - const: x-powers,axp209-adc - const: x-powers,axp221-adc - const: x-powers,axp813-adc From patchwork Sun Oct 16 23:43:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1192793wrs; Sun, 16 Oct 2022 16:43:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4YPbHWjBw7YVFYEFSq+tjOTvnV+GXkKFztvcxrF9927q5BbU5U2Odzr7MhfF/TsqAne1Rd X-Received: by 2002:a63:d241:0:b0:43c:474c:c6c6 with SMTP id t1-20020a63d241000000b0043c474cc6c6mr8151937pgi.523.1665963788510; Sun, 16 Oct 2022 16:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963788; cv=none; d=google.com; s=arc-20160816; b=dXY7s0iE/z6TnXXYEtonfy0RHAOVfd2t+nhF4AKX9HjsA/i1xp3/BSUVVbBQeAx57N RFu9/yE9O1+W+mATzlw6IcVviMovsvO0iCTpX2Vv/l/P95fh3IzA/wN/2nEymgY13rYs faQ3DRXhnuIDYhv7fwbvhCCtvY4F8ja0mGMjcdc3/GHb/lo6bZRmQF2g3CszmLU4HHOz ENBtpuZV2ZxNulJ8um0lJqVqMfeUhK7YylVrn+noiwEP7C3AOgK6KbQij5p0Z3BDEt0J Zme4KUTtVoIvVYy1L5700AcRcZOepPiZjB2LUr1kk4gE4eJo0ajKRIf+Ev3xvhQwBHhS Cblw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HBGk5yA9hr5t3AA+tWd2/rq303jcXV9PFlMj181BSFI=; b=oUFynU2QfuKOZO0/DhIX1/ZCBoPhZIguFShryoc76iv+qpxH84cqs213wwJW26DGyg jJP+4eLO/wD50okj5AvRNgGa2HahS14HQgku5wkvblhh+Xako0bT872xbzR7kFVtWrjV FT51kd2d8v9s15xv9Jt0bHsXtuVW5GkGSeVfjjk9D/Wg9n94YLauK1LyY3JiL/IrBlWJ ONl6mYdgU57J5aGtRvNk50yLB1Gu7VC8OP+Qvf0VfiOWHh+CFIMDWNStbd3MYlx8MaOk PwCg6mP8fQGe4LGeWyOW6wZ4aL7vVubc8PG5nUnFkuq5F/K/qKiUE/YCbSimjElrf5k5 Yojw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FhzdIdle; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a17090302cb00b001781520b28fsi10485496plk.26.2022.10.16.16.42.56; Sun, 16 Oct 2022 16:43:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FhzdIdle; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229920AbiJPXm1 (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbiJPXmV (ORCPT ); Sun, 16 Oct 2022 19:42:21 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 946DA240AF; Sun, 16 Oct 2022 16:42:20 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id az22-20020a05600c601600b003c6b72797fdso8778586wmb.5; Sun, 16 Oct 2022 16:42:20 -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=HBGk5yA9hr5t3AA+tWd2/rq303jcXV9PFlMj181BSFI=; b=FhzdIdle7Byp6UdzdLvBMHNqAXydDtYl8lsjaf+sXGSFAyqWiKijaWH6Gwvy2XXdRc 5SuBEo+syYBxHH+A6SALXgimxXRouIkhHCVh+MmkCrrvK9iZCfFFZSDaE7q9yD8lG7Z+ 0r9fXF+ZUB87e7rot1GrdNYtXfXBZ+qlmAZr1EtVZwf4ZW33ei6IWgck3v7oXNmiQpcm D1/0reRUyJDqOOUsjLTQMqjt46oD8wn6PkKsLLcO0K88r8l6hAHkj5pHHLlppGF/sSSw Asp5bFIn9D2HU/LRD0cfH2G/NwacMnNuHJqZbir2cA6sBu89Lsn9+aLxJ32N1T025h65 PlUQ== 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=HBGk5yA9hr5t3AA+tWd2/rq303jcXV9PFlMj181BSFI=; b=lxGiQ4GVaLf1ecUn7aSdUxqbfVPC9Y6SGe4LnH+FpvP6RU+5IixagR9dtN0hxHDnz3 Eg40FGD03RAARNlrop8tfYsB5O04MduAK1oZrh6vT37lS5x1iv0s5OdXkVgZ/UuSTLY4 rGfi0hvkOf+SJ/rCTS60l5nHTPQwMCXTSthh5p+yrXPeW4JQxhNun8E3zC5vEwc9x3uA lm/D2gRMnqcd5Vhavm5pY4oiYGT+IiQvyQWwmz+qdNfYiaHDRC4f0oztZ+Xg1oIJaxnN Mk9z/p4yT4wYhEm6DfwUfEIr24fHoObhuqBgDbvty9WYKx8HVbrmBTpfhAboJCUnKm1I Caiw== X-Gm-Message-State: ACrzQf0nk1kkK6Obn+a1SU7ZoEbw5q1kgi0/fAesoHsKx8fY4IBUo+FG z7mHddRiSSYXfVsp/0kPyJ4= X-Received: by 2002:a05:600c:1c08:b0:3c6:e398:64e0 with SMTP id j8-20020a05600c1c0800b003c6e39864e0mr5455065wms.2.1665963739130; Sun, 16 Oct 2022 16:42:19 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id o14-20020a05600c4fce00b003c6b67426b0sm14315527wmq.12.2022.10.16.16.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:18 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring Subject: [PATCH v6 03/13] dt-bindings: power: supply: axp20x: Add AXP192 compatible Date: Mon, 17 Oct 2022 00:43:25 +0100 Message-Id: <20221016234335.904212-4-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889645281292917?= X-GMAIL-MSGID: =?utf-8?q?1746889645281292917?= The AXP192's USB power supply is similar to the AXP202 but it has different USB current limits and a different offset for the VBUS status register. Acked-by: Rob Herring Signed-off-by: Aidan MacDonald --- .../bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml index 3ce648dd91bd..34b7959d6772 100644 --- a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml +++ b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml @@ -22,6 +22,7 @@ properties: compatible: oneOf: - enum: + - x-powers,axp192-usb-power-supply - x-powers,axp202-usb-power-supply - x-powers,axp221-usb-power-supply - x-powers,axp223-usb-power-supply From patchwork Sun Oct 16 23:43:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1192819wrs; Sun, 16 Oct 2022 16:43:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7t6asc6y7xMfHg6v+mPxoNr09gL0kNHFpql9xIrMTzPloNm4gxuR0SSKgr7ywxt6u4kQkc X-Received: by 2002:a63:1359:0:b0:43c:753:c319 with SMTP id 25-20020a631359000000b0043c0753c319mr8345222pgt.575.1665963793947; Sun, 16 Oct 2022 16:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963793; cv=none; d=google.com; s=arc-20160816; b=WQ0+MSHhLfZH73DFJOUudHd2U48fBZBy6AhdfRhKi8/py/vs3V+TFwwOX9uG/bAay0 dwJyf5JITmxEpxUWewGy43Fdbd51Td1yYfnWYtUZf+EYHxSmYdH20/UCBUcqXKUAHbF4 NnuzSA6fMr3o/ZN/s2m4dkEk23tVmsEBq8THOhMtvcmG/+YZ52CQFr026fqpB3yHZ0QS C+ke1NVefCQnrhAOpwdJgSYCPLtvVEtVDuR+CpunlqNvTt9hsmNeQdrP5X9XuAEicCCB Sj1zf6LpibPcN1laoacn25QyDZ2pa5Mlqw0oUexLHsi1W/DjRNPkOHKtCG1FEMEEemP3 9Fhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mkCe7sPSDik6TqNHygx3u2xLVqvEa5+V8b5EsZsfws4=; b=ib/A4wJ7R2Kf1PcGMCgnGeopTX5aJdRR6o/o1Aek2LOMowELjHQAtV7xWui/6JxSkT X/RhSk0KE+1QH8DLVbq/Hl9fa3rlQq5cxfsrDUNsRBJDT36R/uUOEnX+qGmewiHnVpbI Y7u5X60KzurDLeaF0TBq25EuvJ8un5fMUPShfmfnnohKQSt8EeJdSY8KE6NLqZWM/fwX vAQfNyQpQgC7K8M90tSmeHWHq0/rIHZ+rTCTPX1+KKpCGXnSIDe2Wt5wv0dc2HiWGpAZ hz0o90zQZV1kS37k40ec3Ko55HAgU0dfoO4ezBj0AeN8GzdzaIYYs+QO3ACE0YS2Tk6t WkYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y3Ze7Elp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r3-20020a63fc43000000b0046afe3e8b16si10245830pgk.91.2022.10.16.16.43.01; Sun, 16 Oct 2022 16:43:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Y3Ze7Elp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbiJPXma (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbiJPXmX (ORCPT ); Sun, 16 Oct 2022 19:42:23 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065D727150; Sun, 16 Oct 2022 16:42:22 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id n12so15964564wrp.10; Sun, 16 Oct 2022 16:42:21 -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=mkCe7sPSDik6TqNHygx3u2xLVqvEa5+V8b5EsZsfws4=; b=Y3Ze7ElpIWs8oa2OXQ0U5hHbqTe7iv2NUU/HJhcolCUIT5ldNECiF1hWl1IEdSSGR2 ExWGWD35hyRaRQQC8PQoGjhKeACFSWyhG7zDq8z00kZ0JjiD0boYWhGrHFfu8OBUnRcx smFi/7UynZxl2TrXo/sguRN8a+tG67Nvrvdy0KT4ryKU1/o5Z6xyZZlnZK4Ve3FUgI0Y v40VtUp92jDE5KpXIWm/CLNRWmyNHexlzWO6jCgz+Y7xnNC40F1lZaR7hdq6St0P+LaH 8RouuZEpgSAwJ5AFNfWTq/5VztI+oHFfn5tA4wy/hx4HpWUD1gOH037BjV8E6TkOoBxu keVg== 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=mkCe7sPSDik6TqNHygx3u2xLVqvEa5+V8b5EsZsfws4=; b=Bqj3hJkEEPtFVB+kzn8eEoOuOSk+O+Xm6MWg0AZuSyj2i5FCov7R1EwLsqLcaimJNy G3xSoxcSP/K4fE0TAGlQs83eveseO5DlxNs2qnKCT9+cVBYiJuKXnhtA1yB1mlgyCTI/ mVw8KVDUoRCXMp3B34IYBRYNE5HW+o+ckFcDdKD6W9Jw5Nbky517x/FJDNhS1YZ3aW3a qlhGCyzAdr5uEsO87gI5/iBxBfHyBpnDpay/CWTCVHZa/IGSn5tEonObmSjPceD7bpVE VYvWEvHevsTB28d9M/PtOcGL3Ll7cil0m4S4rO8Yuw+6F85kpmewNPq6LiBb8OLtKZW2 CcOA== X-Gm-Message-State: ACrzQf0sKcXRHkjjLWtuLcezC/2T3fgH3wRBCDYTe8W+ovjHOfSjC9cH VJpUE0J7h5nvhhnu1lG+PhQ= X-Received: by 2002:a05:6000:2c5:b0:22f:5242:131d with SMTP id o5-20020a05600002c500b0022f5242131dmr4374157wry.228.1665963740536; Sun, 16 Oct 2022 16:42:20 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id h10-20020a5d504a000000b0022a403954c3sm7138795wrt.42.2022.10.16.16.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:20 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring Subject: [PATCH v6 04/13] dt-bindings: power: axp20x-battery: Add AXP192 compatible Date: Mon, 17 Oct 2022 00:43:26 +0100 Message-Id: <20221016234335.904212-5-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889651204356431?= X-GMAIL-MSGID: =?utf-8?q?1746889651204356431?= The AXP192's battery charger is similar to the others supported by the axp20x_battery driver. Acked-by: Rob Herring Signed-off-by: Aidan MacDonald --- .../power/supply/x-powers,axp20x-battery-power-supply.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml index e0b95ecbbebd..11f56b07e788 100644 --- a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml +++ b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-battery-power-supply.yaml @@ -20,6 +20,7 @@ allOf: properties: compatible: oneOf: + - const: x-powers,axp192-battery-power-supply - const: x-powers,axp202-battery-power-supply - const: x-powers,axp209-battery-power-supply - const: x-powers,axp221-battery-power-supply From patchwork Sun Oct 16 23:43:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3161 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1193073wrs; Sun, 16 Oct 2022 16:44:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VbmZCMYVpHnKRsEV3ZKrhJ15nya8/Qrv2qFP+picIHPy0h/BeFI6TvBBIsHQqyEWk0xZa X-Received: by 2002:a63:5158:0:b0:45a:8a3d:9da1 with SMTP id r24-20020a635158000000b0045a8a3d9da1mr8220523pgl.539.1665963857215; Sun, 16 Oct 2022 16:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963857; cv=none; d=google.com; s=arc-20160816; b=wYLqje9es5AWNGfDdgMrjmPkZx2/TmK2xJAMHWZ+GdwirZ1Aw3Syipq8aiGLd/HX5X gD7HlnpJIHxOGuuqA1Iu+uf2VjFz1dT36DtsCqxDgiXs6MUVYEzuIBIvo5oBULI9JgFi WVzvcM3abGM+BIQwwk+b0vIsZF8pKVFng6SeowLl9LoitctN7Eg46l1YMf2aw2+66DlW /0aF4JaaxyJy+I6sXpB1170euOIIgRWAm9CcX5JLVm2RErihlJs/0Cp9RM5XaJoWdPyM S7+qrWOswEWF9Gp9vAvx7d7XOB8UQ/cUy9D91pkun0d7XcLsPb+kggqZ1h2QXRsOMWOl lMMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RC00DptrKqRetsk1LRqkKtKNlqlCvRvibCIGe0/vrcU=; b=tNgMs4vmyMggkw73vAlNDlhxMB1Me0vJBZxkepFhszB47McoU0Ct0zlIlAIF5g2Tge 2xk5wttri520CEZ9nEcWmzZmYZf0+FaI4ifoyafmKhBwP3bkINQgY9CYhtYrRN5gZ3dk ISDt06xtBrZ3xDOCsB3k+fMYO22G/IislmplLmimih+uYLHRloJgWCIPEIgYGgNrodjN w3DPgwQ0/7E/3iwd9JaoEr+kZg8E3tkTkvh197uoXYKWJKn/Lsyqh3WpFHYPiUAOOxXc rPLJOfMgoLLCRcJ2CjKELK/0wBBFPkPECko8HMxDOYwba3wqvGZYPBlGt6+4dvbcTpS/ 1g8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cPyapGYf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc10-20020a170902930a00b0017accae4d05si9465290plb.49.2022.10.16.16.44.04; Sun, 16 Oct 2022 16:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cPyapGYf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbiJPXmc (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiJPXm0 (ORCPT ); Sun, 16 Oct 2022 19:42:26 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D6B6240AF; Sun, 16 Oct 2022 16:42:23 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id j16so16016668wrh.5; Sun, 16 Oct 2022 16:42:23 -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=RC00DptrKqRetsk1LRqkKtKNlqlCvRvibCIGe0/vrcU=; b=cPyapGYf9cJcRULhQ5FbA7DkfzHxTzHbdtf9318vyYIYad6LqawSug1hM37DJQP3hr 3kFusZ++GViiO+cbkAekh6f+wQEKyPEZ4/f4cNTqFkx1ZdBLndcpzF653yS9MIRYKDb0 RhQefcDb0wImiHvISsUsSvtxvOLtc27bicsjwZqtDalHTmAnZKDDHt02c/DHaL777ufX LsgOYhwxlJqzT+vzfyng0hMQH3gpqo0a1IUFfTQ0zxMioeW8auqXFOfKTI7Hmtk3a724 xZhsPirIwxoYpf7aZ9k6C7yCwth+ge6IqNatLdGzn6m9enB8Oglm2SmtUkiZkxfYSpxT 6c/w== 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=RC00DptrKqRetsk1LRqkKtKNlqlCvRvibCIGe0/vrcU=; b=Im5eLHffWNJC/TQlwJ1WJgLcoRvwsf74uUJ4c8O6szuT2CbhXIe64Wpx9k/C4JIdbH jCXhXoqOC4OBrMhFv/eOME7Fj6IxFukT07UzCzklkf58zhLoW8apYCYGDcvXjijEV4VU MTYPi19AF2H+NjSxfTiSMtMs7CtuhYC0/18+J+be0Meq6Cfcj7mgSnQgrRZ8T+Sn34ND TgyOWlQCrx+50hnIkQmd1W5MaLRg6o9XKZrPYlwm2I+TBMdHxYt2qQJJUiA1LZBKFRio IUKQtXWRF2RMo2DfsVI1BlgADaQ3CfwLC6W0wRLUrE7TkgcgLtTCvUD/edmb9BcqzJRK vODw== X-Gm-Message-State: ACrzQf1ldz5yjBFt3U3589xwvtuIQxYhX71/ECEEXASYhmeIS+uy5uCS 4QbVmgWLnLBbybECcCXbBFI= X-Received: by 2002:a5d:4a4d:0:b0:22d:c8cb:8687 with SMTP id v13-20020a5d4a4d000000b0022dc8cb8687mr4499828wrs.554.1665963741858; Sun, 16 Oct 2022 16:42:21 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id c7-20020a05600c0ac700b003c6bd12ac27sm8706305wmr.37.2022.10.16.16.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:21 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 05/13] mfd: axp20x: Add support for AXP192 Date: Mon, 17 Oct 2022 00:43:27 +0100 Message-Id: <20221016234335.904212-6-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889717334056534?= X-GMAIL-MSGID: =?utf-8?q?1746889717334056534?= The AXP192 PMIC is similar to the AXP202/AXP209, but with different regulators, additional GPIOs, and a different IRQ register layout. Acked-for-MFD-by: Lee Jones Reviewed-by: Andy Shevchenko Signed-off-by: Aidan MacDonald --- drivers/mfd/axp20x-i2c.c | 2 + drivers/mfd/axp20x.c | 141 +++++++++++++++++++++++++++++++++++++ include/linux/mfd/axp20x.h | 84 ++++++++++++++++++++++ 3 files changed, 227 insertions(+) diff --git a/drivers/mfd/axp20x-i2c.c b/drivers/mfd/axp20x-i2c.c index 8fd6727dc30a..88d816adc69b 100644 --- a/drivers/mfd/axp20x-i2c.c +++ b/drivers/mfd/axp20x-i2c.c @@ -60,6 +60,7 @@ static void axp20x_i2c_remove(struct i2c_client *i2c) #ifdef CONFIG_OF static const struct of_device_id axp20x_i2c_of_match[] = { { .compatible = "x-powers,axp152", .data = (void *)AXP152_ID }, + { .compatible = "x-powers,axp192", .data = (void *)AXP192_ID }, { .compatible = "x-powers,axp202", .data = (void *)AXP202_ID }, { .compatible = "x-powers,axp209", .data = (void *)AXP209_ID }, { .compatible = "x-powers,axp221", .data = (void *)AXP221_ID }, @@ -73,6 +74,7 @@ MODULE_DEVICE_TABLE(of, axp20x_i2c_of_match); static const struct i2c_device_id axp20x_i2c_id[] = { { "axp152", 0 }, + { "axp192", 0 }, { "axp202", 0 }, { "axp209", 0 }, { "axp221", 0 }, diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 88a212a8168c..7d2949209d77 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -34,6 +34,7 @@ static const char * const axp20x_model_names[] = { "AXP152", + "AXP192", "AXP202", "AXP209", "AXP221", @@ -92,6 +93,35 @@ static const struct regmap_access_table axp20x_volatile_table = { .n_yes_ranges = ARRAY_SIZE(axp20x_volatile_ranges), }; +static const struct regmap_range axp192_writeable_ranges[] = { + regmap_reg_range(AXP192_DATACACHE(0), AXP192_DATACACHE(5)), + regmap_reg_range(AXP192_PWR_OUT_CTRL, AXP192_IRQ5_STATE), + regmap_reg_range(AXP20X_DCDC_MODE, AXP192_N_RSTO_CTRL), + regmap_reg_range(AXP20X_CC_CTRL, AXP20X_CC_CTRL), +}; + +static const struct regmap_range axp192_volatile_ranges[] = { + regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP192_USB_OTG_STATUS), + regmap_reg_range(AXP192_IRQ1_STATE, AXP192_IRQ4_STATE), + regmap_reg_range(AXP192_IRQ5_STATE, AXP192_IRQ5_STATE), + regmap_reg_range(AXP20X_ACIN_V_ADC_H, AXP20X_IPSOUT_V_HIGH_L), + regmap_reg_range(AXP20X_TIMER_CTRL, AXP20X_TIMER_CTRL), + regmap_reg_range(AXP192_GPIO2_0_STATE, AXP192_GPIO2_0_STATE), + regmap_reg_range(AXP192_GPIO4_3_STATE, AXP192_GPIO4_3_STATE), + regmap_reg_range(AXP192_N_RSTO_CTRL, AXP192_N_RSTO_CTRL), + regmap_reg_range(AXP20X_CHRG_CC_31_24, AXP20X_CC_CTRL), +}; + +static const struct regmap_access_table axp192_writeable_table = { + .yes_ranges = axp192_writeable_ranges, + .n_yes_ranges = ARRAY_SIZE(axp192_writeable_ranges), +}; + +static const struct regmap_access_table axp192_volatile_table = { + .yes_ranges = axp192_volatile_ranges, + .n_yes_ranges = ARRAY_SIZE(axp192_volatile_ranges), +}; + /* AXP22x ranges are shared with the AXP809, as they cover the same range */ static const struct regmap_range axp22x_writeable_ranges[] = { regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE), @@ -173,6 +203,19 @@ static const struct resource axp152_pek_resources[] = { DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"), }; +static const struct resource axp192_ac_power_supply_resources[] = { + DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"), + DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"), + DEFINE_RES_IRQ_NAMED(AXP192_IRQ_ACIN_OVER_V, "ACIN_OVER_V"), +}; + +static const struct resource axp192_usb_power_supply_resources[] = { + DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"), + DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"), + DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_VALID, "VBUS_VALID"), + DEFINE_RES_IRQ_NAMED(AXP192_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"), +}; + static const struct resource axp20x_ac_power_supply_resources[] = { DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"), DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"), @@ -245,6 +288,15 @@ static const struct regmap_config axp152_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +static const struct regmap_config axp192_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .wr_table = &axp192_writeable_table, + .volatile_table = &axp192_volatile_table, + .max_register = AXP20X_CC_CTRL, + .cache_type = REGCACHE_RBTREE, +}; + static const struct regmap_config axp20x_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -304,6 +356,42 @@ static const struct regmap_irq axp152_regmap_irqs[] = { INIT_REGMAP_IRQ(AXP152, GPIO0_INPUT, 2, 0), }; +static const struct regmap_irq axp192_regmap_irqs[] = { + INIT_REGMAP_IRQ(AXP192, ACIN_OVER_V, 0, 7), + INIT_REGMAP_IRQ(AXP192, ACIN_PLUGIN, 0, 6), + INIT_REGMAP_IRQ(AXP192, ACIN_REMOVAL, 0, 5), + INIT_REGMAP_IRQ(AXP192, VBUS_OVER_V, 0, 4), + INIT_REGMAP_IRQ(AXP192, VBUS_PLUGIN, 0, 3), + INIT_REGMAP_IRQ(AXP192, VBUS_REMOVAL, 0, 2), + INIT_REGMAP_IRQ(AXP192, VBUS_V_LOW, 0, 1), + INIT_REGMAP_IRQ(AXP192, BATT_PLUGIN, 1, 7), + INIT_REGMAP_IRQ(AXP192, BATT_REMOVAL, 1, 6), + INIT_REGMAP_IRQ(AXP192, BATT_ENT_ACT_MODE, 1, 5), + INIT_REGMAP_IRQ(AXP192, BATT_EXIT_ACT_MODE, 1, 4), + INIT_REGMAP_IRQ(AXP192, CHARG, 1, 3), + INIT_REGMAP_IRQ(AXP192, CHARG_DONE, 1, 2), + INIT_REGMAP_IRQ(AXP192, BATT_TEMP_HIGH, 1, 1), + INIT_REGMAP_IRQ(AXP192, BATT_TEMP_LOW, 1, 0), + INIT_REGMAP_IRQ(AXP192, DIE_TEMP_HIGH, 2, 7), + INIT_REGMAP_IRQ(AXP192, CHARG_I_LOW, 2, 6), + INIT_REGMAP_IRQ(AXP192, DCDC1_V_LONG, 2, 5), + INIT_REGMAP_IRQ(AXP192, DCDC2_V_LONG, 2, 4), + INIT_REGMAP_IRQ(AXP192, DCDC3_V_LONG, 2, 3), + INIT_REGMAP_IRQ(AXP192, PEK_SHORT, 2, 1), + INIT_REGMAP_IRQ(AXP192, PEK_LONG, 2, 0), + INIT_REGMAP_IRQ(AXP192, N_OE_PWR_ON, 3, 7), + INIT_REGMAP_IRQ(AXP192, N_OE_PWR_OFF, 3, 6), + INIT_REGMAP_IRQ(AXP192, VBUS_VALID, 3, 5), + INIT_REGMAP_IRQ(AXP192, VBUS_NOT_VALID, 3, 4), + INIT_REGMAP_IRQ(AXP192, VBUS_SESS_VALID, 3, 3), + INIT_REGMAP_IRQ(AXP192, VBUS_SESS_END, 3, 2), + INIT_REGMAP_IRQ(AXP192, LOW_PWR_LVL, 3, 0), + INIT_REGMAP_IRQ(AXP192, TIMER, 4, 7), + INIT_REGMAP_IRQ(AXP192, GPIO2_INPUT, 4, 2), + INIT_REGMAP_IRQ(AXP192, GPIO1_INPUT, 4, 1), + INIT_REGMAP_IRQ(AXP192, GPIO0_INPUT, 4, 0), +}; + static const struct regmap_irq axp20x_regmap_irqs[] = { INIT_REGMAP_IRQ(AXP20X, ACIN_OVER_V, 0, 7), INIT_REGMAP_IRQ(AXP20X, ACIN_PLUGIN, 0, 6), @@ -514,6 +602,32 @@ static const struct regmap_irq_chip axp152_regmap_irq_chip = { .num_regs = 3, }; +static unsigned int axp192_get_irq_reg(struct regmap_irq_chip_data *data, + unsigned int base, int index) +{ + /* linear mapping for IRQ1 to IRQ4 */ + if (index < 4) + return base + index; + + /* handle IRQ5 separately */ + if (base == AXP192_IRQ1_EN) + return AXP192_IRQ5_EN; + + return AXP192_IRQ5_STATE; +} + +static const struct regmap_irq_chip axp192_regmap_irq_chip = { + .name = "axp192_irq_chip", + .status_base = AXP192_IRQ1_STATE, + .ack_base = AXP192_IRQ1_STATE, + .unmask_base = AXP192_IRQ1_EN, + .init_ack_masked = true, + .irqs = axp192_regmap_irqs, + .num_irqs = ARRAY_SIZE(axp192_regmap_irqs), + .num_regs = 5, + .get_irq_reg = axp192_get_irq_reg, +}; + static const struct regmap_irq_chip axp20x_regmap_irq_chip = { .name = "axp20x_irq_chip", .status_base = AXP20X_IRQ1_STATE, @@ -588,6 +702,27 @@ static const struct regmap_irq_chip axp809_regmap_irq_chip = { .num_regs = 5, }; +static const struct mfd_cell axp192_cells[] = { + { + .name = "axp192-adc", + .of_compatible = "x-powers,axp192-adc", + }, { + .name = "axp20x-battery-power-supply", + .of_compatible = "x-powers,axp192-battery-power-supply", + }, { + .name = "axp20x-ac-power-supply", + .of_compatible = "x-powers,axp202-ac-power-supply", + .num_resources = ARRAY_SIZE(axp192_ac_power_supply_resources), + .resources = axp192_ac_power_supply_resources, + }, { + .name = "axp20x-usb-power-supply", + .of_compatible = "x-powers,axp192-usb-power-supply", + .num_resources = ARRAY_SIZE(axp192_usb_power_supply_resources), + .resources = axp192_usb_power_supply_resources, + }, + { .name = "axp20x-regulator" }, +}; + static const struct mfd_cell axp20x_cells[] = { { .name = "axp20x-gpio", @@ -874,6 +1009,12 @@ int axp20x_match_device(struct axp20x_dev *axp20x) axp20x->regmap_cfg = &axp152_regmap_config; axp20x->regmap_irq_chip = &axp152_regmap_irq_chip; break; + case AXP192_ID: + axp20x->nr_cells = ARRAY_SIZE(axp192_cells); + axp20x->cells = axp192_cells; + axp20x->regmap_cfg = &axp192_regmap_config; + axp20x->regmap_irq_chip = &axp192_regmap_irq_chip; + break; case AXP202_ID: case AXP209_ID: axp20x->nr_cells = ARRAY_SIZE(axp20x_cells); diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index 9ab0e2fca7ea..c9a9ee8ec246 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h @@ -12,6 +12,7 @@ enum axp20x_variants { AXP152_ID = 0, + AXP192_ID, AXP202_ID, AXP209_ID, AXP221_ID, @@ -24,6 +25,7 @@ enum axp20x_variants { NR_AXP20X_VARIANTS, }; +#define AXP192_DATACACHE(m) (0x06 + (m)) #define AXP20X_DATACACHE(m) (0x04 + (m)) /* Power supply */ @@ -45,6 +47,13 @@ enum axp20x_variants { #define AXP152_DCDC_FREQ 0x37 #define AXP152_DCDC_MODE 0x80 +#define AXP192_USB_OTG_STATUS 0x04 +#define AXP192_PWR_OUT_CTRL 0x12 +#define AXP192_DCDC2_V_OUT 0x23 +#define AXP192_DCDC1_V_OUT 0x26 +#define AXP192_DCDC3_V_OUT 0x27 +#define AXP192_LDO2_3_V_OUT 0x28 + #define AXP20X_PWR_INPUT_STATUS 0x00 #define AXP20X_PWR_OP_MODE 0x01 #define AXP20X_USB_OTG_STATUS 0x02 @@ -139,6 +148,17 @@ enum axp20x_variants { #define AXP152_IRQ2_STATE 0x49 #define AXP152_IRQ3_STATE 0x4a +#define AXP192_IRQ1_EN 0x40 +#define AXP192_IRQ2_EN 0x41 +#define AXP192_IRQ3_EN 0x42 +#define AXP192_IRQ4_EN 0x43 +#define AXP192_IRQ1_STATE 0x44 +#define AXP192_IRQ2_STATE 0x45 +#define AXP192_IRQ3_STATE 0x46 +#define AXP192_IRQ4_STATE 0x47 +#define AXP192_IRQ5_EN 0x4a +#define AXP192_IRQ5_STATE 0x4d + #define AXP20X_IRQ1_EN 0x40 #define AXP20X_IRQ2_EN 0x41 #define AXP20X_IRQ3_EN 0x42 @@ -153,6 +173,11 @@ enum axp20x_variants { #define AXP20X_IRQ6_STATE 0x4d /* ADC */ +#define AXP192_GPIO2_V_ADC_H 0x68 +#define AXP192_GPIO2_V_ADC_L 0x69 +#define AXP192_GPIO3_V_ADC_H 0x6a +#define AXP192_GPIO3_V_ADC_L 0x6b + #define AXP20X_ACIN_V_ADC_H 0x56 #define AXP20X_ACIN_V_ADC_L 0x57 #define AXP20X_ACIN_I_ADC_H 0x58 @@ -182,6 +207,8 @@ enum axp20x_variants { #define AXP20X_IPSOUT_V_HIGH_L 0x7f /* Power supply */ +#define AXP192_GPIO30_IN_RANGE 0x85 + #define AXP20X_DCDC_MODE 0x80 #define AXP20X_ADC_EN1 0x82 #define AXP20X_ADC_EN2 0x83 @@ -210,6 +237,16 @@ enum axp20x_variants { #define AXP152_PWM1_FREQ_Y 0x9c #define AXP152_PWM1_DUTY_CYCLE 0x9d +#define AXP192_GPIO0_CTRL 0x90 +#define AXP192_LDO_IO0_V_OUT 0x91 +#define AXP192_GPIO1_CTRL 0x92 +#define AXP192_GPIO2_CTRL 0x93 +#define AXP192_GPIO2_0_STATE 0x94 +#define AXP192_GPIO4_3_CTRL 0x95 +#define AXP192_GPIO4_3_STATE 0x96 +#define AXP192_GPIO2_0_PULL 0x97 +#define AXP192_N_RSTO_CTRL 0x9e + #define AXP20X_GPIO0_CTRL 0x90 #define AXP20X_LDO5_V_OUT 0x91 #define AXP20X_GPIO1_CTRL 0x92 @@ -287,6 +324,17 @@ enum axp20x_variants { #define AXP288_FG_TUNE5 0xed /* Regulators IDs */ +enum { + AXP192_DCDC1 = 0, + AXP192_DCDC2, + AXP192_DCDC3, + AXP192_LDO1, + AXP192_LDO2, + AXP192_LDO3, + AXP192_LDO_IO0, + AXP192_REG_ID_MAX +}; + enum { AXP20X_LDO1 = 0, AXP20X_LDO2, @@ -440,6 +488,42 @@ enum { AXP152_IRQ_GPIO0_INPUT, }; +enum axp192_irqs { + AXP192_IRQ_ACIN_OVER_V = 1, + AXP192_IRQ_ACIN_PLUGIN, + AXP192_IRQ_ACIN_REMOVAL, + AXP192_IRQ_VBUS_OVER_V, + AXP192_IRQ_VBUS_PLUGIN, + AXP192_IRQ_VBUS_REMOVAL, + AXP192_IRQ_VBUS_V_LOW, + AXP192_IRQ_BATT_PLUGIN, + AXP192_IRQ_BATT_REMOVAL, + AXP192_IRQ_BATT_ENT_ACT_MODE, + AXP192_IRQ_BATT_EXIT_ACT_MODE, + AXP192_IRQ_CHARG, + AXP192_IRQ_CHARG_DONE, + AXP192_IRQ_BATT_TEMP_HIGH, + AXP192_IRQ_BATT_TEMP_LOW, + AXP192_IRQ_DIE_TEMP_HIGH, + AXP192_IRQ_CHARG_I_LOW, + AXP192_IRQ_DCDC1_V_LONG, + AXP192_IRQ_DCDC2_V_LONG, + AXP192_IRQ_DCDC3_V_LONG, + AXP192_IRQ_PEK_SHORT = 22, + AXP192_IRQ_PEK_LONG, + AXP192_IRQ_N_OE_PWR_ON, + AXP192_IRQ_N_OE_PWR_OFF, + AXP192_IRQ_VBUS_VALID, + AXP192_IRQ_VBUS_NOT_VALID, + AXP192_IRQ_VBUS_SESS_VALID, + AXP192_IRQ_VBUS_SESS_END, + AXP192_IRQ_LOW_PWR_LVL = 31, + AXP192_IRQ_TIMER, + AXP192_IRQ_GPIO2_INPUT = 37, + AXP192_IRQ_GPIO1_INPUT, + AXP192_IRQ_GPIO0_INPUT, +}; + enum { AXP20X_IRQ_ACIN_OVER_V = 1, AXP20X_IRQ_ACIN_PLUGIN, From patchwork Sun Oct 16 23:43:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1193115wrs; Sun, 16 Oct 2022 16:44:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5OL9SMHpp4mNsSXh0qMHsAv+guskvB7v/ykYfcy7P1We2taVhROi8SreFGx/vsutAFhEJy X-Received: by 2002:a17:903:1c6:b0:185:47ce:f4f0 with SMTP id e6-20020a17090301c600b0018547cef4f0mr9352605plh.132.1665963871339; Sun, 16 Oct 2022 16:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963871; cv=none; d=google.com; s=arc-20160816; b=nKdZXblISdV5fhz51RG4hByPJtHRMVMb5S70Uw5g5fwnn76oJfNKA6Hjyk6XnK9QIh KkGLouho0fVsN4CgODh7xWpcLZXQPwwINFBfWiNc2UMvt2LHOEt5c27wAGqad2cHcd+Z mvhhbpq5mbIs+Ehj8OimfIyHjKp948r4AqrvfhdwnjzyvWaP6yC1+qZkPYdM8E9GUge2 8IlizoXAHIsNeJJK9P3+tVa+GnPuSo3a6X8aKI3frs3XI++LtIqECPobu/etsW/lUmOa VJrIGU+S4eBAB894tIdCAl428RDgWxvriq8W/k+/9dZHIVCadzz3fNjLcoefbPq5+2dN FXTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cVesUdRnr++muKO+nw0A5YMx26afNvf+61fP6zkLiKQ=; b=h0noT4iT3VPhRXMsBQCSVgH17FTXxdhPoWMTPEF0hih1fTGMGMaP+eY2syvXAoV0S6 K26pNCiF9ZcsH+ObsrA16LYT8ZdY3hysMhUyqecwa73V0mh+LWvIZT647D2O80ZLeDWq B7qPlUSLzk6lKCQg31fTQuLxov0ltxIBImzyQEkCNC2NwoKARw/yS2gOGcJjfgaaeGDg ZLSceCeCQyYdDkJsay4CGKMMeOVR8+mUa5GkdP1CwaaeabT5nPJvxFaWNLRjxj1FCU2G 7b42ANocFKjWjuHsovdTRFaItiUP2hrQiEY7RByxZTk+BqrxorxilgLiSyivLC7iBJEa Suwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IAugVCKW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t32-20020a634620000000b0045d8554a062si10189310pga.56.2022.10.16.16.44.16; Sun, 16 Oct 2022 16:44:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IAugVCKW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbiJPXmf (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbiJPXm0 (ORCPT ); Sun, 16 Oct 2022 19:42:26 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3990B27170; Sun, 16 Oct 2022 16:42:25 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id u10so16023042wrq.2; Sun, 16 Oct 2022 16:42:25 -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=cVesUdRnr++muKO+nw0A5YMx26afNvf+61fP6zkLiKQ=; b=IAugVCKWS8iu1mYNPo7x624yhvrgIbtP4XXrcNoyhYsWL3fAto3oNqli2TXyB82xk/ cs/poUkH7S4M18Cnc4r1cbLGzuED9ahz8gXJyOyxSGXTYc6aBMhTpvLUcZyLKEgcGSbJ WQ9db97LwXTqDoli21SimAFakj5iYX0AGbydVjJoSHrdk7MfTazxj4wmsrkmR0c0x1p2 oYQEh33SVn/qiTaaFXssYuPo4l6htg/fd0dXcNIn+liiPqb2rYFTjyj21Z+Tn6+dnvev YKznxwc0Sy9i7i0vCVykDNCD6cNi+DcMUBOFlBSJVyBzJkB0ZGUyk0koMUu9pN/aqCM2 KwWA== 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=cVesUdRnr++muKO+nw0A5YMx26afNvf+61fP6zkLiKQ=; b=CceJCXhfrmw3X6S2owhK+XWh6hEYQhT9wgLBPX5nyf8nC6C6pZzZwrvVrXcHix7dK2 t/+CdXOFygG4HCKkQ/1hguQUODPwsSyPs6E8vdnpT0jOV11ELQkIhxb10kqN2wMBXD9O ii3tKzp8Ioq5RRLr82Fmm1GDMnFzaYO7wH+1miOdkO8v5N2WIrxXtlvcGz+68ltOEK+2 qgngVWET/ubxJPysecdiby5OyFGPNLDinVBGF+cENYEp9gyWBK8UHUwmSvcHcwrpPQ+c fFbSzeIThZPk85bEX9wqlUm+oaw5l/I/NHGDyqo2AZ98dpFwNBVaxnfZd7UbLK1Ko7Tv sLxg== X-Gm-Message-State: ACrzQf2k1EBoOi/Ms7Bik9p4s7qHylWwcFxlGS2wx8eK8X0okI8JG9Ef KQGG6pq0ir0KvgiJC5EvVc4= X-Received: by 2002:a5d:660d:0:b0:22e:57b6:ebd with SMTP id n13-20020a5d660d000000b0022e57b60ebdmr4657441wru.674.1665963743632; Sun, 16 Oct 2022 16:42:23 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id g16-20020a05600c311000b003c6237e867esm8788653wmo.0.2022.10.16.16.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:23 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 06/13] regulator: axp20x: Add support for AXP192 Date: Mon, 17 Oct 2022 00:43:28 +0100 Message-Id: <20221016234335.904212-7-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889732776432109?= X-GMAIL-MSGID: =?utf-8?q?1746889732776432109?= Add support for the AXP192 PMIC. Acked-by: Mark Brown Reviewed-by: Andy Shevchenko Signed-off-by: Aidan MacDonald --- drivers/regulator/axp20x-regulator.c | 100 ++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c index d260c442b788..ee79a9ed0249 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c @@ -27,6 +27,29 @@ #include #include +#define AXP192_GPIO0_FUNC_MASK GENMASK(2, 0) + +#define AXP192_IO_ENABLED 0x02 +#define AXP192_IO_DISABLED 0x06 + +#define AXP192_WORKMODE_DCDC1_MASK BIT_MASK(3) +#define AXP192_WORKMODE_DCDC2_MASK BIT_MASK(2) +#define AXP192_WORKMODE_DCDC3_MASK BIT_MASK(1) + +#define AXP192_DCDC1_V_OUT_MASK GENMASK(6, 0) +#define AXP192_DCDC2_V_OUT_MASK GENMASK(5, 0) +#define AXP192_DCDC3_V_OUT_MASK GENMASK(6, 0) +#define AXP192_LDO2_V_OUT_MASK GENMASK(7, 4) +#define AXP192_LDO3_V_OUT_MASK GENMASK(3, 0) +#define AXP192_LDO_IO0_V_OUT_MASK GENMASK(7, 4) + +#define AXP192_PWR_OUT_EXTEN_MASK BIT_MASK(6) +#define AXP192_PWR_OUT_DCDC2_MASK BIT_MASK(4) +#define AXP192_PWR_OUT_LDO3_MASK BIT_MASK(3) +#define AXP192_PWR_OUT_LDO2_MASK BIT_MASK(2) +#define AXP192_PWR_OUT_DCDC3_MASK BIT_MASK(1) +#define AXP192_PWR_OUT_DCDC1_MASK BIT_MASK(0) + #define AXP20X_GPIO0_FUNC_MASK GENMASK(3, 0) #define AXP20X_GPIO1_FUNC_MASK GENMASK(3, 0) @@ -375,25 +398,32 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) switch (axp20x->variant) { case AXP209_ID: - if (id == AXP20X_DCDC2) { + if (id == AXP20X_LDO3) { slew_rates = axp209_dcdc2_ldo3_slew_rates; rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); reg = AXP20X_DCDC2_LDO3_V_RAMP; - mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK | - AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK; + mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK | + AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK; enable = (ramp > 0) ? - AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN : 0; + AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN : 0; break; } - if (id == AXP20X_LDO3) { + fallthrough; + + case AXP192_ID: + /* + * AXP192 and AXP209 share the same DCDC2 ramp configuration + */ + if ((axp20x->variant == AXP209_ID && id == AXP20X_DCDC2) || + (axp20x->variant == AXP192_ID && id == AXP192_DCDC2)) { slew_rates = axp209_dcdc2_ldo3_slew_rates; rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); reg = AXP20X_DCDC2_LDO3_V_RAMP; - mask = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE_MASK | - AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN_MASK; + mask = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE_MASK | + AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN_MASK; enable = (ramp > 0) ? - AXP20X_DCDC2_LDO3_V_RAMP_LDO3_EN : 0; + AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_EN : 0; break; } @@ -415,7 +445,8 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) if (ramp > slew_rates[i]) break; - if (id == AXP20X_DCDC2) + if ((axp20x->variant == AXP209_ID && id == AXP20X_DCDC2) || + (axp20x->variant == AXP192_ID && id == AXP192_DCDC2)) cfg = AXP20X_DCDC2_LDO3_V_RAMP_DCDC2_RATE(i); else cfg = AXP20X_DCDC2_LDO3_V_RAMP_LDO3_RATE(i); @@ -511,6 +542,29 @@ static const struct regulator_ops axp20x_ops_sw = { .is_enabled = regulator_is_enabled_regmap, }; +static const struct regulator_desc axp192_regulators[] = { + AXP_DESC(AXP192, DCDC1, "dcdc1", "vin1", 700, 3500, 25, + AXP192_DCDC1_V_OUT, AXP192_DCDC1_V_OUT_MASK, + AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_DCDC1_MASK), + AXP_DESC(AXP192, DCDC2, "dcdc2", "vin2", 700, 2275, 25, + AXP192_DCDC2_V_OUT, AXP192_DCDC2_V_OUT_MASK, + AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_DCDC2_MASK), + AXP_DESC(AXP192, DCDC3, "dcdc3", "vin3", 700, 3500, 25, + AXP192_DCDC3_V_OUT, AXP192_DCDC3_V_OUT_MASK, + AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_DCDC3_MASK), + AXP_DESC_FIXED(AXP192, LDO1, "ldo1", "acin", 1250), + AXP_DESC(AXP192, LDO2, "ldo2", "ldoin", 1800, 3300, 100, + AXP192_LDO2_3_V_OUT, AXP192_LDO2_V_OUT_MASK, + AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_LDO2_MASK), + AXP_DESC(AXP192, LDO3, "ldo3", "ldoin", 1800, 3300, 100, + AXP192_LDO2_3_V_OUT, AXP192_LDO3_V_OUT_MASK, + AXP192_PWR_OUT_CTRL, AXP192_PWR_OUT_LDO3_MASK), + AXP_DESC_IO(AXP192, LDO_IO0, "ldo_io0", "ips", 700, 3300, 100, + AXP192_LDO_IO0_V_OUT, AXP192_LDO_IO0_V_OUT_MASK, + AXP192_GPIO0_CTRL, AXP192_GPIO0_FUNC_MASK, + AXP192_IO_ENABLED, AXP192_IO_DISABLED), +}; + static const struct linear_range axp20x_ldo4_ranges[] = { REGULATOR_LINEAR_RANGE(1250000, AXP20X_LDO4_V_OUT_1250mV_START, @@ -1008,6 +1062,12 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) u32 min, max, def, step; switch (axp20x->variant) { + case AXP192_ID: + min = 900; + max = 2025; + def = 1500; + step = 75; + break; case AXP202_ID: case AXP209_ID: min = 750; @@ -1100,6 +1160,24 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work unsigned int mask; switch (axp20x->variant) { + case AXP192_ID: + switch (id) { + case AXP192_DCDC1: + mask = AXP192_WORKMODE_DCDC1_MASK; + break; + case AXP192_DCDC2: + mask = AXP192_WORKMODE_DCDC2_MASK; + break; + case AXP192_DCDC3: + mask = AXP192_WORKMODE_DCDC3_MASK; + break; + default: + return -EINVAL; + } + + workmode <<= ffs(mask) - 1; + break; + case AXP202_ID: case AXP209_ID: if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3)) @@ -1220,6 +1298,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev) bool drivevbus = false; switch (axp20x->variant) { + case AXP192_ID: + regulators = axp192_regulators; + nregulators = AXP192_REG_ID_MAX; + break; case AXP202_ID: case AXP209_ID: regulators = axp20x_regulators; From patchwork Sun Oct 16 23:43:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1192922wrs; Sun, 16 Oct 2022 16:43:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Z5rwCWH6Rk+snI7u9j7Ur5X2qpxvNjGOGma9cGwRO7kiPTEzuEa71TOmeTgAyDSbIEth7 X-Received: by 2002:a17:90b:1c06:b0:20a:f070:9f3c with SMTP id oc6-20020a17090b1c0600b0020af0709f3cmr10611997pjb.151.1665963818890; Sun, 16 Oct 2022 16:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963818; cv=none; d=google.com; s=arc-20160816; b=EPPkmXhKcnbBfVh4zCxKlhA2X2d7UM8V6erXWy6ZOrdDLlZogmvWXpwfepnKhWFQjz HAJX+88b8izuibTAczHDWIz4PM3bZefvDn20CALcfx32iFHf4RidsjNAJ8SR1lC/RArf ZnJ9k/QsctI2Cjn7ZQ+bW5BYljn9nPO4y1j2YOtysjXTL8g65nnStKpYc0XqxKjXMyj3 QOYHXoL8Dh7iBEro1VOdt6sSaPzl3c5i4ohKyG80oksUzVCxHvt6EfgxfP7ik9e+ASsr ImN3q+33Y+IZEPXTdR3gXrB8iMtpBL/4P18oGuv81ZZ7kVPfhYjfdx8JUK7V10s0etF/ ZNtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iLzGYWDmP7UYu1QNx5f+Qbth2SePhNiLrOaMsgn1dzA=; b=Brl2l9Z4Q+Jdp2rFMHuaXOL716Q/C0sJe6s0y+Aybcq3q9Bg1d/dxodxxcp69iePCH xpVjP2g1UPeyiNHCoBYsYgAAQdhcKIKDj6XbBpd7XYubwSo0pws7zpYeMz2lCOXvMy6Q zUPUO1BszUW3GmBaFr7GeVlT+Pwm+ZatrW/uIXX/FI2iRTdRoXwWkiRrYUL1am9yWGQ9 OfCAlol3Muc4+7DDNe6+0wtsCRwvqazv8FhxU1NbGk20hFqK3XEeNbLGnI+8cL1Q1G6z Lgk1c9YDS8bGNwZ2UfC9iKlHvbE0+xuPa+PJk9NrdbtGNWRHy0WnDzJzz8L8+BPOO4iZ S1gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MZmeAAI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g63-20020a636b42000000b0046004f18c6csi9862448pgc.456.2022.10.16.16.43.26; Sun, 16 Oct 2022 16:43:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MZmeAAI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbiJPXmv (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbiJPXma (ORCPT ); Sun, 16 Oct 2022 19:42:30 -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 E87F127150; Sun, 16 Oct 2022 16:42:26 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id w18so15994112wro.7; Sun, 16 Oct 2022 16:42:26 -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=iLzGYWDmP7UYu1QNx5f+Qbth2SePhNiLrOaMsgn1dzA=; b=MZmeAAI6Ahc5u0nPigQy5ddDWdsm7rcBJ8PnwV2YGDnAkxU9KkxHnHWqD5166cOiVu 4eWTXWqQ/bx4S332HPEpUC7Lk4klRm5C9C4vUw8pa+l0OMd/C61x08nAq0C18Ndpc7Cd pF/lqXTWnCJmAZWS/PqvTJ81jHqvv/Jm7PkFM04QPaonNfZtGopr+sJHZdqWg6j1hItt KDsOJBVkIPa7BgV+ao9eWp4XKa+IKWBj+Y8Iou+MVEcrisgf8aDOSnEpXNIU/bu4LB+l 47D0OxMirl4uzr7iPDJQC3E6LIRyi2Bkq/b7Ky/tJasiR0z+zQgyH0KLbSs0MDedPbi9 j0bA== 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=iLzGYWDmP7UYu1QNx5f+Qbth2SePhNiLrOaMsgn1dzA=; b=HVvuKuCQn9y/LkvV3LCjdFQJbcY1gJtzHq7fNKNAlni9ONwqwMwUltLnawtKZ0sekL AD36aoIXrW5vBvWlce23/JH6NTkn6G4OXPEBp8zZ+D3IO4+spQ1m8VqZpLUSJzkTtaev H+/KcR7PP3/cIawUnGJZunIt6izjKHlVNiZYHgzfR+skqvYx70sHvCDiL3yiDa38rnwO U7oKa1xVxft5GEAYQTSBJ5uybeMWQA4xlV5jF74L6nfu/EpRN8X97pNMUxX6iK2svQur y85Ef1MRHQ+a5Hh61WzLhPQBR+3AoTGV6RZsXUdJm32yGCbNSNzEa5dDDmpRzxvmfYn5 2kuw== X-Gm-Message-State: ACrzQf1GgcbZiIkiNw7WqLKURttPXFWAUxYORaD2lemqd+MHT21cFxWZ Q+4O0/9JAo3MbyFyGiw7Ego= X-Received: by 2002:a5d:530b:0:b0:22e:3e8c:45aa with SMTP id e11-20020a5d530b000000b0022e3e8c45aamr4886492wrv.321.1665963745079; Sun, 16 Oct 2022 16:42:25 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id l15-20020a05600c4f0f00b003c6cc57566fsm13008690wmq.14.2022.10.16.16.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:24 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron Subject: [PATCH v6 07/13] iio: adc: axp20x_adc: Minor code cleanups Date: Mon, 17 Oct 2022 00:43:29 +0100 Message-Id: <20221016234335.904212-8-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889677339682143?= X-GMAIL-MSGID: =?utf-8?q?1746889677339682143?= The code may be clearer if parameters are not re-purposed to hold temporary results like register values, so introduce local variables as necessary to avoid that. Regroup macros based on chip type, and use the FIELD_PREP() macro instead of a hand-rolled version. Suggested-by: Jonathan Cameron Reviewed-by: Chen-Yu Tsai Reviewed-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Signed-off-by: Aidan MacDonald --- drivers/iio/adc/axp20x_adc.c | 61 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c index 53bf7d4899d2..ab25e6e1ff65 100644 --- a/drivers/iio/adc/axp20x_adc.c +++ b/drivers/iio/adc/axp20x_adc.c @@ -5,6 +5,7 @@ * Quentin Schulz */ +#include #include #include #include @@ -22,20 +23,20 @@ #include #define AXP20X_ADC_EN1_MASK GENMASK(7, 0) - #define AXP20X_ADC_EN2_MASK (GENMASK(3, 2) | BIT(7)) + #define AXP22X_ADC_EN1_MASK (GENMASK(7, 5) | BIT(0)) #define AXP20X_GPIO10_IN_RANGE_GPIO0 BIT(0) #define AXP20X_GPIO10_IN_RANGE_GPIO1 BIT(1) -#define AXP20X_GPIO10_IN_RANGE_GPIO0_VAL(x) ((x) & BIT(0)) -#define AXP20X_GPIO10_IN_RANGE_GPIO1_VAL(x) (((x) & BIT(0)) << 1) #define AXP20X_ADC_RATE_MASK GENMASK(7, 6) -#define AXP813_V_I_ADC_RATE_MASK GENMASK(5, 4) -#define AXP813_ADC_RATE_MASK (AXP20X_ADC_RATE_MASK | AXP813_V_I_ADC_RATE_MASK) #define AXP20X_ADC_RATE_HZ(x) ((ilog2((x) / 25) << 6) & AXP20X_ADC_RATE_MASK) + #define AXP22X_ADC_RATE_HZ(x) ((ilog2((x) / 100) << 6) & AXP20X_ADC_RATE_MASK) + +#define AXP813_V_I_ADC_RATE_MASK GENMASK(5, 4) +#define AXP813_ADC_RATE_MASK (AXP20X_ADC_RATE_MASK | AXP813_V_I_ADC_RATE_MASK) #define AXP813_TS_GPIO0_ADC_RATE_HZ(x) AXP20X_ADC_RATE_HZ(x) #define AXP813_V_I_ADC_RATE_HZ(x) ((ilog2((x) / 100) << 4) & AXP813_V_I_ADC_RATE_MASK) #define AXP813_ADC_RATE_HZ(x) (AXP20X_ADC_RATE_HZ(x) | AXP813_V_I_ADC_RATE_HZ(x)) @@ -234,7 +235,7 @@ static int axp20x_adc_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val) { struct axp20x_adc_iio *info = iio_priv(indio_dev); - int size = 12; + int ret, size; /* * N.B.: Unlike the Chinese datasheets tell, the charging current is @@ -246,10 +247,11 @@ static int axp20x_adc_raw(struct iio_dev *indio_dev, else size = 12; - *val = axp20x_read_variable_width(info->regmap, chan->address, size); - if (*val < 0) - return *val; + ret = axp20x_read_variable_width(info->regmap, chan->address, size); + if (ret < 0) + return ret; + *val = ret; return IIO_VAL_INT; } @@ -257,11 +259,13 @@ static int axp22x_adc_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val) { struct axp20x_adc_iio *info = iio_priv(indio_dev); + int ret; - *val = axp20x_read_variable_width(info->regmap, chan->address, 12); - if (*val < 0) - return *val; + ret = axp20x_read_variable_width(info->regmap, chan->address, 12); + if (ret < 0) + return ret; + *val = ret; return IIO_VAL_INT; } @@ -269,11 +273,13 @@ static int axp813_adc_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val) { struct axp20x_adc_iio *info = iio_priv(indio_dev); + int ret; - *val = axp20x_read_variable_width(info->regmap, chan->address, 12); - if (*val < 0) - return *val; + ret = axp20x_read_variable_width(info->regmap, chan->address, 12); + if (ret < 0) + return ret; + *val = ret; return IIO_VAL_INT; } @@ -443,27 +449,27 @@ static int axp20x_adc_offset_voltage(struct iio_dev *indio_dev, int channel, int *val) { struct axp20x_adc_iio *info = iio_priv(indio_dev); + unsigned int regval; int ret; - ret = regmap_read(info->regmap, AXP20X_GPIO10_IN_RANGE, val); + ret = regmap_read(info->regmap, AXP20X_GPIO10_IN_RANGE, ®val); if (ret < 0) return ret; switch (channel) { case AXP20X_GPIO0_V: - *val &= AXP20X_GPIO10_IN_RANGE_GPIO0; + regval = FIELD_GET(AXP20X_GPIO10_IN_RANGE_GPIO0, regval); break; case AXP20X_GPIO1_V: - *val &= AXP20X_GPIO10_IN_RANGE_GPIO1; + regval = FIELD_GET(AXP20X_GPIO10_IN_RANGE_GPIO1, regval); break; default: return -EINVAL; } - *val = *val ? 700000 : 0; - + *val = regval ? 700000 : 0; return IIO_VAL_INT; } @@ -548,7 +554,7 @@ static int axp20x_write_raw(struct iio_dev *indio_dev, long mask) { struct axp20x_adc_iio *info = iio_priv(indio_dev); - unsigned int reg, regval; + unsigned int regmask, regval; /* * The AXP20X PMIC allows the user to choose between 0V and 0.7V offsets @@ -560,25 +566,22 @@ static int axp20x_write_raw(struct iio_dev *indio_dev, if (val != 0 && val != 700000) return -EINVAL; - val = val ? 1 : 0; - switch (chan->channel) { case AXP20X_GPIO0_V: - reg = AXP20X_GPIO10_IN_RANGE_GPIO0; - regval = AXP20X_GPIO10_IN_RANGE_GPIO0_VAL(val); + regmask = AXP20X_GPIO10_IN_RANGE_GPIO0; + regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO0, !!val); break; case AXP20X_GPIO1_V: - reg = AXP20X_GPIO10_IN_RANGE_GPIO1; - regval = AXP20X_GPIO10_IN_RANGE_GPIO1_VAL(val); + regmask = AXP20X_GPIO10_IN_RANGE_GPIO1; + regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO1, !!val); break; default: return -EINVAL; } - return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, reg, - regval); + return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, regmask, regval); } static const struct iio_info axp20x_adc_iio_info = { From patchwork Sun Oct 16 23:43:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1192937wrs; Sun, 16 Oct 2022 16:43:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+rAJdMRpHMFgjyIeggEpPJkKBbrAJnHOdAoR8zTBgLGexG7eXEOz2EFdS8PtPYMzLFJeZ X-Received: by 2002:a17:903:2441:b0:178:4f51:1f78 with SMTP id l1-20020a170903244100b001784f511f78mr8771285pls.82.1665963823395; Sun, 16 Oct 2022 16:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963823; cv=none; d=google.com; s=arc-20160816; b=c/OJTxrZG/2LEGEWv0mWpBr32TvMtp8+qNVTPCJdQ6qhTjLbULnsQOpRRIDIeyrVDw UJWgsKCIiqXnW66ugGe6vPvACdjqhNplkdj5lE6VODWoErBMLlnVbOU1Za/KiCwlL0Uo efV6KggSC0jJJrbTQaFgbW6LRIKSckwbE2xIquM3PNRjRZvZWWQFY31j14ktReo803+L Qg8JsECHw8D3KFSMDnKRCE9wL2eN6lszJZZqQohxrPUMa7cif7oroHsqqq13zeitU9MK wtpRZa4bbczZdQIKfXFbWYsTkbcOrCGTMQMh8ZzzNPtXp15CSGE7ERTDpyThTCauzcLn eoUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9iQ42DvT7kTgetW5TS8dmSiYkpUS6xNSvrMGj0peFw8=; b=njiJCpm5w7z3N7G5CI1rITyqi1uSqI6rssf2rQP09p9YneJ5qF47/lt9jCYRheGlEm xm6RdXXzi6gHJ1nYPEKvtm0+SK5m6rB196ZhWf67cC4Ya3UiSIoYA5Ba5sbEKrH+6rBQ 2uHxnAvqWebChPmGngcQmYGhHpSBYVKlhVEYki8I5yeQuAfjQzHAtzguviInBtcOl+TE BEr05cBdAxEeor86lYIC2xlfCmovK5VD+Sj0JiW2Iw4kllwfUxXAAbop3ibSrEYhPRc+ aUH/HieuahP5rw1ejkE7Rqupks9Vt6o+KAyRC6EBJL5Vx5pq+AAYtX2WWBQTmXSV/fUr tNnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o2Qhxs69; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a63930c000000b0042bc6e8d3f7si10258601pge.642.2022.10.16.16.43.31; Sun, 16 Oct 2022 16:43:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o2Qhxs69; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbiJPXms (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbiJPXma (ORCPT ); Sun, 16 Oct 2022 19:42:30 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8BBE27CFD; Sun, 16 Oct 2022 16:42:26 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id j16so16017098wrh.5; Sun, 16 Oct 2022 16:42:26 -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=9iQ42DvT7kTgetW5TS8dmSiYkpUS6xNSvrMGj0peFw8=; b=o2Qhxs69zm3BrTRBcSq0mgrrFPeS3SQwliVPzpHd97HNYWLvDMxJpdDSpOvb1Fy4ye nA/qOVrkWItaVL3PUdKgaRv9Ag3hQnZuusaA/+tO22hW2AlctKoZhJTi7XPkx0qbuW8T AGj640QhXYm0ZkV+17VFia8V6rHjM33bpOjGq0z/wRdf05n4ziC6SbX8EgeZkaBUNRXW vP5BVPrqGF407P5Fgochq0+HyIp/nZ9QqeNbCapziCpXJC551p+BP8D7tjg8X1xzTlhn hvKL6hqTyb4p/X73JclOclG/WhPthJcvnb5viPAniFUuaVnyzVyHF87zC3GYdOjKpnUg CoLg== 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=9iQ42DvT7kTgetW5TS8dmSiYkpUS6xNSvrMGj0peFw8=; b=iIeWHo++uYtWytgvRPVFv4oNW1Q5T9+jzp3ErSwYtHxR48AWsVqPCt7l7064VrfEY6 ey+lgzO6NrXZ+buWMf2LLi4iCgWfE/C7l70MF51shbeImOXhcgMy35Y0uZNztnlD2jBD EKor56wgXbJrxqgTBwqG7tESCl/XCtJjTHJPhyBiNv0bp7rEoYWuALjzcq1jCs/BBWBF I4u1nhsaqvjuMLnix+UTHqT/JYEKXG9VhoZgVw1ZhmC+eBTFIYYPztc3MJJdoPmewEj2 9e6W8aU6mKZzQH+SwUiGW6bZ0xkxaf/spL+WkrXq2CzFEMGkp7JBd0nBSdhMy+PZAZiH iUtg== X-Gm-Message-State: ACrzQf2GRTlX7446y9vDfFhpmOlp2jLM6aSaP0d+ZY4JUonZkTOd4Rby ujhG4o3V0YkJHes14MtIeLI= X-Received: by 2002:a5d:4d07:0:b0:22e:3c45:9f00 with SMTP id z7-20020a5d4d07000000b0022e3c459f00mr4573014wrt.646.1665963746468; Sun, 16 Oct 2022 16:42:26 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id f7-20020a1cc907000000b003b31c560a0csm8397203wmb.12.2022.10.16.16.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:26 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron Subject: [PATCH v6 08/13] iio: adc: axp20x_adc: Replace adc_en2 flag with adc_en2_mask field Date: Mon, 17 Oct 2022 00:43:30 +0100 Message-Id: <20221016234335.904212-9-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889681941678976?= X-GMAIL-MSGID: =?utf-8?q?1746889681941678976?= The adc_en2 flag is essentially specific to axp20x-compatible devices because it hardcodes register values. Replace it with a mask field so the register value can be specified in device match data. Reviewed-by: Andy Shevchenko Reviewed-by: Jonathan Cameron Signed-off-by: Aidan MacDonald --- drivers/iio/adc/axp20x_adc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c index ab25e6e1ff65..75bda94dbce1 100644 --- a/drivers/iio/adc/axp20x_adc.c +++ b/drivers/iio/adc/axp20x_adc.c @@ -623,9 +623,9 @@ struct axp_data { int num_channels; struct iio_chan_spec const *channels; unsigned long adc_en1_mask; + unsigned long adc_en2_mask; int (*adc_rate)(struct axp20x_adc_iio *info, int rate); - bool adc_en2; struct iio_map *maps; }; @@ -634,8 +634,8 @@ static const struct axp_data axp20x_data = { .num_channels = ARRAY_SIZE(axp20x_adc_channels), .channels = axp20x_adc_channels, .adc_en1_mask = AXP20X_ADC_EN1_MASK, + .adc_en2_mask = AXP20X_ADC_EN2_MASK, .adc_rate = axp20x_adc_rate, - .adc_en2 = true, .maps = axp20x_maps, }; @@ -645,7 +645,6 @@ static const struct axp_data axp22x_data = { .channels = axp22x_adc_channels, .adc_en1_mask = AXP22X_ADC_EN1_MASK, .adc_rate = axp22x_adc_rate, - .adc_en2 = false, .maps = axp22x_maps, }; @@ -655,7 +654,6 @@ static const struct axp_data axp813_data = { .channels = axp813_adc_channels, .adc_en1_mask = AXP22X_ADC_EN1_MASK, .adc_rate = axp813_adc_rate, - .adc_en2 = false, .maps = axp22x_maps, }; @@ -713,10 +711,10 @@ static int axp20x_probe(struct platform_device *pdev) /* Enable the ADCs on IP */ regmap_write(info->regmap, AXP20X_ADC_EN1, info->data->adc_en1_mask); - if (info->data->adc_en2) - /* Enable GPIO0/1 and internal temperature ADCs */ + if (info->data->adc_en2_mask) regmap_update_bits(info->regmap, AXP20X_ADC_EN2, - AXP20X_ADC_EN2_MASK, AXP20X_ADC_EN2_MASK); + info->data->adc_en2_mask, + info->data->adc_en2_mask); /* Configure ADCs rate */ info->data->adc_rate(info, 100); @@ -741,7 +739,7 @@ static int axp20x_probe(struct platform_device *pdev) fail_map: regmap_write(info->regmap, AXP20X_ADC_EN1, 0); - if (info->data->adc_en2) + if (info->data->adc_en2_mask) regmap_write(info->regmap, AXP20X_ADC_EN2, 0); return ret; @@ -757,7 +755,7 @@ static int axp20x_remove(struct platform_device *pdev) regmap_write(info->regmap, AXP20X_ADC_EN1, 0); - if (info->data->adc_en2) + if (info->data->adc_en2_mask) regmap_write(info->regmap, AXP20X_ADC_EN2, 0); return 0; From patchwork Sun Oct 16 23:43:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1193033wrs; Sun, 16 Oct 2022 16:44:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5xesEvRYF+YbPN+L/ZW2gqQEQvTiwU52+fsGn/pkFg5XViW5CX6K+ehTbdRHm2xU3Oq2cb X-Received: by 2002:a63:2ac9:0:b0:457:24a2:6fa7 with SMTP id q192-20020a632ac9000000b0045724a26fa7mr8033626pgq.484.1665963850274; Sun, 16 Oct 2022 16:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963850; cv=none; d=google.com; s=arc-20160816; b=Y/1U+OB49zAV21SGTPkIdYmI0U6JN9bPhHmxUAHbXMqmYBzCC1O7JXsNUn7W3dYQg2 wyYon9fExyRSF1eEeHZzCq5JstajD8O+AyhE3vKmAjYvFZEYGdJxVpFGY8LXmdhdmN+j p5YFbVhy1zaesEoR7QO0YnO9gX1PRFVLYvmsad6ToOypgbJpOOrVtHFg1sJbPoKZgelJ KEoFrrbx7GICG3bzBvojybfDzXnrULczGupTFlb/c0sgA0Wra0XDBWtnnWvdd5tX7l3z zBh+oNLbbla+3bPdW7fwIpQDDvI4z07uq1S36AA3HptuH9w6nZR+6F8I1nAF//pZdPpp pu5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZVDsQVUoXvmNA77LPJOpJward80S9xfbJHcpTm+nB6k=; b=oocGAShr3H8bm1wsyuIS8cpTf1d7G8lWVaw0zG3tOCMxFm8Oqa5a9DHvBGORGXihs3 tGXUKL+XpxvV6btuMQXkAGxn84Vi6X68mwN3j1opAsXMxUq3GuxxHygMwujUp+G2JyQL fTzIj+phYHBiB7jcy3YcEP0V27SVoXRWPajO+4VcofR9vxARDu0jm0lLYHksukcQozIO YxHpffTIaIpsTvxtAO32LKMS6PN1CzmCE8CwmRMtt9rzFJJvqjp1mrh8X9QDCJ9PhsAw m1Y1Q18O4PP26sfSBYRIgcdj3A0vbLBXa6ZVWz9OtkClHoUOK+Saa9q2Dca4xXjtqyvo +tng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LdxhTUGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a634f05000000b0046b173cdb6esi10666934pgb.352.2022.10.16.16.43.53; Sun, 16 Oct 2022 16:44:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LdxhTUGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbiJPXm7 (ORCPT + 99 others); Sun, 16 Oct 2022 19:42:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230012AbiJPXms (ORCPT ); Sun, 16 Oct 2022 19:42:48 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 407CB27926; Sun, 16 Oct 2022 16:42:29 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id r3-20020a05600c35c300b003b4b5f6c6bdso8796039wmq.2; Sun, 16 Oct 2022 16:42: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=ZVDsQVUoXvmNA77LPJOpJward80S9xfbJHcpTm+nB6k=; b=LdxhTUGv6G/jlHfDy9pL7GUcaGdHPUeipIafb3dmrWm7Y2wyMQRFqvBwtKK8Ji6cpY nl045tPCGMpLFcHbwnuokGlpuAejRaoqnZR2dGu9dIrS4t8jeNUygscvUE7DifymeyZe hMnqIT1rM60SORrNdgs/vu/XYFFQpGzrG+cHVviow0qbo/M2G3fEYMB+lSDZrhsMmz4H Uc6S3RFfqz1s0Gj/P4otHikC7+SCcqdESEq7Da+JprHXigiMLPwsCI8OxsoF1rcAswuY Tr78r4C5/wag+SZSy2MCcAZ0cqDKRSHx+YQbA0IQt1PTnIBb0Ee/csk0+dqAoIbGFqRi X6EQ== 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=ZVDsQVUoXvmNA77LPJOpJward80S9xfbJHcpTm+nB6k=; b=FoEcxfzYIakofNr6lxferrHQ2eoMl6edYTaZVm0rDlS1heiOk0jpYWPQkrg6nhljlf efvg2lPh0QwTusTTC1Cfi2jHH8K/+/EeEGVM7GCT7RdImEgiNsgY6sEZ2Vut0wKSqOCS H6CW/ZEGtri/mABGBHkq+FfKY/SWvgsm0SCAHRTgZ03l55rF7UkFCdILmGxmobeATvwh vg76o05sOr1UnAUm4DZ5hlg/Rxh2rYPluCS/unihLF0W1SgLowFdEb+LbVavxumrem0a aZYhrQzHWY9syG/jUBrCQOIJhQAawz6fFI72T+OlK7HlCAIdk8QcDjJdc7vwSco3tf5J FpXg== X-Gm-Message-State: ACrzQf0rHbUhLtMbTUi2S0AetKDFQYn8AU7nNs8qsdsrc4uJWG269L56 1/BGSvgFVgU8Bp69HV1xpWY= X-Received: by 2002:a1c:f60d:0:b0:3be:708b:c96c with SMTP id w13-20020a1cf60d000000b003be708bc96cmr17752477wmc.168.1665963747975; Sun, 16 Oct 2022 16:42:27 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id p14-20020a05600c468e00b003c6f3e5ba42sm3442346wmo.46.2022.10.16.16.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:27 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron Subject: [PATCH v6 09/13] iio: adc: axp20x_adc: Add support for AXP192 Date: Mon, 17 Oct 2022 00:43:31 +0100 Message-Id: <20221016234335.904212-10-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889710684653273?= X-GMAIL-MSGID: =?utf-8?q?1746889710684653273?= The AXP192 is identical to the AXP20x, except for the addition of two more GPIO ADC channels. Reviewed-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Signed-off-by: Aidan MacDonald --- drivers/iio/adc/axp20x_adc.c | 279 +++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c index 75bda94dbce1..8d748b814f20 100644 --- a/drivers/iio/adc/axp20x_adc.c +++ b/drivers/iio/adc/axp20x_adc.c @@ -22,11 +22,19 @@ #include #include +#define AXP192_ADC_EN1_MASK GENMASK(7, 0) +#define AXP192_ADC_EN2_MASK (GENMASK(3, 0) | BIT(7)) + #define AXP20X_ADC_EN1_MASK GENMASK(7, 0) #define AXP20X_ADC_EN2_MASK (GENMASK(3, 2) | BIT(7)) #define AXP22X_ADC_EN1_MASK (GENMASK(7, 5) | BIT(0)) +#define AXP192_GPIO30_IN_RANGE_GPIO0 BIT(0) +#define AXP192_GPIO30_IN_RANGE_GPIO1 BIT(1) +#define AXP192_GPIO30_IN_RANGE_GPIO2 BIT(2) +#define AXP192_GPIO30_IN_RANGE_GPIO3 BIT(3) + #define AXP20X_GPIO10_IN_RANGE_GPIO0 BIT(0) #define AXP20X_GPIO10_IN_RANGE_GPIO1 BIT(1) @@ -71,6 +79,25 @@ struct axp20x_adc_iio { const struct axp_data *data; }; +enum axp192_adc_channel_v { + AXP192_ACIN_V = 0, + AXP192_VBUS_V, + AXP192_TS_IN, + AXP192_GPIO0_V, + AXP192_GPIO1_V, + AXP192_GPIO2_V, + AXP192_GPIO3_V, + AXP192_IPSOUT_V, + AXP192_BATT_V, +}; + +enum axp192_adc_channel_i { + AXP192_ACIN_I = 0, + AXP192_VBUS_I, + AXP192_BATT_CHRG_I, + AXP192_BATT_DISCHRG_I, +}; + enum axp20x_adc_channel_v { AXP20X_ACIN_V = 0, AXP20X_VBUS_V, @@ -158,6 +185,43 @@ static struct iio_map axp22x_maps[] = { * The only exception is for the battery. batt_v will be in_voltage6_raw and * charge current in_current6_raw and discharge current will be in_current7_raw. */ +static const struct iio_chan_spec axp192_adc_channels[] = { + AXP20X_ADC_CHANNEL(AXP192_ACIN_V, "acin_v", IIO_VOLTAGE, + AXP20X_ACIN_V_ADC_H), + AXP20X_ADC_CHANNEL(AXP192_ACIN_I, "acin_i", IIO_CURRENT, + AXP20X_ACIN_I_ADC_H), + AXP20X_ADC_CHANNEL(AXP192_VBUS_V, "vbus_v", IIO_VOLTAGE, + AXP20X_VBUS_V_ADC_H), + AXP20X_ADC_CHANNEL(AXP192_VBUS_I, "vbus_i", IIO_CURRENT, + AXP20X_VBUS_I_ADC_H), + { + .type = IIO_TEMP, + .address = AXP20X_TEMP_ADC_H, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_OFFSET), + .datasheet_name = "pmic_temp", + }, + AXP20X_ADC_CHANNEL_OFFSET(AXP192_GPIO0_V, "gpio0_v", IIO_VOLTAGE, + AXP20X_GPIO0_V_ADC_H), + AXP20X_ADC_CHANNEL_OFFSET(AXP192_GPIO1_V, "gpio1_v", IIO_VOLTAGE, + AXP20X_GPIO1_V_ADC_H), + AXP20X_ADC_CHANNEL_OFFSET(AXP192_GPIO2_V, "gpio2_v", IIO_VOLTAGE, + AXP192_GPIO2_V_ADC_H), + AXP20X_ADC_CHANNEL_OFFSET(AXP192_GPIO3_V, "gpio3_v", IIO_VOLTAGE, + AXP192_GPIO3_V_ADC_H), + AXP20X_ADC_CHANNEL(AXP192_IPSOUT_V, "ipsout_v", IIO_VOLTAGE, + AXP20X_IPSOUT_V_HIGH_H), + AXP20X_ADC_CHANNEL(AXP192_BATT_V, "batt_v", IIO_VOLTAGE, + AXP20X_BATT_V_H), + AXP20X_ADC_CHANNEL(AXP192_BATT_CHRG_I, "batt_chrg_i", IIO_CURRENT, + AXP20X_BATT_CHRG_I_H), + AXP20X_ADC_CHANNEL(AXP192_BATT_DISCHRG_I, "batt_dischrg_i", IIO_CURRENT, + AXP20X_BATT_DISCHRG_I_H), + AXP20X_ADC_CHANNEL(AXP192_TS_IN, "ts_v", IIO_VOLTAGE, + AXP20X_TS_IN_H), +}; + static const struct iio_chan_spec axp20x_adc_channels[] = { AXP20X_ADC_CHANNEL(AXP20X_ACIN_V, "acin_v", IIO_VOLTAGE, AXP20X_ACIN_V_ADC_H), @@ -231,6 +295,27 @@ static const struct iio_chan_spec axp813_adc_channels[] = { AXP288_TS_ADC_H), }; +static int axp192_adc_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val) +{ + struct axp20x_adc_iio *info = iio_priv(indio_dev); + int ret, size; + + if (chan->type == IIO_CURRENT && + (chan->channel == AXP192_BATT_CHRG_I || + chan->channel == AXP192_BATT_DISCHRG_I)) + size = 13; + else + size = 12; + + ret = axp20x_read_variable_width(info->regmap, chan->address, size); + if (ret < 0) + return ret; + + *val = ret; + return IIO_VAL_INT; +} + static int axp20x_adc_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val) { @@ -283,6 +368,44 @@ static int axp813_adc_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; } +static int axp192_adc_scale_voltage(int channel, int *val, int *val2) +{ + switch (channel) { + case AXP192_ACIN_V: + case AXP192_VBUS_V: + *val = 1; + *val2 = 700000; + return IIO_VAL_INT_PLUS_MICRO; + + case AXP192_GPIO0_V: + case AXP192_GPIO1_V: + case AXP192_GPIO2_V: + case AXP192_GPIO3_V: + *val = 0; + *val2 = 500000; + return IIO_VAL_INT_PLUS_MICRO; + + case AXP192_BATT_V: + *val = 1; + *val2 = 100000; + return IIO_VAL_INT_PLUS_MICRO; + + case AXP192_IPSOUT_V: + *val = 1; + *val2 = 400000; + return IIO_VAL_INT_PLUS_MICRO; + + case AXP192_TS_IN: + /* 0.8 mV per LSB */ + *val = 0; + *val2 = 800000; + return IIO_VAL_INT_PLUS_MICRO; + + default: + return -EINVAL; + } +} + static int axp20x_adc_scale_voltage(int channel, int *val, int *val2) { switch (channel) { @@ -386,6 +509,29 @@ static int axp20x_adc_scale_current(int channel, int *val, int *val2) } } +static int axp192_adc_scale(struct iio_chan_spec const *chan, int *val, + int *val2) +{ + switch (chan->type) { + case IIO_VOLTAGE: + return axp192_adc_scale_voltage(chan->channel, val, val2); + + case IIO_CURRENT: + /* + * AXP192 current channels are identical to the AXP20x, + * therefore we can re-use the scaling function. + */ + return axp20x_adc_scale_current(chan->channel, val, val2); + + case IIO_TEMP: + *val = 100; + return IIO_VAL_INT; + + default: + return -EINVAL; + } +} + static int axp20x_adc_scale(struct iio_chan_spec const *chan, int *val, int *val2) { @@ -445,6 +591,42 @@ static int axp813_adc_scale(struct iio_chan_spec const *chan, int *val, } } +static int axp192_adc_offset_voltage(struct iio_dev *indio_dev, int channel, + int *val) +{ + struct axp20x_adc_iio *info = iio_priv(indio_dev); + unsigned int regval; + int ret; + + ret = regmap_read(info->regmap, AXP192_GPIO30_IN_RANGE, ®val); + if (ret < 0) + return ret; + + switch (channel) { + case AXP192_GPIO0_V: + regval = FIELD_GET(AXP192_GPIO30_IN_RANGE_GPIO0, regval); + break; + + case AXP192_GPIO1_V: + regval = FIELD_GET(AXP192_GPIO30_IN_RANGE_GPIO1, regval); + break; + + case AXP192_GPIO2_V: + regval = FIELD_GET(AXP192_GPIO30_IN_RANGE_GPIO2, regval); + break; + + case AXP192_GPIO3_V: + regval = FIELD_GET(AXP192_GPIO30_IN_RANGE_GPIO3, regval); + break; + + default: + return -EINVAL; + } + + *val = regval ? 700000 : 0; + return IIO_VAL_INT; +} + static int axp20x_adc_offset_voltage(struct iio_dev *indio_dev, int channel, int *val) { @@ -473,6 +655,22 @@ static int axp20x_adc_offset_voltage(struct iio_dev *indio_dev, int channel, return IIO_VAL_INT; } +static int axp192_adc_offset(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val) +{ + switch (chan->type) { + case IIO_VOLTAGE: + return axp192_adc_offset_voltage(indio_dev, chan->channel, val); + + case IIO_TEMP: + *val = -1447; + return IIO_VAL_INT; + + default: + return -EINVAL; + } +} + static int axp20x_adc_offset(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val) { @@ -489,6 +687,25 @@ static int axp20x_adc_offset(struct iio_dev *indio_dev, } } +static int axp192_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_OFFSET: + return axp192_adc_offset(indio_dev, chan, val); + + case IIO_CHAN_INFO_SCALE: + return axp192_adc_scale(chan, val, val2); + + case IIO_CHAN_INFO_RAW: + return axp192_adc_raw(indio_dev, chan, val); + + default: + return -EINVAL; + } +} + static int axp20x_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -549,6 +766,51 @@ static int axp813_read_raw(struct iio_dev *indio_dev, } } +static int axp192_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, int val2, + long mask) +{ + struct axp20x_adc_iio *info = iio_priv(indio_dev); + unsigned int regmask, regval; + + /* + * The AXP192 PMIC allows the user to choose between 0V and 0.7V offsets + * for (independently) GPIO0-3 when in ADC mode. + */ + if (mask != IIO_CHAN_INFO_OFFSET) + return -EINVAL; + + if (val != 0 && val != 700000) + return -EINVAL; + + switch (chan->channel) { + case AXP192_GPIO0_V: + regmask = AXP192_GPIO30_IN_RANGE_GPIO0; + regval = FIELD_PREP(AXP192_GPIO30_IN_RANGE_GPIO0, !!val); + break; + + case AXP192_GPIO1_V: + regmask = AXP192_GPIO30_IN_RANGE_GPIO1; + regval = FIELD_PREP(AXP192_GPIO30_IN_RANGE_GPIO1, !!val); + break; + + case AXP192_GPIO2_V: + regmask = AXP192_GPIO30_IN_RANGE_GPIO2; + regval = FIELD_PREP(AXP192_GPIO30_IN_RANGE_GPIO2, !!val); + break; + + case AXP192_GPIO3_V: + regmask = AXP192_GPIO30_IN_RANGE_GPIO3; + regval = FIELD_PREP(AXP192_GPIO30_IN_RANGE_GPIO3, !!val); + break; + + default: + return -EINVAL; + } + + return regmap_update_bits(info->regmap, AXP192_GPIO30_IN_RANGE, regmask, regval); +} + static int axp20x_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) @@ -584,6 +846,11 @@ static int axp20x_write_raw(struct iio_dev *indio_dev, return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, regmask, regval); } +static const struct iio_info axp192_adc_iio_info = { + .read_raw = axp192_read_raw, + .write_raw = axp192_write_raw, +}; + static const struct iio_info axp20x_adc_iio_info = { .read_raw = axp20x_read_raw, .write_raw = axp20x_write_raw, @@ -629,6 +896,16 @@ struct axp_data { struct iio_map *maps; }; +static const struct axp_data axp192_data = { + .iio_info = &axp192_adc_iio_info, + .num_channels = ARRAY_SIZE(axp192_adc_channels), + .channels = axp192_adc_channels, + .adc_en1_mask = AXP192_ADC_EN1_MASK, + .adc_en2_mask = AXP192_ADC_EN2_MASK, + .adc_rate = axp20x_adc_rate, + .maps = axp20x_maps, +}; + static const struct axp_data axp20x_data = { .iio_info = &axp20x_adc_iio_info, .num_channels = ARRAY_SIZE(axp20x_adc_channels), @@ -658,6 +935,7 @@ static const struct axp_data axp813_data = { }; static const struct of_device_id axp20x_adc_of_match[] = { + { .compatible = "x-powers,axp192-adc", .data = (void *)&axp192_data, }, { .compatible = "x-powers,axp209-adc", .data = (void *)&axp20x_data, }, { .compatible = "x-powers,axp221-adc", .data = (void *)&axp22x_data, }, { .compatible = "x-powers,axp813-adc", .data = (void *)&axp813_data, }, @@ -666,6 +944,7 @@ static const struct of_device_id axp20x_adc_of_match[] = { MODULE_DEVICE_TABLE(of, axp20x_adc_of_match); static const struct platform_device_id axp20x_adc_id_match[] = { + { .name = "axp192-adc", .driver_data = (kernel_ulong_t)&axp192_data, }, { .name = "axp20x-adc", .driver_data = (kernel_ulong_t)&axp20x_data, }, { .name = "axp22x-adc", .driver_data = (kernel_ulong_t)&axp22x_data, }, { .name = "axp813-adc", .driver_data = (kernel_ulong_t)&axp813_data, }, From patchwork Sun Oct 16 23:43:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1192999wrs; Sun, 16 Oct 2022 16:44:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5U32Z2wMCRule5/2ZVGwBRSz6LUm/akyJ9fmBBE274MhHzrwElq5C5kT1vDRtZlt4DGvDW X-Received: by 2002:a63:5519:0:b0:457:dced:8ba1 with SMTP id j25-20020a635519000000b00457dced8ba1mr7964075pgb.163.1665963843186; Sun, 16 Oct 2022 16:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963843; cv=none; d=google.com; s=arc-20160816; b=MiaB/VkxrOMeg9KMx48OqNh5THp+Mc+50cCG+tscBdVDVIDEXu87o1V9vApFah19w3 Ql0Vr7FWtnrjqGBHcn4naeFPeCNwO9ZG59in13EyIzN1k76zvYvOhTDliWuHLqkk9iNn NNCjHz+5w+Lu1lEaKov//WqzYo7+oQT1x/90xZJRxtRCbxm5T+lRb2qHDTvU0QBKHQ6n qe7ZdrUUv1JByYAZH4M1M1hjk5iJkiI0i67AIgWEvbiIZPqzmTwOSGVJaPjI/ye4ksaA RuN7RnWVThh4O3XYN9GDtJ/7yP29qyAd/K+H38ryYQ0pzPKtEQbJnarEAzlN+lfG1wS1 c65w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xVoR5fEFXEn1wnD9ecqINhC8kaMx1xCBXArxnuhKVxg=; b=j9ISLT8WFMYEi+w0JptX9Kk3p/pJtdEf9VAFScKPblgf6MERoNnTZY54xjcflsKAfD VvufmnhD0o4ND0ncxtqfTZo4276KZBmJo4esHyGz7lrh3SE8P5Sh0sthgIw1hxkMWICC yr0DSRei3uzOVs8568ddnCTYu0g98Y6dgJzA0jXpuRXrbWDWDdqmDHDfUOLLHqbX+hI2 aBcI4m74oNbDV7fqvyQJeLmx7vnay85xMjhCeoSqfY3bjpctKhH5Seb553YLDCYsvDD6 6MClY1KM3mhwVoA2EnuHmc6yPlKn++mEcw2EifJZLNVhjt428gsTgqyXVjr8rNG8uekh qXYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UNtTf7Wn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a056a00174200b00554245aac47si10475873pfc.283.2022.10.16.16.43.50; Sun, 16 Oct 2022 16:44:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UNtTf7Wn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbiJPXnE (ORCPT + 99 others); Sun, 16 Oct 2022 19:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbiJPXmt (ORCPT ); Sun, 16 Oct 2022 19:42:49 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3578437408; Sun, 16 Oct 2022 16:42:31 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id bv10so16003709wrb.4; Sun, 16 Oct 2022 16:42:31 -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=xVoR5fEFXEn1wnD9ecqINhC8kaMx1xCBXArxnuhKVxg=; b=UNtTf7WnJQh34O+QV5PpTFm3pED1tEo6mzd6miSNBXIOHTX33IV/OLXxM9xkrd8iAz RUudZmC6YntaJTSlzrrIAGik5/Fjvh4OVtDlL6uOFPPwM/8gns7u9TptmmjjHHP31jR+ VrOthy3lcVP1rWfvI5WSeykNAytE26qOPipZ53ccpCsO/zz9WIZXNdbKLZGq+XTyAWAo xRed8fZm7vKMTIKUGs7CuPztLfS1jU6QZhH5czgs3JVrNIvGrYgA/6OLReoT3+6Z9Ysn kDmmPJO8AEhHM+x+eZgkHdVtGY6bJ4pW5KGI8GtY5pYtOazHDDGl7ZjcaDtngQKQvE1p qv0A== 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=xVoR5fEFXEn1wnD9ecqINhC8kaMx1xCBXArxnuhKVxg=; b=g4n+s20HF0oGTBXqUYwYKkcm9H6EFpdDRmyC+vK33TupmD25iBbMxmZVQnhYkW/Rys n/Z7tJunLO7AMe9YY1CsjMMRaeSyByYM2/xCmXm13wXKMShxXFDAuE3CgLLxHqrsDt7u huYFxhPRqjbYNSNh1ig+CZNPAS6mmWVaMLC3Pratj647vRV/+zV2tZdvhNwN1uc40hUd s0MCzWFgs2kgfqIdL3QsphSP/yUVVUp68Y96YxnhYFWT+EZmPvBBE0A0SzZ6wNZFg/t+ g0/mHAnmAUSl8202m+srcTF7FLAQGB+z7tNQ6q+2ijJh4fdD3kwk3MCI3uFEeio216Kn grog== X-Gm-Message-State: ACrzQf0uFsObi+9Yh2WamAIVq7kKgZGXoduMhzteCdWVlckULIyFOvki 18vynNIao2K2br5eS9yKFts= X-Received: by 2002:adf:e491:0:b0:22e:4483:a8b5 with SMTP id i17-20020adfe491000000b0022e4483a8b5mr4775629wrm.497.1665963749559; Sun, 16 Oct 2022 16:42:29 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id z6-20020a1cf406000000b003c6deb5c1edsm8496773wma.45.2022.10.16.16.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:29 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel Subject: [PATCH v6 10/13] power: supply: axp20x_usb_power: Add support for AXP192 Date: Mon, 17 Oct 2022 00:43:32 +0100 Message-Id: <20221016234335.904212-11-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889703163958840?= X-GMAIL-MSGID: =?utf-8?q?1746889703163958840?= The AXP192's USB power supply is similar to the AXP202 but it has different USB current limits and a different offset for the VBUS status register. Acked-by: Sebastian Reichel Reviewed-by: Chen-Yu Tsai Reviewed-by: Andy Shevchenko Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_usb_power.c | 84 +++++++++++++++++++++---- 1 file changed, 73 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c index a1e6d1d44808..f83e2ed6d507 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -48,6 +48,9 @@ #define AXP813_VBUS_CLIMIT_2000mA 2 #define AXP813_VBUS_CLIMIT_2500mA 3 +#define AXP192_VBUS_CLIMIT_EN BIT(1) +#define AXP192_VBUS_CLIMIT_100mA BIT(0) + #define AXP20X_ADC_EN1_VBUS_CURR BIT(2) #define AXP20X_ADC_EN1_VBUS_VOLT BIT(3) @@ -121,6 +124,25 @@ static void axp20x_usb_power_poll_vbus(struct work_struct *work) mod_delayed_work(system_power_efficient_wq, &power->vbus_detect, DEBOUNCE_TIME); } +static int axp192_get_current_max(struct axp20x_usb_power *power, int *val) +{ + unsigned int v; + int ret; + + ret = regmap_read(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, &v); + if (ret) + return ret; + + if (!(v & AXP192_VBUS_CLIMIT_EN)) + *val = -1; + else if (v & AXP192_VBUS_CLIMIT_100mA) + *val = 100000; + else + *val = 500000; + + return 0; +} + static int axp20x_get_current_max(struct axp20x_usb_power *power, int *val) { unsigned int v; @@ -179,7 +201,7 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { struct axp20x_usb_power *power = power_supply_get_drvdata(psy); - unsigned int input, v; + unsigned int input, v, reg; int ret; switch (psp) { @@ -215,6 +237,8 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CURRENT_MAX: if (power->axp20x_id == AXP813_ID) return axp813_get_current_max(power, &val->intval); + else if (power->axp20x_id == AXP192_ID) + return axp192_get_current_max(power, &val->intval); return axp20x_get_current_max(power, &val->intval); case POWER_SUPPLY_PROP_CURRENT_NOW: if (IS_ENABLED(CONFIG_AXP20X_ADC)) { @@ -256,16 +280,19 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_HEALTH_GOOD; - if (power->axp20x_id == AXP202_ID) { - ret = regmap_read(power->regmap, - AXP20X_USB_OTG_STATUS, &v); - if (ret) - return ret; + if (power->axp20x_id == AXP192_ID) + reg = AXP192_USB_OTG_STATUS; + else if (power->axp20x_id == AXP202_ID) + reg = AXP20X_USB_OTG_STATUS; + else + break; /* Other chips lack the OTG status register */ - if (!(v & AXP20X_USB_STATUS_VBUS_VALID)) - val->intval = - POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; - } + ret = regmap_read(power->regmap, reg, &v); + if (ret) + return ret; + + if (!(v & AXP20X_USB_STATUS_VBUS_VALID)) + val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; break; case POWER_SUPPLY_PROP_PRESENT: val->intval = !!(input & AXP20X_PWR_STATUS_VBUS_PRESENT); @@ -316,6 +343,28 @@ static int axp20x_usb_power_set_voltage_min(struct axp20x_usb_power *power, return -EINVAL; } +static int axp192_usb_power_set_current_max(struct axp20x_usb_power *power, + int intval) +{ + const unsigned int mask = AXP192_VBUS_CLIMIT_EN | + AXP192_VBUS_CLIMIT_100mA; + unsigned int val; + + switch (intval) { + case 100000: + val = AXP192_VBUS_CLIMIT_EN | AXP192_VBUS_CLIMIT_100mA; + break; + case 500000: + val = AXP192_VBUS_CLIMIT_EN; + break; + default: + return -EINVAL; + } + + return regmap_update_bits(power->regmap, + AXP20X_VBUS_IPSOUT_MGMT, mask, val); +} + static int axp813_usb_power_set_current_max(struct axp20x_usb_power *power, int intval) { @@ -383,6 +432,9 @@ static int axp20x_usb_power_set_property(struct power_supply *psy, if (power->axp20x_id == AXP813_ID) return axp813_usb_power_set_current_max(power, val->intval); + else if (power->axp20x_id == AXP192_ID) + return axp192_usb_power_set_current_max(power, + val->intval); return axp20x_usb_power_set_current_max(power, val->intval); default: @@ -468,6 +520,13 @@ struct axp_data { enum axp20x_variants axp20x_id; }; +static const struct axp_data axp192_data = { + .power_desc = &axp20x_usb_power_desc, + .irq_names = axp20x_irq_names, + .num_irq_names = ARRAY_SIZE(axp20x_irq_names), + .axp20x_id = AXP192_ID, +}; + static const struct axp_data axp202_data = { .power_desc = &axp20x_usb_power_desc, .irq_names = axp20x_irq_names, @@ -600,7 +659,7 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) if (ret) return ret; - if (power->axp20x_id == AXP202_ID) { + if (power->axp20x_id == AXP192_ID || power->axp20x_id == AXP202_ID) { /* Enable vbus valid checking */ ret = regmap_update_bits(power->regmap, AXP20X_VBUS_MON, AXP20X_VBUS_MON_VBUS_VALID, @@ -659,6 +718,9 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) static const struct of_device_id axp20x_usb_power_match[] = { { + .compatible = "x-powers,axp192-usb-power-supply", + .data = &axp192_data, + }, { .compatible = "x-powers,axp202-usb-power-supply", .data = &axp202_data, }, { From patchwork Sun Oct 16 23:43:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3163 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1193226wrs; Sun, 16 Oct 2022 16:45:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QjQCvAX/8OMnuOFd1c+8ukQlUbZ7Nu1vnakUsEqDUsFD1L9lKJ9XNc+ViLjIEElkNEPiW X-Received: by 2002:a05:6a00:1905:b0:566:2a02:e1a1 with SMTP id y5-20020a056a00190500b005662a02e1a1mr9721472pfi.1.1665963899989; Sun, 16 Oct 2022 16:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665963899; cv=none; d=google.com; s=arc-20160816; b=n+Jj95W1NLylENnz9w2F7R4LLwAjyl8LqJKa+wKBD9Nk8PWSTaIfuk+ZbLnyB6ZV5c pGiRPqwklLMH3WYimbuR6A0Bys0p6R+8G9aXSXGi+rFSaiDGzNqBQYVkkPUj2h5nMaQP WClcMekZs6FtMhqdFNYi+F97ZKJwm10lBlyudf5UDMnSBTl9c4aueuLIPNc1cKR8c2GJ EAK30ANpF76qvjYNMM7AhCVyBUa7KvrSwq96LzSc1sa3VSB7tGBvZ/6aQuZY6DFvHrgg qukswEWZSK+4aEAAQ7AWpXjcOVcwNRtci8MZf15/eEzjPHzB0eAsobERycz7DOOUZYnr L8bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6706nU4p7iq9wHYgQ+Dtrw1GcYB0dWgaEHmzw7yDg1c=; b=vrqg/1RxgRobPEnguoLGreFbLXQZw9f4r5j65/P2jU9X3jAq898COr9bc0bpfmWx0T GGU/sDIyW3Ac2+bmWDkiD/wBXP69NHkUOeGqWc9zE6rp/fn/L0humcKZAV7CGdAdod6W E0CKMbjE41KkivPdVO/f/4z+8/U73LGc26LrYxfMZJJC6GZoxsQ60a8xVRi6TjdMtK/b aOjOhdEZC6b+Q1WuCubYWCY8IQct0RYtKOEVon+TrUWtx8EFmA4wqRx3e2R/gn6xrG73 +Tm9YKQwBVqsJMv8qO8qw7BmikSEdk1MW4jLli+cDZsMOulnMPrqHzEXvwKoPh6+9R3m PqBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BIf82YTB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a17090302cb00b001781520b28fsi10490474plk.26.2022.10.16.16.44.47; Sun, 16 Oct 2022 16:44:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BIf82YTB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230107AbiJPXnT (ORCPT + 99 others); Sun, 16 Oct 2022 19:43:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiJPXmx (ORCPT ); Sun, 16 Oct 2022 19:42:53 -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 C433038449; Sun, 16 Oct 2022 16:42:33 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id a3so16087493wrt.0; Sun, 16 Oct 2022 16:42:33 -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=6706nU4p7iq9wHYgQ+Dtrw1GcYB0dWgaEHmzw7yDg1c=; b=BIf82YTB4Ss8IOrnHMsPmUp39Hbw1ZkvXkZZqkYigh/f8Z86X/tFzm3d36uZAF73dJ mzP5U81Wsd8+exjUfqOOIOlnfrQ6NmXCyIquJxrek088/Ew1BjqTvArGxJDojFn000wc B6ENJBF3txgbnvW6kRDf64IEWklPP0nNN6PWBuKSfnvHEyCtTXi3eX7VS2AAcmBluoHD qXAIa4EBMfQEdjzeVHKi3I4Y25nrDQn/gktdFoEpJaLnJ37+NkHZDvuJX9e6zo9UaMON GaJNC2xFNJpGUie7SJqB/TaXoa1oUjfh2R7/DB3bO6zRTcWy8Ie66CEQtug7PMU8BXCc 1z7Q== 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=6706nU4p7iq9wHYgQ+Dtrw1GcYB0dWgaEHmzw7yDg1c=; b=vndZJbExV49fuAz52WjcHYXZNRSzdhYlp4FQ9t9sxaEHMZEaq+tRLo/fAdYNnsDoYc 8979z6TR4XYQ5lzSr19r1uJD+zbRkZ/EHHtXSnUAkCGjxKbcVi59oomtXAMl+aQ6usIM HdmbYf+zDctnxB4v0CnFmG9U11OM6FXGuhy1L/KW0tCl50cIDTlw56DQyhrhFJKhB/J+ mc4hefbVfujACIXHPTVgL7V/Gli/o0x2QEp+WD+3vcWxNCUKlKqEbaOkQILvOL3m78JK ejvbV80n7TCzQqm+MjGzEo1kU1ButyDDyU5vZzI1UV+fKqCVgLzPATLaJ9pw4He8WBYj kR8A== X-Gm-Message-State: ACrzQf1FvLJTmieX6cWjLm/WYPhmtv7ZTHzwVBafuEsQD8eXRydjVmkO 5EBFahX58RWq6eKuE+Zf9/yjqACsR81f8g== X-Received: by 2002:a5d:5612:0:b0:22e:35b7:5654 with SMTP id l18-20020a5d5612000000b0022e35b75654mr4718820wrv.651.1665963751137; Sun, 16 Oct 2022 16:42:31 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id q13-20020a05600c46cd00b003c6f426467fsm3332702wmo.40.2022.10.16.16.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:30 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel Subject: [PATCH v6 11/13] power: axp20x_battery: Add constant charge current table Date: Mon, 17 Oct 2022 00:43:33 +0100 Message-Id: <20221016234335.904212-12-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746889762506620448?= X-GMAIL-MSGID: =?utf-8?q?1746889762506620448?= Add a table-based lookup method for constant charge current, which is necessary when the setting cannot be represented as a linear range. This also replaces the hard-coded 300 mA default ccc setting if the DT-specified value is unsupported; the minimum value for the device is now set exactly instead of relying on the value being rounded down to a supported value. Reviewed-by: Andy Shevchenko Acked-by: Sebastian Reichel Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_battery.c | 59 +++++++++++++++++++++------ 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c index 9106077c0dbb..401779d84d2b 100644 --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -61,6 +61,14 @@ struct axp20x_batt_ps; struct axp_data { int ccc_scale; int ccc_offset; + /* + * Lookup table for constant charge current, if provided this is used + * instead of ccc_scale/ccc_offset. + * + * The table is indexed by the field AXP20X_CHRG_CTRL1_TGT_CURR so it + * must have AXP20X_CHRG_CTRL1_TGT_CURR+1 elements. + */ + const int *ccc_table; bool has_fg_valid; int (*get_max_voltage)(struct axp20x_batt_ps *batt, int *val); int (*set_max_voltage)(struct axp20x_batt_ps *batt, int val); @@ -176,7 +184,10 @@ static int axp20x_get_constant_charge_current(struct axp20x_batt_ps *axp, *val &= AXP20X_CHRG_CTRL1_TGT_CURR; - *val = *val * axp->data->ccc_scale + axp->data->ccc_offset; + if (axp->data->ccc_table) + *val = axp->data->ccc_table[*val]; + else + *val = *val * axp->data->ccc_scale + axp->data->ccc_offset; return 0; } @@ -389,16 +400,35 @@ static int axp20x_battery_set_max_voltage(struct axp20x_batt_ps *axp20x_batt, AXP20X_CHRG_CTRL1_TGT_VOLT, val); } +static int axp20x_get_constant_charge_current_sel(struct axp20x_batt_ps *axp_batt, + int charge_current) +{ + int i; + + if (axp_batt->data->ccc_table) { + for (i = AXP20X_CHRG_CTRL1_TGT_CURR; i >= 0; i--) { + if (axp_batt->data->ccc_table[i] <= charge_current) + return i; + } + + return -EINVAL; + } + + i = (charge_current - axp_batt->data->ccc_offset) / axp_batt->data->ccc_scale; + if (i > AXP20X_CHRG_CTRL1_TGT_CURR || i < 0) + return -EINVAL; + + return i; +} + static int axp20x_set_constant_charge_current(struct axp20x_batt_ps *axp_batt, int charge_current) { if (charge_current > axp_batt->max_ccc) return -EINVAL; - charge_current = (charge_current - axp_batt->data->ccc_offset) / - axp_batt->data->ccc_scale; - - if (charge_current > AXP20X_CHRG_CTRL1_TGT_CURR || charge_current < 0) + charge_current = axp20x_get_constant_charge_current_sel(axp_batt, charge_current); + if (charge_current < 0) return -EINVAL; return regmap_update_bits(axp_batt->regmap, AXP20X_CHRG_CTRL1, @@ -410,14 +440,14 @@ static int axp20x_set_max_constant_charge_current(struct axp20x_batt_ps *axp, { bool lower_max = false; - charge_current = (charge_current - axp->data->ccc_offset) / - axp->data->ccc_scale; - - if (charge_current > AXP20X_CHRG_CTRL1_TGT_CURR || charge_current < 0) + charge_current = axp20x_get_constant_charge_current_sel(axp, charge_current); + if (charge_current < 0) return -EINVAL; - charge_current = charge_current * axp->data->ccc_scale + - axp->data->ccc_offset; + if (axp->data->ccc_table) + charge_current = axp->data->ccc_table[charge_current]; + else + charge_current = charge_current * axp->data->ccc_scale + axp->data->ccc_offset; if (charge_current > axp->max_ccc) dev_warn(axp->dev, @@ -629,7 +659,12 @@ static int axp20x_power_probe(struct platform_device *pdev) ccc)) { dev_err(&pdev->dev, "couldn't set constant charge current from DT: fallback to minimum value\n"); - ccc = 300000; + + if (axp20x_batt->data->ccc_table) + ccc = axp20x_batt->data->ccc_table[0]; + else + ccc = axp20x_batt->data->ccc_offset; + axp20x_batt->max_ccc = ccc; axp20x_set_constant_charge_current(axp20x_batt, ccc); } From patchwork Sun Oct 16 23:43:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1201331wrs; Sun, 16 Oct 2022 17:14:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/Je8C1RomdH+cMHxEi7Wssb7rh30SiwCFuQ5ZlzCxXYWjY9dq/Ehw2eUv+IkXF6bKZ0s+ X-Received: by 2002:a17:907:75e5:b0:78d:cb12:6dcc with SMTP id jz5-20020a17090775e500b0078dcb126dccmr6613592ejc.550.1665965660706; Sun, 16 Oct 2022 17:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665965660; cv=none; d=google.com; s=arc-20160816; b=bttIY6CexaDdHGQDBlupicfyxD1WBpYcUAHTrswDh1E70O1DRk7uyx902uY5y/qhX8 v2bheCcs46AZ8m1Kwt+Z4xg6NJrNQ3hKVgywYfVbs64RbQ0me27QofKVf8VT8IvHjpj6 JAOUAhqonoM3C1fQ9KjP3M05X/L8vXoHifWbOL8kcB3pZgPuhs2uK/padqLfFLDjPb2l P9DFBzfSfjBIt7JW9zGg9Mqj2PEL/gQ5wG3It5ITBFOmg1nf8lTj9QbLvR1k915uxlOf O7zcoLAjHZWJ/x/GgJh8C3HRaMmHG7eyAs6wcZuxJuQIjvv11YW2RdQnY97Nbgum22wK sbxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yLNaaOsLr96TmggGShacOs0+QBHQK9LKPCnPOfIZ4M0=; b=P/3+ane81wXk+GOiFYKOtqWVI5V0UG+IfTLZbQbmuSvjqLRww1prdOxEwl+ieoyTys RbZEivzPM24/+M/+JJ9ERG58dfiZ1RBV1C3rXfYNXAxsmg8zOp8q96Pgh7UafjGiwwh5 3x6s1BBVDAsjoWP+AVKrLBJYrE5s1N9DyxdjLkBy09PQ2Zf2rjf/+zzNTNEvkIn0oBye 3ja5ywunpsunw0yMmbOcPcNLviPufmQ7ZvO6K5Yg9G27s7sIDjWEIYGhwfJwzGuxbuqk Q+TheMgfe2DtgSuQvuADYltjP99wf4PrDtfDVJglLLUYLZV9p6pQZv8l/3H4p0aA5dtz rDog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XHEmXq0x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a50ab13000000b00456e1b5b8e1si6738204edc.426.2022.10.16.17.13.35; Sun, 16 Oct 2022 17:14:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XHEmXq0x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbiJPXn0 (ORCPT + 99 others); Sun, 16 Oct 2022 19:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiJPXm4 (ORCPT ); Sun, 16 Oct 2022 19:42:56 -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 C44DF3844D; Sun, 16 Oct 2022 16:42:33 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id w18so15994876wro.7; Sun, 16 Oct 2022 16:42:33 -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=yLNaaOsLr96TmggGShacOs0+QBHQK9LKPCnPOfIZ4M0=; b=XHEmXq0xose8BCxHQ7cp7eQEBOoG+00uP5Fqf1CATZbpmqd3XJkipc9ZiVNgCEO9ly /dgsR55qnGgGcI8V+aS4DzyWKCXlcr0pmEvGHmASNswkilZ8fS4LGHuySpzQcwyc2XNf GI+JlpHoVqiRYe2qdp52ZckEn9yaqF8lF8QR+CoXeb3q4tAX7tfEhe5mbFfLF9MfRO7r sHl4mJLhkRpsb/Px9i6RYM1HyZjERAdVy0IC45Z8xYbNIygY1QZpjbPgcqpVUrDwL8+t mPwx/xGLFSCNzb5mxDqC5PulNoz5x6CwublCKBzruLKwcy30ynyvC1J/Biqxv8WlriW2 ZLdg== 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=yLNaaOsLr96TmggGShacOs0+QBHQK9LKPCnPOfIZ4M0=; b=6t21k77LkQyxCDpNkWEo5ELhzgZnxnhU/OfE2rcv5NSJFVdoP8e5vAlOPJ9B1r1n7U P7sDN7Fi/jAF6zFjarcVVP6LolIy82tqMYzVsbmbOxD5JGO1W2He8e9vHU7pYPt/eXT0 4oVMbfx2MAnnQgsSgOnjZ5ltxbwjGIZDODu27SlmY58y9mD8tMJvhYroR+jOTA5fbt3p ByXKl9o1wJ/6r+iYE143rDTCTJP3ZypygerGkKRM/KA0ezKuvkAi+NvgFhZRJKCRPlgK iX9/gmRTyWEDZ8V6MMCldN55VcyZAMn9BvekAN2IAu4mWKJw14Z9DCIalchu43WWK3uH YqqQ== X-Gm-Message-State: ACrzQf2XEte5KynSzcJCBwvGeBSw4czWo5yplfDExetHvheo3F240Ka9 R5os3OAfQ4Vl16N7em560Ks= X-Received: by 2002:a5d:4535:0:b0:232:3648:7771 with SMTP id j21-20020a5d4535000000b0023236487771mr4602684wra.342.1665963752790; Sun, 16 Oct 2022 16:42:32 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id u7-20020adfed47000000b002286670bafasm7152829wro.48.2022.10.16.16.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:32 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel Subject: [PATCH v6 12/13] power: axp20x_battery: Support battery status without fuel gauge Date: Mon, 17 Oct 2022 00:43:34 +0100 Message-Id: <20221016234335.904212-13-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746891608927215853?= X-GMAIL-MSGID: =?utf-8?q?1746891608927215853?= Add a "has_fg" flag to indicate that the chip has a fuel gauge. Report battery full status on chips with no fuel gauge using the battery voltage. Acked-by: Sebastian Reichel Reviewed-by: Andy Shevchenko Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_battery.c | 34 ++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c index 401779d84d2b..574c1d001556 100644 --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -69,6 +69,7 @@ struct axp_data { * must have AXP20X_CHRG_CTRL1_TGT_CURR+1 elements. */ const int *ccc_table; + bool has_fg; bool has_fg_valid; int (*get_max_voltage)(struct axp20x_batt_ps *batt, int *val); int (*set_max_voltage)(struct axp20x_batt_ps *batt, int val); @@ -197,7 +198,7 @@ static int axp20x_battery_get_prop(struct power_supply *psy, union power_supply_propval *val) { struct axp20x_batt_ps *axp20x_batt = power_supply_get_drvdata(psy); - int ret = 0, reg, val1; + int ret = 0, reg, val1, val2; switch (psp) { case POWER_SUPPLY_PROP_PRESENT: @@ -231,6 +232,34 @@ static int axp20x_battery_get_prop(struct power_supply *psy, return 0; } + /* + * If the chip does not have a fuel gauge, we check battery full status + * using voltage instead. + */ + if (!axp20x_batt->data->has_fg) { + ret = axp20x_batt->data->get_max_voltage(axp20x_batt, &val1); + if (ret) + return ret; + + ret = iio_read_channel_processed(axp20x_batt->batt_v, &val2); + if (ret) + return ret; + + /* IIO subsystem reports voltage in mV but we need uV */ + val2 *= 1000; + + /* + * According to the AXP192 datasheet, charging will restart if + * the battery voltage drops below V_rch = V_tgt - 0.1 V, so we + * report the battery is full if its voltage is at least V_rch. + */ + if (val2 >= val1 - 100000) + val->intval = POWER_SUPPLY_STATUS_FULL; + else + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; + break; + } + ret = regmap_read(axp20x_batt->regmap, AXP20X_FG_RES, &val1); if (ret) return ret; @@ -552,6 +581,7 @@ static const struct power_supply_desc axp20x_batt_ps_desc = { static const struct axp_data axp209_data = { .ccc_scale = 100000, .ccc_offset = 300000, + .has_fg = true, .get_max_voltage = axp20x_battery_get_max_voltage, .set_max_voltage = axp20x_battery_set_max_voltage, }; @@ -559,6 +589,7 @@ static const struct axp_data axp209_data = { static const struct axp_data axp221_data = { .ccc_scale = 150000, .ccc_offset = 300000, + .has_fg = true, .has_fg_valid = true, .get_max_voltage = axp22x_battery_get_max_voltage, .set_max_voltage = axp22x_battery_set_max_voltage, @@ -567,6 +598,7 @@ static const struct axp_data axp221_data = { static const struct axp_data axp813_data = { .ccc_scale = 200000, .ccc_offset = 200000, + .has_fg = true, .has_fg_valid = true, .get_max_voltage = axp813_battery_get_max_voltage, .set_max_voltage = axp20x_battery_set_max_voltage, From patchwork Sun Oct 16 23:43:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 3165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1202959wrs; Sun, 16 Oct 2022 17:20:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5u/qbTYzzZmEIPP6kenRkMGlltOmdTLRjPwostptHxV+NXSgnciVY2uUnh3TeUiq9pOWL7 X-Received: by 2002:a17:907:75f5:b0:78d:fc53:7d96 with SMTP id jz21-20020a17090775f500b0078dfc537d96mr6656161ejc.718.1665966032676; Sun, 16 Oct 2022 17:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665966032; cv=none; d=google.com; s=arc-20160816; b=MH6yBDY1k7e0ZWupfWr3ds2DQue91t6K2t+WD31DeSSK9KuzsDWl46QSISJqx9RT75 CQ8ZXhBZSbJyyWne2/ZCDzEq8OUMINO8/zr6SNSArbdQoKPTZFzduWBfSQV5jmVjHnQL 6mmvAiiYGF3d5XA4+QoALBYwEm8yvG4anZzSCi9syyYnl9N3ByYUEQgnGZLDDg7yGz3y EJLpv6PUKfOmjPSr1U2rYF8S4eibJvgbEPPvw82sHUlg0ehEvhOanW0okUjvxSQYLkEN ELRltkqnDaCceLnoOyDXU0CLaO4XjEi0EWpeQYEbZ9G8XLMGERwA4KBWnuLd9pK5pIhV k1rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7GeqA6RimLfLm9Mc18q8mMiWhfUsPblKqcrMhkZEToU=; b=jU0Qc1kdDFL3F8mlQar6dXwD2+4WkwLHPth4PKqIPNsZCbLyXpyn3oOYGOJUFUCIOf eMETbtcGRXGzJp+YSHJ85wRnAi7P/IrNydxw9aJ+D9GVe7IT/Nq2BVlmZ3dIE5J1t6V1 yfHRmaBX9U6A/FdpuolS0UdAIlA4Q8+RGyttQyf70WAntzAvvrCwyROac3PPv+Q/MQ4N dFvS9EqCRbDOnnhDmiN0gqzECb4KRmpSBSLdngVie2DPsMfzhiLK/VGxRykKD7L13vjc 6ap5a4Ewyedlu4aR2/0oDyB4mD5h5rZLaqpGMgfk0YGTR7b0rtCYwyplSYWGf++6y0Hn 7yxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LPqoEX9A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb6-20020a170907960600b0078d25914115si9537182ejc.570.2022.10.16.17.20.06; Sun, 16 Oct 2022 17:20:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LPqoEX9A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230113AbiJPXnq (ORCPT + 99 others); Sun, 16 Oct 2022 19:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbiJPXnT (ORCPT ); Sun, 16 Oct 2022 19:43:19 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E340F399CD; Sun, 16 Oct 2022 16:42:36 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id y10so7616867wma.0; Sun, 16 Oct 2022 16:42: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=7GeqA6RimLfLm9Mc18q8mMiWhfUsPblKqcrMhkZEToU=; b=LPqoEX9APVxjLOUyQH+1IzLg92/TOVSLvZn+fPPTowM2hxzd75s6hE6i6eX+5aP+Qw AR/6W8TnL0y9Tg4cqkAy9lbEW1v1NaQkEJhm+ICwGdpKY4ETyVJtuJLxJPC92IBCUCr4 /C67vziOG8rBUo1xPTFP2Yc4HlEy9RIVQqp9HrGOs/uZK++ecmdLPtM+7X9BFyQTDjD9 SnkJ4O+FP5Lb5c07XdWTgAsdREFkqwoBdcssT0MvTURTxpaqO3rVNLWDdAWutyumQWgn EucpPcfgIxbgVvU4eiLYP/sxXNiV/caucPXfNUkS3qby/T02htXiwKhYEkAFMoM+A/9V cb6g== 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=7GeqA6RimLfLm9Mc18q8mMiWhfUsPblKqcrMhkZEToU=; b=MA66+ysGyAuC4s399kYI5JYRof4EnLJZtoayRahUvvY/SKLWQTy16nrz5cWsMa2ddX 8E2N5wQXrxuv/bYqz6d+2CJw0lr8ere2fVLNbURZlA6jRbOZdgDkOgdCwcMuTUJNcjT3 WaDFdFl++bmdJqHRIhb5Er+jIk3qO7zM8HFRaB8fuTeDuyPhW8rXLVKvCgUkCEqgtHmw KrwtPF82tDpR0ft0XY9ZQBz1H/GsPlljTL5xGXltkTtuCJ7OyZwXF3A4jOpy7VxrbIuS Uat3IKTzpGry79DPIJhxJvU2jG7MZ1WFm/bxZwUqdydYBixB53D1i+nLs5/2/20t4ajF 6blQ== X-Gm-Message-State: ACrzQf2DN5nw0dkEI4MA+N4MrTnz06YpZcbj7F3GBSkol459LSvgJqwR 9c6XDukzvohAPKm/9EdwGxI= X-Received: by 2002:a05:600c:4e01:b0:3c6:eba6:75a3 with SMTP id b1-20020a05600c4e0100b003c6eba675a3mr8367606wmq.4.1665963754081; Sun, 16 Oct 2022 16:42:34 -0700 (PDT) Received: from localhost (188.31.4.189.threembb.co.uk. [188.31.4.189]) by smtp.gmail.com with ESMTPSA id f8-20020a05600c4e8800b003b4cba4ef71sm15400056wmq.41.2022.10.16.16.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Oct 2022 16:42:33 -0700 (PDT) From: Aidan MacDonald To: jic23@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, lee.jones@linaro.org, sre@kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, andy.shevchenko@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, michael@walle.cc, samuel@sholland.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel Subject: [PATCH v6 13/13] power: axp20x_battery: Add support for AXP192 Date: Mon, 17 Oct 2022 00:43:35 +0100 Message-Id: <20221016234335.904212-14-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> References: <20221016234335.904212-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746891998826214209?= X-GMAIL-MSGID: =?utf-8?q?1746891998826214209?= The AXP192 has a battery charger similar to other X-Powers PMICs, but unlike the other supported devices, it does not have a fuel gauge and can't report battery capacity directly. Acked-by: Sebastian Reichel Reviewed-by: Andy Shevchenko Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_battery.c | 49 +++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c index 574c1d001556..1e84d26ce8e3 100644 --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -544,6 +544,19 @@ static int axp20x_battery_set_prop(struct power_supply *psy, } } +static enum power_supply_property axp192_battery_props[] = { + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_VOLTAGE_NOW, + POWER_SUPPLY_PROP_CURRENT_NOW, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, + POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, + POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, +}; + static enum power_supply_property axp20x_battery_props[] = { POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_ONLINE, @@ -568,6 +581,16 @@ static int axp20x_battery_prop_writeable(struct power_supply *psy, psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX; } +static const struct power_supply_desc axp192_batt_ps_desc = { + .name = "axp192-battery", + .type = POWER_SUPPLY_TYPE_BATTERY, + .properties = axp192_battery_props, + .num_properties = ARRAY_SIZE(axp192_battery_props), + .property_is_writeable = axp20x_battery_prop_writeable, + .get_property = axp20x_battery_get_prop, + .set_property = axp20x_battery_set_prop, +}; + static const struct power_supply_desc axp20x_batt_ps_desc = { .name = "axp20x-battery", .type = POWER_SUPPLY_TYPE_BATTERY, @@ -578,6 +601,19 @@ static const struct power_supply_desc axp20x_batt_ps_desc = { .set_property = axp20x_battery_set_prop, }; +static const int axp192_ccc_table[AXP20X_CHRG_CTRL1_TGT_CURR+1] = { + 100000, 190000, 280000, 360000, + 450000, 550000, 630000, 700000, + 780000, 880000, 960000, 1000000, + 1080000, 1160000, 1240000, 1320000, +}; + +static const struct axp_data axp192_data = { + .ccc_table = axp192_ccc_table, + .get_max_voltage = axp20x_battery_get_max_voltage, + .set_max_voltage = axp20x_battery_set_max_voltage, +}; + static const struct axp_data axp209_data = { .ccc_scale = 100000, .ccc_offset = 300000, @@ -606,6 +642,9 @@ static const struct axp_data axp813_data = { static const struct of_device_id axp20x_battery_ps_id[] = { { + .compatible = "x-powers,axp192-battery-power-supply", + .data = (void *)&axp192_data, + }, { .compatible = "x-powers,axp209-battery-power-supply", .data = (void *)&axp209_data, }, { @@ -623,6 +662,7 @@ static int axp20x_power_probe(struct platform_device *pdev) struct axp20x_batt_ps *axp20x_batt; struct power_supply_config psy_cfg = {}; struct power_supply_battery_info *info; + const struct power_supply_desc *ps_desc; struct device *dev = &pdev->dev; if (!of_device_is_available(pdev->dev.of_node)) @@ -666,9 +706,12 @@ static int axp20x_power_probe(struct platform_device *pdev) axp20x_batt->data = (struct axp_data *)of_device_get_match_data(dev); - axp20x_batt->batt = devm_power_supply_register(&pdev->dev, - &axp20x_batt_ps_desc, - &psy_cfg); + if (!axp20x_batt->data->has_fg) + ps_desc = &axp192_batt_ps_desc; + else + ps_desc = &axp20x_batt_ps_desc; + + axp20x_batt->batt = devm_power_supply_register(&pdev->dev, ps_desc, &psy_cfg); if (IS_ERR(axp20x_batt->batt)) { dev_err(&pdev->dev, "failed to register power supply: %ld\n", PTR_ERR(axp20x_batt->batt));