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: 6951881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8D52BC05AD for ; Wed, 5 Aug 2015 16:35:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 94E522050E for ; Wed, 5 Aug 2015 16:35:35 +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 A876420495 for ; Wed, 5 Aug 2015 16:35:34 +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 1ZN1dI-0004VJ-IJ; Wed, 05 Aug 2015 16:33:36 +0000 Received: from mail-pd0-f170.google.com ([209.85.192.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZN1d7-0004QF-TG for linux-arm-kernel@lists.infradead.org; Wed, 05 Aug 2015 16:33:26 +0000 Received: by pdco4 with SMTP id o4so20550575pdc.3 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=PJrx2ZKXOtmA7qky8s56mgvH1/n7JBZIpccv3EVMjofMmzwLtLrzpZwE1SXw9ztPti Slx/3xNPk5N29LpEKTHOmsa65XdxJ096MJGeuP8kgkLfZHSPAdSA1yRjvKze9zemdyhF IaAooid/f7RWxezW06CL/8Gf+NATU3/CXbuPyeqa9ioRb+5+IPICgZc+t/97XCXzwN0y z8WYWfn5QRIFqAgRqx71CNMr6K+cp5HzlmRsulhLRhcFxDX2xENd5+VV2i1Be+E3JtSc vriFV8BrjiLkS0nKQioyUe5ziSl8SdYbhIkosYYveQG4OIjYLROqvBQb/Oo+AbWSTNQh TFNg== X-Gm-Message-State: ALoCoQlmZKCnTJzicHfU18ySlayinDnXbmS1dXlwl/bvfxAazX6MMkzHTLFUaVwUR/tgsH+AcP4U 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150805_093325_978245_F54A7573 X-CRM114-Status: GOOD ( 17.35 ) 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 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; }