1 1.4 christos /* $NetBSD: mq200priv.h,v 1.4 2005/12/11 12:17:33 christos Exp $ */ 2 1.1 takemura 3 1.1 takemura /*- 4 1.1 takemura * Copyright (c) 2001 TAKEMURA Shin 5 1.1 takemura * All rights reserved. 6 1.1 takemura * 7 1.1 takemura * Redistribution and use in source and binary forms, with or without 8 1.1 takemura * modification, are permitted provided that the following conditions 9 1.1 takemura * are met: 10 1.1 takemura * 1. Redistributions of source code must retain the above copyright 11 1.1 takemura * notice, this list of conditions and the following disclaimer. 12 1.1 takemura * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 takemura * notice, this list of conditions and the following disclaimer in the 14 1.1 takemura * documentation and/or other materials provided with the distribution. 15 1.1 takemura * 3. The name of the author may not be used to endorse or promote products 16 1.1 takemura * derived from this software without specific prior written permission. 17 1.1 takemura * 18 1.1 takemura * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 1.1 takemura * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 1.1 takemura * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 1.1 takemura * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 1.1 takemura * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 1.1 takemura * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 1.1 takemura * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 1.1 takemura * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 1.1 takemura * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 1.1 takemura * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 1.1 takemura * SUCH DAMAGE. 29 1.1 takemura * 30 1.1 takemura */ 31 1.1 takemura 32 1.1 takemura struct mq200_crt_param { 33 1.1 takemura u_int16_t width, height, clock; 34 1.1 takemura u_int16_t hdtotal; 35 1.1 takemura u_int16_t vdtotal; 36 1.1 takemura u_int16_t hsstart, hsend; 37 1.1 takemura u_int16_t vsstart, vsend; 38 1.1 takemura u_int32_t opt; 39 1.1 takemura }; 40 1.1 takemura #define MQ200_CRT_640x480_60Hz 0 41 1.1 takemura #define MQ200_CRT_800x600_60Hz 1 42 1.1 takemura #define MQ200_CRT_1024x768_60Hz 2 43 1.1 takemura 44 1.1 takemura struct mq200_clock_setting { 45 1.1 takemura u_int8_t mem, ge, gc[2]; 46 1.1 takemura int pll1, pll2, pll3; 47 1.1 takemura }; 48 1.1 takemura 49 1.1 takemura struct mq200_md_param { 50 1.1 takemura platid_t *md_platform; 51 1.1 takemura short md_fp_width, md_fp_height; 52 1.1 takemura int md_baseclock; 53 1.1 takemura int md_flags; 54 1.1 takemura #define MQ200_MD_HAVECRT (1<<0) 55 1.1 takemura #define MQ200_MD_HAVEFP (1<<1) 56 1.1 takemura u_int32_t *md_init_ops; 57 1.1 takemura const struct mq200_clock_setting *md_clock_settings; 58 1.1 takemura u_int32_t md_init_dcmisc; 59 1.1 takemura u_int32_t md_init_pmc; 60 1.1 takemura u_int32_t md_init_mm01; 61 1.1 takemura }; 62 1.1 takemura 63 1.1 takemura extern struct mq200_crt_param mq200_crt_params[]; 64 1.1 takemura extern int mq200_crt_nparams; 65 1.3 he extern const char *mq200_clknames[]; 66 1.1 takemura 67 1.2 takemura int mq200_pllparam(int reqout, u_int32_t *res); 68 1.1 takemura void mq200_set_pll(struct mq200_softc *, int, int); 69 1.1 takemura void mq200_setup_regctx(struct mq200_softc *sc); 70 1.1 takemura void mq200_setup(struct mq200_softc *sc); 71 1.1 takemura void mq200_win_enable(struct mq200_softc *sc, int gc, 72 1.1 takemura u_int32_t depth, u_int32_t start, 73 1.1 takemura int width, int height, int stride); 74 1.1 takemura void mq200_win_disable(struct mq200_softc *sc, int gc); 75 1.1 takemura void mq200_setupmd(struct mq200_softc *sc); 76 1.1 takemura void mq200_mdsetup(struct mq200_softc *sc); 77 1.1 takemura 78 1.1 takemura void mq200_dump_gc(struct mq200_softc *sc, int gc); 79 1.1 takemura void mq200_dump_fp(struct mq200_softc *sc); 80 1.1 takemura void mq200_dump_dc(struct mq200_softc *sc); 81 1.1 takemura void mq200_dump_pll(struct mq200_softc *sc); 82 1.1 takemura void mq200_dump_all(struct mq200_softc *sc); 83 1.1 takemura char* mq200_regname(struct mq200_softc *sc, int offset, char *buf, int size); 84 1.1 takemura 85 1.1 takemura #ifdef MQ200_DEBUG 86 1.1 takemura #ifndef MQ200DEBUG_CONF 87 1.1 takemura #define MQ200DEBUG_CONF 0 88 1.1 takemura #endif 89 1.1 takemura extern int mq200_debug; 90 1.1 takemura #define DPRINTF(fmt, args...) do { if (mq200_debug) printf("mq200: " fmt, ##args); } while(0) 91 1.1 takemura #define VPRINTF(fmt, args...) do { if (bootverbose || mq200_debug) printf("mq200: " fmt, ##args); } while(0) 92 1.1 takemura #else 93 1.1 takemura #define DPRINTF(fmt, args...) do { } while (0) 94 1.1 takemura #define VPRINTF(fmt, args...) do { if (bootverbose) printf("mq200: " fmt, ##args); } while(0) 95 1.1 takemura #endif 96 1.1 takemura 97 1.1 takemura /* 98 1.1 takemura * register access wrappers 99 1.1 takemura */ 100 1.1 takemura static inline void 101 1.1 takemura mq200_writex(struct mq200_softc *sc, int offset, u_int32_t data) 102 1.1 takemura { 103 1.1 takemura #ifdef _KERNEL 104 1.1 takemura bus_space_write_4(sc->sc_iot, sc->sc_ioh, offset, data); 105 1.1 takemura #else 106 1.1 takemura *(volatile unsigned long*)(sc->sc_baseaddr + offset) = data; 107 1.1 takemura #endif 108 1.1 takemura } 109 1.1 takemura 110 1.1 takemura #ifdef MQ200_DEBUG 111 1.1 takemura void 112 1.1 takemura mq200_write(struct mq200_softc *sc, int offset, u_int32_t data); 113 1.1 takemura #else 114 1.1 takemura static inline void 115 1.1 takemura mq200_write(struct mq200_softc *sc, int offset, u_int32_t data) 116 1.1 takemura { 117 1.1 takemura mq200_writex(sc, offset, data); 118 1.1 takemura } 119 1.1 takemura #endif /* MQ200_DEBUG */ 120 1.1 takemura 121 1.1 takemura static inline void 122 1.1 takemura mq200_write2(struct mq200_softc *sc, struct mq200_regctx *reg, u_int32_t data) 123 1.1 takemura { 124 1.1 takemura reg->val = data; 125 1.1 takemura mq200_writex(sc, reg->offset, reg->val); 126 1.1 takemura } 127 1.1 takemura 128 1.1 takemura static inline u_int32_t 129 1.1 takemura mq200_read(struct mq200_softc *sc, int offset) 130 1.1 takemura { 131 1.1 takemura #ifdef _KERNEL 132 1.1 takemura return bus_space_read_4(sc->sc_iot, sc->sc_ioh, offset); 133 1.1 takemura #else 134 1.1 takemura return *(volatile unsigned long*)(sc->sc_baseaddr + offset); 135 1.1 takemura #endif 136 1.1 takemura } 137 1.1 takemura 138 1.1 takemura static inline void 139 1.1 takemura mq200_mod(struct mq200_softc *sc, struct mq200_regctx *reg, u_int32_t mask, u_int32_t data) 140 1.1 takemura { 141 1.1 takemura reg->val &= ~mask; 142 1.1 takemura reg->val |= data; 143 1.1 takemura mq200_writex(sc, reg->offset, reg->val); 144 1.1 takemura } 145 1.1 takemura 146 1.1 takemura static inline void 147 1.1 takemura mq200_on(struct mq200_softc *sc, struct mq200_regctx *reg, unsigned long data) 148 1.1 takemura { 149 1.1 takemura mq200_mod(sc, reg, data, data); 150 1.1 takemura } 151 1.1 takemura 152 1.1 takemura static inline void 153 1.1 takemura mq200_off(struct mq200_softc *sc, struct mq200_regctx *reg, unsigned long data) 154 1.1 takemura { 155 1.1 takemura mq200_mod(sc, reg, data, 0); 156 1.1 takemura } 157