/*
 * include/asm-arm/arch-cxd4105/entry-macro.S
 *
 * Low-level IRQ helper macros
 *
 * Copyright 2005,2006,2007 Sony Corporation
 *
 * This code is based on include/asm-arm/arch-integrator/entry-macro.S.
 */
/*
 * include/asm-arm/arch-integrator/entry-macro.S
 *
 * Low-level IRQ helper macros for Integrator platforms
 *
 * This file is licensed under  the terms of the GNU General Public
 * License version 2. This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */
#include <asm/arch/irqs.h>

		.macro	disable_fiq
		.endm

		.macro  get_irqnr_preamble, base, tmp
#ifdef CONFIG_CXD4105_UART3
		ldr	\base, =0xe6600000  /* IO_ADDRESS(0x76600000) */
#else
		ldr	\base, =0xe6500000  /* IO_ADDRESS(0x76500000) */
#endif
		.endm

		.macro  arch_ret_to_user, tmp1, tmp2
		.endm

		.macro	get_irqnr_and_base, irqnr, irqstat, base, tmp
		ldr	\irqstat, [\base, #IRQ_STATUS]		@ get masked status

#if 0
		mov	\irqnr, #0
1001:		tst	\irqstat, #1
		bne	1002f
		add	\irqnr, \irqnr, #1
		mov	\irqstat, \irqstat, lsr #1

		cmp	\irqnr, #32

		bcc	1001b
#else
		rsb	\irqnr, \irqstat, #0
		and	\irqnr, \irqnr, \irqstat  @ irqnr = -irqstat & irqstat
		clz	\irqnr, \irqnr
		cmp	\irqnr, #32
		rsbne	\irqnr, \irqnr, #31	  @ irqnr = 31 - irqnr
#endif
1002:		/* EQ will be set if we reach 32 */
		.endm
