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