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: 51966 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 24C99229FD for ; Wed, 5 Aug 2015 16:35:06 +0000 (UTC) Received: by wixh2 with SMTP id h2sf18581561wix.0 for ; Wed, 05 Aug 2015 09:35:05 -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=0GwIskPU6h3ARuePQ37JSvuwrbbk6BHVDAP5yr8tHaE=; b=dtno75rNFx08Bq0biIOusyhd7omLUt/mMXh1pKPxbrJo6ixeV0+29TXvdDD4jgWsNt DddrENMuYQ/vOO3FbgcAqmp+kXHJiQtq9ZjKiSGZ1Pu1wHH3WBikQsd1FJcVUIOeWFTB o7VUKfnr5i6D4dcjPZj6HNK3VXCMYpuboA/5AuzDv3Z+lec8HfmTFUsuV8fNElGRepNk hAkwLeJH32q4vmfuNI8A4aPE4bzz1PgNP9vN6n7z/Rmkj5naSEejwmR2YJKBTz2iw4xv YaamtJnI0gwwYaTYw2sBUeAxkiwtc7FqGkha3GMG9QeIXU5eiLy39Q+z3HI8MXjjXNGy cjuw== X-Gm-Message-State: ALoCoQnkrCqz3b3OC9xSsYavKsuRdNiCRbDJRC9cm4G72cu1rPSEesXgapF995+or/iBVsMNWpXL X-Received: by 10.112.99.37 with SMTP id en5mr3011668lbb.7.1438792505439; Wed, 05 Aug 2015 09:35:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.135 with SMTP id q7ls96833laj.77.gmail; Wed, 05 Aug 2015 09:35:05 -0700 (PDT) X-Received: by 10.152.23.72 with SMTP id k8mr10257849laf.34.1438792505291; Wed, 05 Aug 2015 09:35:05 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id sv3si2462424lbc.111.2015.08.05.09.35.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2015 09:35:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by labgo9 with SMTP id go9so32364548lab.3 for ; Wed, 05 Aug 2015 09:35:05 -0700 (PDT) X-Received: by 10.152.203.134 with SMTP id kq6mr10140088lac.106.1438792505066; Wed, 05 Aug 2015 09:35:05 -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 l6csp468025lba; Wed, 5 Aug 2015 09:35:04 -0700 (PDT) X-Received: by 10.55.31.213 with SMTP id n82mr17723151qkh.102.1438792490990; Wed, 05 Aug 2015 09:34:50 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id j194si6134720qhc.122.2015.08.05.09.34.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2015 09:34:50 -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 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-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-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.192.170 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.170 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.215.48 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 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; }