Home | History | Annotate | Line # | Download | only in dev
mq200.c revision 1.1
      1  1.1  takemura /*	$NetBSD: mq200.c,v 1.1 2000/07/22 08:53:36 takemura Exp $	*/
      2  1.1  takemura 
      3  1.1  takemura /*-
      4  1.1  takemura  * Copyright (c) 2000 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 #include <sys/param.h>
     33  1.1  takemura #include <sys/kernel.h>
     34  1.1  takemura #include <sys/device.h>
     35  1.1  takemura #include <sys/systm.h>
     36  1.1  takemura 
     37  1.1  takemura #include <uvm/uvm_extern.h>
     38  1.1  takemura 
     39  1.1  takemura #include <dev/wscons/wsconsio.h>
     40  1.1  takemura 
     41  1.1  takemura #include <machine/bootinfo.h>
     42  1.1  takemura #include <machine/bus.h>
     43  1.1  takemura #include <machine/autoconf.h>
     44  1.1  takemura #include <machine/config_hook.h>
     45  1.1  takemura #include <machine/platid.h>
     46  1.1  takemura #include <machine/platid_mask.h>
     47  1.1  takemura 
     48  1.1  takemura #include <hpcmips/dev/mq200reg.h>
     49  1.1  takemura #include <hpcmips/dev/mq200var.h>
     50  1.1  takemura #include <hpcmips/dev/bivideovar.h>
     51  1.1  takemura 
     52  1.1  takemura #define MQ200DEBUG
     53  1.1  takemura #ifdef MQ200DEBUG
     54  1.1  takemura #ifndef MQ200DEBUG_CONF
     55  1.1  takemura #define MQ200DEBUG_CONF 1
     56  1.1  takemura #endif
     57  1.1  takemura int	mq200_debug = MQ200DEBUG_CONF;
     58  1.1  takemura #define	DPRINTF(arg)     do { if (mq200_debug) printf arg; } while(0);
     59  1.1  takemura #define	DPRINTFN(n, arg) do { if (mq200_debug > (n)) printf arg; } while (0);
     60  1.1  takemura #else
     61  1.1  takemura #define	DPRINTF(arg)     do { } while (0);
     62  1.1  takemura #define DPRINTFN(n, arg) do { } while (0);
     63  1.1  takemura #endif
     64  1.1  takemura 
     65  1.1  takemura /*
     66  1.1  takemura  * function prototypes
     67  1.1  takemura  */
     68  1.1  takemura static void	mq200_power __P((int, void *));
     69  1.1  takemura static int	mq200_hardpower __P((void *, int, long, void *));
     70  1.1  takemura static int	mq200_fbinit __P((struct hpcfb_fbconf *));
     71  1.1  takemura static int	mq200_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
     72  1.1  takemura static paddr_t	mq200_mmap __P((void *, off_t offset, int));
     73  1.1  takemura 
     74  1.1  takemura /*
     75  1.1  takemura  * static variables
     76  1.1  takemura  */
     77  1.1  takemura struct hpcfb_accessops mq200_ha = {
     78  1.1  takemura 	mq200_ioctl, mq200_mmap
     79  1.1  takemura };
     80  1.1  takemura 
     81  1.1  takemura int
     82  1.1  takemura mq200_probe(iot, ioh)
     83  1.1  takemura 	bus_space_tag_t iot;
     84  1.1  takemura 	bus_space_handle_t ioh;
     85  1.1  takemura {
     86  1.1  takemura 	unsigned long regval;
     87  1.1  takemura 
     88  1.1  takemura 	regval = bus_space_read_4(iot, ioh, MQ200_PC00R);
     89  1.1  takemura 	DPRINTF(("mq200 probe: vendor id=%04lx product id=%04lx\n",
     90  1.1  takemura 		 regval & 0xffff, (regval >> 16) & 0xffff));
     91  1.1  takemura 	if (regval != ((MQ200_PRODUCT_ID << 16) | MQ200_VENDOR_ID))
     92  1.1  takemura 		return (0);
     93  1.1  takemura 
     94  1.1  takemura 	return (1);
     95  1.1  takemura }
     96  1.1  takemura 
     97  1.1  takemura void
     98  1.1  takemura mq200_attach(sc)
     99  1.1  takemura 	struct mq200_softc *sc;
    100  1.1  takemura {
    101  1.1  takemura 	unsigned long regval;
    102  1.1  takemura 	struct hpcfb_attach_args ha;
    103  1.1  takemura 	int console = (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) ? 0 : 1;
    104  1.1  takemura 
    105  1.1  takemura 	regval = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MQ200_PC08R);
    106  1.1  takemura 	printf(": MQ200 Rev.%02lx video controller\n", regval & 0xff);
    107  1.1  takemura 
    108  1.1  takemura 	/* Add a power hook to power saving */
    109  1.1  takemura 	sc->sc_powerstate = MQ200_POWERSTATE_D0;
    110  1.1  takemura 	sc->sc_powerhook = powerhook_establish(mq200_power, sc);
    111  1.1  takemura 	if (sc->sc_powerhook == NULL)
    112  1.1  takemura 		printf("%s: WARNING: unable to establish power hook\n",
    113  1.1  takemura 			sc->sc_dev.dv_xname);
    114  1.1  takemura 
    115  1.1  takemura 	/* Add a hard power hook to power saving */
    116  1.1  takemura 	sc->sc_hardpowerhook = config_hook(CONFIG_HOOK_PMEVENT,
    117  1.1  takemura 					   CONFIG_HOOK_PMEVENT_HARDPOWER,
    118  1.1  takemura 					   CONFIG_HOOK_SHARE,
    119  1.1  takemura 					   mq200_hardpower, sc);
    120  1.1  takemura 	if (sc->sc_hardpowerhook == NULL)
    121  1.1  takemura 		printf("%s: WARNING: unable to establish hard power hook\n",
    122  1.1  takemura 			sc->sc_dev.dv_xname);
    123  1.1  takemura 
    124  1.1  takemura 	mq200_fbinit(&sc->sc_fbconf);
    125  1.1  takemura 
    126  1.1  takemura 	if (console && hpcfb_cnattach(&sc->sc_fbconf) != 0) {
    127  1.1  takemura 		panic("mq200_attach: can't init fb console");
    128  1.1  takemura 	}
    129  1.1  takemura 
    130  1.1  takemura 	ha.ha_console = console;
    131  1.1  takemura 	ha.ha_accessops = &mq200_ha;
    132  1.1  takemura 	ha.ha_accessctx = sc;
    133  1.1  takemura 	ha.ha_curfbconf = 0;
    134  1.1  takemura 	ha.ha_nfbconf = 1;
    135  1.1  takemura 	ha.ha_fbconflist = &sc->sc_fbconf;
    136  1.1  takemura 	ha.ha_curdspconf = 0;
    137  1.1  takemura 	ha.ha_ndspconf = 1;
    138  1.1  takemura 	ha.ha_dspconflist = &sc->sc_dspconf;
    139  1.1  takemura 
    140  1.1  takemura 	config_found(&sc->sc_dev, &ha, hpcfbprint);
    141  1.1  takemura 
    142  1.1  takemura 	/*
    143  1.1  takemura 	 * bivideo is no longer need
    144  1.1  takemura 	 */
    145  1.1  takemura 	bivideo_dont_attach = 1;
    146  1.1  takemura }
    147  1.1  takemura 
    148  1.1  takemura static void
    149  1.1  takemura mq200_power(why, arg)
    150  1.1  takemura 	int why;
    151  1.1  takemura 	void *arg;
    152  1.1  takemura {
    153  1.1  takemura #if 0
    154  1.1  takemura 	struct mq200_softc *sc = arg;
    155  1.1  takemura 
    156  1.1  takemura 	switch (why) {
    157  1.1  takemura 	case PWR_SUSPEND:
    158  1.1  takemura 		sc->sc_powerstate = MQ200_POWERSTATE_D2;
    159  1.1  takemura 		break;
    160  1.1  takemura 	case PWR_STANDBY:
    161  1.1  takemura 		sc->sc_powerstate = MQ200_POWERSTATE_D3;
    162  1.1  takemura 		break;
    163  1.1  takemura 	case PWR_RESUME:
    164  1.1  takemura 		sc->sc_powerstate = MQ200_POWERSTATE_D0;
    165  1.1  takemura 		break;
    166  1.1  takemura 	}
    167  1.1  takemura 
    168  1.1  takemura 	printf("MQ200_PMCSR=%08x\n", sc->sc_powerstate);
    169  1.1  takemura 	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
    170  1.1  takemura 			  MQ200_PMCSR, sc->sc_powerstate);
    171  1.1  takemura #endif
    172  1.1  takemura }
    173  1.1  takemura 
    174  1.1  takemura static int
    175  1.1  takemura mq200_hardpower(ctx, type, id, msg)
    176  1.1  takemura 	void *ctx;
    177  1.1  takemura 	int type;
    178  1.1  takemura 	long id;
    179  1.1  takemura 	void *msg;
    180  1.1  takemura {
    181  1.1  takemura 	struct mq200_softc *sc = ctx;
    182  1.1  takemura 	int why = (int)msg;
    183  1.1  takemura 
    184  1.1  takemura 	switch (why) {
    185  1.1  takemura 	case PWR_SUSPEND:
    186  1.1  takemura 		sc->sc_powerstate = MQ200_POWERSTATE_D2;
    187  1.1  takemura 		break;
    188  1.1  takemura 	case PWR_STANDBY:
    189  1.1  takemura 		sc->sc_powerstate = MQ200_POWERSTATE_D3;
    190  1.1  takemura 		break;
    191  1.1  takemura 	case PWR_RESUME:
    192  1.1  takemura 		sc->sc_powerstate = MQ200_POWERSTATE_D0;
    193  1.1  takemura 		break;
    194  1.1  takemura 	}
    195  1.1  takemura 
    196  1.1  takemura 	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
    197  1.1  takemura 			  MQ200_PMCSR, sc->sc_powerstate);
    198  1.1  takemura 
    199  1.1  takemura 	/*
    200  1.1  takemura 	 * you should wait until the
    201  1.1  takemura 	 * power state transit sequence will end.
    202  1.1  takemura 	 */
    203  1.1  takemura 	{
    204  1.1  takemura 		unsigned long tmp;
    205  1.1  takemura 		do {
    206  1.1  takemura 			tmp = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
    207  1.1  takemura 					       MQ200_PMCSR);
    208  1.1  takemura 		} while ((tmp & 0x3) != (sc->sc_powerstate & 0x3));
    209  1.1  takemura 		delay(100000); /* XXX */
    210  1.1  takemura 	}
    211  1.1  takemura 
    212  1.1  takemura 	return (0);
    213  1.1  takemura }
    214  1.1  takemura 
    215  1.1  takemura 
    216  1.1  takemura static int
    217  1.1  takemura mq200_fbinit(fb)
    218  1.1  takemura 	struct hpcfb_fbconf *fb;
    219  1.1  takemura {
    220  1.1  takemura 
    221  1.1  takemura 	/*
    222  1.1  takemura 	 * get fb settings from bootinfo
    223  1.1  takemura 	 */
    224  1.1  takemura 	if (bootinfo == NULL ||
    225  1.1  takemura 	    bootinfo->fb_addr == 0 ||
    226  1.1  takemura 	    bootinfo->fb_line_bytes == 0 ||
    227  1.1  takemura 	    bootinfo->fb_width == 0 ||
    228  1.1  takemura 	    bootinfo->fb_height == 0) {
    229  1.1  takemura 		printf("no frame buffer infomation.\n");
    230  1.1  takemura 		return (-1);
    231  1.1  takemura 	}
    232  1.1  takemura 
    233  1.1  takemura 	/* zero fill */
    234  1.1  takemura 	bzero(fb, sizeof(*fb));
    235  1.1  takemura 
    236  1.1  takemura 	fb->hf_conf_index	= 0;	/* configuration index		*/
    237  1.1  takemura 	fb->hf_nconfs		= 1;   	/* how many configurations	*/
    238  1.1  takemura 	strcpy(fb->hf_name, "built-in video");
    239  1.1  takemura 					/* frame buffer name		*/
    240  1.1  takemura 	strcpy(fb->hf_conf_name, "default");
    241  1.1  takemura 					/* configuration name		*/
    242  1.1  takemura 	fb->hf_height		= bootinfo->fb_height;
    243  1.1  takemura 	fb->hf_width		= bootinfo->fb_width;
    244  1.1  takemura 	fb->hf_baseaddr		= mips_ptob(mips_btop(bootinfo->fb_addr));
    245  1.1  takemura 	fb->hf_offset		= (u_long)bootinfo->fb_addr - fb->hf_baseaddr;
    246  1.1  takemura 					/* frame buffer start offset   	*/
    247  1.1  takemura 	fb->hf_bytes_per_line	= bootinfo->fb_line_bytes;
    248  1.1  takemura 	fb->hf_nplanes		= 1;
    249  1.1  takemura 	fb->hf_bytes_per_plane	= bootinfo->fb_height *
    250  1.1  takemura 					bootinfo->fb_line_bytes;
    251  1.1  takemura 
    252  1.1  takemura 	fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
    253  1.1  takemura 	fb->hf_access_flags |= HPCFB_ACCESS_WORD;
    254  1.1  takemura 	fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
    255  1.1  takemura 
    256  1.1  takemura 	switch (bootinfo->fb_type) {
    257  1.1  takemura 		/*
    258  1.1  takemura 		 * gray scale
    259  1.1  takemura 		 */
    260  1.1  takemura 	case BIFB_D2_M2L_3:
    261  1.1  takemura 	case BIFB_D2_M2L_3x2:
    262  1.1  takemura 		fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
    263  1.1  takemura 		/* fall through */
    264  1.1  takemura 	case BIFB_D2_M2L_0:
    265  1.1  takemura 	case BIFB_D2_M2L_0x2:
    266  1.1  takemura 		fb->hf_class = HPCFB_CLASS_GRAYSCALE;
    267  1.1  takemura 		fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
    268  1.1  takemura 		fb->hf_pack_width = 8;
    269  1.1  takemura 		fb->hf_pixels_per_pack = 4;
    270  1.1  takemura 		fb->hf_pixel_width = 2;
    271  1.1  takemura 		fb->hf_class_data_length = sizeof(struct hf_gray_tag);
    272  1.1  takemura 		fb->hf_u.hf_gray.hf_flags = 0;	/* reserved for future use */
    273  1.1  takemura 		break;
    274  1.1  takemura 
    275  1.1  takemura 		/*
    276  1.1  takemura 		 * indexed color
    277  1.1  takemura 		 */
    278  1.1  takemura 	case BIFB_D8_FF:
    279  1.1  takemura 		fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
    280  1.1  takemura 		/* fall through */
    281  1.1  takemura 	case BIFB_D8_00:
    282  1.1  takemura 		fb->hf_class = HPCFB_CLASS_INDEXCOLOR;
    283  1.1  takemura 		fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
    284  1.1  takemura 		fb->hf_pack_width = 8;
    285  1.1  takemura 		fb->hf_pixels_per_pack = 1;
    286  1.1  takemura 		fb->hf_pixel_width = 8;
    287  1.1  takemura 		fb->hf_class_data_length = sizeof(struct hf_indexed_tag);
    288  1.1  takemura 		fb->hf_u.hf_indexed.hf_flags = 0; /* reserved for future use */
    289  1.1  takemura 		break;
    290  1.1  takemura 
    291  1.1  takemura 		/*
    292  1.1  takemura 		 * RGB color
    293  1.1  takemura 		 */
    294  1.1  takemura 	case BIFB_D16_FFFF:
    295  1.1  takemura 		fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
    296  1.1  takemura 		/* fall through */
    297  1.1  takemura 	case BIFB_D16_0000:
    298  1.1  takemura 		fb->hf_class = HPCFB_CLASS_RGBCOLOR;
    299  1.1  takemura 		fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
    300  1.1  takemura #if BYTE_ORDER == LITTLE_ENDIAN
    301  1.1  takemura 		fb->hf_swap_flags = HPCFB_SWAP_BYTE;
    302  1.1  takemura #endif
    303  1.1  takemura 		fb->hf_pack_width = 16;
    304  1.1  takemura 		fb->hf_pixels_per_pack = 1;
    305  1.1  takemura 		fb->hf_pixel_width = 16;
    306  1.1  takemura 
    307  1.1  takemura 		fb->hf_class_data_length = sizeof(struct hf_rgb_tag);
    308  1.1  takemura 		fb->hf_u.hf_rgb.hf_flags = 0;	/* reserved for future use */
    309  1.1  takemura 
    310  1.1  takemura 		fb->hf_u.hf_rgb.hf_red_width = 5;
    311  1.1  takemura 		fb->hf_u.hf_rgb.hf_red_shift = 11;
    312  1.1  takemura 		fb->hf_u.hf_rgb.hf_green_width = 6;
    313  1.1  takemura 		fb->hf_u.hf_rgb.hf_green_shift = 5;
    314  1.1  takemura 		fb->hf_u.hf_rgb.hf_blue_width = 5;
    315  1.1  takemura 		fb->hf_u.hf_rgb.hf_blue_shift = 0;
    316  1.1  takemura 		fb->hf_u.hf_rgb.hf_alpha_width = 0;
    317  1.1  takemura 		fb->hf_u.hf_rgb.hf_alpha_shift = 0;
    318  1.1  takemura 		break;
    319  1.1  takemura 
    320  1.1  takemura 	default:
    321  1.1  takemura 		printf("unknown type (=%d).\n", bootinfo->fb_type);
    322  1.1  takemura 		return (-1);
    323  1.1  takemura 		break;
    324  1.1  takemura 	}
    325  1.1  takemura 
    326  1.1  takemura 	return (0); /* no error */
    327  1.1  takemura }
    328  1.1  takemura 
    329  1.1  takemura int
    330  1.1  takemura mq200_ioctl(v, cmd, data, flag, p)
    331  1.1  takemura 	void *v;
    332  1.1  takemura 	u_long cmd;
    333  1.1  takemura 	caddr_t data;
    334  1.1  takemura 	int flag;
    335  1.1  takemura 	struct proc *p;
    336  1.1  takemura {
    337  1.1  takemura 	struct mq200_softc *sc = (struct mq200_softc *)v;
    338  1.1  takemura 	struct hpcfb_fbconf *fbconf;
    339  1.1  takemura 	struct hpcfb_dspconf *dspconf;
    340  1.1  takemura 	struct wsdisplay_cmap *cmap;
    341  1.1  takemura 
    342  1.1  takemura 	switch (cmd) {
    343  1.1  takemura 	case WSDISPLAYIO_GETCMAP:
    344  1.1  takemura 		cmap = (struct wsdisplay_cmap*)data;
    345  1.1  takemura 
    346  1.1  takemura 		if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR ||
    347  1.1  takemura 		    sc->sc_fbconf.hf_pack_width != 8 ||
    348  1.1  takemura 		    256 <= cmap->index ||
    349  1.1  takemura 		    256 < (cmap->index + cmap->count))
    350  1.1  takemura 			return (EINVAL);
    351  1.1  takemura 
    352  1.1  takemura #if 0
    353  1.1  takemura 		if (!uvm_useracc(cmap->red, cmap->count, B_WRITE) ||
    354  1.1  takemura 		    !uvm_useracc(cmap->green, cmap->count, B_WRITE) ||
    355  1.1  takemura 		    !uvm_useracc(cmap->blue, cmap->count, B_WRITE))
    356  1.1  takemura 			return (EFAULT);
    357  1.1  takemura 
    358  1.1  takemura 		copyout(&bivideo_cmap_r[cmap->index], cmap->red, cmap->count);
    359  1.1  takemura 		copyout(&bivideo_cmap_g[cmap->index], cmap->green,cmap->count);
    360  1.1  takemura 		copyout(&bivideo_cmap_b[cmap->index], cmap->blue, cmap->count);
    361  1.1  takemura #endif
    362  1.1  takemura 
    363  1.1  takemura 		return (0);
    364  1.1  takemura 
    365  1.1  takemura 	case WSDISPLAYIO_PUTCMAP:
    366  1.1  takemura 		/*
    367  1.1  takemura 		 * This driver can't set color map.
    368  1.1  takemura 		 */
    369  1.1  takemura 		return (EINVAL);
    370  1.1  takemura 
    371  1.1  takemura 	case HPCFBIO_GCONF:
    372  1.1  takemura 		fbconf = (struct hpcfb_fbconf *)data;
    373  1.1  takemura 		if (fbconf->hf_conf_index != 0 &&
    374  1.1  takemura 		    fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
    375  1.1  takemura 			return (EINVAL);
    376  1.1  takemura 		}
    377  1.1  takemura 		*fbconf = sc->sc_fbconf;	/* structure assignment */
    378  1.1  takemura 		return (0);
    379  1.1  takemura 	case HPCFBIO_SCONF:
    380  1.1  takemura 		fbconf = (struct hpcfb_fbconf *)data;
    381  1.1  takemura 		if (fbconf->hf_conf_index != 0 &&
    382  1.1  takemura 		    fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
    383  1.1  takemura 			return (EINVAL);
    384  1.1  takemura 		}
    385  1.1  takemura 		/*
    386  1.1  takemura 		 * nothing to do because we have only one configration
    387  1.1  takemura 		 */
    388  1.1  takemura 		return (0);
    389  1.1  takemura 	case HPCFBIO_GDSPCONF:
    390  1.1  takemura 		dspconf = (struct hpcfb_dspconf *)data;
    391  1.1  takemura 		if ((dspconf->hd_unit_index != 0 &&
    392  1.1  takemura 		     dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
    393  1.1  takemura 		    (dspconf->hd_conf_index != 0 &&
    394  1.1  takemura 		     dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
    395  1.1  takemura 			return (EINVAL);
    396  1.1  takemura 		}
    397  1.1  takemura 		*dspconf = sc->sc_dspconf;	/* structure assignment */
    398  1.1  takemura 		return (0);
    399  1.1  takemura 	case HPCFBIO_SDSPCONF:
    400  1.1  takemura 		dspconf = (struct hpcfb_dspconf *)data;
    401  1.1  takemura 		if ((dspconf->hd_unit_index != 0 &&
    402  1.1  takemura 		     dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
    403  1.1  takemura 		    (dspconf->hd_conf_index != 0 &&
    404  1.1  takemura 		     dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
    405  1.1  takemura 			return (EINVAL);
    406  1.1  takemura 		}
    407  1.1  takemura 		/*
    408  1.1  takemura 		 * nothing to do
    409  1.1  takemura 		 * because we have only one unit and one configration
    410  1.1  takemura 		 */
    411  1.1  takemura 		return (0);
    412  1.1  takemura 	case HPCFBIO_GOP:
    413  1.1  takemura 	case HPCFBIO_SOP:
    414  1.1  takemura 		/*
    415  1.1  takemura 		 * curently not implemented...
    416  1.1  takemura 		 */
    417  1.1  takemura 		return (EINVAL);
    418  1.1  takemura 	}
    419  1.1  takemura 
    420  1.1  takemura 	return (ENOTTY);
    421  1.1  takemura }
    422  1.1  takemura 
    423  1.1  takemura paddr_t
    424  1.1  takemura mq200_mmap(ctx, offset, prot)
    425  1.1  takemura 	void *ctx;
    426  1.1  takemura 	off_t offset;
    427  1.1  takemura 	int prot;
    428  1.1  takemura {
    429  1.1  takemura 	struct mq200_softc *sc = (struct mq200_softc *)ctx;
    430  1.1  takemura 
    431  1.1  takemura 	if (offset < 0 ||
    432  1.1  takemura 	    (sc->sc_fbconf.hf_bytes_per_plane +
    433  1.1  takemura 		sc->sc_fbconf.hf_offset) <  offset)
    434  1.1  takemura 		return -1;
    435  1.1  takemura 
    436  1.1  takemura 	return mips_btop(sc->sc_fbconf.hf_baseaddr + offset);
    437  1.1  takemura }
    438