Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp271633ybg; Wed, 18 Mar 2020 22:41:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsTeD5zdonGDJ5WCIjQyXH5hR8ExqsQaJqMu8pusf5xQkdczz0CanLwowag9mFnjXoGihmx X-Received: by 2002:aca:a857:: with SMTP id r84mr1143734oie.65.1584596475258; Wed, 18 Mar 2020 22:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584596475; cv=none; d=google.com; s=arc-20160816; b=edJppev72ALPbvV1tIKDSgFdjEbi/h6ILUuGbEdGvMdMBJ/+rTAa6FM6UTm9T5iy/L KeiozXJtYaLsi1oLy6TALUFkzMaTLogPw5BnJhg6g+l/UtJeBOBtMLP4Kb9ZAD9KMJwv QAFj0zlBUepIY2czTOCLqaNWK4oxIXn/m9lQ7mX53BUGwSJdYvsZ1MFOHKYyhSAbFA6Y KyifgBNAmnkvFNN3sXAswKXDApjAkDl2ee7N9cft6pMxrz+77DBRrMCqz5goVVlrLafD IHavdQPPHdmw82m1b2mW4mpbvUZn0IuDt070XVAPetJcAkFzwqCrDnCpso0HpaHzUX9n d5Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VjRbI/Qcy2ZipTYHWuUTokoOEV5DVKKVy86kR+PhWiE=; b=HZtRHRUe3vaglPFSS+/If+suwALPSSglksOjvKJfZz8lY17F9h39ruMVOutAcwxm3M 86d7ECDDBFwNH2V2lsbLsXPcr7mfRZx4UPoZgjLxr+OOw6hFFMQbqVmDupHaPK3DMDvD YXAT3zoKXIAmOp3oZF0Dso/Yk+ohZLWLmDWy0H1Uq8lrMaH0Q1WHo8ww8z8a5lTOwn+n c5VJsZiduEfqllXVAVJ1JEZB1PHcLlwIv5mdUDjyyyPDekQnvh6PvgYoUfR/SwBBdJ9n FoTHoV47FVoIXQMHw8nW5NWJAX1m+X11V9RdvKsmE/Ivv/edvZ7V8wn3u4az05IwwtiN Unog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FFUErapf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l20si486154oil.6.2020.03.18.22.41.02; Wed, 18 Mar 2020 22:41:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FFUErapf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727048AbgCSFko (ORCPT + 99 others); Thu, 19 Mar 2020 01:40:44 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46084 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbgCSFkn (ORCPT ); Thu, 19 Mar 2020 01:40:43 -0400 Received: by mail-pg1-f193.google.com with SMTP id y30so614160pga.13 for ; Wed, 18 Mar 2020 22:40:43 -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=VjRbI/Qcy2ZipTYHWuUTokoOEV5DVKKVy86kR+PhWiE=; b=FFUErapf5Y2xQAQXCjZUnjfCRN0y0A0wXHXw/sJjUknTYFS2v99P/qu6S388LrmOBm WLQv+cq5ggJaBRDLDscsPzceMAR4Ms8QpkQ2bX8IBLhuFHBxHfIPq1m2LbgMU4MM1by+ NUPMaf8roA6uBTCE3QIQs1E4S6LoODWGK7/yl06GM+eQ75gKvAWjElYhZ6WYdomNYDxg XJHKMLQDANCKHRwGmr6mUwcaTQOpMDyIggWwmZmDx0Mesp/M8ucO9QmwOTm3oG8IUdxT C+bR2+rPRQYoK3OofEwW0JSBzL1nrf90wfYGe3UDT2fWVttqFZcBgDkUAYwdb++3iwVJ 9JXQ== 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=VjRbI/Qcy2ZipTYHWuUTokoOEV5DVKKVy86kR+PhWiE=; b=KQcDZeqcDgxn+yUDG07zGAdmyf/lwJt5cUp4wyK8FWGScQIyy9JKQBOZCoE1uLyh9H MDvmviOr0T9Q7n67jeYTk9mB5hqiUF7FwEr5Vd5800IrCBTopORe6nymvvks5zeT/xu7 zQefWTR+9JdOHdsulqLm5iitxhFOkNybrjfg6cZjOvCauxTCqJ5XAm4AoAWCxgFE6eNf L0J1a86WFcYYMVr1cuNxpW7x7nAr/IYtr2axIlaBI4FXiBdULVp6ZURiCvvMctS5jUk1 6j46csYUfgbTDvCpewAuz12wiY31zMzRdCfnxfoPSUsKTWGWmdZwdI9zd2W+/Th+9gbR jXDQ== X-Gm-Message-State: ANhLgQ2C36Vma5MVmY2+CdwyrrptPT2jlcBu8Y1r8cj/n76Eob/Rz8CF Lp+GrVZ6vz/cybYhG3zZjU8exQ== X-Received: by 2002:aa7:8ec1:: with SMTP id b1mr2136428pfr.125.1584596442589; Wed, 18 Mar 2020 22:40:42 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id l125sm229126pgl.57.2020.03.18.22.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 22:40:41 -0700 (PDT) From: Bjorn Andersson To: Michael Turquette , Stephen Boyd Cc: Andy Gross , Rob Herring , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Clark Subject: [PATCH 1/4] clk: qcom: gdsc: Handle GDSC regulator supplies Date: Wed, 18 Mar 2020 22:38:59 -0700 Message-Id: <20200319053902.3415984-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200319053902.3415984-1-bjorn.andersson@linaro.org> References: <20200319053902.3415984-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Certain GDSCs, such as the GPU_GX on MSM8996, requires that the upstream regulator supply is powered in order to be turned on. It's not guaranteed that the bootloader will leave these supplies on and the driver core will attempt to enable any GDSCs before allowing the individual drivers to probe defer on the PMIC regulator driver not yet being present. So the gdsc driver needs to be made aware of supplying regulators and probe defer on their absence, and it needs to enable and disable the regulator accordingly. Voltage adjustments of the supplying regulator are deferred to the client drivers themselves. Signed-off-by: Bjorn Andersson --- drivers/clk/qcom/gdsc.c | 24 ++++++++++++++++++++++++ drivers/clk/qcom/gdsc.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index a250f59708d8..3528789cc9d0 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "gdsc.h" #define PWR_ON_MASK BIT(31) @@ -112,6 +113,12 @@ static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status) int ret; u32 val = (status == GDSC_ON) ? 0 : SW_COLLAPSE_MASK; + if (status == GDSC_ON && sc->rsupply) { + ret = regulator_enable(sc->rsupply); + if (ret < 0) + return ret; + } + ret = regmap_update_bits(sc->regmap, sc->gdscr, SW_COLLAPSE_MASK, val); if (ret) return ret; @@ -143,6 +150,13 @@ static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status) ret = gdsc_poll_status(sc, status); WARN(ret, "%s status stuck at 'o%s'", sc->pd.name, status ? "ff" : "n"); + + if (!ret && status == GDSC_OFF && sc->rsupply) { + ret = regulator_disable(sc->rsupply); + if (ret < 0) + return ret; + } + return ret; } @@ -371,6 +385,16 @@ int gdsc_register(struct gdsc_desc *desc, if (!data->domains) return -ENOMEM; + /* Resolve any regulator supplies */ + for (i = 0; i < num; i++) { + if (!scs[i] || !scs[i]->supply) + continue; + + scs[i]->rsupply = devm_regulator_get(dev, scs[i]->supply); + if (IS_ERR(scs[i]->rsupply)) + return PTR_ERR(scs[i]->rsupply); + } + data->num_domains = num; for (i = 0; i < num; i++) { if (!scs[i]) diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h index 64cdc8cf0d4d..c36fc26dcdff 100644 --- a/drivers/clk/qcom/gdsc.h +++ b/drivers/clk/qcom/gdsc.h @@ -10,6 +10,7 @@ #include struct regmap; +struct regulator; struct reset_controller_dev; /** @@ -52,6 +53,9 @@ struct gdsc { struct reset_controller_dev *rcdev; unsigned int *resets; unsigned int reset_count; + + const char *supply; + struct regulator *rsupply; }; struct gdsc_desc { -- 2.24.0