From patchwork Wed Aug 5 16:32:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 51969 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 2757D229FD for ; Wed, 5 Aug 2015 16:35:24 +0000 (UTC) Received: by labop5 with SMTP id op5sf8619775lab.1 for ; Wed, 05 Aug 2015 09:35:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=NlK6O/9ENjIo5en0YKacqRNXrnAgFp2SKHKvqERY7PE=; b=JRdcwzoAfuJ4/MaUVUlM+JX2xJaBDJZtXEOe5mxfGvYZWY/7D/MZtYDPTm3PSbZS5T TG6wGH7xjFo+vu6sIbsrdxOiIx7SIT3OSyIJeGwcRPMYtSDWg/IOeqIWlIUJLBzO2Ua8 3sVJDrXNH4TLPjTwLbjklfcvk9XFXvGQUBYtkJsfLdzD2PePhecn+52sHtWHeaD1c4LK ifktG2R+kUNCtf1yWPFZkB+U4xtXU2bmwyvDvwI/4DctQw8qtlTOla5Y3u89hQoEv2ZZ yB+xhOku34Ki9XC8LXddkiQiMRU4O4YqKQW9kbX/tAO075Z26o8SVDUk6lQ7y0kMyWtN Z7wg== X-Gm-Message-State: ALoCoQnlx13PpxIBSSC51OeUFXS6P9qy//JVur/DEl21QUJz+kQntAkl8WCoYeR/OnT1m8cKT66r X-Received: by 10.181.13.202 with SMTP id fa10mr48107wid.4.1438792522861; Wed, 05 Aug 2015 09:35:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.3 with SMTP id ky3ls226214lab.70.gmail; Wed, 05 Aug 2015 09:35:22 -0700 (PDT) X-Received: by 10.153.8.137 with SMTP id dk9mr3112530lad.57.1438792522501; Wed, 05 Aug 2015 09:35:22 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id xr5si2482470lbb.76.2015.08.05.09.35.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2015 09:35:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbbyj8 with SMTP id yj8so27712876lbb.0 for ; Wed, 05 Aug 2015 09:35:22 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr9946963lbc.112.1438792522050; Wed, 05 Aug 2015 09:35:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp468148lba; Wed, 5 Aug 2015 09:35:20 -0700 (PDT) X-Received: by 10.140.150.21 with SMTP id 21mr1588731qhw.15.1438792517509; Wed, 05 Aug 2015 09:35:17 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 1si6230469qkr.51.2015.08.05.09.35.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2015 09:35:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZN1df-0004cL-Bv; Wed, 05 Aug 2015 16:33:59 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZN1dA-0004QT-Dy for linux-arm-kernel@lists.infradead.org; Wed, 05 Aug 2015 16:33:29 +0000 Received: by pabxd6 with SMTP id xd6so22264409pab.2 for ; Wed, 05 Aug 2015 09:33:07 -0700 (PDT) X-Received: by 10.66.145.74 with SMTP id ss10mr21298745pab.28.1438792387695; Wed, 05 Aug 2015 09:33:07 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id oq10sm3434036pdb.75.2015.08.05.09.33.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Aug 2015 09:33:07 -0700 (PDT) From: Lina Iyer To: linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH RFC 03/10] drivers: qcom: spm: Enable runtime suspend/resume of CPU PM domain Date: Wed, 5 Aug 2015 10:32:39 -0600 Message-Id: <1438792366-2737-4-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438792366-2737-1-git-send-email-lina.iyer@linaro.org> References: <438731339-58317-1-git-send-email-lina.iyer@linaro.org> <1438792366-2737-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150805_093328_683626_EB1B376D X-CRM114-Status: GOOD ( 16.74 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.44 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.44 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: msivasub@codeaurora.org, robh@kernel.org, sboyd@codeaurora.org, Lina Iyer , agross@codeaurora.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lina.iyer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 On APQ8084 QCOM SoC's, the CPUs are powered by a single rail controlled by the L2 cache power controller (L2 SPM). The L2 power domain supplies power to all the CPUs and L2. It is safe to power down the domain when all the CPUs and the L2 are powered down. Powering down of the domain is done through the finite state machine on the L2 SAW. The L2 SPM can be configured to enter an idle state, when all CPUs enter their idle state. The L2 SPM state machine would turn off the cache and possibly power off the power domain as well. The SPM also guarantees that the h/w is ready for the CPU to resume, when woken up by an interrupt. Define a cluster that holds the SPM and possibly other common cluster elements. The L2 SAW is also the genpd domain provider and the CPUs are the devices attached to the domain. When CPUIdle powers down each CPU, the ARM domain framework would callback to notify that the domain may be powered off. Configure the L2 SPM at that time to flush the L2 cache and turn off the CPU power rail. Signed-off-by: Lina Iyer --- drivers/soc/qcom/spm.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c index efbf5e5..b6d75db 100644 --- a/drivers/soc/qcom/spm.c +++ b/drivers/soc/qcom/spm.c @@ -24,8 +24,11 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -132,6 +135,7 @@ static const struct spm_reg_data spm_reg_8064_cpu = { static DEFINE_PER_CPU(struct spm_driver_data *, cpu_spm_drv); static struct spm_driver_data *domain_spm; +static int l2_flush_flag; typedef int (*idle_fn)(int); static DEFINE_PER_CPU(idle_fn*, qcom_idle_ops); @@ -187,7 +191,14 @@ static void spm_set_low_power_mode(struct spm_driver_data *drv, static int qcom_pm_collapse(unsigned long int unused) { - qcom_scm_cpu_power_down(QCOM_SCM_CPU_PWR_DOWN_L2_ON); + /* + * Flush the non-secure cache for Krait processors. + * SCM will flush the secure cache. + */ + if (l2_flush_flag == QCOM_SCM_CPU_PWR_DOWN_L2_OFF) + flush_cache_all(); + + qcom_scm_cpu_power_down(l2_flush_flag); /* * Returns here only if there was a pending interrupt and we did not @@ -300,6 +311,33 @@ static struct cpuidle_ops qcom_cpuidle_ops __initdata = { CPUIDLE_METHOD_OF_DECLARE(qcom_idle_v1, "qcom,kpss-acc-v1", &qcom_cpuidle_ops); CPUIDLE_METHOD_OF_DECLARE(qcom_idle_v2, "qcom,kpss-acc-v2", &qcom_cpuidle_ops); +static int pd_init(struct device_node *dn, struct generic_pm_domain *domain) +{ + return 0; +} + +static int pd_power_on(struct generic_pm_domain *domain) +{ + l2_flush_flag = QCOM_SCM_CPU_PWR_DOWN_L2_ON; + spm_set_low_power_mode(domain_spm, PM_SLEEP_MODE_STBY); + return 0; +} + +static int pd_power_off(struct generic_pm_domain *domain) +{ + l2_flush_flag = QCOM_SCM_CPU_PWR_DOWN_L2_OFF; + spm_set_low_power_mode(domain_spm, PM_SLEEP_MODE_SPC); + return 0; +} + +static struct of_arm_pd_ops pd_ops __initdata = { + .init = pd_init, + .power_on = pd_power_on, + .power_off = pd_power_off, +}; + +ARM_PD_METHOD_OF_DECLARE(qcom_cpu_pd, "qcom,apq8084-saw2-v2.1-l2", &pd_ops); + static struct spm_driver_data *spm_get_drv(struct platform_device *pdev, int *index, bool *is_domain_spm) {