summaryrefslogtreecommitdiff
path: root/sys/arch/hpcmips/dev/mq200priv.h
blob: cf234a82ceb3f630ddc7fb9330706439dc2c9187 (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
/*	$NetBSD: mq200priv.h,v 1.4 2005/12/11 12:17:33 christos Exp $	*/

/*-
 * Copyright (c) 2001 TAKEMURA Shin
 * All rights reserved.
 *
 * 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.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
 *
 */

struct mq200_crt_param {
	u_int16_t width, height, clock;
	u_int16_t hdtotal;
	u_int16_t vdtotal;
	u_int16_t hsstart, hsend;
	u_int16_t vsstart, vsend;
	u_int32_t opt;
};
#define MQ200_CRT_640x480_60Hz	0
#define MQ200_CRT_800x600_60Hz	1
#define MQ200_CRT_1024x768_60Hz	2

struct mq200_clock_setting {
	u_int8_t	mem, ge, gc[2];
	int		pll1, pll2, pll3;
};

struct mq200_md_param {
	platid_t	*md_platform;
	short		md_fp_width, md_fp_height;
	int		md_baseclock;
	int		md_flags;
#define MQ200_MD_HAVECRT	(1<<0)
#define MQ200_MD_HAVEFP		(1<<1)
	u_int32_t	*md_init_ops;
	const struct mq200_clock_setting *md_clock_settings;
	u_int32_t	md_init_dcmisc;
	u_int32_t	md_init_pmc;
	u_int32_t	md_init_mm01;
};

extern struct mq200_crt_param mq200_crt_params[];
extern int mq200_crt_nparams;
extern const char *mq200_clknames[];

int mq200_pllparam(int reqout, u_int32_t *res);
void mq200_set_pll(struct mq200_softc *, int, int);
void mq200_setup_regctx(struct mq200_softc *sc);
void mq200_setup(struct mq200_softc *sc);
void mq200_win_enable(struct mq200_softc *sc, int gc,
			   u_int32_t depth, u_int32_t start,
			   int width, int height, int stride);
void mq200_win_disable(struct mq200_softc *sc, int gc);
void mq200_setupmd(struct mq200_softc *sc);
void mq200_mdsetup(struct mq200_softc *sc);

void mq200_dump_gc(struct mq200_softc *sc, int gc);
void mq200_dump_fp(struct mq200_softc *sc);
void mq200_dump_dc(struct mq200_softc *sc);
void mq200_dump_pll(struct mq200_softc *sc);
void mq200_dump_all(struct mq200_softc *sc);
char* mq200_regname(struct mq200_softc *sc, int offset, char *buf, int size);

#ifdef MQ200_DEBUG
#ifndef MQ200DEBUG_CONF
#define MQ200DEBUG_CONF 0
#endif
extern int mq200_debug;
#define DPRINTF(fmt, args...)	do { if (mq200_debug) printf("mq200: " fmt, ##args); } while(0)
#define	VPRINTF(fmt, args...)	do { if (bootverbose || mq200_debug) printf("mq200: " fmt, ##args); } while(0)
#else
#define	DPRINTF(fmt, args...)	do { } while (0)
#define	VPRINTF(fmt, args...)	do { if (bootverbose) printf("mq200: " fmt, ##args); } while(0)
#endif

/*
 * register access wrappers
 */
static inline void
mq200_writex(struct mq200_softc *sc, int offset, u_int32_t data)
{
#ifdef _KERNEL
	bus_space_write_4(sc->sc_iot, sc->sc_ioh, offset, data);
#else
	*(volatile unsigned long*)(sc->sc_baseaddr + offset) = data;
#endif
}

#ifdef MQ200_DEBUG
void
mq200_write(struct mq200_softc *sc, int offset, u_int32_t data);
#else
static inline void
mq200_write(struct mq200_softc *sc, int offset, u_int32_t data)
{
	mq200_writex(sc, offset, data);
}
#endif /* MQ200_DEBUG */

static inline void
mq200_write2(struct mq200_softc *sc, struct mq200_regctx *reg, u_int32_t data)
{
	reg->val = data;
	mq200_writex(sc, reg->offset, reg->val);
}

static inline u_int32_t
mq200_read(struct mq200_softc *sc, int offset)
{
#ifdef _KERNEL
	return bus_space_read_4(sc->sc_iot, sc->sc_ioh, offset);
#else
	return *(volatile unsigned long*)(sc->sc_baseaddr + offset);
#endif
}

static inline void
mq200_mod(struct mq200_softc *sc, struct mq200_regctx *reg, u_int32_t mask, u_int32_t data)
{
	reg->val &= ~mask;
	reg->val |= data;
	mq200_writex(sc, reg->offset, reg->val);
}

static inline void
mq200_on(struct mq200_softc *sc, struct mq200_regctx *reg, unsigned long data)
{
	mq200_mod(sc, reg, data, data);
}

static inline void
mq200_off(struct mq200_softc *sc, struct mq200_regctx *reg, unsigned long data)
{
	mq200_mod(sc, reg, data, 0);
}