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: 7642981 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 BCC249F392 for ; Tue, 17 Nov 2015 22:39:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C43E62051A for ; Tue, 17 Nov 2015 22:39:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 852EE20523 for ; Tue, 17 Nov 2015 22:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932653AbbKQWjI (ORCPT ); Tue, 17 Nov 2015 17:39:08 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:33032 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932639AbbKQWjB (ORCPT ); Tue, 17 Nov 2015 17:39:01 -0500 Received: by pabfh17 with SMTP id fh17so22938235pab.0 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=BUQ3/QJNeBpe6cLVr8rz3xv7vtaqlMHPSqKTFTlKBr2f+aiI9kSV/UqlsPQqVtCxtK 1fnJf4/KV/jUUIQKO+WNJWFF4SOJ7gmaol4QS0CxW/1SbTDYTb5IUxJgmZuZnW9vuIMk KwzV5B/hAbD8Ms0ARsMmCl3ZUnodP53PcE7w7axh+R0wwStCT6s+cpaCU+JK/4/Fhq5F USamIsJk7z8KNOpNjEW3hsTguABUkBYJcmy6/y06PpckLaK+nFbj0WZwT5cZF0Vmu52w ZeQhxc2tIycvUtxNf/E6aRxA+ElBEh1/9uzbwMTi3ta3wpQWL56ILKYw1HwNtO7YNmss wv3g== X-Gm-Message-State: ALoCoQlh7obrZy+F93szZApKRO0rqnPh+ETKP9/cZcHneBuDla8na5V5Sj2K68wxJBimTWewGSRb 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 Cc: geert@linux-m68k.org, k.kozlowski@samsung.com, msivasub@codeaurora.org, agross@codeaurora.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, lorenzo.pieralisi@arm.com, ahaslam@baylibre.com, mtitinger@baylibre.com, Lina Iyer , Rob Herring 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> 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.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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__ */