tx39var.h revision 1.8.2.2 1 1.8.2.2 bouyer /* $NetBSD: tx39var.h,v 1.8.2.2 2000/11/20 20:47:37 bouyer Exp $ */
2 1.8.2.2 bouyer
3 1.8.2.2 bouyer /*-
4 1.8.2.2 bouyer * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
5 1.8.2.2 bouyer * All rights reserved.
6 1.8.2.2 bouyer *
7 1.8.2.2 bouyer * This code is derived from software contributed to The NetBSD Foundation
8 1.8.2.2 bouyer * by UCHIYAMA Yasushi.
9 1.8.2.2 bouyer *
10 1.8.2.2 bouyer * Redistribution and use in source and binary forms, with or without
11 1.8.2.2 bouyer * modification, are permitted provided that the following conditions
12 1.8.2.2 bouyer * are met:
13 1.8.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
14 1.8.2.2 bouyer * notice, this list of conditions and the following disclaimer.
15 1.8.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
16 1.8.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
17 1.8.2.2 bouyer * documentation and/or other materials provided with the distribution.
18 1.8.2.2 bouyer * 3. All advertising materials mentioning features or use of this software
19 1.8.2.2 bouyer * must display the following acknowledgement:
20 1.8.2.2 bouyer * This product includes software developed by the NetBSD
21 1.8.2.2 bouyer * Foundation, Inc. and its contributors.
22 1.8.2.2 bouyer * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.8.2.2 bouyer * contributors may be used to endorse or promote products derived
24 1.8.2.2 bouyer * from this software without specific prior written permission.
25 1.8.2.2 bouyer *
26 1.8.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.8.2.2 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.8.2.2 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.8.2.2 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.8.2.2 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.8.2.2 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.8.2.2 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.8.2.2 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.8.2.2 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.8.2.2 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.8.2.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
37 1.8.2.2 bouyer */
38 1.8.2.2 bouyer
39 1.8.2.2 bouyer enum tx_chipset {
40 1.8.2.2 bouyer __TX391X,
41 1.8.2.2 bouyer __TX392X,
42 1.8.2.2 bouyer };
43 1.8.2.2 bouyer
44 1.8.2.2 bouyer /* attach priority of TX-internal modules. */
45 1.8.2.2 bouyer enum tx_attach_order {
46 1.8.2.2 bouyer ATTACH_FIRST = 3,
47 1.8.2.2 bouyer ATTACH_NORMAL = 2,
48 1.8.2.2 bouyer ATTACH_LAST = 1,
49 1.8.2.2 bouyer };
50 1.8.2.2 bouyer
51 1.8.2.2 bouyer /* unified I/O manager */
52 1.8.2.2 bouyer enum txio_group {
53 1.8.2.2 bouyer MFIO = 0,
54 1.8.2.2 bouyer IO,
55 1.8.2.2 bouyer BETTY,
56 1.8.2.2 bouyer SNOWBALL,
57 1.8.2.2 bouyer PLUM,
58 1.8.2.2 bouyer NTXIO_GROUP
59 1.8.2.2 bouyer };
60 1.8.2.2 bouyer
61 1.8.2.2 bouyer struct txio_ops;
62 1.8.2.2 bouyer
63 1.8.2.2 bouyer struct tx_chipset_tag {
64 1.8.2.2 bouyer enum tx_chipset tc_chipset;
65 1.8.2.2 bouyer void *tc_intrt; /* interrupt tag */
66 1.8.2.2 bouyer void *tc_powert; /* power tag */
67 1.8.2.2 bouyer void *tc_clockt; /* clock/timer tag */
68 1.8.2.2 bouyer void *tc_soundt; /* sound tag */
69 1.8.2.2 bouyer struct txio_ops *tc_ioops[NTXIO_GROUP];
70 1.8.2.2 bouyer void *tc_videot; /* video chip tag */
71 1.8.2.2 bouyer };
72 1.8.2.2 bouyer
73 1.8.2.2 bouyer typedef struct tx_chipset_tag* tx_chipset_tag_t __attribute__((__unused__));
74 1.8.2.2 bouyer typedef u_int32_t txreg_t;
75 1.8.2.2 bouyer extern struct tx_chipset_tag tx_chipset;
76 1.8.2.2 bouyer #define tx_conf_get_tag() (&tx_chipset)
77 1.8.2.2 bouyer
78 1.8.2.2 bouyer #if defined TX391X && defined TX392X
79 1.8.2.2 bouyer #define IS_TX391X(t) ((t)->tc_chipset == __TX391X)
80 1.8.2.2 bouyer #define IS_TX392X(t) ((t)->tc_chipset == __TX392X)
81 1.8.2.2 bouyer #elif defined TX391X
82 1.8.2.2 bouyer #define IS_TX391X(t) (1)
83 1.8.2.2 bouyer #define IS_TX392X(t) (0)
84 1.8.2.2 bouyer #elif defined TX392X
85 1.8.2.2 bouyer #define IS_TX391X(t) (0)
86 1.8.2.2 bouyer #define IS_TX392X(t) (1)
87 1.8.2.2 bouyer #endif
88 1.8.2.2 bouyer
89 1.8.2.2 bouyer void tx_conf_register_intr(tx_chipset_tag_t, void *);
90 1.8.2.2 bouyer void tx_conf_register_power(tx_chipset_tag_t, void *);
91 1.8.2.2 bouyer void tx_conf_register_clock(tx_chipset_tag_t, void *);
92 1.8.2.2 bouyer void tx_conf_register_sound(tx_chipset_tag_t, void *);
93 1.8.2.2 bouyer void tx_conf_register_ioman(tx_chipset_tag_t, struct txio_ops *);
94 1.8.2.2 bouyer void tx_conf_register_video(tx_chipset_tag_t, void *);
95 1.8.2.2 bouyer
96 1.8.2.2 bouyer /* Unified IO manager */
97 1.8.2.2 bouyer struct txio_ops {
98 1.8.2.2 bouyer void *_v; /* context */
99 1.8.2.2 bouyer enum txio_group _group;
100 1.8.2.2 bouyer int (*_in)(void *, int);
101 1.8.2.2 bouyer void (*_out)(void *, int, int);
102 1.8.2.2 bouyer void (*_intr_map)(void *, int, int *, int *);
103 1.8.2.2 bouyer void *(*_intr_establish)(void *, int, int (*)(void *), void *);
104 1.8.2.2 bouyer void (*_intr_disestablish)(void *, void *);
105 1.8.2.2 bouyer void (*_update)(void *); /* debug */
106 1.8.2.2 bouyer void (*_dump)(void *); /* debug */
107 1.8.2.2 bouyer };
108 1.8.2.2 bouyer #define tx_ioman_T(g, ops, args...) \
109 1.8.2.2 bouyer ({ \
110 1.8.2.2 bouyer struct txio_ops *__o = tx_chipset.tc_ioops[g]; \
111 1.8.2.2 bouyer KASSERT(__o); \
112 1.8.2.2 bouyer __o->_##ops(__o->_v , ##args); \
113 1.8.2.2 bouyer })
114 1.8.2.2 bouyer /* access ops */
115 1.8.2.2 bouyer #define tx_ioman_in(g, args...) tx_ioman_T(g, in, args)
116 1.8.2.2 bouyer #define tx_ioman_out(g, args...) tx_ioman_T(g, out, args)
117 1.8.2.2 bouyer #define tx_ioman_intr_map(g, args...) tx_ioman_T(g, intr_map, args)
118 1.8.2.2 bouyer #define tx_ioman_intr_establish(g, args...) \
119 1.8.2.2 bouyer tx_ioman_T(g, intr_establish, args)
120 1.8.2.2 bouyer #define tx_ioman_intr_disestablish(g, args...) \
121 1.8.2.2 bouyer tx_ioman_T(g, intr_disestablish, args)
122 1.8.2.2 bouyer #define tx_ioman_update(g) tx_ioman_T(g, update)
123 1.8.2.2 bouyer #define tx_ioman_dump(g) tx_ioman_T(g, dump)
124 1.8.2.2 bouyer
125 1.8.2.2 bouyer /*
126 1.8.2.2 bouyer * TX39 Internal Function Register access
127 1.8.2.2 bouyer */
128 1.8.2.2 bouyer #define TX39_SYSADDR_CONFIG_REG_KSEG1 0xb0c00000
129 1.8.2.2 bouyer #define tx_conf_read(t, reg) ( \
130 1.8.2.2 bouyer (*((volatile txreg_t *)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg)))))
131 1.8.2.2 bouyer #define tx_conf_write(t, reg, val) ( \
132 1.8.2.2 bouyer (*((volatile txreg_t *)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))) \
133 1.8.2.2 bouyer = (val)))
134 1.8.2.2 bouyer
135 1.8.2.2 bouyer /*
136 1.8.2.2 bouyer * txsim attach arguments. (txsim ... TX System Internal Module)
137 1.8.2.2 bouyer */
138 1.8.2.2 bouyer struct txsimbus_attach_args {
139 1.8.2.2 bouyer char *tba_busname;
140 1.8.2.2 bouyer };
141 1.8.2.2 bouyer
142 1.8.2.2 bouyer /*
143 1.8.2.2 bouyer * txsim module attach arguments.
144 1.8.2.2 bouyer */
145 1.8.2.2 bouyer struct txsim_attach_args {
146 1.8.2.2 bouyer tx_chipset_tag_t ta_tc; /* Chipset tag */
147 1.8.2.2 bouyer };
148 1.8.2.2 bouyer
149 1.8.2.2 bouyer /*
150 1.8.2.2 bouyer * Interrupt staff
151 1.8.2.2 bouyer */
152 1.8.2.2 bouyer #define MAKEINTR(s, b) ((s) * 32 + (ffs(b) - 1))
153 1.8.2.2 bouyer void* tx_intr_establish(tx_chipset_tag_t, int, int, int, int (*)(void *),
154 1.8.2.2 bouyer void *);
155 1.8.2.2 bouyer void tx_intr_disestablish(tx_chipset_tag_t, void *);
156 1.8.2.2 bouyer
157 1.8.2.2 bouyer #ifdef USE_POLL
158 1.8.2.2 bouyer void* tx39_poll_establish(tx_chipset_tag_t, int, int, int (*)(void *),
159 1.8.2.2 bouyer void *);
160 1.8.2.2 bouyer void tx39_poll_disestablish(tx_chipset_tag_t, void *);
161 1.8.2.2 bouyer #define POLL_CONT 0
162 1.8.2.2 bouyer #define POLL_END 1
163 1.8.2.2 bouyer #endif /* USE_POLL */
164 1.8.2.2 bouyer
165 1.8.2.2 bouyer u_int32_t tx_intr_status(tx_chipset_tag_t, int);
166 1.8.2.2 bouyer extern u_int32_t tx39intrvec;
167 1.8.2.2 bouyer
168 1.8.2.2 bouyer /*
169 1.8.2.2 bouyer * Power management staff
170 1.8.2.2 bouyer */
171 1.8.2.2 bouyer void tx39power_suspend_cpu(void);
172 1.8.2.2 bouyer
173 1.8.2.2 bouyer #ifdef TX39_DEBUG
174 1.8.2.2 bouyer extern u_int32_t tx39debugflag;
175 1.8.2.2 bouyer /*
176 1.8.2.2 bouyer * Debugging use.
177 1.8.2.2 bouyer */
178 1.8.2.2 bouyer #define __bitdisp(a, s, e, m, c) \
179 1.8.2.2 bouyer ({ \
180 1.8.2.2 bouyer u_int32_t __j, __j1; \
181 1.8.2.2 bouyer int __i, __s, __e, __n; \
182 1.8.2.2 bouyer __n = sizeof(typeof(a)) * NBBY - 1; \
183 1.8.2.2 bouyer __j1 = 1 << __n; \
184 1.8.2.2 bouyer __e = e ? e : __n; \
185 1.8.2.2 bouyer __s = s; \
186 1.8.2.2 bouyer for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) { \
187 1.8.2.2 bouyer if (__i > __e || __i < __s) { \
188 1.8.2.2 bouyer printf("%c", a & __j ? '+' : '-'); \
189 1.8.2.2 bouyer } else { \
190 1.8.2.2 bouyer printf("%c", a & __j ? '|' : '.'); \
191 1.8.2.2 bouyer } \
192 1.8.2.2 bouyer } \
193 1.8.2.2 bouyer if (m) { \
194 1.8.2.2 bouyer printf("[%s]", (char*)m); \
195 1.8.2.2 bouyer } \
196 1.8.2.2 bouyer if (c) { \
197 1.8.2.2 bouyer for (__j = __j1, __i = __n; __j > 0; __j >>=1, __i--) { \
198 1.8.2.2 bouyer if (!(__i > __e || __i < __s) && (a & __j)) { \
199 1.8.2.2 bouyer printf(" %d", __i); \
200 1.8.2.2 bouyer } \
201 1.8.2.2 bouyer } \
202 1.8.2.2 bouyer } \
203 1.8.2.2 bouyer printf("\n"); \
204 1.8.2.2 bouyer })
205 1.8.2.2 bouyer #define bitdisp(a) __bitdisp((a), 0, 0, 0, 1)
206 1.8.2.2 bouyer #else /* TX39_DEBUG */
207 1.8.2.2 bouyer #define __bitdisp(a, s, e, m, c)
208 1.8.2.2 bouyer #define bitdisp(a)
209 1.8.2.2 bouyer #endif /* TX39_DEBUG */
210 1.8.2.2 bouyer
211 1.8.2.2 bouyer int __is_set_print(u_int32_t, int, char *);
212