From patchwork Tue Apr 27 13:07:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 427982 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57C06C43462 for ; Tue, 27 Apr 2021 13:05:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2ACED613D8 for ; Tue, 27 Apr 2021 13:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236241AbhD0NGW (ORCPT ); Tue, 27 Apr 2021 09:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235795AbhD0NGV (ORCPT ); Tue, 27 Apr 2021 09:06:21 -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 B721CC06175F for ; Tue, 27 Apr 2021 06:05:36 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id q9so5232309wrs.6 for ; Tue, 27 Apr 2021 06:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=byleSoR3uVivo8lWUxItN76uGnD6h4WkxkvPblf1pgs=; b=Vm62xYFJD6sXJffoKQwrG3Qm/9tpvPEPak3PAkkh+WJTaHtNBM6qd/5cvg9RxyEjz1 TgnkkMuGSip/FDy1c8of7lDfWBrJFVCihuOriM3Wkdas73I1WHrMiRCEyg8GrZwTtg+t sQNbKZ5tqzSRvcriiTrtzmn192RpuIJmHFQOOlOMeHS3xaR2pJCBcFz7+Ebc7r8RfTTA EPVVLlIiG7jJYP5vdeCjUsnRVNUPFzTCbBQDZa96wNHed+NSGq1AF/cEPLeBFJ/3Vd+Y qyVL/SRoCSDU7IXJID4bya/uiwb+6zcFKKhUSibsl7K8+bt22CwwNrgSG+Z14j1tNUzq 9DKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=byleSoR3uVivo8lWUxItN76uGnD6h4WkxkvPblf1pgs=; b=CmwaWmMgWnl0So57Pxd35hJLJa/o8HGi6YnPSOjOiw084pA0vING1m6/aWp+WIV+zM a5yF06W5CncwtP3/zlFMju7k3XCKhV3TUP/wwSOMum0a7z3xVdCppjZ3xXFA+f7S00+D Fb56zGP2WF1cSQr3BniYLQ8fNtBaTfElBzBXjr21NRBprJ5mJMGBpr1RryhxH+VBm52d 1lz15GqXmOFPDCe+yYa2IXwKkraxGSsFKnoNkekyDN+i9Sn5rEhNKbODcCWFB+aA7zNq WblIXqKjTnHkJa3TD6Muchnal06z2u7Ah9eurB3ktsKT0s6e2vHdvpeD3sX7O/MuNPxU 2aYA== X-Gm-Message-State: AOAM530TpyZB8FYjPM4HUw+06jyj7IrwnrhWVXLQSpjk6hKXdmvb+Qv+ +5z79wrGYMVwqCQ8ttl5DJbF0g== X-Google-Smtp-Source: ABdhPJwvqnAUP+plOV3sNDJDRqdEc2y3nYQfJGdjh0rvTer9whOfCxjB9ykZHZbhCrhBGcvnt18FYw== X-Received: by 2002:adf:f6c8:: with SMTP id y8mr8991884wrp.325.1619528735458; Tue, 27 Apr 2021 06:05:35 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id y19sm2488118wmj.28.2021.04.27.06.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:05:34 -0700 (PDT) From: Bryan O'Donoghue To: agross@kernel.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, robh@kernel.org, devicetree@vger.kernel.org Cc: wcheng@codeaurora.org, linux-arm-msm@vger.kernel.org, dmitry.baryshkov@linaro.org, bryan.odonoghue@linaro.org Subject: [PATCH v3 1/2] regulator: Add a routine to set the current limit for QCOM PMIC VBUS Date: Tue, 27 Apr 2021 14:07:11 +0100 Message-Id: <20210427130712.2005456-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210427130712.2005456-1-bryan.odonoghue@linaro.org> References: <20210427130712.2005456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add hooks to regulator_get_current_limit_regmap() and regulator_set_current_limit_regmap() with an accompanying map of amperages. This lets us use the existing helper functions to map requested current settings to register bit-map/indicies. This change is required to elevate the default 2 Amps set by the bootloader to 3 Amps or indeed to constrain the value lower as the system design may dictate. The valid range is 500 mA to 3 A in increments of 500 mA. Cc: Mark Brown Signed-off-by: Bryan O'Donoghue --- drivers/regulator/qcom_usb_vbus-regulator.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/regulator/qcom_usb_vbus-regulator.c b/drivers/regulator/qcom_usb_vbus-regulator.c index 457788b505720..2e627c2b6c512 100644 --- a/drivers/regulator/qcom_usb_vbus-regulator.c +++ b/drivers/regulator/qcom_usb_vbus-regulator.c @@ -16,13 +16,21 @@ #define CMD_OTG 0x40 #define OTG_EN BIT(0) +#define OTG_CURRENT_LIMIT_CFG 0x52 +#define OTG_CURRENT_LIMIT_MASK GENMASK(2, 0) #define OTG_CFG 0x53 #define OTG_EN_SRC_CFG BIT(1) +static const unsigned int curr_table[] = { + 500000, 1000000, 1500000, 2000000, 2500000, 3000000, +}; + static const struct regulator_ops qcom_usb_vbus_reg_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap, + .get_current_limit = regulator_get_current_limit_regmap, + .set_current_limit = regulator_set_current_limit_regmap, }; static struct regulator_desc qcom_usb_vbus_rdesc = { @@ -30,6 +38,8 @@ static struct regulator_desc qcom_usb_vbus_rdesc = { .ops = &qcom_usb_vbus_reg_ops, .owner = THIS_MODULE, .type = REGULATOR_VOLTAGE, + .curr_table = curr_table, + .n_current_limits = ARRAY_SIZE(curr_table), }; static int qcom_usb_vbus_regulator_probe(struct platform_device *pdev) @@ -61,6 +71,8 @@ static int qcom_usb_vbus_regulator_probe(struct platform_device *pdev) qcom_usb_vbus_rdesc.enable_reg = base + CMD_OTG; qcom_usb_vbus_rdesc.enable_mask = OTG_EN; + qcom_usb_vbus_rdesc.csel_reg = base + OTG_CURRENT_LIMIT_CFG; + qcom_usb_vbus_rdesc.csel_mask = OTG_CURRENT_LIMIT_MASK; config.dev = dev; config.init_data = init_data; config.of_node = dev->of_node; From patchwork Tue Apr 27 13:07:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 428648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56CF5C43470 for ; Tue, 27 Apr 2021 13:05:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 258A5613D0 for ; Tue, 27 Apr 2021 13:05:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235875AbhD0NGY (ORCPT ); Tue, 27 Apr 2021 09:06:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235795AbhD0NGX (ORCPT ); Tue, 27 Apr 2021 09:06:23 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5C3EC061574 for ; Tue, 27 Apr 2021 06:05:37 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id h15so7148817wre.11 for ; Tue, 27 Apr 2021 06:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V7VVwj3gBbXxEDF0SIhHnzpvvo8dbDhx3Tm2X6iKzEo=; b=XuWEDpr2cKPdEYcPmm0sqv07TJiSlqZnEPlDLAHUGQH7+uKOhaBtYe0fXwLnhEeqXt xO9rX5k/dnwWoHkuQlWYhEjD/6lz7MGKVa9EauiEejtGHclImhS4iWwvb2KMN6bC+1FW C9qHnuAFbkxh2yre/+8zbR6KQ5VA1EswmQI6x6PUsG1IZlCxNeORhXBJWRwRzCtRau7p 9rHanUrjhsJIuitdZmszGkXeiQ50pC53HdSIHvPORIfFTBN9PG4CRaKCJvSQ7Jla5hea rA1D7/ltlEE/bDL4PgwUHTxB05DQ9tyceqoyyZX6IxWI3mxtVEzjX9LZsPJv1FRG91w5 JWHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V7VVwj3gBbXxEDF0SIhHnzpvvo8dbDhx3Tm2X6iKzEo=; b=Eg/WGYCb4HyuzZPzWbU15TN1D8tYmyN0LSLL44ye03gCRiY9Ar4awrFu0Mk0xY9pLa UZebYvBWubWKJ8xCgypFcerx3/UEJPAN0Nph+3DhAKV8I7ifrFRVWup0Qh/eaHTUsOdO 1qgMvKYUmy8z9ohVA9Vi7ezXUdpN9Z7nJ2v9sn9HQKSsD0YZOm+5vksi9VrHDgW4zb0L K2JvRIxb+ChOPTJrgc4l661iIsw6nbIK2hAiK+hO7pkYco/KaevtlkDFpMWpJOrX7RBH 0vXDVyhXu8k5Q+D9dNvA2A+4Aeoskij7qdmrlqSZevP/lZxS2glv0yqohPiLKGv1+SlI euKg== X-Gm-Message-State: AOAM532IV0R0Ulkp3s4HuoLfZSy22kONx4B+Q0sy812o8fpKFneO4Jml XN9OlvTHTDqcS6uxid5e5UmJag== X-Google-Smtp-Source: ABdhPJyYCliOenBy7EHYf+qMNRR/6w1fR3fSlv1pNp7KfOC4kB+ko+mDgou4gFHhebyUg7uOD6XVng== X-Received: by 2002:adf:cc89:: with SMTP id p9mr28389734wrj.223.1619528736515; Tue, 27 Apr 2021 06:05:36 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id y19sm2488118wmj.28.2021.04.27.06.05.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:05:36 -0700 (PDT) From: Bryan O'Donoghue To: agross@kernel.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, robh@kernel.org, devicetree@vger.kernel.org Cc: wcheng@codeaurora.org, linux-arm-msm@vger.kernel.org, dmitry.baryshkov@linaro.org, bryan.odonoghue@linaro.org Subject: [PATCH v3 2/2] arm64: boot: dts: qcom: pm8150b: Add DTS node for PMIC VBUS booster Date: Tue, 27 Apr 2021 14:07:12 +0100 Message-Id: <20210427130712.2005456-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210427130712.2005456-1-bryan.odonoghue@linaro.org> References: <20210427130712.2005456-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Wesley Cheng Add the required DTS node for the USB VBUS output regulator, which is available on PM8150B. This will provide the VBUS source to connected peripherals. Cc: Rob Herring Signed-off-by: Wesley Cheng Signed-off-by: Bryan O'Donoghue --- arch/arm64/boot/dts/qcom/pm8150b.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/pm8150b.dtsi b/arch/arm64/boot/dts/qcom/pm8150b.dtsi index b21e56a46145b..058cc5107c754 100644 --- a/arch/arm64/boot/dts/qcom/pm8150b.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8150b.dtsi @@ -53,6 +53,12 @@ power-on@800 { status = "disabled"; }; + pm8150b_vbus: dcdc@1100 { + compatible = "qcom,pm8150b-vbus-reg"; + status = "disabled"; + reg = <0x1100>; + }; + pm8150b_temp: temp-alarm@2400 { compatible = "qcom,spmi-temp-alarm"; reg = <0x2400>;