From patchwork Wed Aug 5 16:32:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 6952071 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 D3B259F457 for ; Wed, 5 Aug 2015 16:37:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0143320529 for ; Wed, 5 Aug 2015 16:37:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2B4B204E2 for ; Wed, 5 Aug 2015 16:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753204AbbHEQg5 (ORCPT ); Wed, 5 Aug 2015 12:36:57 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:34843 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753196AbbHEQdE (ORCPT ); Wed, 5 Aug 2015 12:33:04 -0400 Received: by pdrg1 with SMTP id g1so20765654pdr.2 for ; Wed, 05 Aug 2015 09:33:04 -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=EQWjmOhCOOtoT88Aiq7d/WYLcQ46XQidqiKblG/YFfk=; b=UUM5HTKh5IKO3HWU+apOYWh/96nzrAd9IQ0bpqcJwhics58so0vnI0PjiTW9Qj0vSk 3HN0bPhW3/T2ImuJrASMS1GJCyi6W/YpDKZi/nmMGrIp+fMWGBCRpy6ps6di97KxcI/1 gzJz5dtYEhGgUxSuVBxjxs7L0hTMskYL/XRaF9wRkE0DRlbRjmn0o/8PF1so6hx8V5s3 5fnvzddqrfZOyavIIFPmjkAcQ9IdckAbBv5ZTyM6sKqeExKBuw92pV8R1bvafU+lstG0 06XvNRjfzfqZjBKoh/tpVN3ybtvNBSOdNlX4CXjXHIWbITki68LI6cbNjmANlcbDIVi2 6+kw== X-Gm-Message-State: ALoCoQmidEO3Ypt9HPbBpqhNxLTWybRw+cDlLN3gJ08Hu+5I+jz3ysSHpwzTPNxuPWJOWeAuI/aV X-Received: by 10.70.39.74 with SMTP id n10mr21157248pdk.57.1438792384150; Wed, 05 Aug 2015 09:33:04 -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.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Aug 2015 09:33:03 -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 01/10] drivers: qcom: spm: Support cache SPMs Date: Wed, 5 Aug 2015 10:32:37 -0600 Message-Id: <1438792366-2737-2-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 Recognize cache SPM devices defined in the DT and configure the corresponding SPM hardware. SPM controllers for L2 controls the cache's idle low power state and may also be used to turn off the CPU power rail. Cc: Stephen Boyd Cc: Andy Gross Signed-off-by: Lina Iyer --- drivers/soc/qcom/spm.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c index b04b05a..9f5edaa27 100644 --- a/drivers/soc/qcom/spm.c +++ b/drivers/soc/qcom/spm.c @@ -115,6 +115,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; typedef int (*idle_fn)(int); static DEFINE_PER_CPU(idle_fn*, qcom_idle_ops); @@ -283,13 +284,18 @@ 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 struct spm_driver_data *spm_get_drv(struct platform_device *pdev, - int *spm_cpu) + int *index, bool *is_domain_spm) { struct spm_driver_data *drv = NULL; struct device_node *cpu_node, *saw_node; int cpu; bool found; + drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); + if (!drv) + return ERR_PTR(-ENOMEM); + + /* Check for a CPU SPM, if found we are done */ for_each_possible_cpu(cpu) { cpu_node = of_cpu_device_node_get(cpu); if (!cpu_node) @@ -302,11 +308,14 @@ static struct spm_driver_data *spm_get_drv(struct platform_device *pdev, break; } - if (found) { - drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); - if (drv) - *spm_cpu = cpu; - } + /* + * If found, we have a CPU SPM, if not, + * we have a cache SPM + */ + if (found) + *index = cpu; + + *is_domain_spm = !found; return drv; } @@ -327,21 +336,22 @@ static int spm_dev_probe(struct platform_device *pdev) struct resource *res; const struct of_device_id *match_id; void __iomem *addr; - int cpu; + int index; + bool is_domain_spm; - drv = spm_get_drv(pdev, &cpu); - if (!drv) - return -EINVAL; + match_id = of_match_node(spm_match_table, pdev->dev.of_node); + if (!match_id) + return -ENODEV; + + drv = spm_get_drv(pdev, &index, &is_domain_spm); + if (IS_ERR(drv)) + return PTR_ERR(drv); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); drv->reg_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(drv->reg_base)) return PTR_ERR(drv->reg_base); - match_id = of_match_node(spm_match_table, pdev->dev.of_node); - if (!match_id) - return -ENODEV; - drv->reg_data = match_id->data; /* Write the SPM sequences first.. */ @@ -366,8 +376,13 @@ static int spm_dev_probe(struct platform_device *pdev) /* Set up Standby as the default low power mode */ spm_set_low_power_mode(drv, PM_SLEEP_MODE_STBY); - per_cpu(cpu_spm_drv, cpu) = drv; + /* We are ready to use the CPU/Cache SPM. */ + if (is_domain_spm) + domain_spm = drv; + else + per_cpu(cpu_spm_drv, index) = drv; + dev_dbg(&pdev->dev, "SPM device probed.\n"); return 0; }