Home | History | Annotate | Line # | Download | only in iq80310
iq80310_intr.h revision 1.6.8.1
      1  1.6.8.1     yamt /*	$NetBSD: iq80310_intr.h,v 1.6.8.1 2008/05/18 12:31:49 yamt Exp $	*/
      2      1.1   briggs 
      3      1.1   briggs /*
      4      1.1   briggs  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
      5      1.1   briggs  * All rights reserved.
      6      1.1   briggs  *
      7      1.1   briggs  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8      1.1   briggs  *
      9      1.1   briggs  * Redistribution and use in source and binary forms, with or without
     10      1.1   briggs  * modification, are permitted provided that the following conditions
     11      1.1   briggs  * are met:
     12      1.1   briggs  * 1. Redistributions of source code must retain the above copyright
     13      1.1   briggs  *    notice, this list of conditions and the following disclaimer.
     14      1.1   briggs  * 2. Redistributions in binary form must reproduce the above copyright
     15      1.1   briggs  *    notice, this list of conditions and the following disclaimer in the
     16      1.1   briggs  *    documentation and/or other materials provided with the distribution.
     17      1.1   briggs  * 3. All advertising materials mentioning features or use of this software
     18      1.1   briggs  *    must display the following acknowledgement:
     19      1.1   briggs  *	This product includes software developed for the NetBSD Project by
     20      1.1   briggs  *	Wasabi Systems, Inc.
     21      1.1   briggs  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22      1.1   briggs  *    or promote products derived from this software without specific prior
     23      1.1   briggs  *    written permission.
     24      1.1   briggs  *
     25      1.1   briggs  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26      1.1   briggs  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27      1.1   briggs  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28      1.1   briggs  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29      1.1   briggs  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30      1.1   briggs  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31      1.1   briggs  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32      1.1   briggs  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33      1.1   briggs  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34      1.1   briggs  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35      1.1   briggs  * POSSIBILITY OF SUCH DAMAGE.
     36      1.1   briggs  */
     37      1.1   briggs 
     38      1.1   briggs #ifndef _IQ80310_INTR_H_
     39      1.1   briggs #define _IQ80310_INTR_H_
     40      1.1   briggs 
     41      1.1   briggs #include "opt_iop310.h"
     42      1.1   briggs 
     43      1.1   briggs #include <arm/armreg.h>
     44      1.1   briggs #include <arm/cpufunc.h>
     45      1.1   briggs 
     46      1.1   briggs #include <arm/xscale/i80200reg.h>
     47      1.1   briggs #include <arm/xscale/i80200var.h>
     48      1.1   briggs 
     49      1.1   briggs #if defined(IOP310_TEAMASA_NPWR)
     50      1.1   briggs /*
     51      1.1   briggs  * We have 5 interrupt source bits -- all in XINT3.  All interrupts
     52      1.1   briggs  * can be masked in the CPLD.
     53      1.1   briggs  */
     54      1.1   briggs #define	IRQ_BITS		0x1f
     55      1.1   briggs #define	IRQ_BITS_ALWAYS_ON	0x00
     56      1.1   briggs #else /* Default to stock IQ80310 */
     57      1.1   briggs /*
     58      1.1   briggs  * We have 8 interrupt source bits -- 5 in the XINT3 register, and 3
     59      1.1   briggs  * in the XINT0 register (the upper 3).  Note that the XINT0 IRQs
     60      1.1   briggs  * (SPCI INTA, INTB, and INTC) are always enabled, since they can not
     61      1.1   briggs  * be masked out in the CPLD (it provides only status, not masking,
     62      1.1   briggs  * for those interrupts).
     63      1.1   briggs  */
     64      1.1   briggs #define	IRQ_BITS		0xff
     65      1.1   briggs #define	IRQ_BITS_ALWAYS_ON	0xe0
     66      1.1   briggs #define	IRQ_READ_XINT0		1	/* XXX only if board rev >= F */
     67      1.1   briggs #endif /* list of IQ80310-based designs */
     68      1.1   briggs 
     69      1.6     matt #ifdef __HAVE_FAST_SOFTINTS
     70      1.1   briggs void	iq80310_do_soft(void);
     71      1.6     matt #endif
     72      1.1   briggs 
     73      1.5    perry static inline int __attribute__((__unused__))
     74      1.1   briggs iq80310_splraise(int ipl)
     75      1.1   briggs {
     76      1.1   briggs 	extern int iq80310_imask[];
     77      1.1   briggs 	int old;
     78      1.1   briggs 
     79  1.6.8.1     yamt 	old = curcpl();
     80  1.6.8.1     yamt 	set_curcpl(old | iq80310_imask[ipl]);
     81      1.1   briggs 
     82      1.3       he 	/* Don't let the compiler re-order this code with subsequent code */
     83      1.3       he 	__insn_barrier();
     84      1.3       he 
     85      1.1   briggs 	return (old);
     86      1.1   briggs }
     87      1.1   briggs 
     88      1.5    perry static inline void __attribute__((__unused__))
     89      1.1   briggs iq80310_splx(int new)
     90      1.1   briggs {
     91      1.5    perry 	extern volatile int iq80310_ipending;
     92      1.1   briggs 	int old;
     93      1.1   briggs 
     94      1.3       he 	/* Don't let the compiler re-order this code with preceding code */
     95      1.3       he 	__insn_barrier();
     96      1.3       he 
     97  1.6.8.1     yamt 	old = curcpl();
     98  1.6.8.1     yamt 	set_curcpl(new);
     99      1.1   briggs 
    100      1.6     matt #ifdef __HAVE_FAST_SOFTINTS
    101      1.1   briggs 	/* If there are software interrupts to process, do it. */
    102      1.1   briggs 	if ((iq80310_ipending & ~IRQ_BITS) & ~new)
    103      1.1   briggs 		iq80310_do_soft();
    104      1.6     matt #endif
    105      1.1   briggs 
    106      1.1   briggs 	/*
    107      1.1   briggs 	 * If there are pending hardware interrupts (i.e. the
    108      1.1   briggs 	 * external interrupt is disabled in the ICU), and all
    109      1.1   briggs 	 * hardware interrupts are being unblocked, then re-enable
    110      1.1   briggs 	 * the external hardware interrupt.
    111      1.1   briggs 	 *
    112      1.1   briggs 	 * XXX We have to wait for ALL hardware interrupts to
    113      1.1   briggs 	 * XXX be unblocked, because we currently lose if we
    114      1.1   briggs 	 * XXX get nested interrupts, and I don't know why yet.
    115      1.1   briggs 	 */
    116      1.1   briggs 	if ((new & IRQ_BITS) == 0 && (iq80310_ipending & IRQ_BITS))
    117      1.1   briggs 		i80200_intr_enable(INTCTL_IM | INTCTL_PM);
    118      1.1   briggs }
    119      1.1   briggs 
    120      1.5    perry static inline int __attribute__((__unused__))
    121      1.1   briggs iq80310_spllower(int ipl)
    122      1.1   briggs {
    123      1.1   briggs 	extern int iq80310_imask[];
    124  1.6.8.1     yamt 	const int old = curcpl();
    125      1.1   briggs 
    126      1.1   briggs 	iq80310_splx(iq80310_imask[ipl]);
    127      1.1   briggs 	return (old);
    128      1.1   briggs }
    129      1.1   briggs 
    130      1.2  thorpej #if !defined(EVBARM_SPL_NOINLINE)
    131      1.2  thorpej 
    132      1.1   briggs #define _splraise(ipl)		iq80310_splraise(ipl)
    133      1.1   briggs #define	_spllower(ipl)		iq80310_spllower(ipl)
    134      1.1   briggs #define	splx(spl)		iq80310_splx(spl)
    135      1.6     matt #ifdef __HAVE_FAST_SOFTINTS
    136      1.1   briggs void	_setsoftintr(int);
    137      1.6     matt #endif
    138      1.2  thorpej 
    139      1.1   briggs #else
    140      1.1   briggs 
    141      1.1   briggs int	_splraise(int);
    142      1.1   briggs int	_spllower(int);
    143      1.1   briggs void	splx(int);
    144      1.6     matt #ifdef __HAVE_FAST_SOFTINTS
    145      1.1   briggs void	_setsoftintr(int);
    146      1.6     matt #endif
    147      1.1   briggs 
    148      1.2  thorpej #endif /* ! EVBARM_SPL_NOINLINE */
    149      1.1   briggs 
    150      1.1   briggs #endif /* _IQ80310_INTR_H_ */
    151