From patchwork Mon Feb 15 21:16:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 8319321 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 D7D869F72C for ; Mon, 15 Feb 2016 21:17:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2481E203B8 for ; Mon, 15 Feb 2016 21:17:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 343A1203C0 for ; Mon, 15 Feb 2016 21:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752458AbcBOVRU (ORCPT ); Mon, 15 Feb 2016 16:17:20 -0500 Received: from andre.telenet-ops.be ([195.130.132.53]:60593 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752519AbcBOVRM (ORCPT ); Mon, 15 Feb 2016 16:17:12 -0500 Received: from ayla.of.borg ([84.195.106.123]) by andre.telenet-ops.be with bizsmtp id JlH81s00U2fm56U01lH8bG; Mon, 15 Feb 2016 22:17:10 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1aVQW4-00082c-Ep; Mon, 15 Feb 2016 22:17:08 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1aVQW5-0004xI-6J; Mon, 15 Feb 2016 22:17:09 +0100 From: Geert Uytterhoeven To: Simon Horman , Magnus Damm , Laurent Pinchart Cc: linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC v2 05/11] soc: renesas: rcar: Handle clock domain devices in SYSC PM domains Date: Mon, 15 Feb 2016 22:16:54 +0100 Message-Id: <1455571020-18968-6-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455571020-18968-1-git-send-email-geert+renesas@glider.be> References: <1455571020-18968-1-git-send-email-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 R-Car H3 contains some hardware modules (e.g. VSP and FCP_V) that are not only located in a power area controlled by the SYSC system controller, but that are also part of the generic CPG/MSSR clock domain. Make sure both are handled by enabling module clock PM when the device for such a hardware module is attached to the SYSC PM Domain. FIXME Share code with the renesas-cpg-mssr driver. Signed-off-by: Geert Uytterhoeven --- v2: - New. --- drivers/soc/renesas/pm-rcar.c | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/soc/renesas/pm-rcar.c b/drivers/soc/renesas/pm-rcar.c index c0540934126e58eb..d1bf8c231540b11d 100644 --- a/drivers/soc/renesas/pm-rcar.c +++ b/drivers/soc/renesas/pm-rcar.c @@ -9,16 +9,20 @@ * for more details. */ +#include #include #include #include #include +#include #include #include #include #include #include +#include + /* SYSC Common */ #define SYSCSR 0x00 /* SYSC Status Register */ #define SYSCISR 0x04 /* Interrupt Status Register */ @@ -248,11 +252,75 @@ static int rcar_pd_power_up(struct generic_pm_domain *genpd) return rcar_sysc_power_up(&to_rcar_pd(genpd)->ch); } +#ifdef CONFIG_ARCH_R8A7795 +static int rcar_clk_pd_attach_dev(struct generic_pm_domain *genpd, + struct device *dev) +{ + struct device_node *np = dev->of_node; + struct of_phandle_args clkspec; + struct clk *clk; + int i = 0; + int error; + + while (!of_parse_phandle_with_args(np, "clocks", "#clock-cells", i, + &clkspec)) { + if (clkspec.args_count == 2 && clkspec.args[0] == CPG_MOD && + of_device_is_compatible(clkspec.np, + "renesas,r8a7795-cpg-mssr")) + goto found; + + of_node_put(clkspec.np); + i++; + } + + return 0; + +found: + clk = of_clk_get_from_provider(&clkspec); + of_node_put(clkspec.np); + + if (IS_ERR(clk)) + return PTR_ERR(clk); + + error = pm_clk_create(dev); + if (error) { + dev_err(dev, "pm_clk_create failed %d\n", error); + goto fail_put; + } + + error = pm_clk_add_clk(dev, clk); + if (error) { + dev_err(dev, "pm_clk_add_clk %pC failed %d\n", clk, error); + goto fail_destroy; + } + + return 0; + +fail_destroy: + pm_clk_destroy(dev); +fail_put: + clk_put(clk); + return error; +} + +static void rcar_clk_pd_detach_dev(struct generic_pm_domain *genpd, + struct device *dev) +{ + if (!list_empty(&dev->power.subsys_data->clock_list)) + pm_clk_destroy(dev); +} +#endif /* CONFIG_ARCH_R8A7795 */ + static void rcar_init_pm_domain(struct rcar_pm_domain *rcar_pd) { struct generic_pm_domain *genpd = &rcar_pd->genpd; struct dev_power_governor *gov = rcar_pd->gov; +#ifdef CONFIG_ARCH_R8A7795 + genpd->flags = GENPD_FLAG_PM_CLK; + genpd->attach_dev = rcar_clk_pd_attach_dev; + genpd->detach_dev = rcar_clk_pd_detach_dev; +#endif pm_genpd_init(genpd, gov ? : &simple_qos_governor, false); genpd->dev_ops.active_wakeup = rcar_pd_active_wakeup; genpd->power_off = rcar_pd_power_down;