hd64461.c revision 1.7.6.3 1 1.7.6.3 thorpej /* $NetBSD: hd64461.c,v 1.7.6.3 2003/01/03 16:45:10 thorpej Exp $ */
2 1.7.6.2 nathanw
3 1.7.6.2 nathanw /*-
4 1.7.6.2 nathanw * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
5 1.7.6.2 nathanw * All rights reserved.
6 1.7.6.2 nathanw *
7 1.7.6.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.7.6.2 nathanw * by UCHIYAMA Yasushi.
9 1.7.6.2 nathanw *
10 1.7.6.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.7.6.2 nathanw * modification, are permitted provided that the following conditions
12 1.7.6.2 nathanw * are met:
13 1.7.6.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.7.6.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.7.6.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.7.6.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.7.6.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.7.6.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.7.6.2 nathanw * must display the following acknowledgement:
20 1.7.6.2 nathanw * This product includes software developed by the NetBSD
21 1.7.6.2 nathanw * Foundation, Inc. and its contributors.
22 1.7.6.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.7.6.2 nathanw * contributors may be used to endorse or promote products derived
24 1.7.6.2 nathanw * from this software without specific prior written permission.
25 1.7.6.2 nathanw *
26 1.7.6.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.7.6.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.7.6.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.7.6.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.7.6.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.7.6.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.7.6.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.7.6.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.7.6.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.7.6.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.7.6.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.7.6.2 nathanw */
38 1.7.6.2 nathanw
39 1.7.6.2 nathanw #include <sys/param.h>
40 1.7.6.2 nathanw #include <sys/systm.h>
41 1.7.6.2 nathanw #include <sys/device.h>
42 1.7.6.2 nathanw #include <sys/boot_flag.h>
43 1.7.6.2 nathanw
44 1.7.6.2 nathanw #include <machine/bus.h>
45 1.7.6.2 nathanw #include <machine/intr.h>
46 1.7.6.2 nathanw #include <machine/debug.h>
47 1.7.6.2 nathanw
48 1.7.6.2 nathanw #include <hpcsh/dev/hd64461/hd64461var.h>
49 1.7.6.2 nathanw #include <hpcsh/dev/hd64461/hd64461reg.h>
50 1.7.6.2 nathanw #include <hpcsh/dev/hd64461/hd64461intcreg.h>
51 1.7.6.2 nathanw
52 1.7.6.2 nathanw /* HD64461 modules. INTC, TIMER, POWER modules are included in hd64461if */
53 1.7.6.2 nathanw STATIC struct hd64461_module {
54 1.7.6.2 nathanw const char *name;
55 1.7.6.2 nathanw } hd64461_modules[] = {
56 1.7.6.2 nathanw [HD64461_MODULE_VIDEO] = { "hd64461video" },
57 1.7.6.2 nathanw [HD64461_MODULE_PCMCIA] = { "hd64461pcmcia" },
58 1.7.6.2 nathanw [HD64461_MODULE_GPIO] = { "hd64461gpio" },
59 1.7.6.2 nathanw [HD64461_MODULE_AFE] = { "hd64461afe" },
60 1.7.6.2 nathanw [HD64461_MODULE_UART] = { "hd64461uart" },
61 1.7.6.2 nathanw [HD64461_MODULE_FIR] = { "hd64461fir" },
62 1.7.6.2 nathanw };
63 1.7.6.2 nathanw #define HD64461_NMODULE \
64 1.7.6.2 nathanw (sizeof hd64461_modules / sizeof(struct hd64461_module))
65 1.7.6.2 nathanw
66 1.7.6.2 nathanw STATIC int hd64461_match(struct device *, struct cfdata *, void *);
67 1.7.6.2 nathanw STATIC void hd64461_attach(struct device *, struct device *, void *);
68 1.7.6.2 nathanw STATIC int hd64461_print(void *, const char *);
69 1.7.6.2 nathanw #ifdef DEBUG
70 1.7.6.2 nathanw STATIC void hd64461_info(void);
71 1.7.6.2 nathanw #endif
72 1.7.6.2 nathanw
73 1.7.6.2 nathanw CFATTACH_DECL(hd64461if, sizeof(struct device),
74 1.7.6.2 nathanw hd64461_match, hd64461_attach, NULL, NULL);
75 1.7.6.2 nathanw
76 1.7.6.2 nathanw int
77 1.7.6.2 nathanw hd64461_match(struct device *parent, struct cfdata *cf, void *aux)
78 1.7.6.2 nathanw {
79 1.7.6.2 nathanw
80 1.7.6.2 nathanw switch (cpu_product) {
81 1.7.6.2 nathanw default:
82 1.7.6.2 nathanw /* HD64461 only supports SH7709 interface */
83 1.7.6.2 nathanw return (0);
84 1.7.6.2 nathanw case CPU_PRODUCT_7709:
85 1.7.6.2 nathanw break;
86 1.7.6.2 nathanw case CPU_PRODUCT_7709A:
87 1.7.6.2 nathanw break;
88 1.7.6.2 nathanw }
89 1.7.6.2 nathanw
90 1.7.6.2 nathanw if (strcmp("hd64461if", cf->cf_name))
91 1.7.6.2 nathanw return (0);
92 1.7.6.2 nathanw
93 1.7.6.2 nathanw return (1);
94 1.7.6.2 nathanw }
95 1.7.6.2 nathanw
96 1.7.6.2 nathanw void
97 1.7.6.2 nathanw hd64461_attach(struct device *parent, struct device *self, void *aux)
98 1.7.6.2 nathanw {
99 1.7.6.2 nathanw struct hd64461_attach_args ha;
100 1.7.6.2 nathanw struct hd64461_module *module;
101 1.7.6.2 nathanw int i;
102 1.7.6.2 nathanw
103 1.7.6.2 nathanw printf("\n");
104 1.7.6.2 nathanw #ifdef DEBUG
105 1.7.6.2 nathanw if (bootverbose)
106 1.7.6.2 nathanw hd64461_info();
107 1.7.6.2 nathanw #endif
108 1.7.6.2 nathanw
109 1.7.6.2 nathanw /* Attach all sub modules */
110 1.7.6.2 nathanw for (i = 0, module = hd64461_modules; i < HD64461_NMODULE;
111 1.7.6.2 nathanw i++, module++) {
112 1.7.6.2 nathanw if (module->name == 0)
113 1.7.6.2 nathanw continue;
114 1.7.6.2 nathanw ha.ha_module_id = i;
115 1.7.6.2 nathanw config_found(self, &ha, hd64461_print);
116 1.7.6.2 nathanw }
117 1.7.6.2 nathanw }
118 1.7.6.2 nathanw
119 1.7.6.2 nathanw int
120 1.7.6.2 nathanw hd64461_print(void *aux, const char *pnp)
121 1.7.6.2 nathanw {
122 1.7.6.2 nathanw struct hd64461_attach_args *ha = aux;
123 1.7.6.2 nathanw
124 1.7.6.2 nathanw if (pnp)
125 1.7.6.3 thorpej aprint_normal("%s at %s",
126 1.7.6.2 nathanw hd64461_modules[ha->ha_module_id].name, pnp);
127 1.7.6.2 nathanw
128 1.7.6.2 nathanw return (UNCONF);
129 1.7.6.2 nathanw }
130 1.7.6.2 nathanw
131 1.7.6.2 nathanw #ifdef DEBUG
132 1.7.6.2 nathanw void
133 1.7.6.2 nathanw hd64461_info()
134 1.7.6.2 nathanw {
135 1.7.6.2 nathanw u_int16_t r16;
136 1.7.6.2 nathanw
137 1.7.6.2 nathanw dbg_banner_function();
138 1.7.6.2 nathanw
139 1.7.6.2 nathanw /*
140 1.7.6.2 nathanw * System
141 1.7.6.2 nathanw */
142 1.7.6.2 nathanw printf("STBCR (System Control Register)\n");
143 1.7.6.2 nathanw r16 = hd64461_reg_read_2(HD64461_SYSSTBCR_REG16);
144 1.7.6.2 nathanw #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_SYSSTBCR_##m, #m)
145 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, CKIO_STBY);
146 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SAFECKE_IST);
147 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SLCKE_IST);
148 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SAFECKE_OST);
149 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SLCKE_OST);
150 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SMIAST);
151 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SLCDST);
152 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPC0ST);
153 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPC1ST);
154 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SAFEST);
155 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, STM0ST);
156 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, STM1ST);
157 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SIRST);
158 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SURTSD);
159 1.7.6.2 nathanw #undef DBG_BITMASK_PRINT
160 1.7.6.2 nathanw printf("\n");
161 1.7.6.2 nathanw
162 1.7.6.2 nathanw printf("SYSCR (System Configuration Register)\n");
163 1.7.6.2 nathanw r16 = hd64461_reg_read_2(HD64461_SYSSYSCR_REG16);
164 1.7.6.2 nathanw #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_SYSSYSCR_##m, #m)
165 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SCPU_BUS_IGAT);
166 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPTA_IR);
167 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPTA_TM);
168 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPTB_UR);
169 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, WAIT_CTL_SEL);
170 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SMODE1);
171 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SMODE0);
172 1.7.6.2 nathanw #undef DBG_BITMASK_PRINT
173 1.7.6.2 nathanw printf("\n");
174 1.7.6.2 nathanw
175 1.7.6.2 nathanw printf("SCPUCR (CPU Data Bus Control Register)\n");
176 1.7.6.2 nathanw r16 = hd64461_reg_read_2(HD64461_SYSSCPUCR_REG16);
177 1.7.6.2 nathanw #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_SYSSCPUCR_##m, #m)
178 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPDSTOF);
179 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPDSTIG);
180 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPCSTOF);
181 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPCSTIG);
182 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPBSTOF);
183 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPBSTIG);
184 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPASTOF);
185 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SPASTIG);
186 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SLCDSTIG);
187 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SCPU_CS56_EP);
188 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SCPU_CMD_EP);
189 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SCPU_ADDR_EP);
190 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SCPDPU);
191 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, SCPU_A2319_EP);
192 1.7.6.2 nathanw #undef DBG_BITMASK_PRINT
193 1.7.6.2 nathanw printf("\n");
194 1.7.6.2 nathanw
195 1.7.6.2 nathanw printf("\n");
196 1.7.6.2 nathanw /*
197 1.7.6.2 nathanw * INTC
198 1.7.6.2 nathanw */
199 1.7.6.2 nathanw printf("NIRR (Interrupt Request Register)\n");
200 1.7.6.2 nathanw r16 = hd64461_reg_read_2(HD64461_INTCNIRR_REG16);
201 1.7.6.2 nathanw #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_INTCNIRR_##m, #m)
202 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, PCC0R);
203 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, PCC1R);
204 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, AFER);
205 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, GPIOR);
206 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, TMU0R);
207 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, TMU1R);
208 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, IRDAR);
209 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, UARTR);
210 1.7.6.2 nathanw #undef DBG_BITMASK_PRINT
211 1.7.6.2 nathanw printf("\n");
212 1.7.6.2 nathanw
213 1.7.6.2 nathanw printf("NIMR (Interrupt Mask Register)\n");
214 1.7.6.2 nathanw r16 = hd64461_reg_read_2(HD64461_INTCNIMR_REG16);
215 1.7.6.2 nathanw #define DBG_BITMASK_PRINT(r, m) dbg_bitmask_print(r, HD64461_INTCNIMR_##m, #m)
216 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, PCC0M);
217 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, PCC1M);
218 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, AFEM);
219 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, GPIOM);
220 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, TMU0M);
221 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, TMU1M);
222 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, IRDAM);
223 1.7.6.2 nathanw DBG_BITMASK_PRINT(r16, UARTM);
224 1.7.6.2 nathanw #undef DBG_BITMASK_PRINT
225 1.7.6.2 nathanw printf("\n");
226 1.7.6.2 nathanw
227 1.7.6.2 nathanw dbg_banner_line();
228 1.7.6.2 nathanw }
229 1.7.6.2 nathanw #endif /* DEBUG */
230