From patchwork Wed Jun 29 14:30: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: 586019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12CB8CCA47C for ; Wed, 29 Jun 2022 14:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231933AbiF2O3v (ORCPT ); Wed, 29 Jun 2022 10:29:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiF2O3t (ORCPT ); Wed, 29 Jun 2022 10:29:49 -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 19A9F1EC55; Wed, 29 Jun 2022 07:29:48 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id r20so22782131wra.1; Wed, 29 Jun 2022 07:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sJNTQf7wx4UpBpK95P+gz9d+4LtTZzJuXzrg3Y7Mt7c=; b=AYU+MwgyLByuAmknrOSdWfRXNOnJYrfon59biHEvoKVbu3bIzgKbSutHxHh7LyHfC+ Np7z8e7GVpFNH1utmFHS7pw1TrgXifW25dkxBC98hR8yJz3rbDOownuhRjKHPLJDGLhQ oUgkN953SAhIRw4VwHbWurpSXtpAzzwIqPRE7uZ/sfN+UWLjHHEO5E8cWPtEX0634C+Q OlizGcMLmhXoKkxj9d2HAqqfM3M3CmNpj5FLKnz+0qoECs4fD6x3W1Yxg6PBkZfo1XEc IeYLM6bGd4vFbNqwe3BS9CbyZ3rTctNwZOaia/+WxsCn+oXc00zN5+HcNjHG5laMk6gl Jr0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sJNTQf7wx4UpBpK95P+gz9d+4LtTZzJuXzrg3Y7Mt7c=; b=iYwz6i3Tn+M/ubEYYKFMpLqISgd4xnOV4JzpXea2GW3dkWfbq/VzN3uAZhgF7z3OEo 0DQRKmbpmiQkTMOMJKB6DkvzHDj7WKdEzrcLlNeN07EYtQmYWxKz65iyB5rRQK8jgWm4 PQvuFg5Yo4BiVXUm5wnU0uMSre02sUGG9zFjf3eRBLecmi/WJqJiSpEn1iKOFy/yozLQ g6npcLHt6d+Rnwx0qfK1hdEUZUntk3bo7uS0g8jMZgXU7gU7GkrqUTb6WXWnkrCmJI5Y qJ3ZVXJ6xUkXD87HiZod+E3WQFEpnVq7vqaaDSmftKrB+sRWyZcWo81H/zNrXU5p5JiW JwZg== X-Gm-Message-State: AJIora94PuC0rZBvUq6XPEp5+dcMAAM7fV1WHz1p6J3gCDIN7rwgW9rF KF3ZLpzaFrjOHjMzo8ZBza8= X-Google-Smtp-Source: AGRyM1sAUHHusomS3GLPEpYp6RNLaaaU8yv5kidsSF9bXSVny3h7Qk0Vx3Qxa3I0hf4NoDs7jY11ZQ== X-Received: by 2002:a5d:59a5:0:b0:21d:205b:3c5b with SMTP id p5-20020a5d59a5000000b0021d205b3c5bmr3461203wrr.97.1656512986736; Wed, 29 Jun 2022 07:29:46 -0700 (PDT) Received: from localhost (92.40.168.16.threembb.co.uk. [92.40.168.16]) by smtp.gmail.com with ESMTPSA id v6-20020a5d6106000000b00213ba0cab3asm17130495wrt.44.2022.06.29.07.29.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 07:29:46 -0700 (PDT) From: Aidan MacDonald To: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, jic23@kernel.org, sre@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, quic_gurus@quicinc.com, sebastian.reichel@collabora.com, andy.shevchenko@gmail.com, michael@walle.cc, rdunlap@infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 01/15] dt-bindings: mfd: add bindings for AXP192 MFD device Date: Wed, 29 Jun 2022 15:30:32 +0100 Message-Id: <20220629143046.213584-2-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> References: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 3a53bae611bc..33c9b1b3cc04 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 Wed Jun 29 14:30: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: 586018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5255BC43334 for ; Wed, 29 Jun 2022 14:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbiF2O35 (ORCPT ); Wed, 29 Jun 2022 10:29:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232169AbiF2O3y (ORCPT ); Wed, 29 Jun 2022 10:29:54 -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 06D6321269; Wed, 29 Jun 2022 07:29:54 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id e28so17604783wra.0; Wed, 29 Jun 2022 07:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=un6FOGrLaQROKEAY9nSCj2eZpRsEUWt4G2drKQth4h4=; b=RWbgWr3SKAbWD5CDg+dOcH5Mpl9yzXSj2cuinVscASxUiANWyCRCw2cgNQdLwvRcoJ fEZKS9/sqpboMgLiDiwZDWLoB+bMRYhzUK5YzjrddAP/ArlpCMoYWFWXbwCEAx/buzX6 Gmnf3L1rBS39xNBY9MibUw+BFSp9qetw/wWEfdgn8+7LOVPqzSBWduBtMAhURe80wLTz a7aUb2CoZPp7dC1fQ70h0/BgC3dUMuAFFCTtuE242ZhF9fewaR6j48pANGvknZFHFNNf dtG2EcX0UOm42Sn2r6kkG9/vaty0ySLBI35DHOoCL66PSJCLow1Tc02HXhUOnC7dNrkD CFpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=un6FOGrLaQROKEAY9nSCj2eZpRsEUWt4G2drKQth4h4=; b=npGgplBhNCb06RMARMevkk8YcmMOe8IhwIWq7RUWFRL4+hj2Mn1kNeSrKantEigsgn lAAEFtdW+v6aIiHeTEUeZNqw+rEjNw21qs41KiDUNsZgznmh1FTNNUmeIbJ3jjKeyDOT Gv/b880J6gV5+D/lsMaZ10bdp926KT840lW4H9xJaDbvrRn3vbMnArPt1pKG9ln1yTHJ xwLSZT6u/Fojve7O+MpXngcvqkSJnYitw5+LMcsO/eo+NSz6kiKVUGX0QVNXmSMiq+ak ibh28tEYirYx9B/pQzFp4V2foCNpjcMwYxtYO/MtiplVOP0lawqsSrtWCHDep5oX5I8w dPDA== X-Gm-Message-State: AJIora8DVN5L2UD18FB8KOKi/fP4p4BVaXIYl6J0YfWKl9lAycO7zEP7 EwlNATyoT5H61YsBJ5cjXh8= X-Google-Smtp-Source: AGRyM1us7cK1sEh6+QfaCGJhX9HKUKQ8xXgXHS382a/7gayxblhJYLvovDmJ6ykA/c4uk4l2MLK4MA== X-Received: by 2002:adf:e988:0:b0:21b:8c9d:6ba3 with SMTP id h8-20020adfe988000000b0021b8c9d6ba3mr3585524wrm.10.1656512992631; Wed, 29 Jun 2022 07:29:52 -0700 (PDT) Received: from localhost (92.40.168.16.threembb.co.uk. [92.40.168.16]) by smtp.gmail.com with ESMTPSA id z18-20020a05600c0a1200b0039c45fc58c4sm3362248wmp.21.2022.06.29.07.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 07:29:51 -0700 (PDT) From: Aidan MacDonald To: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, jic23@kernel.org, sre@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, quic_gurus@quicinc.com, sebastian.reichel@collabora.com, andy.shevchenko@gmail.com, michael@walle.cc, rdunlap@infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 04/15] dt-bindings: gpio: Add AXP192 GPIO bindings Date: Wed, 29 Jun 2022 15:30:35 +0100 Message-Id: <20220629143046.213584-5-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> References: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The AXP192 PMIC is different enough from the PMICs supported by the AXP20x GPIO driver to warrant a separate driver. The AXP192 driver also supports interrupts and pinconf settings. Signed-off-by: Aidan MacDonald --- .../bindings/gpio/x-powers,axp192-gpio.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/x-powers,axp192-gpio.yaml diff --git a/Documentation/devicetree/bindings/gpio/x-powers,axp192-gpio.yaml b/Documentation/devicetree/bindings/gpio/x-powers,axp192-gpio.yaml new file mode 100644 index 000000000000..ceb94aa2bc97 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/x-powers,axp192-gpio.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/gpio/x-powers,axp192-gpio.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: X-Powers AXP192 GPIO Device Tree Bindings + +maintainers: + - Chen-Yu Tsai + +properties: + compatible: + const: x-powers,axp192-gpio + + gpio-controller: true + + "#gpio-cells": + const: 2 + description: > + The first cell is the pin number and the second is the GPIO flags. + + gpio-ranges: + maxItems: 1 + +patternProperties: + "-pins$": + $ref: /schemas/pinctrl/pinmux-node.yaml# + + properties: + pins: + items: + enum: + - GPIO0 + - GPIO1 + - GPIO2 + - GPIO3 + - GPIO4 + - N_RSTO + + function: + enum: + - output + - input + - ldo + - pwm + - adc + - low_output + - floating + - ext_chg_ctl + - ldo_status + +required: + - compatible + - "#gpio-cells" + - gpio-controller + - gpio-ranges + +additionalProperties: false + +examples: + - | + pinctrl0: gpio { + compatible = "x-powers,axp192-gpio"; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinctrl0 0 0 6>; + }; From patchwork Wed Jun 29 14:30:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 586017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3EF5CCA489 for ; Wed, 29 Jun 2022 14:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232563AbiF2O37 (ORCPT ); Wed, 29 Jun 2022 10:29:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232252AbiF2O3z (ORCPT ); Wed, 29 Jun 2022 10:29:55 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 032931EC55; Wed, 29 Jun 2022 07:29:55 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id k22so22763138wrd.6; Wed, 29 Jun 2022 07:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZG+WV9b/8zIynOLD+NGGVzMJIIPqNVNIfED/0tYW0ms=; b=acwvd10g+JlEA4GvNK/Kdz7Oj5A+muFPi3vh5CoiC+bovtAKJT3lWNpdPhNNTFgaQH ojjHfwAVwE9n/5cgi8gk7qRV3oN7t+kf7hg2HmeXw20j+Q6zzcq3skR5YRNE3fBe44l4 EHSqlA8I7X/rE4eRkj3F+J0BT/a+ngPoHlpGI533vnKEErUSb5I0tknOgWSonejwdLCK 7JnavG1z6XmZPaqcwl/WNmDXyiTisPFiZu1bGCQBP3EwBwZuoerbQ3vvWC6n4NAdNDnV O1jiFHcFdjeCrl8YH7RZJnN8lMhpv5c6P7EXdIlD6n+MKct1tOW9pVPZUeoHKsGJUVNZ eCXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZG+WV9b/8zIynOLD+NGGVzMJIIPqNVNIfED/0tYW0ms=; b=nYDv31CHy0zT7MGISjxm5wbj4MgE/CwAKay6tGe0jnW+MoLe5Uh2cKNy7ygdRK4c6d Q3N2yKDAI8M4qX5lYzKmE5kWd7zoM8OggpUKNlh7RW+0uqhoHDxMCdDJtJA7qmr5ilv7 fitdYpsk+q8o8aed9JlMid1KbEMxOhjNmGlm/6VD9805uD8ASWsiCzAAgv0sCwCi/A7b zDl9IzHzOvel17S20yrEa/m8PY3Pg67VCJFwbQ108TDOyHoEnk0qzALCW/lrcFEQULT7 G2S698OyS79/q/+GjDF8naVvDZxRLI03xNBdDyNy++u3CzPbitjurymBr5JLE2qT2lSW H6Jg== X-Gm-Message-State: AJIora8N6I+3dXE82cYNoyaRM9vYhfm5xpEAcBKgWpAf2M8pgkLHpWxm LWvEAMJTL+mWUQAiDnlFXQw= X-Google-Smtp-Source: AGRyM1uFtX4RK80XPeqS9v9Uhu/4TlS8QqTn9bEyqhOjC8/7aySG0wCF38J6Qk3htOroWUcH0bm+ug== X-Received: by 2002:adf:ed41:0:b0:210:20a5:26c2 with SMTP id u1-20020adfed41000000b0021020a526c2mr3327742wro.603.1656512994642; Wed, 29 Jun 2022 07:29:54 -0700 (PDT) Received: from localhost (92.40.168.16.threembb.co.uk. [92.40.168.16]) by smtp.gmail.com with ESMTPSA id a8-20020a05600c348800b00397623ff335sm3467907wmq.10.2022.06.29.07.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 07:29:53 -0700 (PDT) From: Aidan MacDonald To: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, jic23@kernel.org, sre@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, quic_gurus@quicinc.com, sebastian.reichel@collabora.com, andy.shevchenko@gmail.com, michael@walle.cc, rdunlap@infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 05/15] dt-bindings: power: axp20x-battery: Add AXP192 compatible Date: Wed, 29 Jun 2022 15:30:36 +0100 Message-Id: <20220629143046.213584-6-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> References: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 d055428ae39f..b7347683a07e 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 Wed Jun 29 14:30:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 586016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63352CCA47C for ; Wed, 29 Jun 2022 14:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232943AbiF2OaF (ORCPT ); Wed, 29 Jun 2022 10:30:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232767AbiF2OaB (ORCPT ); Wed, 29 Jun 2022 10:30:01 -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 3080F1D0DC; Wed, 29 Jun 2022 07:30:00 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id i1so18266116wrb.11; Wed, 29 Jun 2022 07:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SaiBnjQBZH/tI+Dt9pV+rDgBClMSUaWb1GMjR/tUjvs=; b=T5HOChOXp/MamaN1f1/ZBqmhEcq6aevYRJUrkqFMKnAE0L/id+m9t8nZalY3FlZ8Mv N15m0Y1b8p8ssti3znmuutIkTsTbKdLvRJlSrtmYsAqzmdIm+KjnbIzrDY9xUIyKp/+R TH/gcBsEetXEtzsIwK6J7RZjgsgqyRwIWlJeXS3CbqKOhBlT6+nIG/6pmXp7zY5VJ5xL aOAw3joUM0yPz4Bo600qUQHCGvl7ld9XPNh6BXrCB3lyt7FH+qwBj1Y1Tw06pmpvhz4j cjpl5IZxILX/L/PwdAYDk7Tm/Fx+zkEDS3Qm94Tz8Hy38tpWleYE5M7ueeeU+0u9RNHG 6rvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SaiBnjQBZH/tI+Dt9pV+rDgBClMSUaWb1GMjR/tUjvs=; b=H0PoZYSCgTnQjFrxjcP/XcvpoQ9CNwgyEcD8yufrR5nJECCdyMdQ36Ylaa1YKKzqd5 NWrS60XE6KvDqRECkTz+ub1ZNBb6VITvFZ6dvOUZlGUbXtoTnRSHZMsWISHkKqiFtIJG axBQXFBOBu0d7h8PAjiASA8U0zsKkJ41mtAmtZpESMpyfk1mKUa0zpQUsjCGSNU4V2Eq 4noyTdlKps9E+53KM+kONxXUJL/uKhkRTZqMx2DRdGrtAQe9fNEaTIR4OYpZ2ItKGKee vbNZR5B8jfads2kTZv5WLi7dKh6D8U4IJdhxoYgPW7dyON8Yvsv3B83zXID67WHsq26l WroA== X-Gm-Message-State: AJIora/PgExOZiqYmrRuDrzbWj9mpvHzUCM9AoDrBm1uCNwam8kXpGJc x2jezfx3o8XQZ3oBv5zCoq8= X-Google-Smtp-Source: AGRyM1tnItvPnHl2nGPwgBlrM+cOmsZCl7e+BBHxdAnq8kwKnvzVsXicYMJXWet5Lu+jaVLoN7pT3A== X-Received: by 2002:adf:f5ce:0:b0:21b:832c:80dd with SMTP id k14-20020adff5ce000000b0021b832c80ddmr3397079wrp.235.1656512998716; Wed, 29 Jun 2022 07:29:58 -0700 (PDT) Received: from localhost (92.40.168.16.threembb.co.uk. [92.40.168.16]) by smtp.gmail.com with ESMTPSA id a8-20020a05600c348800b00397623ff335sm3468122wmq.10.2022.06.29.07.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 07:29:58 -0700 (PDT) From: Aidan MacDonald To: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, jic23@kernel.org, sre@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, quic_gurus@quicinc.com, sebastian.reichel@collabora.com, andy.shevchenko@gmail.com, michael@walle.cc, rdunlap@infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 07/15] regulator: axp20x: Add support for AXP192 Date: Wed, 29 Jun 2022 15:30:38 +0100 Message-Id: <20220629143046.213584-8-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> References: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add support for the AXP192 PMIC. Acked-by: Mark Brown 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 Wed Jun 29 14:30:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 586015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D392CCA47E for ; Wed, 29 Jun 2022 14:30:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233253AbiF2OaX (ORCPT ); Wed, 29 Jun 2022 10:30:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232920AbiF2OaF (ORCPT ); Wed, 29 Jun 2022 10:30:05 -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 EACF72E680; Wed, 29 Jun 2022 07:30:03 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id i25so17248011wrc.13; Wed, 29 Jun 2022 07:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oALC17+xHWdMD5emD1myNyIF9g5exghbqAWAGYP9uCI=; b=KewG3lon1dOEk2MIgsdxTHygbprU3VnFu4vSwE/Nt634xd25dfN/GxiZK5tg/9fhJJ Vx7U93bE8n9kjv/d5srCdR4uSSphBJgW0QDtiNwsKptYhrFKbqeTQojUHiX0Ffpe2Wx4 jQRRAHlAdVlfSwNMtjp1/ijnBbwXYh21zThad1tpKRYmSAhJDhbKVDzCSXVpy0xGqFt1 gr3fu4lVt7BI52l9Kcpj0LRhQPtL/vF2OjCwtc1ORI0eIQ+1jA1s+r9U7rBu0xDmYWQe exB1cNRZYshIB+lbZZW7VxFouEwdZvzRwOTflCz09QB90YGvxaomGG4ThR+UZlDcNIis 8ntg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oALC17+xHWdMD5emD1myNyIF9g5exghbqAWAGYP9uCI=; b=qWjo4eS5tBpTMS+zcEM5X6pPrwLCKtpHe9LOf+z8HGNXBTBPwLbADsyg+syxVb+E9t MbVYtydNvyhatFC4GAgKxjeV20yrr9l0zeILlVFeuwWYNMDi+SlIcc02V2Q6OSAtbvRS kdqYH/KaX0XHOnkUU+OH0i1TEN+5NYKPHgBFtU7hbvxfNkSu1vs2XnZmdJ8lU/wn+12n +3eY7hCAAd19Y0J9597B8aJ3qg+liBhFfuRVqhgquqQZ3iqTkKRWNlZrTbDvBkIrz7s1 ShI9EFdyFuOsnXKtIzCl23WCfC2mqcjABPk7P4OuszWtVauYmftGafLIX6zzyHc5dNoC p0jg== X-Gm-Message-State: AJIora9ceqCd/nF2uwMQX+Edg55CzjcyJTb+LoB8zbm2wvQdAeooUrWr ZjJeVyUavomYcsn7rivISmY= X-Google-Smtp-Source: AGRyM1tkB+038HWCl9sBAm4/x6I6mvd6zkiI2b0xTLGy+cqKv5dpE2Mkkh0UKuSpY1BgacxdGaMsPA== X-Received: by 2002:a5d:5846:0:b0:21b:c444:9913 with SMTP id i6-20020a5d5846000000b0021bc4449913mr3295665wrf.128.1656513002510; Wed, 29 Jun 2022 07:30:02 -0700 (PDT) Received: from localhost (92.40.168.16.threembb.co.uk. [92.40.168.16]) by smtp.gmail.com with ESMTPSA id y15-20020a5d4acf000000b0021b9c520953sm16845237wrs.64.2022.06.29.07.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 07:30:01 -0700 (PDT) From: Aidan MacDonald To: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, jic23@kernel.org, sre@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, quic_gurus@quicinc.com, sebastian.reichel@collabora.com, andy.shevchenko@gmail.com, michael@walle.cc, rdunlap@infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 09/15] iio: adc: axp20x_adc: Replace adc_en2 flag with adc_en2_mask field Date: Wed, 29 Jun 2022 15:30:40 +0100 Message-Id: <20220629143046.213584-10-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> References: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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. Signed-off-by: Aidan MacDonald Reviewed-by: Jonathan Cameron --- 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 Wed Jun 29 14:30:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 586014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB65BCCA47C for ; Wed, 29 Jun 2022 14:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233074AbiF2Oaa (ORCPT ); Wed, 29 Jun 2022 10:30:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233095AbiF2OaV (ORCPT ); Wed, 29 Jun 2022 10:30:21 -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 D8F5C3054B; Wed, 29 Jun 2022 07:30:07 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id e28so17605796wra.0; Wed, 29 Jun 2022 07:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z7o4tF/gtDrRCcpZ88soilLOFMUthquvodxNmmBfEYs=; b=GdLvPrDFzcEEWAA4JpRInaagGdJj503Zr2xjAZkn5Mdp6Ay9sZ2Fan2xAAqNSpwwBT T/z4fsxLNJL+C1fVIrR33rBq0SSh1zMtdF0ZPdnfl9r4fE9u4pmfRq7/vHTF3IZ3hK29 8+vBNdQ9EpIwOjKDHvHXpdFLQiSZc7DA31K1OpPcybMHgQnWx8jNwVGjn28RSLKcC4qm CpqFtmHOB9at1Z5GbapOvJNpxwxiGiUMkWAyxVyXFxsLTch+gZNRNbbhiZlYg/sd6qVj Fv8Nzwztp8hrf2uN7RbtNofZJR9qtvrkVoD1uP+2Zl6PbDPzgeu26oWUKbXwwtcdFKAp JyIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z7o4tF/gtDrRCcpZ88soilLOFMUthquvodxNmmBfEYs=; b=N32tNLZ48FI7c2xH4Ls8LeORUdMr0okvfbyenKiXDTMdMdWpS4apzng3+vCkzQBPHu RK9ycmVcfVKvGeUGAbf/zRBJdRU63a9Nk5M5ZY2nK+ViiMtlFLta3ZKgcGUdAAajDzDk S+HRjaf85QmhO+czsgHDWqon22w21eMgXwGQzDDbCPPCe4gEEKamEXuzEumC+XrLJyx1 axLo0WYjaC70RimPvJ3f+ZN+EWpOPr+dCrwowCn95y8PLsfK99EIPL6uRz2Tq/x7Imz6 y1oQ4JmuE2Wo/FgNgswG0ll1RPqp51DFSymlKRCELy9XTtBCVCNzhyTDangT1mUaYB2e l6GA== X-Gm-Message-State: AJIora/caL4eRjJ5rF4dWV0tLwWR/ZxTqE82zwQJNquJ9rjBtK/gkBdn XVK/r/p4zOR1pr5rLFhtHqg= X-Google-Smtp-Source: AGRyM1sBUIO2E1geRpNeoOmUqDC6LyvA/BNgIlIKnqzZYPvNX/9lAPOpQ68bdPP3BnKgNCD2rktVyQ== X-Received: by 2002:adf:fe83:0:b0:21b:9cc6:4c91 with SMTP id l3-20020adffe83000000b0021b9cc64c91mr3604289wrr.414.1656513006441; Wed, 29 Jun 2022 07:30:06 -0700 (PDT) Received: from localhost (92.40.168.16.threembb.co.uk. [92.40.168.16]) by smtp.gmail.com with ESMTPSA id c7-20020adffb07000000b0021b98d73a4esm16997309wrr.114.2022.06.29.07.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 07:30:06 -0700 (PDT) From: Aidan MacDonald To: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, jic23@kernel.org, sre@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, quic_gurus@quicinc.com, sebastian.reichel@collabora.com, andy.shevchenko@gmail.com, michael@walle.cc, rdunlap@infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 11/15] power: supply: axp20x_usb_power: Add support for AXP192 Date: Wed, 29 Jun 2022 15:30:42 +0100 Message-Id: <20220629143046.213584-12-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> References: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 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 Wed Jun 29 14:30:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 586013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD740CCA485 for ; Wed, 29 Jun 2022 14:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233239AbiF2Oav (ORCPT ); Wed, 29 Jun 2022 10:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233222AbiF2OaW (ORCPT ); Wed, 29 Jun 2022 10:30:22 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1E823BE6; Wed, 29 Jun 2022 07:30:12 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 189so9016643wmz.2; Wed, 29 Jun 2022 07:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=huOUgohMa6HSSO8lmmPUC18ErSlu3Lc7c1e9dFxmbGc=; b=Wm1mz8unakgPVLn6X0Lkp9MK22xHjcjuI1FOdjTI239U6fP3XpKKbtwTe46Qx2KG2l /nrfnn8kIeLclBq6DzJfuwaO6rwOyu7GoSNTT7yztMrryOWWGzKVweX3jO4gBT0bc+99 WUmOF0UZBOU8B5pCyziRVXcEIWmHvcl4uC6EhPzS4KdFapK+A9wMWQWsdcdtN9AdmGON cLJABV+WFDGSguAktKJ7BbcH/CwInYBsdfnHEIVxKMZ6O0GUdKK/XtOs0Tjaq3QwSbeN IUl9hHfYLGdZvaNyQ74klnDZeTVqLnR2zRRALzaoYGA3XgFV/thpjwlEXAikjNavWEc6 uyaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=huOUgohMa6HSSO8lmmPUC18ErSlu3Lc7c1e9dFxmbGc=; b=DSXwKeIGRcKv+XA+YFC5dkcpSYhYWFVR+guqOZ7whv2MWU/f1GBHLvmAEx8Ovcjl// L0Twm4ZzubH+XOL/Co9onA+tcjRZLGLb0SH3izehitX41ZLrT5wmf8v85i4z7cNi6G7H FsSayHmZeBfJJY7EbD+YyQOEZ6rL76nEoO/Th+DBKjyVRetZ4Pi/MF8HvmxfeEI8BPCk O8ak0aUG87PCRFZGER1wGD8Qi6ojlzgf49/4FmHqhUg6k348pyr8dsu9tmjmLlR1+Zxv RGSP81lH2jOwFHSyu064xLTrmuMQK3g55jPp7zOGgwlCAxAOHWl+ODyz/pfuzjrZYxzZ XUaQ== X-Gm-Message-State: AJIora8y6bCJ71ufFsw8R31XSsBUefvTOKv5Qc4mTZMQowNwMfiAOiMR n83Gzi/uhpZM9JGiVBOlPhA= X-Google-Smtp-Source: AGRyM1u4KTFPybHVMFdcYM6BYDjaMnpWE2ULHL13DQhzRQSavcVOPj6ateaC9yO9+eJP7agqWsC4WA== X-Received: by 2002:a05:600c:1549:b0:3a1:6f35:c431 with SMTP id f9-20020a05600c154900b003a16f35c431mr2643546wmg.74.1656513011058; Wed, 29 Jun 2022 07:30:11 -0700 (PDT) Received: from localhost (92.40.168.16.threembb.co.uk. [92.40.168.16]) by smtp.gmail.com with ESMTPSA id o4-20020a5d6484000000b0020d02262664sm16810313wri.25.2022.06.29.07.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 07:30:10 -0700 (PDT) From: Aidan MacDonald To: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, jic23@kernel.org, sre@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, quic_gurus@quicinc.com, sebastian.reichel@collabora.com, andy.shevchenko@gmail.com, michael@walle.cc, rdunlap@infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 13/15] power: axp20x_battery: Add constant charge current table Date: Wed, 29 Jun 2022 15:30:44 +0100 Message-Id: <20220629143046.213584-14-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> References: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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. Signed-off-by: Aidan MacDonald Reviewed-by: Andy Shevchenko --- 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 Wed Jun 29 14:30:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 586012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDB33CCA480 for ; Wed, 29 Jun 2022 14:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232499AbiF2Oa5 (ORCPT ); Wed, 29 Jun 2022 10:30:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232876AbiF2OaY (ORCPT ); Wed, 29 Jun 2022 10:30:24 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68F8C35DF2; Wed, 29 Jun 2022 07:30:15 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id s1so22744601wra.9; Wed, 29 Jun 2022 07:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I/6knLBCspYoJbBWZ+ks97ukajAgwVFBs4o2jAnU4CE=; b=F0whcHo7Zc3k+GEpoS8SmLr8tVyFTKmt1wCz/oaQlx6Ib7ZKEX063yRQrkxoZs0r67 WuH740v9d1VXR0yfCyonHdTDr8SULH4ZkFuzdySuwlPcuOZ3LaJDMsxWd41SESYBfEIv H8ji5KUI/doCTfmHIKSZX+Np38hQVSim+qGxZGJwI8ju5NQQox6gytgsiS1hLzkxMhVe oRMky2ppDq/8k+h45DL81Ypj1rsrXdhjxJ/CW3xMCD+sE4+iUveaR5KbVMxWVdpWMNDA 81k4aiE8tNaiW0ZsvzBSEG1sNt6/1tKZAl0RtIhF/GQjlSGVa8zdL/IIkkA54mS5jP5f nTvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I/6knLBCspYoJbBWZ+ks97ukajAgwVFBs4o2jAnU4CE=; b=QarWicW+fkgt/0GTNZH//6FRRqB2kd6Py7+WkTPz+arB9pbW8uR3bZa6daHDfiWzwD KXVq19sZtMoa7nHI9cKB9CGosUnhcHdID3Lr5qgEGlXeIm4JCT0G963S9whz8kyDdhSd 9UC2KbOQgkDYjGO9CEY23Rb15WS2PbMjfZSS3/VIzpCDrpcGyV16TpNpNfZRleLH+Y+y AsN25oyJSH0hWev5hziUxidkEcfwaYx6w2yz5ffKRE40g4/NwRVle6j/wIQpOfEMQE8W h3F5SnPrq3XPkwfSTNogfZ//Ta7Ctvfj1wrb1oHl1EyOYS3RMcUdDfVu5puATWWD5/dX 8nSA== X-Gm-Message-State: AJIora8XkPWU9Px00XwtbiBCAt4Gf1yIcmBk0nD6LuB2NLi8uTRrN3iv MyngoEuwrJNpMNCIV9gYURc= X-Google-Smtp-Source: AGRyM1ssJB+8a1pR4WAQ+kpPKxT8wl7jYM6SAD5uwinvRVog9qTcEzaMAvr1kw6gi5jmBcgoMiZX1g== X-Received: by 2002:a5d:528e:0:b0:21b:b85b:5873 with SMTP id c14-20020a5d528e000000b0021bb85b5873mr3425379wrv.191.1656513015000; Wed, 29 Jun 2022 07:30:15 -0700 (PDT) Received: from localhost (92.40.168.16.threembb.co.uk. [92.40.168.16]) by smtp.gmail.com with ESMTPSA id c21-20020a05600c0a5500b0039c4d022a44sm3402041wmq.1.2022.06.29.07.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 07:30:14 -0700 (PDT) From: Aidan MacDonald To: linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wens@csie.org, jic23@kernel.org, sre@kernel.org, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org Cc: lars@metafoo.de, quic_gurus@quicinc.com, sebastian.reichel@collabora.com, andy.shevchenko@gmail.com, michael@walle.cc, rdunlap@infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v4 15/15] power: axp20x_battery: Add support for AXP192 Date: Wed, 29 Jun 2022 15:30:46 +0100 Message-Id: <20220629143046.213584-16-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> References: <20220629143046.213584-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 Signed-off-by: Aidan MacDonald Reviewed-by: Andy Shevchenko --- 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));