1/*	$NetBSD: tx39var.h,v 1.13 2005/12/11 12:17:34 christos Exp $ */
2
3/*-
4 * Copyright (c) 1999-2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#include "opt_use_poll.h"
33
34enum tx_chipset {
35	__TX391X,
36	__TX392X,
37};
38
39/* attach priority of TX-internal modules. */
40enum tx_attach_order {
41	ATTACH_FIRST	= 3,
42	ATTACH_NORMAL	= 2,
43	ATTACH_LAST	= 1,
44};
45
46/* unified I/O manager */
47enum txio_group {
48	MFIO = 0,
49	IO,
50	BETTY,
51	SNOWBALL,
52	PLUM,
53	NTXIO_GROUP
54};
55
56struct hpcio_chip;
57
58struct tx_chipset_tag {
59	enum tx_chipset tc_chipset;
60	void *tc_intrt;  /* interrupt tag */
61	void *tc_powert; /* power tag */
62	void *tc_clockt; /* clock/timer tag */
63	void *tc_soundt; /* sound tag */
64	struct hpcio_chip *tc_iochip[NTXIO_GROUP];
65	void *tc_videot; /* video chip tag */
66};
67
68typedef struct tx_chipset_tag* tx_chipset_tag_t __attribute__((__unused__));
69typedef u_int32_t txreg_t;
70extern struct tx_chipset_tag tx_chipset;
71#define tx_conf_get_tag() (&tx_chipset)
72
73#if defined TX391X && defined TX392X
74#define IS_TX391X(t)	((t)->tc_chipset == __TX391X)
75#define IS_TX392X(t)	((t)->tc_chipset == __TX392X)
76#elif defined TX391X
77#define IS_TX391X(t)	(1)
78#define IS_TX392X(t)	(0)
79#elif defined TX392X
80#define IS_TX391X(t)	(0)
81#define IS_TX392X(t)	(1)
82#endif
83
84void	tx_conf_register_intr(tx_chipset_tag_t, void *);
85void	tx_conf_register_power(tx_chipset_tag_t, void *);
86void	tx_conf_register_clock(tx_chipset_tag_t, void *);
87void	tx_conf_register_sound(tx_chipset_tag_t, void *);
88void	tx_conf_register_ioman(tx_chipset_tag_t, struct hpcio_chip *);
89void	tx_conf_register_video(tx_chipset_tag_t, void *);
90
91/*
92 *	TX39 Internal Function Register access
93 */
94#define TX39_SYSADDR_CONFIG_REG_KSEG1	0xb0c00000
95#define tx_conf_read(t, reg) (						\
96	(*((volatile txreg_t *)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg)))))
97#define tx_conf_write(t, reg, val) (					\
98	(*((volatile txreg_t *)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))) \
99	= (val)))
100
101/*
102 *	txsim attach arguments. (txsim ... TX System Internal Module)
103 */
104struct txsimbus_attach_args {
105	char *tba_busname;
106};
107
108/*
109 *	txsim module attach arguments.
110 */
111struct txsim_attach_args {
112	tx_chipset_tag_t ta_tc; /* Chipset tag */
113};
114
115/*
116 *	Interrupt staff
117 */
118#define MAKEINTR(s, b)	((s) * 32 + (ffs(b) - 1))
119void*	tx_intr_establish(tx_chipset_tag_t, int, int, int, int (*)(void *),
120			  void *);
121void	tx_intr_disestablish(tx_chipset_tag_t, void *);
122
123#ifdef USE_POLL
124void*	tx39_poll_establish(tx_chipset_tag_t, int, int, int (*)(void *),
125			    void *);
126void	tx39_poll_disestablish(tx_chipset_tag_t, void *);
127#define POLL_CONT	0
128#define POLL_END	1
129#endif /* USE_POLL */
130
131u_int32_t tx_intr_status(tx_chipset_tag_t, int);
132extern u_int32_t tx39intrvec;
133
134/*
135 *	Power management staff
136 */
137void tx39power_suspend_cpu(void);
138
139/*
140 *	Debug print configuration.
141 */
142#define USE_HPC_DPRINTF
143#define __DPRINTF_EXT
144