From patchwork Mon Nov 18 02:24:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 13878040 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD2AC1F5FD for ; Mon, 18 Nov 2024 02:24:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731896681; cv=none; b=JVnngeVOGWi865HvHH9hPi5t3wMcYTYrbmbaGtZrcAERV74tTwJHObIUhk4pUQHKCLOL0sv+s/Mvtnrh8XBsfgkuLrnVvz19KUNt5EuUKIekjyfK+eRw36nTZFT6CNdjnQfwpHDOElGfIDB4RpjiewDMRfKxU9HcBinKZOZ99yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731896681; c=relaxed/simple; bh=shX2kfmh21qvlv6tMATByELEIKpfpJiUwHfYedYY7LY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PsW1oDoPf/erkaky1f/Nv1Jv0rec9q+mDWXWg7o+ReQ5FW74ApPB6ld5sUKnTAISryLNYwwvgRWiwBfn9SJgtLK3Ed6aOkmQ7Wl2oUcrpad6UXPKcfTUG8IUJn+qGCO7i5ethf9Mgke/9OqW5Hf0NgyJ9Qg1pLwcpPWrbpiZINc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Info+vqM; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Info+vqM" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-43193678216so33817215e9.0 for ; Sun, 17 Nov 2024 18:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731896677; x=1732501477; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0uAgwDoSqBQNwda9c8A09U/nNCzQI5DjCJkCg9WC4y8=; b=Info+vqMq4ZdcTOE4MoIeGdCM13THyF2Evc+8RmhTw8FuUnkAHlnf4qOUNlVVjrXXa tI21P91yn0DVaZvQusUfZMg7O2VYUrLeaIA/U8aevaNUV7iIjqTt39HFwstpGjnzVZuG o0NGzUqNIOb2GX0TvI03WvPj4sI11nS+PxgE5x5QcREc8KcoOh+1hYszE+8MA2vIuZNU M3M/dryimRiYB8lSGjY3Qhz4GPoFNKnzZlmtfDlI/X9FsN6zJj69ACcMkUwh+mAi/+np K8DPDl/t1dimvkQR54+uxPo1K7RmBHsvxGY/zCG6quPOYhHpmcALBam6S0xPJe06pUM+ cBnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731896677; x=1732501477; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0uAgwDoSqBQNwda9c8A09U/nNCzQI5DjCJkCg9WC4y8=; b=ku/Fm8tOvTcsjGlTCeFyUWvx3MPHVMnh5MEkhSm0wJ8nPc3x+nO3dfOCk36hEkX+13 wv1NHRtZf0JR8+5kLTYD2Su8eaeUyT0CXtFKqHcQ58XBoyBcFrSPxEFunJUNQ8u/DzZf dlvcAEWcTP5krA5wtfIo1em02eu5ahLbXVaVWGjmAooSsFQkuVdfc1zSSMLbQ2bAzlT9 xCYRnm0odIbJbAkzZsbzEBUqFCLAPjKnTIEJndexmGBx7Z+xX4ufDT5RUqoPvI5yv6pC zTudRh1PHkhcDxOG9XSIVF/K6sKBVSMrF0ZkN0JzurEPzDRESV9zx0NTGJf2riDqGnSU 9uCQ== X-Forwarded-Encrypted: i=1; AJvYcCUJcmaL4K4hlbdOMB3DPNVR+nKu8aVMfQLNJL0iNdzV9f6HQeGuwx6QmDuPu0ot0DyChn59VmSD4gk=@vger.kernel.org X-Gm-Message-State: AOJu0YwCUVDisuSHZfuUstjGN9geJYMd3Vtq+RqlvkBnuz4VjIByUfpP HR0ogrKaoQbHxY40bwJcz7MR3aNN/rAjj/BLNqU7PJCRcPaT96XMrWS1ya3IIQM= X-Google-Smtp-Source: AGHT+IFWe31hEGUtGQdW0wnikA7Pm+kGTH+e7FHWreYjGM669kTCqSCSwoXnjqCTIwK31qMF2tpcuw== X-Received: by 2002:a5d:64c8:0:b0:382:2ba9:9d65 with SMTP id ffacd0b85a97d-3822ba9a39cmr6495066f8f.31.1731896677072; Sun, 17 Nov 2024 18:24:37 -0800 (PST) Received: from [127.0.1.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ada2e35sm11387902f8f.5.2024.11.17.18.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2024 18:24:36 -0800 (PST) From: Bryan O'Donoghue Date: Mon, 18 Nov 2024 02:24:32 +0000 Subject: [PATCH 1/2] clk: qcom: common: Add support for power-domain attachment Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241118-b4-linux-next-24-11-18-clock-multiple-power-domains-v1-1-b7a2bd82ba37@linaro.org> References: <20241118-b4-linux-next-24-11-18-clock-multiple-power-domains-v1-0-b7a2bd82ba37@linaro.org> In-Reply-To: <20241118-b4-linux-next-24-11-18-clock-multiple-power-domains-v1-0-b7a2bd82ba37@linaro.org> To: Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Bryan O'Donoghue X-Mailer: b4 0.15-dev-355e8 Right now we have a plethora of singleton power-domains which power clock controllers. These singletons are switched on by core logic when we probe the clocks. However when multiple power-domains are attached to a clock controller that list of power-domains needs to be managed outside of core logic. Use dev_pm_domain_attach_list() to automatically hook the list of given power-domains in the dtsi for the clock being registered in qcom_cc_really_probe(). Signed-off-by: Bryan O'Donoghue --- drivers/clk/qcom/common.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 33cc1f73c69d1f875a193aea0552902268dc8716..b4377fa09f7c0ec8d3c63dfc97d04fbb8cd6e10b 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -22,6 +22,7 @@ struct qcom_cc { struct qcom_reset_controller reset; struct clk_regmap **rclks; size_t num_rclks; + struct dev_pm_domain_list *pd_list; }; const @@ -283,6 +284,25 @@ static int qcom_cc_icc_register(struct device *dev, desc->num_icc_hws, icd); } +static int qcom_cc_pds_attach(struct device *dev, struct qcom_cc *cc) +{ + struct dev_pm_domain_attach_data pd_data = { + .pd_names = 0, + .num_pd_names = 0, + }; + int ret; + + /* Only one power-domain platform framework will hook it up */ + if (dev->pm_domain) + return 0; + + ret = dev_pm_domain_attach_list(dev, &pd_data, &cc->pd_list); + if (ret < 0) + return ret; + + return 0; +} + int qcom_cc_really_probe(struct device *dev, const struct qcom_cc_desc *desc, struct regmap *regmap) { @@ -299,6 +319,10 @@ int qcom_cc_really_probe(struct device *dev, if (!cc) return -ENOMEM; + ret = qcom_cc_pds_attach(dev, cc); + if (ret) + return ret; + reset = &cc->reset; reset->rcdev.of_node = dev->of_node; reset->rcdev.ops = &qcom_reset_ops; From patchwork Mon Nov 18 02:24:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 13878041 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D726F4DA03 for ; Mon, 18 Nov 2024 02:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731896682; cv=none; b=EMofYRzv6s9dMnmZoPiNDzU/azZu3b5AdTsvyekBmKDe0pEEz75UAPM0xjb23GOFwDEEvjK7yOLvIXG/vudqavJQeNSXvaDwkcVlhYytJFBzf+CEf8ep2hAsueJZ0a+mjIKz0LKbpv94IloN/oSQOGHldpJc3hoPPSnqut+tWJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731896682; c=relaxed/simple; bh=4A7Nlfh/Wzmyb8Sqa9yNc0VHqXNcgy/cxKUPLI57RVA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bmunRN9pj86BZupuHFJwr+aMWK12KMjhRy/KSztMoxKLq5rywUEoPGitTobkCUVi7rmz+JPVSFV4gn72/WmoUobM4xMvwATujeHKf/u1RtxpZyBF88VOqZc1X7YUEfumeR1qRw3HVtyHDlPsMGlxfkiAaULlUzCP63UmXNKA5SQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=AiO2ilLs; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AiO2ilLs" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-38231e9d518so1395265f8f.0 for ; Sun, 17 Nov 2024 18:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731896679; x=1732501479; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4iGkwvgZgVeZ73yqZCKTsgB+AcLdw1tSbIMHtFSZKEQ=; b=AiO2ilLsmVmpBsxZ1sKeWV8PocTybMVIr4LSRIDNyPu0In7j6S0HVRzK1Xv0Z4CvBR AkkTLBjueU6qEe9XF3GAGMton1IyNmp9ju+9Nagmw9HWpnYii3QEK0hCWddk1+Bq0dCW L6yqthDFgOpZjnBYtwT++1Yp903FTjEW0208SqEPiKY4l8/FmN/dt3o0HlNcLWCNUsve 2a9NC8FH3bh7OP/ECqB/H0kymz8jtWNsQkgj5lt7wbXC8GNqWzfIPiNBHchpTvm0hVDp /q6fV3xL78Ya3ilWmlPYX3dQNRf/sV3f+r5HD0fRR1VESOCTDdrI/Q3KQ0YS9cPfgsPs znAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731896679; x=1732501479; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4iGkwvgZgVeZ73yqZCKTsgB+AcLdw1tSbIMHtFSZKEQ=; b=mlnK4q6v0HHfLGNIeN+Pp4ZJv59S/szcOpT0xWsLumwaMoZJjm3qMLGCBSEGmcq2kD jHUFHWYcHIe8OTtTPRCxUjYldkMRwHh3YJyscfQ+ifDWDNlaKV178xL3KP160NeoXwwJ Y2ZtUDR1aBAedJrk+8xm7lJDIRoHA2VoQb99VG4AgtNoeiDcgTPNqiacKFabPODg9/Vj Qd4JuLcPQlzb6hHlHbuJ0Xwmn+1UPRmbd3DsnZ/vB9y8B3OAL+xcSr00ub0QVp1culKL GBryMexdf6j4Bmx+Bv7Uzf8l8oeFqF4DJdfmTJxi7Qwldwe7Fh+xFr4r6FGD+GM2Geg+ fhlQ== X-Forwarded-Encrypted: i=1; AJvYcCV+/J0m6SOAcTnHUk4/bSew6s65v4FpPQrICUFgL0YVukZU/6VAxvwwxm1ipRO11+vIKec5l+hTE9s=@vger.kernel.org X-Gm-Message-State: AOJu0Yzi+14BS2h6FVbM6HHlEObhVmQqHdlESp81ODjUMgWHp/XIjLIT kf3h3CG7xhGxelH2pqbvG/Y7PoHUcboBEV/+OKgAtw8pLyBcRlZP31jLghXjwoY= X-Google-Smtp-Source: AGHT+IFdCwt308Q7rR5HQPTUr0kdBp0HSjUA+z9CSb7a6F9Yj/68W8pIPqC2Zj4QRv6VV5zlTYUhOg== X-Received: by 2002:a05:6000:1a8c:b0:37d:4657:ea7d with SMTP id ffacd0b85a97d-38225aafc3bmr6924217f8f.49.1731896679328; Sun, 17 Nov 2024 18:24:39 -0800 (PST) Received: from [127.0.1.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ada2e35sm11387902f8f.5.2024.11.17.18.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2024 18:24:38 -0800 (PST) From: Bryan O'Donoghue Date: Mon, 18 Nov 2024 02:24:33 +0000 Subject: [PATCH 2/2] clk: qcom: gdsc: Add pm_runtime hooks Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241118-b4-linux-next-24-11-18-clock-multiple-power-domains-v1-2-b7a2bd82ba37@linaro.org> References: <20241118-b4-linux-next-24-11-18-clock-multiple-power-domains-v1-0-b7a2bd82ba37@linaro.org> In-Reply-To: <20241118-b4-linux-next-24-11-18-clock-multiple-power-domains-v1-0-b7a2bd82ba37@linaro.org> To: Bjorn Andersson , Michael Turquette , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Bryan O'Donoghue X-Mailer: b4 0.15-dev-355e8 Introduce pm_runtime_get() and pm_runtime_put_sync() on the gdsc_toggle_logic(). This allows for the switching of the GDSC on/off to propagate to the parent clock controller and consequently for any list of power-domains powering that controller to be switched on/off. Signed-off-by: Bryan O'Donoghue --- drivers/clk/qcom/gdsc.c | 26 ++++++++++++++++++-------- drivers/clk/qcom/gdsc.h | 2 ++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c index fa5fe4c2a2ee7786c2e8858f3e41301f639e5d59..ff5df942147f87e0df24a70cf9ee53bb2df36e54 100644 --- a/drivers/clk/qcom/gdsc.c +++ b/drivers/clk/qcom/gdsc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -141,10 +142,14 @@ static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status, { int ret; - if (status == GDSC_ON && sc->rsupply) { - ret = regulator_enable(sc->rsupply); - if (ret < 0) - return ret; + if (status == GDSC_ON) { + if (sc->rsupply) { + ret = regulator_enable(sc->rsupply); + if (ret < 0) + return ret; + } + if (pm_runtime_enabled(sc->dev)) + pm_runtime_resume_and_get(sc->dev); } ret = gdsc_update_collapse_bit(sc, status == GDSC_OFF); @@ -177,10 +182,14 @@ 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; + if (!ret && status == GDSC_OFF) { + if (pm_runtime_enabled(sc->dev)) + pm_runtime_put_sync(sc->dev); + if (sc->rsupply) { + ret = regulator_disable(sc->rsupply); + if (ret < 0) + return ret; + } } return ret; @@ -544,6 +553,7 @@ int gdsc_register(struct gdsc_desc *desc, continue; scs[i]->regmap = regmap; scs[i]->rcdev = rcdev; + scs[i]->dev = dev; ret = gdsc_init(scs[i]); if (ret) return ret; diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h index 1e2779b823d1c8ca077c9b4cd0a0dbdf5f9457ef..71ca02c78c5d089cdf96deadc417982ad6079255 100644 --- a/drivers/clk/qcom/gdsc.h +++ b/drivers/clk/qcom/gdsc.h @@ -30,6 +30,7 @@ struct reset_controller_dev; * @resets: ids of resets associated with this gdsc * @reset_count: number of @resets * @rcdev: reset controller + * @dev: device associated with this gdsc */ struct gdsc { struct generic_pm_domain pd; @@ -74,6 +75,7 @@ struct gdsc { const char *supply; struct regulator *rsupply; + struct device *dev; }; struct gdsc_desc {