From patchwork Mon Jan 30 10:18:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Walmsley X-Patchwork-Id: 138540 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CAABC1007D2 for ; Mon, 30 Jan 2012 21:23:25 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RroLF-0002JC-T2; Mon, 30 Jan 2012 10:20:06 +0000 Received: from utopia.booyaka.com ([72.9.107.138]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RroJw-0001wq-CC for linux-arm-kernel@lists.infradead.org; Mon, 30 Jan 2012 10:18:50 +0000 Received: (qmail 7702 invoked by uid 1019); 30 Jan 2012 10:18:43 -0000 MBOX-Line: From nobody Mon Jan 30 03:18:17 2012 Subject: [PATCH 5/7] ARM: OMAP2+: hwmod: add omap_hwmod_get_mpu_irq() and omap_hwmod_get_mpu_rt_pa() To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org From: Paul Walmsley Date: Mon, 30 Jan 2012 03:18:17 -0700 Message-ID: <20120130101816.10450.2624.stgit@dusk> In-Reply-To: <20120130101251.10450.58423.stgit@dusk> References: <20120130101251.10450.58423.stgit@dusk> User-Agent: StGit/0.15 MIME-Version: 1.0 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 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Tony Lindgren , =?utf-8?q?Beno=C3=AEt?= Cousson X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org The timer integration code pokes around in hwmod data structures. Those data structures are about to change. Define some functions for the timer integration code to use instead. Signed-off-by: Paul Walmsley Cc: BenoƮt Cousson Cc: Tony Lindgren --- arch/arm/mach-omap2/omap_hwmod.c | 82 ++++++++++++++++++++++++++ arch/arm/plat-omap/include/plat/omap_hwmod.h | 3 + 2 files changed, 85 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 4e8d332..f7bf759 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -2794,3 +2794,85 @@ int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx) return 0; } + +/* + * IP block data retrieval functions + */ + +/** + * omap_hwmod_get_mpu_irq - return a hwmod's MPU IRQ line ID, if it only has one + * @oh: struct omap_hwmod * to examine MPU IRQs on + * + * If the IP block represented by @oh only has one IRQ line, return its + * ID; otherwise, return -ENOENT if the IP block has no MPU IRQs, or -EINVAL + * if @oh is null or hasn't yet been registered. + */ +int omap_hwmod_get_mpu_irq(struct omap_hwmod *oh) +{ + struct omap_hwmod_irq_info *ii; + + if (!oh) + return -EINVAL; + + if (oh->_state == _HWMOD_STATE_UNKNOWN) + return -EINVAL; + + if (!oh->mpu_irqs) + return -ENOENT; + + ii = &oh->mpu_irqs[0]; + + if (ii->irq == -1) + return -ENOENT; + + return ii->irq; +} + +/** + * omap_hwmod_get_mpu_rt_pa - get the register target physical start & end addrs + * @oh: struct omap_hwmod * to retrieve physical address information for + * @pa_start: ptr to a u32 to return the starting physical address of the RT + * @pa_end: ptr to a u32 to return the ending physical address of the RT + * + * For a given hwmod @oh, return the starting MPU physical address of + * @oh's register target address space in the u32 pointed to by + * @pa_start, and return the ending MPU physical address of @oh's + * register target address space in the u32 pointed to by @pa_end. + * (Device registers, particularly the OCP header registers, are + * expected to reside in this space.) The previous contents of the + * data pointed to by @pa_start and @pa_end are ignored and + * overwritten. @pa_start is usually (but not always) the same as the + * device's "base address." Note that @pa_start and @pa_end are + * currently only guaranteed to be valid addresses for the MPU, not + * for other interconnect initiators. + * + * Returns 0 upon success, -EINVAL if any arguments are null or if the + * hwmod hasn't been registered, or -ENOENT if @oh has no MPU register + * target address space. + */ +int omap_hwmod_get_mpu_rt_pa(struct omap_hwmod *oh, u32 *pa_start, u32 *pa_end) +{ + struct omap_hwmod_addr_space *mem; + + if (!oh || !pa_start || !pa_end) + return -EINVAL; + + if (oh->_state == _HWMOD_STATE_UNKNOWN) + return -EINVAL; + + if (oh->_int_flags & _HWMOD_NO_MPU_PORT) + return -ENOENT; + + mem = _find_mpu_rt_addr_space(oh); + if (!mem) { + pr_debug("omap_hwmod: %s: no MPU register target found\n", + oh->name); + return -ENOENT; + } + + *pa_start = mem->pa_start; + *pa_end = mem->pa_end; + + return 0; +} + diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h index 6470101..0d95c86 100644 --- a/arch/arm/plat-omap/include/plat/omap_hwmod.h +++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h @@ -610,6 +610,9 @@ int omap_hwmod_no_setup_reset(struct omap_hwmod *oh); int omap_hwmod_pad_route_irq(struct omap_hwmod *oh, int pad_idx, int irq_idx); +int omap_hwmod_get_mpu_irq(struct omap_hwmod *oh); +int omap_hwmod_get_mpu_rt_pa(struct omap_hwmod *oh, u32 *pa_start, u32 *pa_end); + /* * Chip variant-specific hwmod init routines - XXX should be converted * to use initcalls once the initial boot ordering is straightened out