1 /* $NetBSD: vr4181ip.c,v 1.1.2.3 2004/09/21 13:16:13 skrll Exp $ */
4 * Copyright (c) 1999, 2002
5 * Shin Takemura and PocketBSD Project. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: vr4181ip.c,v 1.1.2.3 2004/09/21 13:16:13 skrll Exp $");
36 #include "opt_vr41xx.h"
38 #include <sys/param.h>
39 #include <sys/device.h>
40 #include <sys/systm.h>
42 #include <machine/bus.h>
44 #include <hpcmips/vr/vrcpudef.h>
45 #include <hpcmips/vr/vripunit.h>
46 #include <hpcmips/vr/vripreg.h>
47 #include <hpcmips/vr/vripvar.h>
48 #include <hpcmips/vr/vr4181ipvar.h>
49 #include <hpcmips/vr/icureg.h>
50 #include <hpcmips/vr/cmureg.h>
52 static void vr4181ipattach(struct device
*, struct device
*, void *);
54 CFATTACH_DECL(vr4181ip
, sizeof(struct vrip_softc
),
55 vripmatch
, vr4181ipattach
, NULL
, NULL
);
57 static const struct vrip_unit vr4181ip_units
[] = {
58 [VRIP_UNIT_RTC
] = { "rtc",
59 { VRIP_INTR_RTCL1
, }, },
60 [VRIP_UNIT_SIU
] = { "siu",
61 { VRIP_INTR_SIU
, }, },
62 [VRIP_UNIT_GIU
] = { "giu",
63 { VRIP_INTR_GIU
, }, },
64 [VRIP_UNIT_ECU
] = { "ecu",
65 { VRIP_INTR_ECU
, }, },
66 [VRIP_UNIT_AIU
] = { "aiu",
67 { VRIP_INTR_DCU81
, }, },
69 [VRIP_UNIT_PMU
] = { "pmu",
70 { VRIP_INTR_POWER
, VRIP_INTR_BAT
, }, },
71 [VRIP_UNIT_PIU
] = { "piu",
74 ICUPIUINT_REG_W
, MPIUINT_REG_W
},
75 [VRIP_UNIT_KIU
] = { "kiu",
78 KIUINT_REG_W
, MKIUINT_REG_W
},
79 [VRIP_UNIT_LED
] = { "led",
80 { VRIP_INTR_LED
, }, },
81 [VRIP_UNIT_AIU
] = { "aiu",
84 AIUINT_REG_W
, MAIUINT_REG_W
},
85 [VRIP_UNIT_FIR
] = { "fir",
88 FIRINT_REG_W
, MFIRINT_REG_W
},
89 [VRIP_UNIT_DSIU
]= { "dsiu",
92 DSIUINT_REG_W
, MDSIUINT_REG_W
},
93 [VRIP_UNIT_PCIU
]= { "pciu",
96 PCIINT_REG_W
, MPCIINT_REG_W
},
97 [VRIP_UNIT_SCU
] = { "scu",
100 SCUINT_REG_W
, MSCUINT_REG_W
},
101 [VRIP_UNIT_CSI
] = { "csi",
104 CSIINT_REG_W
, MCSIINT_REG_W
},
105 [VRIP_UNIT_BCU
] = { "bcu",
108 BCUINT_REG_W
, MBCUINT_REG_W
},
114 struct vr4181ip_intrhand
{
115 int (*ih_fun
)(void *);
119 static struct vr4181ip_intrhand intrhands
[MAXCOMINTR
];
120 static int registered
= 0;
124 vr4181ipattach(struct device
*parent
, struct device
*self
, void *aux
)
126 struct vrip_softc
*sc
= (struct vrip_softc
*) self
;
130 sc
->sc_units
= vr4181ip_units
;
131 sc
->sc_nunits
= sizeof(vr4181ip_units
)/sizeof(struct vrip_unit
);
132 sc
->sc_icu_addr
= VR4181_ICU_ADDR
;
133 sc
->sc_sysint2
= VR4181_SYSINT2_REG_W
;
134 sc
->sc_msysint2
= VR4181_MSYSINT2_REG_W
;
136 vripattach_common(parent
, self
, aux
);
140 vr4181ip_comintr(void *arg
)
142 struct vr4181ip_intrhand
*ih
= arg
;
145 for (i
= 0; i
< MAXCOMINTR
; i
++) {
147 ih
[i
].ih_fun(ih
[i
].ih_arg
);
153 vr4181ip_comintr_establish(vrip_chipset_tag_t vc
, int unit
, int line
,
154 int level
, int (*ih_fun
)(void *), void *ih_arg
)
159 if (!vrip_intr_establish(vc
, unit
, 0, IPL_TTY
,
160 vr4181ip_comintr
, intrhands
)) {
161 panic("vr4181ip_comintr_establish: "
162 "can't map interrupt line.");
167 for (i
= 0; i
< MAXCOMINTR
; i
++) {
168 if (intrhands
[i
].ih_fun
== NULL
) {
169 intrhands
[i
].ih_fun
= ih_fun
;
170 intrhands
[i
].ih_arg
= ih_arg
;
175 panic("too many vr4181 SIU");