1/*	$NetBSD: gboxreg.h,v 1.1 2011/02/06 18:26:51 tsutsui Exp $	*/
2/*	$OpenBSD: gboxreg.h,v 1.2 2005/01/24 21:36:39 miod Exp $	*/
3/*	NetBSD: grf_gbreg.h,v 1.4 1994/10/26 07:23:53 cgd Exp 	*/
4
5/*
6 * Copyright (c) 1988 University of Utah.
7 * Copyright (c) 1990, 1993
8 *	The Regents of the University of California.  All rights reserved.
9 *
10 * This code is derived from software contributed to Berkeley by
11 * the Systems Programming Group of the University of Utah Computer
12 * Science Department.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 *    notice, this list of conditions and the following disclaimer in the
21 *    documentation and/or other materials provided with the distribution.
22 * 3. Neither the name of the University nor the names of its contributors
23 *    may be used to endorse or promote products derived from this software
24 *    without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * from: Utah $Hdr: grf_gbreg.h 1.11 92/01/21$
39 *
40 *	@(#)grf_gbreg.h	8.1 (Berkeley) 6/10/93
41 */
42
43/*
44 * Gatorbox driver regs
45 */
46
47#define TILER_ENABLE		0x80
48#define LINE_MOVER_ENABLE	0x80
49#define UP_LEFT			0x00
50#define DOWN_RIGHT		0x40
51#define MOVE_UP_LEFT		(TILER_ENABLE | UP_LEFT)
52#define MOVE_DOWN_RIGHT		(TILER_ENABLE | DOWN_RIGHT)
53
54#define tile_mover_waitbusy(regaddr)					\
55do {									\
56	while (((volatile struct gboxfb *)(regaddr))->regs.sec_interrupt & 0x10) \
57		DELAY(1);						\
58} while (/* CONSTCOND */0)
59
60#define line_mover_waitbusy(regaddr)					\
61do {									\
62	while ((((volatile struct gboxfb *)(regaddr))->status & 0x80) == 0) \
63		DELAY(1);						\
64} while (/* CONSTCOND */0)
65
66#define gbcm_waitbusy(regaddr)						\
67do {									\
68	while (((volatile struct gboxfb *)(regaddr))->cmap_busy != 0xff) \
69		DELAY(1);						\
70} while (/* CONSTCOND */0)
71
72struct gboxfb {
73	struct diofbreg regs;
74	uint8_t f2[0x4000-0x5f-1];
75	uint8_t crtc_address;		/* CTR controller address reg 0x4000 */
76	uint8_t status;			/* Status register	      0x4001 */
77	uint8_t crtc_data;		/* CTR controller data reg    0x4002 */
78	uint8_t f3[6];
79	uint8_t line_mover_rep_rule;	/* Line move rep rule		     */
80	uint8_t :8, :8;
81	uint8_t line_mover_width;	/* Line move width		     */
82	uint8_t f4[0xff3];
83	uint8_t width;			/* width in tiles	      0x5001 */
84	uint8_t :8;
85	uint8_t height;			/* height in tiles	      0x5003 */
86	uint8_t f5[3];
87	uint8_t rep_rule;		/* replacement rule	      0x5007 */
88	uint8_t f6[0x6001-0x5007-1];
89	uint8_t blink1;			/* blink 1		      0x6001 */
90	uint8_t f7[3];
91	uint8_t blink2;			/* blink 2		      0x6005 */
92	uint8_t f8[3];
93	uint8_t write_protect;		/* write protect	      0x6009 */
94	uint8_t f9[0x6803-0x6009-1];
95	uint8_t cmap_busy;		/* color map busy	      0x6803 */
96	uint8_t f10[0x68b9-0x6803-1];
97	uint8_t creg_select;		/* color map register select  0x68b8 */
98	uint8_t f11[0x68f1-0x68b9-1];
99	uint8_t cmap_write;		/* color map write trigger    0x68f1 */
100	uint8_t f12[0x69b3-0x68f1-1];
101	uint8_t cmap_red;		/* red value register	      0x69b3 */
102	uint8_t :8;
103	uint8_t cmap_grn;		/* green value register	      0x69b5 */
104	uint8_t :8;
105	uint8_t cmap_blu;		/* blue value register	      0x69b6 */
106};
107