From patchwork Fri Jul 13 16:37:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 1204131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 2F52B3FC8E for ; Tue, 17 Jul 2012 09:06:12 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sr3eL-00050n-3g; Tue, 17 Jul 2012 09:00:57 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Spisg-0000nE-I0 for linux-arm-kernel@lists.infradead.org; Fri, 13 Jul 2012 16:39:01 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q6DGc8wR004057; Fri, 13 Jul 2012 11:38:08 -0500 Received: from DFLE70.ent.ti.com (dfle70.ent.ti.com [128.247.5.40]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6DGc7cV004101; Fri, 13 Jul 2012 11:38:08 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle70.ent.ti.com (128.247.5.40) with Microsoft SMTP Server id 14.1.323.3; Fri, 13 Jul 2012 11:38:08 -0500 Received: from localhost.localdomain (h64-15.vpn.ti.com [172.24.64.15]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6DGbxqf001357; Fri, 13 Jul 2012 11:38:06 -0500 From: Tero Kristo To: , , Subject: [RFC 4/6] ARM: OMAP3: hwmod data: add custom setup_preprogram for iva hwmod Date: Fri, 13 Jul 2012 19:37:37 +0300 Message-ID: <1342197459-7920-5-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1342197459-7920-1-git-send-email-t-kristo@ti.com> References: <1342197459-7920-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Mailman-Approved-At: Tue, 17 Jul 2012 04:58:13 -0400 Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org IVA2 module must be properly put to idle mode during boot, as it is possible that it is enabled by bootloader, and this will prevent core retention/off. Previously this was done by an init time hook from pm34xx.c file, but this functionality is now moved within hwmod setup_preprogram hook for iva hwmod. This patch introduces following warning during boot: omap_hwmod: iva: failed to hardreset This is generated by asserting the 'logic' hardreset for IVA2 hwmod. However, this warning is not fatal, and doesn't cause any functional problems. Signed-off-by: Tero Kristo --- arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 13 +++++- arch/arm/mach-omap2/pm34xx.c | 49 ------------------- include/linux/platform_data/omap3-iva.h | 73 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 50 deletions(-) create mode 100644 include/linux/platform_data/omap3-iva.h diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c index 98bc6f9..1ef6c90 100644 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c @@ -14,6 +14,12 @@ * * XXX these should be marked initdata for multi-OMAP kernels */ + +#include +#include "control.h" +#include "iomap.h" +#include + #include #include #include @@ -105,9 +111,14 @@ static struct omap_hwmod_rst_info omap3xxx_iva_resets[] = { { .name = "seq1", .rst_shift = 2, .st_shift = 10 }, }; +static struct omap_hwmod_class omap3xxx_iva_hwmod_class = { + .name = "iva", + .setup_preprogram = hwmod_iva_preprogram, +}; + static struct omap_hwmod omap3xxx_iva_hwmod = { .name = "iva", - .class = &iva_hwmod_class, + .class = &omap3xxx_iva_hwmod_class, .clkdm_name = "iva2_clkdm", .rst_lines = omap3xxx_iva_resets, .rst_lines_cnt = ARRAY_SIZE(omap3xxx_iva_resets), diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index 474ed9d..d407b32 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c @@ -333,54 +333,6 @@ restore: #endif /* CONFIG_SUSPEND */ - -/** - * omap3_iva_idle(): ensure IVA is in idle so it can be put into - * retention - * - * In cases where IVA2 is activated by bootcode, it may prevent - * full-chip retention or off-mode because it is not idle. This - * function forces the IVA2 into idle state so it can go - * into retention/off and thus allow full-chip retention/off. - * - **/ -static void __init omap3_iva_idle(void) -{ - /* ensure IVA2 clock is disabled */ - omap2_cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN); - - /* if no clock activity, nothing else to do */ - if (!(omap2_cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST) & - OMAP3430_CLKACTIVITY_IVA2_MASK)) - return; - - /* Reset IVA2 */ - omap2_prm_write_mod_reg(OMAP3430_RST1_IVA2_MASK | - OMAP3430_RST2_IVA2_MASK | - OMAP3430_RST3_IVA2_MASK, - OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL); - - /* Enable IVA2 clock */ - omap2_cm_write_mod_reg(OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_MASK, - OMAP3430_IVA2_MOD, CM_FCLKEN); - - /* Set IVA2 boot mode to 'idle' */ - omap_ctrl_writel(OMAP3_IVA2_BOOTMOD_IDLE, - OMAP343X_CONTROL_IVA2_BOOTMOD); - - /* Un-reset IVA2 */ - omap2_prm_write_mod_reg(0, OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL); - - /* Disable IVA2 clock */ - omap2_cm_write_mod_reg(0, OMAP3430_IVA2_MOD, CM_FCLKEN); - - /* Reset IVA2 */ - omap2_prm_write_mod_reg(OMAP3430_RST1_IVA2_MASK | - OMAP3430_RST2_IVA2_MASK | - OMAP3430_RST3_IVA2_MASK, - OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL); -} - static void __init omap3_d2d_idle(void) { u16 mask, padconf; @@ -478,7 +430,6 @@ static void __init prcm_setup_regs(void) /* Clear any pending PRCM interrupts */ omap2_prm_write_mod_reg(0, OCP_MOD, OMAP3_PRM_IRQSTATUS_MPU_OFFSET); - omap3_iva_idle(); omap3_d2d_idle(); } diff --git a/include/linux/platform_data/omap3-iva.h b/include/linux/platform_data/omap3-iva.h new file mode 100644 index 0000000..742349a --- /dev/null +++ b/include/linux/platform_data/omap3-iva.h @@ -0,0 +1,73 @@ +/* + * OMAP3 IVA IP block integration + * + * Copyright (C) 2012 Texas Instruments, Inc. + * Tero Kristo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#ifndef __LINUX_PLATFORM_DATA_OMAP3_IVA_H__ +#define __LINUX_PLATFORM_DATA_OMAP3_IVA_H__ + +#include +#include + +#include + +/** + * hwmod_iva_preprogram - execute reset sequence for IVA2 + * @oh: pointer to iva2 hwmod + * + * Runs reset sequence for IVA2. In cases where IVA2 is activated + * by bootcode, it may prevent full-chip retention or off-mode + * because it is not idle. This function forces the IVA2 into idle + * state so it can go into retention/off and thus allow full-chip + * retention/off. Always returns 0. + */ +static int __maybe_unused hwmod_iva_preprogram(struct omap_hwmod *oh) +{ + int i; + + /* Ensure clock is disabled */ + omap_hwmod_enable_clocks(oh); + omap_hwmod_disable_clocks(oh); + + /* Reset IVA2 */ + for (i = 0; i < oh->rst_lines_cnt; i++) + omap_hwmod_assert_hardreset(oh, oh->rst_lines[i].name); + + + /* Enable IVA2 clock */ + omap_hwmod_enable_clocks(oh); + + /* Set IVA2 bootmode to 'idle' */ + omap_ctrl_writel(OMAP3_IVA2_BOOTMOD_IDLE, + OMAP343X_CONTROL_IVA2_BOOTMOD); + + /* Un-reset IVA2 */ + for (i = 0; i < oh->rst_lines_cnt; i++) + omap_hwmod_deassert_hardreset(oh, oh->rst_lines[i].name); + + /* Disable IVA2 clock */ + omap_hwmod_disable_clocks(oh); + + /* Reset IVA2 */ + for (i = 0; i < oh->rst_lines_cnt; i++) + omap_hwmod_assert_hardreset(oh, oh->rst_lines[i].name); + + return 0; +} + +#endif /* __LINUX_PLATFORM_DATA_OMAP3_IVA_H__ */