xref: /openbsd/sys/dev/tc/tcvar.h (revision 7b36286a)
1 /* $OpenBSD: tcvar.h,v 1.14 2008/08/09 16:42:30 miod Exp $ */
2 /* $NetBSD: tcvar.h,v 1.17 2000/06/04 19:15:15 cgd Exp $ */
3 
4 /*
5  * Copyright (c) 1995 Carnegie-Mellon University.
6  * All rights reserved.
7  *
8  * Author: Chris G. Demetriou
9  *
10  * Permission to use, copy, modify and distribute this software and
11  * its documentation is hereby granted, provided that both the copyright
12  * notice and this permission notice appear in all copies of the
13  * software, derivative works or modified versions, and any portions
14  * thereof, and that both notices appear in supporting documentation.
15  *
16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19  *
20  * Carnegie Mellon requests users of this software to return to
21  *
22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
23  *  School of Computer Science
24  *  Carnegie Mellon University
25  *  Pittsburgh PA 15213-3890
26  *
27  * any improvements or extensions that they make and grant Carnegie the
28  * rights to redistribute these changes.
29  */
30 
31 #ifndef __DEV_TC_TCVAR_H__
32 #define __DEV_TC_TCVAR_H__
33 
34 /*
35  * Definitions for TURBOchannel autoconfiguration.
36  */
37 
38 #include <machine/bus.h>
39 #include <dev/tc/tcreg.h>
40 
41 /*
42  * Machine-dependent definitions.
43  */
44 #include <machine/tc_machdep.h>
45 
46 struct tc_softc {
47 	struct	device sc_dv;
48 
49 	int	sc_speed;
50 	int	sc_nslots;
51 	struct tc_slotdesc *sc_slots;
52 
53 	void	(*sc_intr_establish)(struct device *, void *,
54 			int, int (*)(void *), void *, const char *);
55 	void	(*sc_intr_disestablish)(struct device *, void *);
56 	bus_dma_tag_t (*sc_get_dma_tag)(int);
57 };
58 
59 /*
60  * Arguments used to attach TURBOchannel busses.
61  */
62 struct tcbus_attach_args {
63 	char		*tba_busname;		/* XXX should be common */
64 	bus_space_tag_t tba_memt;
65 
66 	/* Bus information */
67 	u_int		tba_speed;		/* see TC_SPEED_* below */
68 	u_int		tba_nslots;
69 	struct tc_slotdesc *tba_slots;
70 	u_int		tba_nbuiltins;
71 	const struct tc_builtin *tba_builtins;
72 
73 
74 	/* TC bus resource management; XXX will move elsewhere eventually. */
75 	void	(*tba_intr_establish)(struct device *, void *,
76 			int, int (*)(void *), void *, const char *);
77 	void	(*tba_intr_disestablish)(struct device *, void *);
78 	bus_dma_tag_t (*tba_get_dma_tag)(int);
79 };
80 
81 /*
82  * Arguments used to attach TURBOchannel devices.
83  */
84 struct tc_attach_args {
85 	bus_space_tag_t ta_memt;
86 	bus_dma_tag_t	ta_dmat;
87 
88 	char		ta_modname[TC_ROM_LLEN+1];
89 	u_int		ta_slot;
90 	tc_offset_t	ta_offset;
91 	tc_addr_t	ta_addr;
92 	void		*ta_cookie;
93 	u_int		ta_busspeed;		/* see TC_SPEED_* below */
94 };
95 
96 /*
97  * Description of TURBOchannel slots, provided by machine-dependent
98  * code to the TURBOchannel bus driver.
99  */
100 struct tc_slotdesc {
101 	tc_addr_t	tcs_addr;
102 	void		*tcs_cookie;
103 	int		tcs_used;
104 };
105 
106 /*
107  * Description of built-in TURBOchannel devices, provided by
108  * machine-dependent code to the TURBOchannel bus driver.
109  */
110 struct tc_builtin {
111 	char		*tcb_modname;
112 	u_int		tcb_slot;
113 	tc_offset_t	tcb_offset;
114 	void		*tcb_cookie;
115 };
116 
117 /*
118  * Interrupt establishment functions.
119  */
120 int	tc_checkslot(tc_addr_t, char *);
121 void	tc_devinfo(const char *, char *, size_t);
122 void	tcattach(struct device *, struct device *, void *);
123 void	tc_intr_establish(struct device *, void *, int, int (*)(void *),
124 	    void *, const char *);
125 void	tc_intr_disestablish(struct device *, void *);
126 
127 /*
128  * Easy to remember names for TURBOchannel device locators.
129  */
130 #define	tccf_slot	cf_loc[0]		/* slot */
131 #define	tccf_offset	cf_loc[1]		/* offset */
132 
133 #define	TCCF_SLOT_UNKNOWN	-1
134 #define	TCCF_OFFSET_UNKNOWN	-1
135 
136 /*
137  * Miscellaneous definitions.
138  */
139 #define	TC_SPEED_12_5_MHZ	0		/* 12.5MHz TC bus */
140 #define	TC_SPEED_25_MHZ		1		/* 25MHz TC bus */
141 
142 #endif /* __DEV_TC_TCVAR_H__ */
143