summaryrefslogtreecommitdiff
path: root/sys/dev/ic/ibm525reg.h
blob: a602128093a0063207d4de4c224d8ea8e0a92b9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*	$OpenBSD: ibm525reg.h,v 1.1 2005/07/19 09:34:14 miod Exp $	*/
/*
 * Copyright (c) 2005, Miodrag Vallat.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * IBM RGB525 Ramdac registers
 */

#define	IBM525_REVISION		0x00
#define	IBM525_ID		0x01

/* Miscellaneous clock control */
#define	IBM525_MISC_CLOCK	0x02
#define	MC_B24P_PLL		0x00
#define	MC_B24P_SCLK		0x20
#define	MC_DDOT_DIV_1		0x00	/* (VRAM size / 1) bpp */
#define	MC_DDOT_DIV_2		0x02	/* (VRAM size / 2) bpp */
#define	MC_DDOT_DIV_4		0x04	/* (VRAM size / 4) bpp */
#define	MC_DDOT_DIV_8		0x06	/* (VRAM size / 8) bpp */
#define	MC_DDOT_DIV_16		0x08	/* (VRAM size / 16) bpp */
#define	MC_DDOT_DIV_MASK	0x0e
#define	MC_PLL_ENABLE		0x01

/* Sync control */
#define	IBM525_SYNC		0x03
#define	S_CSYN_INVERT		0x40	/* Composite sync invert */
#define	S_VSYN_INVERT		0x20	/* Vertical sync invert (positive) */
#define	S_HSYN_INVERT		0x10	/* Horizontal sync invert (positive) */
#define	S_VSYN_NORMAL		0x00
#define	S_VSYN_HIGH		0x04
#define	S_VSYN_LOW		0x08
#define	S_VSYN_DISABLE		0x0c
#define	S_VSYN_MASK		0x0c
#define	S_HSYN_NORMAL		0x00
#define	S_HSYN_HIGH		0x01
#define	S_HSYN_LOW		0x02
#define	S_HSYN_DISABLE		0x03
#define	S_HSYN_MASK		0x03

/* Horizontal sync position */
#define	IBM525_HSYNC_POS	0x04

/* Power management */
#define	IBM525_POWER		0x05
#define	P_SCLK_DISABLE		0x10
#define	P_DDOT_DISABLE		0x08
#define	P_SYNC_DISABLE		0x04
#define	P_ICLK_DISABLE		0x02	/* Disable internal DAC clock */
#define	P_DAC_PWR_DISABLE	0x01	/* Disable internal DAC power */

/* DAC operation */
#define	IBM525_DAC_OP		0x06
#define	DO_SOG			0x08	/* Sync on Green */
#define	DO_FAST_SLEW		0x02	/* fast (>= 20 MHz) pixel clock */
#define	DO_BLANK_BR		0x04	/* blank blue and red channels */
#define	DO_PEDESTAL		0x01

/* Palette control */
#define	IBM525_PALETTE		0x07

/* System clock control */
#define	IBM525_SYSCLK		0x08
#define	SC_ENABLE		0x01

/* Pixel format */
#define	IBM525_PIXEL		0x0a
#define	PIX_4BPP		0x02
#define	PIX_8BPP		0x03
#define	PIX_16BPP		0x04
#define	PIX_24BPP		0x05
#define	PIX_32BPP		0x06

/* 8bpp pixel format */
#define	IBM525_PF8		0x0b
#define	PF8_INDIRECT		0x00
#define	PF8_DIRECT		0x01

/* 16bpp pixel format */
#define	IBM525_PF16		0x0c
#define	PF16_INDIRECT		0x00
#define	PF16_DIRECT		0xc0
#define	PF16_LINEAR		0x04
#define	PF16_555		0x00	/* 5:5:5 15bpp */
#define	PF16_565		0x02	/* 5:6:5 15bpp */

/* 24bpp pixel format */
#define	IBM525_PF24		0x0d
#define	PF24_INDIRECT		0x00
#define	PF24_DIRECT		0x01

/* 32bpp pixel format */
#define	IBM525_PF32		0x0e
#define	PF32_INDIRECT		0x00
#define	PF32_DIRECT		0x03
#define	PF32_BYPASS		0x00
#define	PF32_LOOKUP		0x04

/* Pixel PLL control #1 */
#define	IBM525_PLL1		0x10
#define	P1_CLK_REF		0x00
#define	P1_CLK_EXT		0x10
#define	P1_SRC_EXT_F		0x00	/* Use F registers for timing */
#define	P1_SRC_EXT_MN		0x01	/* Use M:N registers for timing */
#define	P1_SRC_DIRECT_F		0x02	/* Use F registers for timing */
#define	P1_SRC_DIRECT_MN	0x03	/* Use M:N registers for timing */

/* Pixel PLL control #2 */
#define	IBM525_PLL2		0x11

/* Fixed PLL reference */
#define	IBM525_PLL_FIXED_REF	0x14

/* PLL reference divider */
#define	IBM525_PLL_REF_DIV	0x15

/* PLL VCO divider */
#define	IBM525_PLL_VCO_DIV	0x16

/* N0-N15 */
#define	IBM525_F(n)		(0x20 + (n))

/* Miscellaneous control #1 */
#define	IBM525_MISC1		0x70
#define	M1_VRAM_32		0x00
#define	M1_VRAM_64		0x01
#define	M1_VRAM_SIZE_MASK	0x01
#define	M1_SENSE_DISABLE	0x10

/* Miscellaneous control #2 */
#define	IBM525_MISC2		0x71
#define	M2_PCLK_LOCAL		0x00
#define	M2_PCLK_PLL		0x40
#define	M2_PCLK_EXT		0x80
#define	M2_PCLK_MASK		0xc0
#define	M2_PALETTE_6		0x00	/* VGA compatible 6bit palette */
#define	M2_PALETTE_8		0x04	/* 8bit palette */
#define	M2_PALETTE_MASK		0x04
#define	M2_MODE_VRAM		0x01
#define	M2_MODE_VGA		0x00
#define	M2_MODE_MASK		0x01

/* Miscellaneous control #3 */
#define	IBM525_MISC3		0x72
#define	M3_SWAP_BR		0x80	/* swap blue and red */
#define	M3_SWAP_WORDS		0x10
#define	M3_SWAP_NIBBLES		0x02

/* Miscellaneous control #4 */
#define	IBM525_MISC4		0x73
#define	M4_INVERT_DCLK		0x10
#define	M4_FAST			0x20	/* Fast (>= 50 MHz) pixel clock */

/*
 * Pixel clock encoding
 */
#define	MHZ_TO_PLL(m) \
	(m) < 32 ? 0x00 | (4 * (m) - 65) : \
	  (m) < 64 ? 0x40 | (2 * (m) - 65) : \
	    (m) < 128 ? 0x80 | ((m) - 65) : \
	      0xc0 | ((m) / 2 - 65)