From patchwork Tue Nov 17 22:37:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 7643281 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 72D4FBF90C for ; Tue, 17 Nov 2015 22:47:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EEC520459 for ; Tue, 17 Nov 2015 22:47:17 +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 3646F20457 for ; Tue, 17 Nov 2015 22:47:16 +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 1Zyozp-0004Ab-PU; Tue, 17 Nov 2015 22:45:05 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyouE-0005f3-3I for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 22:39:24 +0000 Received: by pacdm15 with SMTP id dm15so22086494pac.3 for ; Tue, 17 Nov 2015 14:39:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K/J/zFrYZIx/2jB6iZordxvJUDb9U5kIgre85v+G8X4=; b=JR1Tgm4wpEqVQuvzVDX32X/leZgl4CyDDKL3W+D0AqdLAltr0Qx33oHBvXFKU4JWGD nRRWhltIZvOaeL2w5t9fv5Bgj+N+gPGzKqt31qlob0Z/0OyYYlDh+MPqcUFugaqZ8qcG 3QOZBAqfTYUOXhdNtFaMwkZSQqqJBfLQvE7dUPi1BalakxWfNGz3tmsgyj/Gvh/ujzNr jrldSVZN+ayYAtQbC7JSecszR+0mqKUeVRthTscyANvksc822oUKS+f6I5uLksGJbCju myHUZBSe/dqtNmT2d5u8SvSSVbibyhV462XlghtCUiWmXLSpJChgRw/noI4hboO9Ibv1 5aLg== 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=K/J/zFrYZIx/2jB6iZordxvJUDb9U5kIgre85v+G8X4=; b=Ae7iix2XaIpMUGtb6o0d/nIKaZTTUYEWj933/GHZVvFWfFDJ7Iux7Zb0SCd1MlRM4k X5BdtFRRHMCCsaT5O/hLiSvLeZQS/eJzIn43h0sjM+hVBCaYadV//sX2UoEy0pNlu7Nx VcMncoYDH8+Dn1/mZ7PUBg+XBKNhNeqbMRCVS5H3YTYs/Iwkv5vavyaiDuIHQvwcOdIW 9fHkCPXm9rWo+kRlYgAy5/6GvGYhr9Hi3j6ASTK/RIfH8H5KUDYCwE26IrAdA/xRUsN8 crCvmYiMzDiZygPv7QXyJ+RI30EIfhywTBX88zLg0vE/PjyeeagdsXBmcq3oJLb2zWz1 BeKg== X-Gm-Message-State: ALoCoQkqJ+AXHWju7pac3fFqmFUu5ODr7iV343YvnxhHQNbGUVUiwy0PygzcxLJyyuuRCYrTAGVB X-Received: by 10.68.78.66 with SMTP id z2mr66417988pbw.144.1447799940657; Tue, 17 Nov 2015 14:39:00 -0800 (PST) Received: from ubuntu.localdomain ([8.42.77.226]) by smtp.gmail.com with ESMTPSA id hy1sm14875199pbb.63.2015.11.17.14.38.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Nov 2015 14:38:59 -0800 (PST) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@linaro.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 21/27] drivers: cpu-pd: Parse topology to setup CPU PM domains Date: Tue, 17 Nov 2015 15:37:45 -0700 Message-Id: <1447799871-56374-22-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447799871-56374-1-git-send-email-lina.iyer@linaro.org> References: <1447799871-56374-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_143918_565199_4B12DAE6 X-CRM114-Status: GOOD ( 15.78 ) 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: k.kozlowski@samsung.com, lorenzo.pieralisi@arm.com, ahaslam@baylibre.com, linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, msivasub@codeaurora.org, geert@linux-m68k.org, Lina Iyer , agross@codeaurora.org, Rob Herring , mtitinger@baylibre.com 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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Architectures that support CPU domain control in the firmware specify the domain heirarchy as part of the topology nodes. Parse and initialize domains from the topology node for such architectures. Cc: Rob Herring Cc: Stephen Boyd Cc: Kevin Hilman Cc: Ulf Hansson Cc: Lorenzo Pieralisi Signed-off-by: Lina Iyer --- drivers/base/power/cpu-pd.c | 76 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/cpu-pd.h | 1 + 2 files changed, 77 insertions(+) diff --git a/drivers/base/power/cpu-pd.c b/drivers/base/power/cpu-pd.c index e331ae6..2872c18 100644 --- a/drivers/base/power/cpu-pd.c +++ b/drivers/base/power/cpu-pd.c @@ -429,3 +429,79 @@ int of_attach_cpu_pm_domain(struct device_node *dn) return 0; } EXPORT_SYMBOL(of_attach_cpu_pm_domain); + +static int of_parse_cpu_pd(struct device_node *cluster, + const struct cpu_pd_ops *ops) +{ + struct device_node *domain_node; + struct generic_pm_domain *genpd; + char name[10]; + struct device_node *c; + int i, ret; + + for (i = 0; ; i++) { + snprintf(name, sizeof(name), "cluster%d", i); + c = of_get_child_by_name(cluster, name); + if (!c) + break; + + domain_node = of_parse_phandle(c, "cluster", 0); + if (!domain_node) + return -1; + + /* Initialize CPU PM domain domain at this level */ + genpd = of_init_cpu_pm_domain(domain_node, ops); + if (IS_ERR(genpd)) + return -1; + + /* Initialize and attach child domains */ + ret = of_parse_cpu_pd(c, ops); + + /* + * Attach the domain to its parent after reading + * the children, so the mask of CPUs in this domain + * are setup correctly. + */ + if (!ret) + of_attach_cpu_pm_domain(domain_node); + + of_node_put(c); + if (ret != 0) + return ret; + } + + return 0; +} + +/** + * of_setup_cpu_domain_topology() - Setup the CPU domains from the CPU + * topology node in DT. + * + * @ops: The PM domain suspend/resume ops for all the domains in the topology + */ +int of_setup_cpu_domain_topology(const struct cpu_pd_ops *ops) +{ + struct device_node *cn, *map; + int ret = 0; + + cn = of_find_node_by_path("/cpus"); + if (!cn) { + pr_err("No CPU information found in DT\n"); + return 0; + } + + map = of_get_child_by_name(cn, "cpu-map"); + if (!map) + goto out; + + ret = of_parse_cpu_pd(map, ops); + if (ret != 0) + goto out_map; + +out_map: + of_node_put(map); +out: + of_node_put(cn); + return ret; +} +EXPORT_SYMBOL(of_setup_cpu_domain_topology); diff --git a/include/linux/cpu-pd.h b/include/linux/cpu-pd.h index 489ee2f..e8290db 100644 --- a/include/linux/cpu-pd.h +++ b/include/linux/cpu-pd.h @@ -32,4 +32,5 @@ struct cpu_pm_domain { struct generic_pm_domain *of_init_cpu_pm_domain(struct device_node *dn, const struct cpu_pd_ops *ops); int of_attach_cpu_pm_domain(struct device_node *dn); +int of_setup_cpu_domain_topology(const struct cpu_pd_ops *ops); #endif /* __CPU_PD_H__ */