intiovar.h revision 1.1.2.4 1 /* $NetBSD: intiovar.h,v 1.1.2.4 1999/01/31 06:44:26 minoura Exp $ */
2
3 /*
4 *
5 * Copyright (c) 1998 NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Charles D. Cranor and
19 * Washington University.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 /*
36 * NetBSD/x68k internal I/O virtual bus.
37 */
38
39 #ifndef _INTIOVAR_H_
40 #define _INTIOVAR_H_
41
42 #include <machine/frame.h>
43 #include <sys/malloc.h>
44 #include <sys/extent.h>
45 #include "locators.h"
46
47 #define cf_addr cf_loc[INTIOCF_ADDR]
48 #define cf_intr cf_loc[INTIOCF_INTR]
49 #define cf_dma cf_loc[INTIOCF_DMA]
50 #define cf_dmaintr cf_loc[INTIOCF_DMAINTR]
51
52
53 struct intio_attach_args {
54 bus_space_tag_t ia_bst; /* bus_space tag */
55 bus_dma_tag_t ia_dmat; /* bus_dma tag */
56
57 char *ia_name; /* device name */
58 int ia_addr; /* addr */
59 int ia_size;
60 int ia_intr; /* interrupt vector */
61 int ia_dma; /* dma channel */
62 int ia_dmaintr; /* interrupt vector for dmac */
63 };
64
65 struct intio_softc {
66 struct device sc_dev;
67 bus_space_tag_t sc_bst;
68 bus_dma_tag_t sc_dmat;
69 struct extent *sc_map;
70 struct device *sc_dmac;
71 };
72
73 enum intio_map_flag {
74 INTIO_MAP_ALLOCATE = 0,
75 INTIO_MAP_TESTONLY = 1
76 };
77 int intio_map_allocate_region __P((struct device*, struct intio_attach_args*, enum intio_map_flag));
78 int intio_map_free_region __P((struct device*, struct intio_attach_args*));
79
80
81 typedef int (*intio_intr_handler_t) __P((void*));
82
83 int intio_intr_establish __P((int, const char *, intio_intr_handler_t, void *));
84 int intio_intr_disestablish __P((int, void *));
85 int intio_intr __P((struct frame *));
86
87
88 #define PHYS_INTIODEV 0x00c00000
89
90 extern u_int8_t *intiobase;
91
92 #define INTIO_ADDR(a) ((volatile u_int8_t *) (((u_int32_t) (a)) - (PHYS_INTIODEV) + intiobase))
93
94 #define INTIO_SYSPORT (0x00e8e000)
95 #define intio_sysport INTIO_ADDR(INTIO_SYSPORT)
96 #define sysport_contrast 1
97 #define sysport_tvctrl 3
98 #define sysport_imageunit 5
99 #define sysport_keyctrl 7
100 #define sysport_waitctrl 9
101 #define sysport_mpustat 11
102 #define sysport_sramwp 13
103 #define sysport_powoff 15
104
105 #define intio_set_sysport_contrast(a) \
106 intio_sysport[sysport_contrast] = (a) /* 0-15 */
107 #define intio_set_sysport_tvctrl(a) \
108 intio_sysport[sysport_tvctrl] = (a)
109 #define INTIO_SYSPORT_TVCTRL 0x08
110 #define intio_set_sysport_imageunit(a) \
111 intio_sysport[sysport_imageunit] = (a)
112 #define intio_set_sysport_keyctrl(a) \
113 intio_sysport[sysport_keyctrl] = (a)
114 #define INTIO_SYSPORT_KBENABLE 0x08
115 #define intio_set_sysport_waitctrl(a) \
116 intio_sysport[sysport_waitctrl] = (a) /* X68030 only */
117 #define intio_set_sysport_sramwp(a) \
118 intio_sysport[sysport_sramwp] = (a)
119 #define INTIO_SYSPORT_SRAMWP 0x31
120 #define intio_set_sysport_powoff(a) \
121 intio_sysport[sysport_powoff] = (a)
122
123 #define intio_get_sysport_contrast() \
124 (intio_sysport[sysport_contrast])
125 #define intio_get_sysport_tvctrl() \
126 (intio_sysport[sysport_tvctrl])
127 #define INTIO_SYSPORT_TVSTAT 0x08
128 #define intio_get_sysport_keyctrl() \
129 (intio_sysport[sysport_keyctrl])
130 #define INTIO_SYSPORT_KBEXIST 0x08
131 #define intio_get_sysport_waitctrl() \
132 (intio_sysport[sysport_waitctrl])
133 #define intio_get_sysport_mpustat() \
134 (intio_sysport[sysport_mpustat])
135
136 struct intio_dma_cookie {
137 int id_flags; /* flags; see below */
138
139 /*
140 * Information about the original buffer used during
141 * DMA map syncs. Note that origibuflen is only used
142 * for ID_BUFTYPE_LINEAR.
143 */
144 void *id_origbuf; /* pointer to orig buffer if
145 bouncing */
146 bus_size_t id_origbuflen; /* ...and size */
147 int id_buftype; /* type of buffer */
148
149 void *id_bouncebuf; /* pointer to the bounce buffer */
150 bus_size_t id_bouncebuflen; /* ...and size */
151 int id_nbouncesegs; /* number of valid bounce segs */
152 bus_dma_segment_t id_bouncesegs[0]; /* array of bounce buffer
153 physical memory segments */
154 };
155
156 /* id_flags */
157 #define ID_MIGHT_NEED_BOUNCE 0x01 /* map could need bounce buffers */
158 #define ID_HAS_BOUNCE 0x02 /* map currently has bounce buffers */
159 #define ID_IS_BOUNCING 0x04 /* map is bouncing current xfer */
160
161 /* id_buftype */
162 #define ID_BUFTYPE_INVALID 0
163 #define ID_BUFTYPE_LINEAR 1
164 #define ID_BUFTYPE_MBUF 2
165 #define ID_BUFTYPE_UIO 3
166 #define ID_BUFTYPE_RAW 4
167
168 #endif
169