i80200_icu.c revision 1.3.2.3 1 1.3.2.3 jdolecek /* $NetBSD: i80200_icu.c,v 1.3.2.3 2002/06/23 17:34:57 jdolecek Exp $ */
2 1.3.2.2 jdolecek
3 1.3.2.2 jdolecek /*
4 1.3.2.2 jdolecek * Copyright (c) 2002 Wasabi Systems, Inc.
5 1.3.2.2 jdolecek * All rights reserved.
6 1.3.2.2 jdolecek *
7 1.3.2.2 jdolecek * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.3.2.2 jdolecek *
9 1.3.2.2 jdolecek * Redistribution and use in source and binary forms, with or without
10 1.3.2.2 jdolecek * modification, are permitted provided that the following conditions
11 1.3.2.2 jdolecek * are met:
12 1.3.2.2 jdolecek * 1. Redistributions of source code must retain the above copyright
13 1.3.2.2 jdolecek * notice, this list of conditions and the following disclaimer.
14 1.3.2.2 jdolecek * 2. Redistributions in binary form must reproduce the above copyright
15 1.3.2.2 jdolecek * notice, this list of conditions and the following disclaimer in the
16 1.3.2.2 jdolecek * documentation and/or other materials provided with the distribution.
17 1.3.2.2 jdolecek * 3. All advertising materials mentioning features or use of this software
18 1.3.2.2 jdolecek * must display the following acknowledgement:
19 1.3.2.2 jdolecek * This product includes software developed for the NetBSD Project by
20 1.3.2.2 jdolecek * Wasabi Systems, Inc.
21 1.3.2.2 jdolecek * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.3.2.2 jdolecek * or promote products derived from this software without specific prior
23 1.3.2.2 jdolecek * written permission.
24 1.3.2.2 jdolecek *
25 1.3.2.2 jdolecek * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.3.2.2 jdolecek * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.3.2.2 jdolecek * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.3.2.2 jdolecek * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.3.2.2 jdolecek * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.3.2.2 jdolecek * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.3.2.2 jdolecek * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.3.2.2 jdolecek * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.3.2.2 jdolecek * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.3.2.2 jdolecek * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.3.2.2 jdolecek * POSSIBILITY OF SUCH DAMAGE.
36 1.3.2.2 jdolecek */
37 1.3.2.2 jdolecek
38 1.3.2.2 jdolecek /*
39 1.3.2.2 jdolecek * Intel i80200 Interrupt Controller Unit support.
40 1.3.2.2 jdolecek */
41 1.3.2.2 jdolecek
42 1.3.2.2 jdolecek #include <sys/param.h>
43 1.3.2.2 jdolecek #include <sys/systm.h>
44 1.3.2.2 jdolecek
45 1.3.2.2 jdolecek #include <arm/cpufunc.h>
46 1.3.2.2 jdolecek
47 1.3.2.2 jdolecek #include <arm/xscale/i80200reg.h>
48 1.3.2.2 jdolecek #include <arm/xscale/i80200var.h>
49 1.3.2.2 jdolecek
50 1.3.2.2 jdolecek /* Software shadow copy of INTCTL. */
51 1.3.2.2 jdolecek static __volatile uint32_t intctl;
52 1.3.2.2 jdolecek
53 1.3.2.2 jdolecek /* Pointer to board-specific external IRQ dispatcher. */
54 1.3.2.2 jdolecek void (*i80200_extirq_dispatch)(struct clockframe *);
55 1.3.2.2 jdolecek
56 1.3.2.2 jdolecek static void
57 1.3.2.2 jdolecek i80200_default_extirq_dispatch(struct clockframe *framep)
58 1.3.2.2 jdolecek {
59 1.3.2.2 jdolecek
60 1.3.2.2 jdolecek panic("external IRQ with no dispatch routine");
61 1.3.2.2 jdolecek }
62 1.3.2.2 jdolecek
63 1.3.2.2 jdolecek /*
64 1.3.2.3 jdolecek * i80200_icu_init:
65 1.3.2.2 jdolecek *
66 1.3.2.2 jdolecek * Initialize the i80200 ICU.
67 1.3.2.2 jdolecek */
68 1.3.2.2 jdolecek void
69 1.3.2.3 jdolecek i80200_icu_init(void)
70 1.3.2.2 jdolecek {
71 1.3.2.2 jdolecek
72 1.3.2.2 jdolecek /* Disable all interrupt sources. */
73 1.3.2.2 jdolecek intctl = 0;
74 1.3.2.2 jdolecek __asm __volatile("mcr p13, 0, %0, c0, c0"
75 1.3.2.2 jdolecek :
76 1.3.2.2 jdolecek : "r" (intctl));
77 1.3.2.2 jdolecek
78 1.3.2.2 jdolecek /* Steer PMU and BMU to IRQ. */
79 1.3.2.2 jdolecek __asm __volatile("mcr p13, 0, %0, c2, c0"
80 1.3.2.2 jdolecek :
81 1.3.2.2 jdolecek : "r" (0));
82 1.3.2.2 jdolecek
83 1.3.2.2 jdolecek i80200_extirq_dispatch = i80200_default_extirq_dispatch;
84 1.3.2.2 jdolecek }
85 1.3.2.2 jdolecek
86 1.3.2.2 jdolecek /*
87 1.3.2.2 jdolecek * i80200_intr_enable:
88 1.3.2.2 jdolecek *
89 1.3.2.2 jdolecek * Enable an interrupt source in the i80200 ICU.
90 1.3.2.2 jdolecek */
91 1.3.2.2 jdolecek void
92 1.3.2.2 jdolecek i80200_intr_enable(uint32_t intr)
93 1.3.2.2 jdolecek {
94 1.3.2.2 jdolecek u_int oldirqstate;
95 1.3.2.2 jdolecek
96 1.3.2.2 jdolecek oldirqstate = disable_interrupts(I32_bit|F32_bit);
97 1.3.2.2 jdolecek
98 1.3.2.2 jdolecek intctl |= intr;
99 1.3.2.2 jdolecek __asm __volatile("mcr p13, 0, %0, c0, c0"
100 1.3.2.2 jdolecek :
101 1.3.2.2 jdolecek : "r" (intctl));
102 1.3.2.2 jdolecek
103 1.3.2.2 jdolecek restore_interrupts(oldirqstate);
104 1.3.2.2 jdolecek }
105 1.3.2.2 jdolecek
106 1.3.2.2 jdolecek /*
107 1.3.2.2 jdolecek * i80200_intr_disable:
108 1.3.2.2 jdolecek *
109 1.3.2.2 jdolecek * Disable an interrupt source in the i80200 ICU.
110 1.3.2.2 jdolecek */
111 1.3.2.2 jdolecek void
112 1.3.2.2 jdolecek i80200_intr_disable(uint32_t intr)
113 1.3.2.2 jdolecek {
114 1.3.2.2 jdolecek u_int oldirqstate;
115 1.3.2.2 jdolecek
116 1.3.2.2 jdolecek oldirqstate = disable_interrupts(I32_bit|F32_bit);
117 1.3.2.2 jdolecek
118 1.3.2.2 jdolecek intctl &= ~intr;
119 1.3.2.2 jdolecek __asm __volatile("mcr p13, 0, %0, c0, c0"
120 1.3.2.2 jdolecek :
121 1.3.2.2 jdolecek : "r" (intctl));
122 1.3.2.2 jdolecek
123 1.3.2.2 jdolecek restore_interrupts(oldirqstate);
124 1.3.2.2 jdolecek }
125