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: 6951961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 92A6F9F39D for ; Wed, 5 Aug 2015 16:36:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A753720495 for ; Wed, 5 Aug 2015 16:36:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48688204AB for ; Wed, 5 Aug 2015 16:36:03 +0000 (UTC) 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1env5DIxyw9FxDICIbERE05xSUu6eTT47G+Sh+5f76c=; b=RjGsVn9kAB4PQvMQGa0bu4fDjxHluoPi15wpQP2DzeV1mBIYIJmAaF1KhWP7IuUCeG PQBJ6pICwMKf94SrugNboYSTKy9DMx6MBsquUdwAPu0PINbBH4hVI987HYgICnoJV8T7 Lu2cxPATEsWwIAsC+0YyXvVn9s7mDjm/PYBnI8b+vmBLOFIeoaZKSNpzMytcB3LWInpR HPWKAk6GX39tqZJyzPfDtRQX9sXzNGYUPkA22cvqiBRVd1EmxU1LBtKuvrbaGn7pzRy+ quw1hz6rF1WYtUKttmlxE5jxBCIUAjENFqyOrtTgH9DxWE41Sgw/4lgdPrHBMJU7h1Wi mQIQ== X-Gm-Message-State: ALoCoQmU4OOGEtaLf6IgLNIql7Kgdls0sjD8W1SuwsR7/C/5vuUwOB0RkMWkArR9tlT+ggM4wNTV 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-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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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) {