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: 9603603 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 4BEA6602B4 for ; Fri, 3 Mar 2017 21:51:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D7C728610 for ; Fri, 3 Mar 2017 21:51:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3203B28614; Fri, 3 Mar 2017 21:51:13 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B585828613 for ; Fri, 3 Mar 2017 21:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fbG3UPXhRlnBWOXGmDFR+7ppKVmUG3VV1DXlc40vjwc=; b=MjZqskyUau7B0rBYquhxheDoNd RP5RkDbBLGHQ4vRjqcnGyB1IBSb+hCLB+LxkGCEIOIqlfw9mDfj3ZDUjlP2XFLYj3QvxgWtb5Atya wNyVNF2E9MuQsSWt1lDF9mPmTktHzbftlONop5zHhzt9KHtLo3MegLMJvBGUEyrf36lyqR7bLL1lY WBl6BTvvLIG88Skj2lfWpkXlx/5UyS3zC3JE0Q8prws125sSGYIJSL/DkREoGB/6QpE+IdPJEkWy2 YeD8Zx3HEQCI0zz/CjAAV9zgV5gdNBvZWqgTi22a7IongN9dXebMpOxBHOfIAPBcf+JNfWG0nBHrY 9uDCKrng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cjv6Q-0002Wl-Vy; Fri, 03 Mar 2017 21:51:06 +0000 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjv4G-00005g-Ea for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2017 21:48:54 +0000 Received: by mail-pf0-x22f.google.com with SMTP id v190so148919pfb.1 for ; Fri, 03 Mar 2017 13:48:32 -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=FPklzA5cKRvN360BA8d1TchXZGr1OfvMGa9nyg6A2avwSlGEDRKlVJI+NpPJ0Zoswl 21fZfVSnhPnpahCZsTTFd19Tj61E4gCsTYOPT0bU8WKRvP+NQy+4fnSQdTTfwzpR3IK2 l6mgslQP3B9bQx1KQEn6BmKhaMkmWyrNue+FzCUALS0ji0ZuzIfttZVNOzxB58IRS5Yk gS4JgLeHWexibvXQeX/XAQWH1bWqpvQ6P59gEP3pok1hsR5FdA4d4UYBe21OzBFI4gxH 6SVFTDMSFKQH9G2rUN4lGopopmNMApX5xMKzXzl3By8RYtzbHKlk/ciFLY0scMSJOkH1 tScQ== X-Gm-Message-State: AMke39lCMI7Pqawkdgmm7fBmVxUIzWrCRWjBLgtbBqN/vwVD9nqu71yq9V2E6H7O8PheoAd4 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170303_134852_522539_713313A2 X-CRM114-Status: GOOD ( 12.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lorenzo.pieralisi@arm.com, Juri.Lelli@arm.com, linux-arm-msm@vger.kernel.org, sboyd@codeaurora.org, brendan.jackman@arm.com, sudeep.holla@arm.com, andy.gross@linaro.org, Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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",