From patchwork Mon Jul 29 09:12:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 2834863 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 437F09F4D4 for ; Mon, 29 Jul 2013 09:13:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D7E220126 for ; Mon, 29 Jul 2013 09:13:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F894200E1 for ; Mon, 29 Jul 2013 09:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752269Ab3G2JNY (ORCPT ); Mon, 29 Jul 2013 05:13:24 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:50282 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752093Ab3G2JNY (ORCPT ); Mon, 29 Jul 2013 05:13:24 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6T9CxS6017068; Mon, 29 Jul 2013 04:12:59 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r6T9CxLb014246; Mon, 29 Jul 2013 04:12:59 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Mon, 29 Jul 2013 04:12:59 -0500 Received: from ula0131687.itg.ti.com (ula0131687-172024145046.apr.dhcp.ti.com [172.24.145.46]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6T9CqZO024245; Mon, 29 Jul 2013 04:12:57 -0500 From: Rajendra Nayak To: , CC: , , Rajendra Nayak Subject: [RFC 2/2] ARM: OMAP2+: hwmod: Do the late part of init and setup/reset on first enable Date: Mon, 29 Jul 2013 14:42:42 +0530 Message-ID: <1375089162-30664-3-git-send-email-rnayak@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1375089162-30664-1-git-send-email-rnayak@ti.com> References: <1375089162-30664-1-git-send-email-rnayak@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.4 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 Instead of doing a complete init and setup(including reset) of all modules early at boot, do it when a module is asked to be enabled the first time. This should get rid of all the need for having all the rest of PM frameworks in place quite early at boot, and should also make sure reset happens only when drivers are initializing the modules. For the modules which do not have drivers build in, do this as part of a late initcall. Signed-off-by: Rajendra Nayak --- arch/arm/mach-omap2/omap_hwmod.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index e49159c..7e4d602 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -2082,6 +2082,9 @@ static int _enable_preprogram(struct omap_hwmod *oh) return oh->class->enable_preprogram(oh); } +static int _init_late(struct omap_hwmod *oh, void *data); +static void _setup_iclk_autoidle(struct omap_hwmod *oh); + /** * _enable - enable an omap_hwmod * @oh: struct omap_hwmod * @@ -2094,9 +2097,17 @@ static int _enable(struct omap_hwmod *oh) { int r; int hwsup = 0; + bool needs_reset; pr_debug("omap_hwmod: %s: enabling\n", oh->name); + if (oh->_state == _HWMOD_STATE_REGISTERED) { + _init_late(oh, NULL); + _setup_iclk_autoidle(oh); + if (!(oh->flags & HWMOD_INIT_NO_RESET)) + needs_reset = true; + } + /* * hwmods with HWMOD_INIT_NO_IDLE flag set are left in enabled * state at init. Now that someone is really trying to enable @@ -2200,6 +2211,9 @@ static int _enable(struct omap_hwmod *oh) clkdm_hwmod_disable(oh->clkdm, oh); } + if (needs_reset) + r = _reset(oh); + return r; } @@ -3309,13 +3323,27 @@ static int __init omap_hwmod_setup_all(void) _ensure_mpu_hwmod_is_setup(NULL); omap_hwmod_for_each(_init_early, NULL); - omap_hwmod_for_each(_init_late, NULL); - omap_hwmod_for_each(_setup, NULL); return 0; } omap_core_initcall(omap_hwmod_setup_all); +static int __init omap_hwmod_setup_rest(void) +{ + struct omap_hwmod *oh; + + _ensure_mpu_hwmod_is_setup(NULL); + + list_for_each_entry(oh, &omap_hwmod_list, node) { + if (oh->_state == _HWMOD_STATE_REGISTERED) { + _init_late(oh, NULL); + _setup(oh, NULL); + } + } + return 0; +} +omap_late_initcall(omap_hwmod_setup_rest); + /** * omap_hwmod_enable - enable an omap_hwmod * @oh: struct omap_hwmod *