From patchwork Fri Mar 3 21:48:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 9603629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C842F604E2 for ; Fri, 3 Mar 2017 21:58:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA31B2861B for ; Fri, 3 Mar 2017 21:58:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF16E2861D; Fri, 3 Mar 2017 21:58:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 657322861C for ; Fri, 3 Mar 2017 21:58:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752087AbdCCV6O (ORCPT ); Fri, 3 Mar 2017 16:58:14 -0500 Received: from mail-pf0-f177.google.com ([209.85.192.177]:33790 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752145AbdCCV6N (ORCPT ); Fri, 3 Mar 2017 16:58:13 -0500 Received: by mail-pf0-f177.google.com with SMTP id w189so36962109pfb.0 for ; Fri, 03 Mar 2017 13:57:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LLQLK6gfKneRYNsCbHw6GnSwl9fGy6r9Hg8jLcfeRjk=; b=VSRlHsa+U6REIVwB+GH1yOwbOpszALoZsgwNbPV9oZlnSgsS6py2SuXKcNDUk8hHzU ndCE6LTBASjNch+qkr59iH2Ox6jM+BX/kON3dJXhKG2KE8Su4e/gQs5OjLmtuvydyLoW NdO+0r4KFhNeEAzJNt5/yA3wAknzwcTbn/jm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LLQLK6gfKneRYNsCbHw6GnSwl9fGy6r9Hg8jLcfeRjk=; b=uPgyL5AyA9KLeGH5M6ZjSzpl2nZXXY9KMp+rqZIsep+riC8NtHJOsgq/55aEhtsF+S gQVUS9/2UxLkjmhvVQKYBy9atib9fUApkv6Za/XsMNvbNRnBPa6pnaz8UxRRFyd5GbKv gRQxxS5kl1cVow9ZgygSQzDFlGdwPp8mf7VSQoZ9dRUrMQ4xA746ep9N8zT8541nicbb ZWs68erZS2g3W50OQb4Y4D6mCIwrQEnmS2QTFBRfZeAKXI8fTwg6+sD6WEZc3c0DqpeR ZPHyi6NkYv3sLiv2AfCFdFbdxpZCRtCVV33oisjnrsfoOOSU1Z3XDnOnw38OxXqRTjwL ocJg== X-Gm-Message-State: AMke39misG0ix/buPFcanMp0d89+TF+m3JypNHGNXx+1UNOsk6v2D7sjT/U53a8o5TmXaX/a X-Received: by 10.99.146.7 with SMTP id o7mr6013260pgd.6.1488577711601; Fri, 03 Mar 2017 13:48:31 -0800 (PST) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id q23sm25200585pfg.63.2017.03.03.13.48.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 13:48:30 -0800 (PST) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: andy.gross@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, brendan.jackman@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Juri.Lelli@arm.com, Lina Iyer Subject: [PATCH V5 4/6] drivers: firmwware: psci: Support hierachical idle states Date: Fri, 3 Mar 2017 13:48:15 -0800 Message-Id: <1488577697-127445-5-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488577697-127445-1-git-send-email-lina.iyer@linaro.org> References: <1488577697-127445-1-git-send-email-lina.iyer@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Read in the idle state properties for a CPU's idle state from its PM domain, if such a domain exists or use the existing CPU node property. Signed-off-by: Lina Iyer --- drivers/firmware/psci.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 18ae62d..190d3a7 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -292,15 +292,24 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) { int i, ret, count = 0; u32 *psci_states; - struct device_node *state_node; - - /* Count idle states */ - while ((state_node = of_parse_phandle(cpu_node, "cpu-idle-states", - count))) { - count++; - of_node_put(state_node); + struct device_node *state_node, *dn; + struct of_phandle_args args; + bool cpu_has_domain = false; + const char *property; + + /* Is there a domain provider for this CPU? */ + ret = of_parse_phandle_with_args(cpu_node, "power-domains", + "#power-domain-cells", 0, &args); + if (!ret) { + dn = args.np; + ret = of_count_phandle_with_args(dn, "domain-idle-states", + NULL); + cpu_has_domain = (ret > 0); } + count = (cpu_has_domain) ? ret : + of_count_phandle_with_args(cpu_node, "cpu-idle-states", NULL); + if (!count) return -ENODEV; @@ -308,10 +317,17 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) if (!psci_states) return -ENOMEM; + if (cpu_has_domain) { + property = "domain-idle-states"; + } else { + property = "cpu-idle-states"; + dn = cpu_node; + } + for (i = 0; i < count; i++) { u32 state; - state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); + state_node = of_parse_phandle(dn, property, i); ret = of_property_read_u32(state_node, "arm,psci-suspend-param",