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: 6952041 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: X-Original-To: patchwork-linux-arm-msm@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 331789F457 for ; Wed, 5 Aug 2015 16:36:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B8AA20495 for ; Wed, 5 Aug 2015 16:36:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4086C20524 for ; Wed, 5 Aug 2015 16:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753532AbbHEQgV (ORCPT ); Wed, 5 Aug 2015 12:36:21 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35583 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753239AbbHEQdI (ORCPT ); Wed, 5 Aug 2015 12:33:08 -0400 Received: by pabxd6 with SMTP id xd6so22264410pab.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=UXy3zh4gs7JCMe8q3lUM+DyFND5muFoBFzI/9p2vEen5yk2VG02I4O4xaNs4haCCYF lJLtrG/hJ+PkkJjWkirlm9nD8/Ny5/1/fu/6b2wUUZaVqGZkaeHsk84VgSf40X1XevJw 39Nu1PvTRA00gTlyWLSOTmdBu6PMI+O8qNeQlxUCl6E0iWEgzuHR+y/C+KBHkHn9t8s/ RO4ZItULH57qqMv0gSgqqHq3glCaT4eRoYlVYF7H+Hb4VxKEDDrfZosCifo8xKVAK3Vp vExKReDFIXeaqXD9AnHFHIe5m4C1mTTaUt6eR3PPQAkzsDa0XAy/GxClxZ38+nspAiKR n12g== X-Gm-Message-State: ALoCoQnPPMOD9Gcboc+LJgSYL7u/jihlIgqxhtBWLPQyp0UyfaTiQ17m0h7qmZTyBPsRAhMfFZ+w 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 Cc: agross@codeaurora.org, msivasub@codeaurora.org, sboyd@codeaurora.org, robh@kernel.org, Lina Iyer 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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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) {