igsfbreg.h revision 1.1 1 1.1 uwe /* $NetBSD: igsfbreg.h,v 1.1 2002/03/30 19:48:56 uwe Exp $ */
2 1.1 uwe
3 1.1 uwe /*
4 1.1 uwe * Copyright (c) 2002 Valeriy E. Ushakov
5 1.1 uwe * All rights reserved.
6 1.1 uwe *
7 1.1 uwe * Redistribution and use in source and binary forms, with or without
8 1.1 uwe * modification, are permitted provided that the following conditions
9 1.1 uwe * are met:
10 1.1 uwe * 1. Redistributions of source code must retain the above copyright
11 1.1 uwe * notice, this list of conditions and the following disclaimer.
12 1.1 uwe * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 uwe * notice, this list of conditions and the following disclaimer in the
14 1.1 uwe * documentation and/or other materials provided with the distribution.
15 1.1 uwe * 3. The name of the author may not be used to endorse or promote products
16 1.1 uwe * derived from this software without specific prior written permission
17 1.1 uwe *
18 1.1 uwe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1 uwe * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1 uwe * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1 uwe * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.1 uwe * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.1 uwe * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.1 uwe * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.1 uwe * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.1 uwe * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 1.1 uwe * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.1 uwe */
29 1.1 uwe
30 1.1 uwe /*
31 1.1 uwe * Integraphics Systems IGA 1682 and (untested) CyberPro 2k.
32 1.1 uwe */
33 1.1 uwe #ifndef _DEV_IC_IGSFBREG_H_
34 1.1 uwe #define _DEV_IC_IGSFBREG_H_
35 1.1 uwe
36 1.1 uwe /*
37 1.1 uwe * Magic address decoding for memory space accesses in CyberPro.
38 1.1 uwe */
39 1.1 uwe #define IGS_MEM_MMIO_SELECT 0x00800000 /* memory mapped i/o */
40 1.1 uwe #define IGS_MEM_BE_SELECT 0x00400000 /* endian */
41 1.1 uwe
42 1.1 uwe /*
43 1.1 uwe * Registers in I/O space (could be memory-mapped i/o).
44 1.1 uwe */
45 1.1 uwe #define IGS_IO_SIZE 0x400
46 1.1 uwe #define IGS_COP_SIZE 0x400
47 1.1 uwe
48 1.1 uwe /*
49 1.1 uwe * Cursor sprite data: 64x64 pixels, 2bpp = 1Kb.
50 1.1 uwe */
51 1.1 uwe #define IGS_CURSOR_DATA_SIZE 0x0400
52 1.1 uwe
53 1.1 uwe
54 1.1 uwe /*
55 1.1 uwe * Starting up the chip.
56 1.1 uwe */
57 1.1 uwe
58 1.1 uwe /* Video Enable/Setup */
59 1.1 uwe #define IGS_VDO 0x46e8
60 1.1 uwe #define IGS_VDO_ENABLE 0x08
61 1.1 uwe #define IGS_VDO_SETUP 0x10
62 1.1 uwe
63 1.1 uwe /* Video Enable */
64 1.1 uwe #define IGS_VSE 0x102
65 1.1 uwe #define IGS_VSE_ENABLE 0x01
66 1.1 uwe
67 1.1 uwe
68 1.1 uwe
69 1.1 uwe /*
70 1.1 uwe * Palette Read/Write: write palette index to the index port.
71 1.1 uwe * Read/write R/G/B in three consecutive accesses to data port.
72 1.1 uwe * After third access to data the index is autoincremented and you can
73 1.1 uwe * proceed with reading/writing data port for the next entry.
74 1.1 uwe *
75 1.1 uwe * When MRS2 bit in sprite control is set, these registers are used to
76 1.1 uwe * access sprite (i.e. cursor) 2-color palette. (NB: apparently, in
77 1.1 uwe * this mode index autoincrement doesn't work).
78 1.1 uwe */
79 1.1 uwe #define IGS_DAC_PEL_READ_IDX 0x3c7
80 1.1 uwe #define IGS_DAC_PEL_WRITE_IDX 0x3c8
81 1.1 uwe #define IGS_DAC_PEL_DATA 0x3c9
82 1.1 uwe
83 1.1 uwe
84 1.1 uwe /*
85 1.1 uwe * Extended Registers. Indexed access via IGS_EXT_PORT.
86 1.1 uwe */
87 1.1 uwe #define IGS_EXT_IDX 0x3ce
88 1.1 uwe
89 1.1 uwe
90 1.1 uwe /*
91 1.1 uwe * Sync Control.
92 1.1 uwe * Two bit combinations for h/v:
93 1.1 uwe * 00 - normal, 01 - force 0, 1x - force 1
94 1.1 uwe */
95 1.1 uwe #define IGS_EXT_SYNC_CTL 0x16
96 1.1 uwe #define IGS_EXT_SYNC_H0 0x01
97 1.1 uwe #define IGS_EXT_SYNC_H1 0x02
98 1.1 uwe #define IGS_EXT_SYNC_V0 0x04
99 1.1 uwe #define IGS_EXT_SYNC_V1 0x08
100 1.1 uwe
101 1.1 uwe /*
102 1.1 uwe * For PCI just use normal BAR config.
103 1.1 uwe */
104 1.1 uwe #define IGS_EXT_BUS_CTL 0x30
105 1.1 uwe #define IGS_EXT_BUS_CTL_LINSIZE_SHIFT 0
106 1.1 uwe #define IGS_EXT_BUS_CTL_LINSIZE_MASK 0x03
107 1.1 uwe #define IGS_EXT_BUS_CTL_LINSIZE(x) \
108 1.1 uwe (((x) >> IGS_EXT_BUS_CTL_LINSIZE_SHIFT) & IGS_EXT_BUS_CTL_LINSIZE_MASK)
109 1.1 uwe
110 1.1 uwe /*
111 1.1 uwe * COPREN - enable direct access to coprocessor registers
112 1.1 uwe * COPASELB - COP address select 0xbfc00..0xbffff
113 1.1 uwe */
114 1.1 uwe #define IGS_EXT_BIU_MISC_CTL 0x33
115 1.1 uwe #define IGS_EXT_BIU_LINEAREN 0x01
116 1.1 uwe #define IGS_EXT_BIU_LIN2MEM 0x02
117 1.1 uwe #define IGS_EXT_BIU_COPREN 0x04
118 1.1 uwe #define IGS_EXT_BIU_COPASELB 0x08
119 1.1 uwe #define IGS_EXT_BIU_SEGON 0x10
120 1.1 uwe #define IGS_EXT_BIU_SEG2MEM 0x20
121 1.1 uwe
122 1.1 uwe /*
123 1.1 uwe * Linear Address register
124 1.1 uwe * PCI: don't write directly, just use nomral PCI configuration
125 1.1 uwe * ISA: only bits [23..20] are programmable, the rest MBZ
126 1.1 uwe */
127 1.1 uwe #define IGS_EXT_LINA_LO 0x34 /* [3..0] -> [23..20] */
128 1.1 uwe #define IGS_EXT_LINA_HI 0x35 /* [7..0] -> [31..24] */
129 1.1 uwe
130 1.1 uwe /* Hardware cursor (sprite) */
131 1.1 uwe #define IGS_EXT_SPRITE_HSTART_LO 0x50
132 1.1 uwe #define IGS_EXT_SPRITE_HSTART_HI 0x51 /* bits [2..0] */
133 1.1 uwe #define IGS_EXT_SPRITE_HPRESET 0x52 /* bits [5..0] */
134 1.1 uwe
135 1.1 uwe #define IGS_EXT_SPRITE_VSTART_LO 0x53
136 1.1 uwe #define IGS_EXT_SPRITE_VSTART_HI 0x54 /* bits [2..0] */
137 1.1 uwe #define IGS_EXT_SPRITE_VPRESET 0x55 /* bits [5..0] */
138 1.1 uwe
139 1.1 uwe #define IGS_EXT_SPRITE_CTL 0x56
140 1.1 uwe #define IGS_EXT_SPRITE_VISIBLE 0x01
141 1.1 uwe #define IGS_EXT_SPRITE_64x64 0x02
142 1.1 uwe #define IGS_EXT_SPRITE_SELECT 0x04
143 1.1 uwe
144 1.1 uwe /* Overscan R/G/B registers */
145 1.1 uwe #define IGS_EXT_OVERSCAN_RED 0x58
146 1.1 uwe #define IGS_EXT_OVERSCAN_GREEN 0x59
147 1.1 uwe #define IGS_EXT_OVERSCAN_BLUE 0x5a
148 1.1 uwe
149 1.1 uwe /* Hardware cursor (sprite) data location */
150 1.1 uwe #define IGS_EXT_SPRITE_DATA_LO 0x7e
151 1.1 uwe #define IGS_EXT_SPRITE_DATA_HI 0x7f /* bits [3..0] */
152 1.1 uwe
153 1.1 uwe
154 1.1 uwe /*********************************************************************
155 1.1 uwe * Access sugar for indexed registers
156 1.1 uwe */
157 1.1 uwe
158 1.1 uwe static __inline__ u_int8_t
159 1.1 uwe igs_idx_read(bus_space_tag_t, bus_space_handle_t, u_int, u_int8_t);
160 1.1 uwe
161 1.1 uwe static __inline__ u_int8_t
162 1.1 uwe igs_idx_read(t, h, idxport, idx)
163 1.1 uwe bus_space_tag_t t;
164 1.1 uwe bus_space_handle_t h;
165 1.1 uwe u_int idxport;
166 1.1 uwe u_int8_t idx;
167 1.1 uwe {
168 1.1 uwe bus_space_write_1(t, h, idxport, idx);
169 1.1 uwe return (bus_space_read_1(t, h, idxport + 1));
170 1.1 uwe }
171 1.1 uwe
172 1.1 uwe static __inline__ void
173 1.1 uwe igs_idx_write(bus_space_tag_t, bus_space_handle_t, u_int, u_int8_t, u_int8_t);
174 1.1 uwe
175 1.1 uwe static __inline__ void
176 1.1 uwe igs_idx_write(t, h, idxport, idx, val)
177 1.1 uwe bus_space_tag_t t;
178 1.1 uwe bus_space_handle_t h;
179 1.1 uwe u_int idxport;
180 1.1 uwe u_int8_t idx, val;
181 1.1 uwe {
182 1.1 uwe bus_space_write_1(t, h, idxport, idx);
183 1.1 uwe bus_space_write_1(t, h, idxport + 1, val);
184 1.1 uwe }
185 1.1 uwe
186 1.1 uwe /* more sugar for extended registers */
187 1.1 uwe #define igs_ext_read(t,h,x) (igs_idx_read((t),(h),IGS_EXT_IDX,(x)))
188 1.1 uwe #define igs_ext_write(t,h,x,v) (igs_idx_write((t),(h),IGS_EXT_IDX,(x),(v)))
189 1.1 uwe
190 1.1 uwe #endif /* _DEV_IC_IGSFBREG_H_ */
191