ixp425_intr.h revision 164426
1164426Ssam/*	$NetBSD: ixp425_intr.h,v 1.6 2005/12/24 20:06:52 perry Exp $	*/
2164426Ssam
3164426Ssam/*
4164426Ssam * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
5164426Ssam * All rights reserved.
6164426Ssam *
7164426Ssam * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8164426Ssam *
9164426Ssam * Redistribution and use in source and binary forms, with or without
10164426Ssam * modification, are permitted provided that the following conditions
11164426Ssam * are met:
12164426Ssam * 1. Redistributions of source code must retain the above copyright
13164426Ssam *    notice, this list of conditions and the following disclaimer.
14164426Ssam * 2. Redistributions in binary form must reproduce the above copyright
15164426Ssam *    notice, this list of conditions and the following disclaimer in the
16164426Ssam *    documentation and/or other materials provided with the distribution.
17164426Ssam * 3. All advertising materials mentioning features or use of this software
18164426Ssam *    must display the following acknowledgement:
19164426Ssam *	This product includes software developed for the NetBSD Project by
20164426Ssam *	Wasabi Systems, Inc.
21164426Ssam * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22164426Ssam *    or promote products derived from this software without specific prior
23164426Ssam *    written permission.
24164426Ssam *
25164426Ssam * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26164426Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27164426Ssam * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28164426Ssam * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29164426Ssam * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30164426Ssam * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31164426Ssam * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32164426Ssam * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33164426Ssam * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34164426Ssam * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35164426Ssam * POSSIBILITY OF SUCH DAMAGE.
36164426Ssam *
37164426Ssam * $FreeBSD: head/sys/arm/xscale/ixp425/ixp425_intr.h 164426 2006-11-19 23:55:23Z sam $
38164426Ssam *
39164426Ssam */
40164426Ssam
41164426Ssam#ifndef _IXP425_INTR_H_
42164426Ssam#define _IXP425_INTR_H_
43164426Ssam
44164426Ssam#define	ARM_IRQ_HANDLER	_C_LABEL(ixp425_intr_dispatch)
45164426Ssam
46164426Ssam#ifndef _LOCORE
47164426Ssam
48164426Ssam#include <machine/armreg.h>
49164426Ssam#include <machine/cpufunc.h>
50164426Ssam
51164426Ssam#include <arm/xscale/ixp425/ixp425reg.h>
52164426Ssam
53164426Ssam#define IXPREG(reg)     *((__volatile u_int32_t*) (reg))
54164426Ssam
55164426Ssamvoid ixp425_do_pending(void);
56164426Ssam
57164426Ssamextern __volatile uint32_t intr_enabled;
58164426Ssamextern uint32_t intr_steer;
59164426Ssam
60164426Ssamstatic __inline void __attribute__((__unused__))
61164426Ssamixp425_set_intrmask(void)
62164426Ssam{
63164426Ssam	IXPREG(IXP425_INT_ENABLE) = intr_enabled & IXP425_INT_HWMASK;
64164426Ssam}
65164426Ssam
66164426Ssamstatic __inline void
67164426Ssamixp425_set_intrsteer(void)
68164426Ssam{
69164426Ssam	IXPREG(IXP425_INT_SELECT) = intr_steer & IXP425_INT_HWMASK;
70164426Ssam}
71164426Ssam
72164426Ssam#define INT_SWMASK						\
73164426Ssam	((1U << IXP425_INT_bit31) | (1U << IXP425_INT_bit30) |	\
74164426Ssam	 (1U << IXP425_INT_bit14) | (1U << IXP425_INT_bit11))
75164426Ssam
76164426Ssam#if 0
77164426Ssamstatic __inline void __attribute__((__unused__))
78164426Ssamixp425_splx(int new)
79164426Ssam{
80164426Ssam	extern __volatile uint32_t intr_enabled;
81164426Ssam	extern __volatile int current_spl_level;
82164426Ssam	extern __volatile int ixp425_ipending;
83164426Ssam	extern void ixp425_do_pending(void);
84164426Ssam	int oldirqstate, hwpend;
85164426Ssam
86164426Ssam	/* Don't let the compiler re-order this code with preceding code */
87164426Ssam	__insn_barrier();
88164426Ssam
89164426Ssam	current_spl_level = new;
90164426Ssam
91164426Ssam	hwpend = (ixp425_ipending & IXP425_INT_HWMASK) & ~new;
92164426Ssam	if (hwpend != 0) {
93164426Ssam		oldirqstate = disable_interrupts(I32_bit);
94164426Ssam		intr_enabled |= hwpend;
95164426Ssam		ixp425_set_intrmask();
96164426Ssam		restore_interrupts(oldirqstate);
97164426Ssam	}
98164426Ssam
99164426Ssam	if ((ixp425_ipending & INT_SWMASK) & ~new)
100164426Ssam		ixp425_do_pending();
101164426Ssam}
102164426Ssam
103164426Ssamstatic __inline int __attribute__((__unused__))
104164426Ssamixp425_splraise(int ipl)
105164426Ssam{
106164426Ssam	extern __volatile int current_spl_level;
107164426Ssam	extern int ixp425_imask[];
108164426Ssam	int	old;
109164426Ssam
110164426Ssam	old = current_spl_level;
111164426Ssam	current_spl_level |= ixp425_imask[ipl];
112164426Ssam
113164426Ssam	/* Don't let the compiler re-order this code with subsequent code */
114164426Ssam	__insn_barrier();
115164426Ssam
116164426Ssam	return (old);
117164426Ssam}
118164426Ssam
119164426Ssamstatic __inline int __attribute__((__unused__))
120164426Ssamixp425_spllower(int ipl)
121164426Ssam{
122164426Ssam	extern __volatile int current_spl_level;
123164426Ssam	extern int ixp425_imask[];
124164426Ssam	int old = current_spl_level;
125164426Ssam
126164426Ssam	ixp425_splx(ixp425_imask[ipl]);
127164426Ssam	return(old);
128164426Ssam}
129164426Ssam
130164426Ssam#endif
131164426Ssam#if !defined(EVBARM_SPL_NOINLINE)
132164426Ssam
133164426Ssam#define splx(new)		ixp425_splx(new)
134164426Ssam#define	_spllower(ipl)		ixp425_spllower(ipl)
135164426Ssam#define	_splraise(ipl)		ixp425_splraise(ipl)
136164426Ssamvoid	_setsoftintr(int);
137164426Ssam
138164426Ssam#else
139164426Ssam
140164426Ssamint	_splraise(int);
141164426Ssamint	_spllower(int);
142164426Ssamvoid	splx(int);
143164426Ssamvoid	_setsoftintr(int);
144164426Ssam
145164426Ssam#endif /* ! EVBARM_SPL_NOINLINE */
146164426Ssam
147164426Ssam#endif /* _LOCORE */
148164426Ssam
149164426Ssam#endif /* _IXP425_INTR_H_ */
150