From patchwork Thu Apr 7 12:20:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 8772731 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 A93CCC0554 for ; Thu, 7 Apr 2016 12:21:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 07D7F20263 for ; Thu, 7 Apr 2016 12:21:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E83B202A1 for ; Thu, 7 Apr 2016 12:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756101AbcDGMU6 (ORCPT ); Thu, 7 Apr 2016 08:20:58 -0400 Received: from laurent.telenet-ops.be ([195.130.137.89]:58980 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755460AbcDGMUX (ORCPT ); Thu, 7 Apr 2016 08:20:23 -0400 Received: from ayla.of.borg ([84.195.106.123]) by laurent.telenet-ops.be with bizsmtp id fQLN1s00k2fm56U01QLPAK; Thu, 07 Apr 2016 14:20:23 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1ao8v8-0005zD-TO; Thu, 07 Apr 2016 14:20:22 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1ao8vG-0003UG-51; Thu, 07 Apr 2016 14:20:30 +0200 From: Geert Uytterhoeven To: Simon Horman , Magnus Damm Cc: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Laurent Pinchart , linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v4 05/11] soc: renesas: rcar-sysc: Enable Clock Domain for r8a7795 I/O devices Date: Thu, 7 Apr 2016 14:20:22 +0200 Message-Id: <1460031628-13336-6-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460031628-13336-1-git-send-email-geert+renesas@glider.be> References: <1460031628-13336-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=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 On R-Car H3, some power areas (e.g. A3VP) contain I/O devices, which are also part of the CPG/MSSR Clock Domain. Hook up the CPG/MSSR Clock Domain attach/detach callbacks to enable power management using module clocks. This also allows to support the Clock Domain for devices in the "always-on" power area. Signed-off-by: Geert Uytterhoeven --- v4: - Remove the explicit dependency on the CPG/MSSR driver by forwarding the attach/detach callbacks to the parent PM Domain. If deemed reusable, rcar_sysc_{at,de}tach_dev() can be moved to common genpd code later. v3: - Hook up the CPG/MSSR Clock Domain attach/detach callbacks instead of using our own copies, v2: - New. --- drivers/soc/renesas/rcar-sysc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c index bdab8ac6803300e7..6fad1311133a3ac7 100644 --- a/drivers/soc/renesas/rcar-sysc.c +++ b/drivers/soc/renesas/rcar-sysc.c @@ -224,6 +224,36 @@ static int rcar_sysc_pd_power_on(struct generic_pm_domain *genpd) return rcar_sysc_power_up(&pd->ch); } +#ifdef CONFIG_ARCH_R8A7795 +static int rcar_sysc_attach_dev(struct generic_pm_domain *genpd, + struct device *dev) +{ + struct gpd_link *link; + int error; + + /* Forward call to parent */ + list_for_each_entry(link, &genpd->slave_links, slave_node) + if (link->master && link->master->attach_dev) { + error = link->master->attach_dev(link->master, dev); + if (error) + return error; + } + + return 0; +} + +static void rcar_sysc_detach_dev(struct generic_pm_domain *genpd, + struct device *dev) +{ + struct gpd_link *link; + + /* Forward call to parent */ + list_for_each_entry(link, &genpd->slave_links, slave_node) + if (link->master && link->master->detach_dev) + link->master->detach_dev(link->master, dev); +} +#endif /* CONFIG_ARCH_R8A7795 */ + static void __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd) { struct generic_pm_domain *genpd = &pd->genpd; @@ -249,6 +279,15 @@ static void __init rcar_sysc_pd_setup(struct rcar_sysc_pd *pd) gov = &pm_domain_always_on_gov; } +#ifdef CONFIG_ARCH_R8A7795 + if (!(pd->flags & (PD_CPU | PD_SCU))) { + /* Enable Clock Domain for I/O devices */ + genpd->flags = GENPD_FLAG_PM_CLK; + genpd->attach_dev = rcar_sysc_attach_dev; + genpd->detach_dev = rcar_sysc_detach_dev; + } +#endif + pm_genpd_init(genpd, gov, false); genpd->dev_ops.active_wakeup = rcar_sysc_active_wakeup; genpd->power_off = rcar_sysc_pd_power_off;