From patchwork Mon Jun 22 12:41:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 198679 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=-10.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,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 B399AC433E0 for ; Mon, 22 Jun 2020 12:41:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90E5820732 for ; Mon, 22 Jun 2020 12:41:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NkDb2DIJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728200AbgFVMl0 (ORCPT ); Mon, 22 Jun 2020 08:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728194AbgFVMl0 (ORCPT ); Mon, 22 Jun 2020 08:41:26 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B1AFC061796 for ; Mon, 22 Jun 2020 05:41:25 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id ga6so8107505pjb.1 for ; Mon, 22 Jun 2020 05:41:25 -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=MSKivOm6p95vIF+xsCRXaxJ3RfMT5lkhjSXb8u6KQ/A=; b=NkDb2DIJjstzdPiJdgcoV7o5+9TSMEIkFBQ+LImKCcn68yw1O6jSJ0sJS3RUovdmvJ ZhrNk7JcomCIeopxGzxo/wiVYUYeX1Cv/kJoXZz0R+rpgvd1RWiMaOgaRJWIEzBK3n16 N+dxNCqAhAqJJzL5AFAITBdwNUjof2bNxUUCX5X+7CNtXBmcdO3EgO4/uEsdOTb9oSEC pf2XsmG4GkSU2lshTb0Nw++svCUpbOFDqbHUDET+TwZVa4RGien0pdR6mLLpnm5zFKDX izayXw0yxcrHkDSDqLYe+aBdXmTfUgFMsjO6XBz5cR4Fbw16ziPdWjH+Z9f1cAnEozOh eI9g== 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=MSKivOm6p95vIF+xsCRXaxJ3RfMT5lkhjSXb8u6KQ/A=; b=RjdRrtz6lcuE2ab1I1o1h+li4BLSjKdmNBILts3Unr4G6xfeUE6Iljh7xcGI2bRRx1 Ton4/YvSg4q7l7Ca+kMdkQHnwWPKWDxZQBCnUP6LMBlxqt1qyitZ2Eh5PClfkAFzXmmc Hs9pf81XOgCasa3bNxHe40GtVbtvzpzCwm3MQzxqyFIB0h91UA9pgmpKix3L4zXxBgOh X/4JPjCq84L7g1sOlva1CnStI5ZoTncfAxyWu3BZkxpQQDDL6N8dLcZdTEcT6DGwWdat fTZoEUR+DHgFRW81C37BzOcGf2sLwyFW0aTeaJDdC1e5yIfs4guZ5gjDZZRp3RqcavR2 FxeQ== X-Gm-Message-State: AOAM530uEm/tvjsFHoA6qpp48QhMCYDrRoYpyf8DEuDslClTQePTOwxY nrw4jyLfp7gwcHY2X8+J6rqFTw== X-Google-Smtp-Source: ABdhPJyG2/JwS7bC4HVB0uvJoH/UbZ7OpMiVe3Q06q9v0mo7oPqV1SK3siOBx609yancSdugVYIVTQ== X-Received: by 2002:a17:902:8694:: with SMTP id g20mr19560597plo.332.1592829684630; Mon, 22 Jun 2020 05:41:24 -0700 (PDT) Received: from nagraj.local ([49.206.21.239]) by smtp.gmail.com with ESMTPSA id i62sm14590581pfg.90.2020.06.22.05.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 05:41:24 -0700 (PDT) From: Sumit Semwal To: agross@kernel.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org Cc: nishakumari@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kgunda@codeaurora.org, rnayak@codeaurora.org, Sumit Semwal Subject: [PATCH v5 1/4] regulator: Allow regulators to verify enabled during enable() Date: Mon, 22 Jun 2020 18:11:07 +0530 Message-Id: <20200622124110.20971-2-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200622124110.20971-1-sumit.semwal@linaro.org> References: <20200622124110.20971-1-sumit.semwal@linaro.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some regulators might need to verify that they have indeed been enabled after the enable() call is made and enable_time delay has passed. This is implemented by repeatedly checking is_enabled() upto poll_enabled_time, waiting for the already calculated enable delay in each iteration. Signed-off-by: Sumit Semwal --- v3: addressed minor review comments, improved kernel doc v2: Address review comments, including swapping enable_time and poll_enabled_time. --- drivers/regulator/core.c | 63 +++++++++++++++++++++++++++++++- include/linux/regulator/driver.h | 5 +++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 03154f5b939f..538a2779986a 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2347,6 +2347,37 @@ static void _regulator_enable_delay(unsigned int delay) udelay(us); } +/** + * _regulator_check_status_enabled + * + * A helper function to check if the regulator status can be interpreted + * as 'regulator is enabled'. + * @rdev: the regulator device to check + * + * Return: + * * 1 - if status shows regulator is in enabled state + * * 0 - if not enabled state + * * Error Value - as received from ops->get_status() + */ +static inline int _regulator_check_status_enabled(struct regulator_dev *rdev) +{ + int ret = rdev->desc->ops->get_status(rdev); + + if (ret < 0) { + rdev_info(rdev, "get_status returned error: %d\n", ret); + return ret; + } + + switch (ret) { + case REGULATOR_STATUS_OFF: + case REGULATOR_STATUS_ERROR: + case REGULATOR_STATUS_UNDEFINED: + return 0; + default: + return 1; + } +} + static int _regulator_do_enable(struct regulator_dev *rdev) { int ret, delay; @@ -2407,7 +2438,37 @@ static int _regulator_do_enable(struct regulator_dev *rdev) * together. */ trace_regulator_enable_delay(rdev_get_name(rdev)); - _regulator_enable_delay(delay); + /* If poll_enabled_time is set, poll upto the delay calculated + * above, delaying poll_enabled_time uS to check if the regulator + * actually got enabled. + * If the regulator isn't enabled after enable_delay has + * expired, return -ETIMEDOUT. + */ + if (rdev->desc->poll_enabled_time) { + unsigned int time_remaining = delay; + + while (time_remaining > 0) { + _regulator_enable_delay(rdev->desc->poll_enabled_time); + + if (rdev->desc->ops->get_status) { + ret = _regulator_check_status_enabled(rdev); + if (ret < 0) + return ret; + else if (ret) + break; + } else if (rdev->desc->ops->is_enabled(rdev)) + break; + + time_remaining -= rdev->desc->poll_enabled_time; + } + + if (time_remaining <= 0) { + rdev_err(rdev, "Enabled check timed out\n"); + return -ETIMEDOUT; + } + } else { + _regulator_enable_delay(delay); + } trace_regulator_enable_complete(rdev_get_name(rdev)); diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 7eb9fea8e482..436df3ba0b2a 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -305,6 +305,9 @@ enum regulator_type { * @enable_time: Time taken for initial enable of regulator (in uS). * @off_on_delay: guard time (in uS), before re-enabling a regulator * + * @poll_enabled_time: The polling interval (in uS) to use while checking that + * the regulator was actually enabled. Max upto enable_time. + * * @of_map_mode: Maps a hardware mode defined in a DeviceTree to a standard mode */ struct regulator_desc { @@ -372,6 +375,8 @@ struct regulator_desc { unsigned int off_on_delay; + unsigned int poll_enabled_time; + unsigned int (*of_map_mode)(unsigned int mode); }; From patchwork Mon Jun 22 12:41:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Semwal X-Patchwork-Id: 198678 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=-10.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,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 89074C433E2 for ; Mon, 22 Jun 2020 12:41:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65B2F2071A for ; Mon, 22 Jun 2020 12:41:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZOojp91P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728242AbgFVMlg (ORCPT ); Mon, 22 Jun 2020 08:41:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728222AbgFVMlc (ORCPT ); Mon, 22 Jun 2020 08:41:32 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E22C061795 for ; Mon, 22 Jun 2020 05:41:32 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id d66so8359874pfd.6 for ; Mon, 22 Jun 2020 05:41:32 -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=gVIUeXQMCzWAcTP6WaAZI7/yPZyluiCjZUpguitY3Jw=; b=ZOojp91Pido+aL3yZ7zrmjtfRZ8Rj0b57hyjeHOQp6DeGl5HWGlCbn6CRDcFZ6x2TQ OGjgXQAYk9vb5Z6Pns/GOLInjxC0/4F9IVjUZpuj15j7HlFCH5reerk6T/pN0KRwU9Bb u0IQ2vcQpjjAP0z87Lus7w/xu7CknL7VSWrti80qeROkDVNoS2gM/1P7lJEnzGJzzQM9 LBbyXm4aUXqYMGPsMUFksBvsmj1K3Rcs4ic+kxJypBQ3w16Q6rm7xi0l9Ul4OM168xVh PjeK/Shfu4r4EkO4Yt9B0Jb4KqSMnjckWITV77AdmF5ymk/DolM516H29m3oan9c6RWv +jAA== 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=gVIUeXQMCzWAcTP6WaAZI7/yPZyluiCjZUpguitY3Jw=; b=m/3/HpSsRBr45gBhmNHB2ijcrnLoSgIKO7QDl5HFsPXXpGSPqSnQajolhwLEz0FsAJ SPkh9mAGH4wZ/Wun9Y1Dcwq6epI8h2XSTyWA12/AhQkFmEANIzD8PcLVecUNlzMUZsO+ 5O1OLkkuYIfGal2hS5iRYGX8XjjtT1bn+yxJbJV1Uy5XcWFw4fgfTjCeAT1Hgk9ozUFN eVQXDiJMCac7mcGs+pdd52n00RhwQ2Gkmofdw0LgdGpjhjNbKB4lGaRIIuau9bKrXqRk hzt8IOBo/ivtxnil6dbHSoFjMZAvyItxONgZRM0ZZF0IpX0NDVcsDl1c8qJxtcGKuxgm uXVA== X-Gm-Message-State: AOAM531nzdleZNJW/ZWFn6f949x4+3UrnEQcAVo+4opC5jF0JmVoN59F D34ZpeM5APMo0oE9UMEg9CVQHQ== X-Google-Smtp-Source: ABdhPJyKEJiZz5eiUolIb6ebzSomKmKeC2lbQasGljaZr3D0E5NLOjUhinZlJgNU+qTJaWl0NaR8gQ== X-Received: by 2002:aa7:96b0:: with SMTP id g16mr20562410pfk.126.1592829691927; Mon, 22 Jun 2020 05:41:31 -0700 (PDT) Received: from nagraj.local ([49.206.21.239]) by smtp.gmail.com with ESMTPSA id i62sm14590581pfg.90.2020.06.22.05.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 05:41:31 -0700 (PDT) From: Sumit Semwal To: agross@kernel.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org Cc: nishakumari@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kgunda@codeaurora.org, rnayak@codeaurora.org, Sumit Semwal Subject: [PATCH v5 3/4] arm64: dts: qcom: pmi8998: Add nodes for LAB and IBB regulators Date: Mon, 22 Jun 2020 18:11:09 +0530 Message-Id: <20200622124110.20971-4-sumit.semwal@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200622124110.20971-1-sumit.semwal@linaro.org> References: <20200622124110.20971-1-sumit.semwal@linaro.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Nisha Kumari This patch adds devicetree nodes for LAB and IBB regulators. Signed-off-by: Nisha Kumari Signed-off-by: Sumit Semwal [sumits: Updated for better compatible strings and names] --- v5: sumits: removed interrupt-names, since there is only one interrupt per node v4: sumits: removed labibb label which is not needed v3: sumits: updated interrupt-names as per review comments v2: sumits: updated for better compatible string and names --- arch/arm64/boot/dts/qcom/pmi8998.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/pmi8998.dtsi b/arch/arm64/boot/dts/qcom/pmi8998.dtsi index 23f9146a161e..d016b12967eb 100644 --- a/arch/arm64/boot/dts/qcom/pmi8998.dtsi +++ b/arch/arm64/boot/dts/qcom/pmi8998.dtsi @@ -25,5 +25,17 @@ pmi8998_lsid1: pmic@3 { reg = <0x3 SPMI_USID>; #address-cells = <1>; #size-cells = <0>; + + labibb { + compatible = "qcom,pmi8998-lab-ibb"; + + ibb: ibb { + interrupts = <0x3 0xdc 0x2 IRQ_TYPE_EDGE_RISING>; + }; + + lab: lab { + interrupts = <0x3 0xde 0x0 IRQ_TYPE_EDGE_RISING>; + }; + }; }; };