From patchwork Tue Jun 23 12:09:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 6660471 Return-Path: X-Original-To: patchwork-linux-omap@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 DB9AC9F39B for ; Tue, 23 Jun 2015 12:10:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CAA3E206BE for ; Tue, 23 Jun 2015 12:10:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3179020645 for ; Tue, 23 Jun 2015 12:10:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754707AbbFWMKE (ORCPT ); Tue, 23 Jun 2015 08:10:04 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:53921 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754504AbbFWMKD (ORCPT ); Tue, 23 Jun 2015 08:10:03 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id t5NC9xCY024340; Tue, 23 Jun 2015 07:09:59 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5NC9xjk014129; Tue, 23 Jun 2015 07:09:59 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Tue, 23 Jun 2015 07:09:58 -0500 Received: from rockdesk.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5NC9sVc020875; Tue, 23 Jun 2015 07:09:57 -0500 From: Roger Quadros To: CC: , , , , , Roger Quadros Subject: [PATCH 1/3] ARM: OMAP2+: clockdomain: Add mechanism for disabling HW_AUTO Date: Tue, 23 Jun 2015 15:09:52 +0300 Message-ID: <1435061394-20379-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435061394-20379-1-git-send-email-rogerq@ti.com> References: <1435061394-20379-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.3 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 For some hwmods (e.g. DCAN on DRA7) we need the possibility to disable HW_AUTO for the clockdomain while the module is active. To achieve this there needs to be a refcounting mechanism to indicate whether any module in the clockdomain has requested to disable HW_AUTO. We keep track of this in 'noidlecount'. Hwmod code must use clkdm_hwmod_prevent_hwauto() to prevent HW_AUTO of the clockdomain in the future clkdm_hwmod_hwauto() calls. It must use clkdm_hwmod_allow_hwauto() to allow HW_AUTO in the future clkdm_hwmod_hwauto() calls. Hwmod code must use clkdm_hwmod_allow_hwauto() whenever it needs to request HW_AUTO of any clockdomain. (Typically after it has enabled the module). Signed-off-by: Roger Quadros --- arch/arm/mach-omap2/clockdomain.c | 71 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/clockdomain.h | 5 +++ 2 files changed, 76 insertions(+) diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c index 2da3b5e..a7190d2 100644 --- a/arch/arm/mach-omap2/clockdomain.c +++ b/arch/arm/mach-omap2/clockdomain.c @@ -1212,6 +1212,77 @@ ccd_exit: return 0; } +/* + * prevent future hwauto for this clkdm. If clkdm->usecount becomes hwauto isn't prevented. + * It will only prevnt future hwauto but not bring it out of hwauto. + */ +int clkdm_hwmod_prevent_hwauto(struct clockdomain *clkdm, struct omap_hwmod *oh) +{ + /* The clkdm attribute does not exist yet prior OMAP4 */ + if (cpu_is_omap24xx() || cpu_is_omap34xx()) + return 0; + + if (!clkdm || !oh || !arch_clkdm || !arch_clkdm->clkdm_clk_disable) + return -EINVAL; + + + pwrdm_lock(clkdm->pwrdm.ptr); + clkdm->noidlecount++; + pwrdm_unlock(clkdm->pwrdm.ptr); + + return 0; +} + +/* + * allow future hwauto for this clkdm + * It won't put clkdm into hwauto. use clkdm_hwmod_hwauto() for that. + */ +int clkdm_hwmod_allow_hwauto(struct clockdomain *clkdm, struct omap_hwmod *oh) +{ + /* The clkdm attribute does not exist yet prior OMAP4 */ + if (cpu_is_omap24xx() || cpu_is_omap34xx()) + return 0; + + if (!clkdm || !oh || !arch_clkdm || !arch_clkdm->clkdm_clk_disable) + return -EINVAL; + + + pwrdm_lock(clkdm->pwrdm.ptr); + + if (clkdm->noidlecount == 0) { + pwrdm_unlock(clkdm->pwrdm.ptr); + WARN_ON(1); /* underflow */ + return -ERANGE; + } + + clkdm->noidlecount--; + pwrdm_unlock(clkdm->pwrdm.ptr); + + return 0; +} + +/* + * put clkdm in hwauto if we can. checks noidlecount to see if we can. + */ +int clkdm_hwmod_hwauto(struct clockdomain *clkdm, struct omap_hwmod *oh) +{ + /* The clkdm attribute does not exist yet prior OMAP4 */ + if (cpu_is_omap24xx() || cpu_is_omap34xx()) + return 0; + + if (!clkdm || !oh || !arch_clkdm || !arch_clkdm->clkdm_clk_disable) + return -EINVAL; + + + pwrdm_lock(clkdm->pwrdm.ptr); + if (clkdm->noidlecount == 0) + clkdm_allow_idle_nolock(clkdm); + + pwrdm_unlock(clkdm->pwrdm.ptr); + + return 0; +} + /** * clkdm_hwmod_enable - add an enabled downstream hwmod to this clkdm * @clkdm: struct clockdomain * diff --git a/arch/arm/mach-omap2/clockdomain.h b/arch/arm/mach-omap2/clockdomain.h index 77bab5f..8c491be 100644 --- a/arch/arm/mach-omap2/clockdomain.h +++ b/arch/arm/mach-omap2/clockdomain.h @@ -114,6 +114,7 @@ struct omap_hwmod; * @wkdep_srcs: Clockdomains that can be told to wake this powerdomain up * @sleepdep_srcs: Clockdomains that can be told to keep this clkdm from inact * @usecount: Usecount tracking + * @noidlecount: Noidle count tracking. Domain won't be auto idled this is > 0. * @node: list_head to link all clockdomains together * * @prcm_partition should be a macro from mach-omap2/prcm44xx.h (OMAP4 only) @@ -138,6 +139,7 @@ struct clockdomain { struct clkdm_dep *wkdep_srcs; struct clkdm_dep *sleepdep_srcs; int usecount; + int noidlecount; struct list_head node; }; @@ -211,6 +213,9 @@ int clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk); int clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk); int clkdm_hwmod_enable(struct clockdomain *clkdm, struct omap_hwmod *oh); int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh); +int clkdm_hwmod_prevent_hwauto(struct clockdomain *clkdm, struct omap_hwmod *oh); +int clkdm_hwmod_allow_hwauto(struct clockdomain *clkdm, struct omap_hwmod *oh); +int clkdm_hwmod_hwauto(struct clockdomain *clkdm, struct omap_hwmod *oh); extern void __init omap242x_clockdomains_init(void); extern void __init omap243x_clockdomains_init(void);