Home | History | Annotate | Line # | Download | only in dev
sti_machdep.c revision 1.6
      1  1.6  tsutsui /*	$NetBSD: sti_machdep.c,v 1.6 2025/05/28 17:33:38 tsutsui Exp $	*/
      2  1.1  tsutsui /*	$OpenBSD: sti_sgc.c,v 1.14 2007/05/26 00:36:03 krw Exp $	*/
      3  1.1  tsutsui 
      4  1.1  tsutsui /*
      5  1.1  tsutsui  * Copyright (c) 2005, Miodrag Vallat
      6  1.1  tsutsui  *
      7  1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
      8  1.1  tsutsui  * modification, are permitted provided that the following conditions
      9  1.1  tsutsui  * are met:
     10  1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     11  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     12  1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     15  1.1  tsutsui  *
     16  1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1  tsutsui  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18  1.1  tsutsui  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     19  1.1  tsutsui  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     20  1.1  tsutsui  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21  1.1  tsutsui  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     22  1.1  tsutsui  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1  tsutsui  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     24  1.1  tsutsui  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     25  1.1  tsutsui  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1  tsutsui  * POSSIBILITY OF SUCH DAMAGE.
     27  1.1  tsutsui  *
     28  1.1  tsutsui  */
     29  1.1  tsutsui /*-
     30  1.1  tsutsui  * Copyright (c) 2020, 2025 Izumi Tsutsui.  All rights reserved.
     31  1.1  tsutsui  *
     32  1.1  tsutsui  * Redistribution and use in source and binary forms, with or without
     33  1.1  tsutsui  * modification, are permitted provided that the following conditions
     34  1.1  tsutsui  * are met:
     35  1.1  tsutsui  * 1. Redistributions of source code must retain the above copyright
     36  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer.
     37  1.1  tsutsui  * 2. Redistributions in binary form must reproduce the above copyright
     38  1.1  tsutsui  *    notice, this list of conditions and the following disclaimer in the
     39  1.1  tsutsui  *    documentation and/or other materials provided with the distribution.
     40  1.1  tsutsui  *
     41  1.1  tsutsui  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     42  1.1  tsutsui  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     43  1.1  tsutsui  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     44  1.1  tsutsui  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     45  1.1  tsutsui  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     46  1.1  tsutsui  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     47  1.1  tsutsui  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     48  1.1  tsutsui  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     49  1.1  tsutsui  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     50  1.1  tsutsui  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     51  1.1  tsutsui  */
     52  1.1  tsutsui 
     53  1.1  tsutsui #include <sys/cdefs.h>
     54  1.6  tsutsui __KERNEL_RCSID(0, "$NetBSD: sti_machdep.c,v 1.6 2025/05/28 17:33:38 tsutsui Exp $");
     55  1.1  tsutsui 
     56  1.1  tsutsui #include <sys/param.h>
     57  1.1  tsutsui #include <sys/device.h>
     58  1.1  tsutsui #include <sys/bus.h>
     59  1.1  tsutsui 
     60  1.1  tsutsui #include <dev/wscons/wsconsio.h>
     61  1.1  tsutsui 
     62  1.1  tsutsui #include <hp300/dev/sti_machdep.h>
     63  1.1  tsutsui 
     64  1.1  tsutsui /*
     65  1.4  tsutsui  * 425e and 362/382 EVRX specific hardware
     66  1.1  tsutsui  */
     67  1.1  tsutsui /*
     68  1.4  tsutsui  * RAMDAC (Bt458) on 425e EVRX is found at offset 0x00060000 from SGC bus PA.
     69  1.4  tsutsui  * RAMDAC (Bt474) on 362/382 EVRX is also found at offset 0x00060000
     70  1.4  tsutsui  * from DIO scode (132) + STI_DIO_SCODE_OFFSET PA (i.e. 0x01800000).
     71  1.4  tsutsui  *
     72  1.4  tsutsui  * Offset 0x040000 length 0x1c0000 is mapped in MI sti via ROM region 2
     73  1.4  tsutsui  * on both 425e and 362/382.
     74  1.1  tsutsui  */
     75  1.4  tsutsui #define STI_EVRX_REGNO2OFFSET	0x00020000	/* 0x00060000 - 0x00040000 */
     76  1.4  tsutsui 
     77  1.4  tsutsui /* bitmap memory can be accessed at offset +0x200000 */
     78  1.4  tsutsui #define STI_EVRX_FBOFFSET	0x00200000
     79  1.1  tsutsui 
     80  1.1  tsutsui #define EVRX_BT458_ADDR		(STI_EVRX_REGNO2OFFSET + 0x200 + 2)
     81  1.1  tsutsui #define EVRX_BT458_CMAP		(STI_EVRX_REGNO2OFFSET + 0x204 + 2)
     82  1.1  tsutsui #define EVRX_BT458_CTRL		(STI_EVRX_REGNO2OFFSET + 0x208 + 2)
     83  1.1  tsutsui #define EVRX_BT458_OMAP		(STI_EVRX_REGNO2OFFSET + 0x20C + 2)
     84  1.1  tsutsui 
     85  1.4  tsutsui /* These registers are partially common between Bt474 and Bt458 */
     86  1.4  tsutsui #define EVRX_BT4xx_ADDR		EVRX_BT458_ADDR
     87  1.4  tsutsui #define EVRX_BT4xx_CMAP		EVRX_BT458_CMAP
     88  1.4  tsutsui #define EVRX_BT4xx_CTRL		EVRX_BT458_CTRL
     89  1.4  tsutsui 
     90  1.1  tsutsui /* from HP-UX /usr/lib/libddevrx.a */
     91  1.1  tsutsui #define EVRX_MAGIC00		(STI_EVRX_REGNO2OFFSET + 0x600)
     92  1.1  tsutsui #define EVRX_MAGIC04		(STI_EVRX_REGNO2OFFSET + 0x604)
     93  1.1  tsutsui #define EVRX_MAGIC08		(STI_EVRX_REGNO2OFFSET + 0x608)
     94  1.1  tsutsui #define EVRX_MAGIC0C		(STI_EVRX_REGNO2OFFSET + 0x60c)
     95  1.1  tsutsui #define EVRX_MAGIC10		(STI_EVRX_REGNO2OFFSET + 0x610)
     96  1.1  tsutsui #define EVRX_MAGIC10_BSY	0x00010000
     97  1.1  tsutsui #define EVRX_MAGIC18		(STI_EVRX_REGNO2OFFSET + 0x618)
     98  1.1  tsutsui #define EVRX_MAGIC1C		(STI_EVRX_REGNO2OFFSET + 0x61c)
     99  1.1  tsutsui 
    100  1.1  tsutsui /*
    101  1.1  tsutsui  * HP A1659A CRX specific hardware
    102  1.1  tsutsui  */
    103  1.4  tsutsui /* bitmap memory can be accessed at offset +0x1000000 */
    104  1.1  tsutsui #define STI_CRX_FBOFFSET	0x01000000
    105  1.1  tsutsui 
    106  1.4  tsutsui /* hp300 EVRX and CRX specific access functions */
    107  1.1  tsutsui static int sti_evrx_putcmap(struct sti_screen *, u_int, u_int);
    108  1.1  tsutsui static void sti_evrx_resetramdac(struct sti_screen *);
    109  1.1  tsutsui static void sti_evrx_resetcmap(struct sti_screen *);
    110  1.1  tsutsui static void sti_evrx_setupfb(struct sti_screen *);
    111  1.1  tsutsui static paddr_t sti_m68k_mmap(void *, void *, off_t, int);
    112  1.1  tsutsui 
    113  1.1  tsutsui static struct bus_space_tag sticn_tag;
    114  1.1  tsutsui static struct sti_rom sticn_rom;
    115  1.1  tsutsui static struct sti_screen sticn_scr;
    116  1.1  tsutsui static bus_addr_t sticn_bases[STI_REGION_MAX];
    117  1.1  tsutsui 
    118  1.1  tsutsui static const struct wsdisplay_accessops sti_m68k_accessops = {
    119  1.5  tsutsui 	.ioctl        = sti_ioctl,
    120  1.5  tsutsui 	.mmap         = sti_m68k_mmap,
    121  1.5  tsutsui 	.alloc_screen = sti_alloc_screen,
    122  1.5  tsutsui 	.free_screen  = sti_free_screen,
    123  1.5  tsutsui 	.show_screen  = sti_show_screen,
    124  1.5  tsutsui 	.load_font    = sti_load_font
    125  1.1  tsutsui };
    126  1.1  tsutsui 
    127  1.1  tsutsui void
    128  1.1  tsutsui sti_machdep_attach_console(struct sti_machdep_softc *sc)
    129  1.1  tsutsui {
    130  1.1  tsutsui 	struct sti_softc *ssc = &sc->sc_sti;
    131  1.1  tsutsui 
    132  1.1  tsutsui 	ssc->sc_flags |= STI_CONSOLE | STI_ATTACHED;
    133  1.1  tsutsui 	ssc->sc_rom = &sticn_rom;
    134  1.1  tsutsui 	ssc->sc_rom->rom_softc = ssc;
    135  1.1  tsutsui 	ssc->sc_scr = &sticn_scr;
    136  1.1  tsutsui 	ssc->sc_scr->scr_rom = ssc->sc_rom;
    137  1.1  tsutsui 	memcpy(ssc->bases, sticn_bases, sizeof(ssc->bases));
    138  1.1  tsutsui 
    139  1.1  tsutsui 	sti_describe(ssc);
    140  1.1  tsutsui }
    141  1.1  tsutsui 
    142  1.1  tsutsui void
    143  1.1  tsutsui sti_machdep_attach(struct sti_machdep_softc *sc)
    144  1.1  tsutsui {
    145  1.1  tsutsui 	struct sti_softc *ssc = &sc->sc_sti;
    146  1.1  tsutsui 	struct sti_screen *scr;
    147  1.1  tsutsui 	paddr_t base = sc->sc_base;
    148  1.1  tsutsui 	struct wsemuldisplaydev_attach_args waa;
    149  1.1  tsutsui 	struct sti_dd *rom_dd;
    150  1.1  tsutsui 	uint32_t grid0;
    151  1.1  tsutsui 
    152  1.1  tsutsui 	/* Identify the board model by dd_grid */
    153  1.1  tsutsui 	rom_dd = &ssc->sc_rom->rom_dd;
    154  1.1  tsutsui 	grid0 = rom_dd->dd_grid[0];
    155  1.1  tsutsui 	scr = ssc->sc_scr;
    156  1.1  tsutsui 
    157  1.1  tsutsui 	switch (grid0) {
    158  1.1  tsutsui 	case STI_DD_EVRX:
    159  1.4  tsutsui 	case STI_DD_382C:
    160  1.4  tsutsui 	case STI_DD_3X2V:
    161  1.1  tsutsui 		/*
    162  1.4  tsutsui 		 * 425e and 362/382 on-board EVRX framebuffer.
    163  1.1  tsutsui 		 */
    164  1.1  tsutsui 		sc->sc_bitmap = base + STI_EVRX_FBOFFSET;
    165  1.1  tsutsui 
    166  1.1  tsutsui 		aprint_normal_dev(ssc->sc_dev, "Enable mmap support\n");
    167  1.1  tsutsui 
    168  1.1  tsutsui 		/*
    169  1.4  tsutsui 		 * initialize Bt458/474 RAMDAC and preserve initial color map
    170  1.1  tsutsui 		 */
    171  1.1  tsutsui 		sti_evrx_resetramdac(scr);
    172  1.1  tsutsui 		sti_evrx_resetcmap(scr);
    173  1.1  tsutsui 
    174  1.1  tsutsui 		scr->setupfb = sti_evrx_setupfb;
    175  1.1  tsutsui 		scr->putcmap = sti_evrx_putcmap;
    176  1.1  tsutsui 
    177  1.1  tsutsui 		scr->scr_wsmode = WSDISPLAYIO_MODE_EMUL;
    178  1.1  tsutsui 		waa.console = ssc->sc_flags & STI_CONSOLE ? 1 : 0;
    179  1.1  tsutsui 		waa.scrdata = &scr->scr_screenlist;
    180  1.1  tsutsui 		waa.accessops = &sti_m68k_accessops;
    181  1.1  tsutsui 		waa.accesscookie = scr;
    182  1.1  tsutsui 
    183  1.1  tsutsui 		config_found(ssc->sc_dev, &waa, wsemuldisplaydevprint,
    184  1.1  tsutsui 		    CFARGS_NONE);
    185  1.1  tsutsui 		break;
    186  1.1  tsutsui 
    187  1.1  tsutsui 	case STI_DD_CRX:
    188  1.1  tsutsui 		/*
    189  1.1  tsutsui 		 * HP A1659A CRX on some 425t variants.
    190  1.1  tsutsui 		 */
    191  1.1  tsutsui 		sc->sc_bitmap = base + STI_CRX_FBOFFSET;
    192  1.1  tsutsui 
    193  1.1  tsutsui 		aprint_normal_dev(ssc->sc_dev, "Enable mmap support\n");
    194  1.1  tsutsui 
    195  1.1  tsutsui 		scr->scr_wsmode = WSDISPLAYIO_MODE_EMUL;
    196  1.1  tsutsui 		waa.console = ssc->sc_flags & STI_CONSOLE ? 1 : 0;
    197  1.1  tsutsui 		waa.scrdata = &scr->scr_screenlist;
    198  1.1  tsutsui 		waa.accessops = &sti_m68k_accessops;
    199  1.1  tsutsui 		waa.accesscookie = scr;
    200  1.1  tsutsui 
    201  1.1  tsutsui 		config_found(ssc->sc_dev, &waa, wsemuldisplaydevprint,
    202  1.1  tsutsui 		    CFARGS_NONE);
    203  1.1  tsutsui 		break;
    204  1.1  tsutsui 	default:
    205  1.1  tsutsui 		/*
    206  1.1  tsutsui 		 * Unsupported variants.
    207  1.1  tsutsui 		 * Use default common sti(4) attachment (no bitmap support).
    208  1.1  tsutsui 		 */
    209  1.1  tsutsui 		sti_end_attach(ssc);
    210  1.1  tsutsui 		break;
    211  1.1  tsutsui 	}
    212  1.1  tsutsui }
    213  1.1  tsutsui 
    214  1.1  tsutsui static int
    215  1.1  tsutsui sti_evrx_putcmap(struct sti_screen *scr, u_int index, u_int count)
    216  1.1  tsutsui {
    217  1.1  tsutsui 	struct sti_rom *rom = scr->scr_rom;
    218  1.1  tsutsui 	bus_space_tag_t bst = rom->memt;
    219  1.1  tsutsui 	bus_space_handle_t bsh = rom->regh[2];
    220  1.1  tsutsui 	int i;
    221  1.1  tsutsui 
    222  1.1  tsutsui 	/* magic setup from HP-UX */
    223  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC08, 0x00000001);
    224  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC00, 0x00000001);
    225  1.1  tsutsui 	for (i = index; i < index + count; i++) {
    226  1.1  tsutsui 		/* this is what HP-UX woodDownloadCmap() does */
    227  1.1  tsutsui 		while ((bus_space_read_4(bst, bsh, EVRX_MAGIC10) &
    228  1.1  tsutsui 		    EVRX_MAGIC10_BSY) != 0)
    229  1.1  tsutsui 			continue;
    230  1.4  tsutsui 		bus_space_write_1(bst, bsh, EVRX_BT4xx_ADDR, i);
    231  1.4  tsutsui 		bus_space_write_1(bst, bsh, EVRX_BT4xx_CMAP, scr->scr_rcmap[i]);
    232  1.4  tsutsui 		bus_space_write_1(bst, bsh, EVRX_BT4xx_CMAP, scr->scr_gcmap[i]);
    233  1.4  tsutsui 		bus_space_write_4(bst, bsh, EVRX_MAGIC10,    scr->scr_bcmap[i]);
    234  1.1  tsutsui 	}
    235  1.1  tsutsui 	return 0;
    236  1.1  tsutsui }
    237  1.1  tsutsui 
    238  1.1  tsutsui static void
    239  1.1  tsutsui sti_evrx_resetramdac(struct sti_screen *scr)
    240  1.1  tsutsui {
    241  1.1  tsutsui 	struct sti_rom *rom = scr->scr_rom;
    242  1.1  tsutsui 	bus_space_tag_t bst = rom->memt;
    243  1.1  tsutsui 	bus_space_handle_t bsh = rom->regh[2];
    244  1.1  tsutsui #if 0
    245  1.1  tsutsui 	int i;
    246  1.1  tsutsui #endif
    247  1.1  tsutsui 
    248  1.1  tsutsui 	/*
    249  1.1  tsutsui 	 * Initialize the Bt458.  When we write to control registers,
    250  1.1  tsutsui 	 * the address is not incremented automatically. So we specify
    251  1.1  tsutsui 	 * it ourselves for each control register.
    252  1.1  tsutsui 	 */
    253  1.1  tsutsui 
    254  1.1  tsutsui 	/* all planes will be read */
    255  1.4  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT4xx_ADDR, 0x04);
    256  1.4  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT4xx_CTRL, 0xff);
    257  1.1  tsutsui 
    258  1.4  tsutsui #if 0
    259  1.4  tsutsui 	/*
    260  1.4  tsutsui 	 * HP-UX woodInitializeHardware() doesn't touch these
    261  1.4  tsutsui 	 * Bt458 specific registers. Maybe initialized by STI ROM?
    262  1.4  tsutsui 	 */
    263  1.1  tsutsui 	/* all planes have non-blink */
    264  1.1  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, 0x05);
    265  1.1  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT458_CTRL, 0x00);
    266  1.1  tsutsui 
    267  1.1  tsutsui 	/* palette enabled, ovly plane disabled */
    268  1.1  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, 0x06);
    269  1.1  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT458_CTRL, 0x40);
    270  1.1  tsutsui 
    271  1.1  tsutsui 	/* no test mode */
    272  1.1  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, 0x07);
    273  1.1  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT458_CTRL, 0x00);
    274  1.4  tsutsui #endif
    275  1.1  tsutsui 
    276  1.1  tsutsui 	/* magic initialization from HP-UX woodInitializeHardware() */
    277  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC00, 0x00000001);
    278  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC04, 0x00000001);
    279  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC08, 0x00000001);
    280  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC0C, 0x00000001);
    281  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC18, 0xFFFFFFFF);
    282  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC1C, 0x00000000);
    283  1.1  tsutsui 
    284  1.1  tsutsui #if 0
    285  1.1  tsutsui 	bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, 0x00);
    286  1.1  tsutsui 	for (i = 0; i < 4; i++) {
    287  1.1  tsutsui 		bus_space_write_1(bst, bsh, EVRX_BT458_OMAP, 0x00);
    288  1.1  tsutsui 		bus_space_write_1(bst, bsh, EVRX_BT458_OMAP, 0x00);
    289  1.1  tsutsui 		bus_space_write_1(bst, bsh, EVRX_BT458_OMAP, 0x00);
    290  1.1  tsutsui 	}
    291  1.1  tsutsui #endif
    292  1.1  tsutsui }
    293  1.1  tsutsui 
    294  1.1  tsutsui static void
    295  1.1  tsutsui sti_evrx_resetcmap(struct sti_screen *scr)
    296  1.1  tsutsui {
    297  1.1  tsutsui 	struct sti_rom *rom = scr->scr_rom;
    298  1.1  tsutsui 	bus_space_tag_t bst = rom->memt;
    299  1.1  tsutsui 	bus_space_handle_t bsh = rom->regh[2];
    300  1.1  tsutsui 	int i;
    301  1.1  tsutsui 
    302  1.1  tsutsui 	/* magic setup from HP-UX */
    303  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC08, 0x00000001);
    304  1.1  tsutsui 	bus_space_write_4(bst, bsh, EVRX_MAGIC00, 0x00000001);
    305  1.1  tsutsui 
    306  1.1  tsutsui 	/* preserve palette values initialized by STI firmware */
    307  1.1  tsutsui 	for (i = 0; i < STI_NCMAP; i++) {
    308  1.1  tsutsui 		/* this is what HP-UX woodUploadCmap() does */
    309  1.1  tsutsui 		while ((bus_space_read_4(bst, bsh, EVRX_MAGIC10) &
    310  1.1  tsutsui 		    EVRX_MAGIC10_BSY) != 0)
    311  1.1  tsutsui 			continue;
    312  1.1  tsutsui 		bus_space_write_1(bst, bsh, EVRX_BT458_ADDR, i);
    313  1.4  tsutsui 		scr->scr_rcmap[i] = bus_space_read_1(bst, bsh, EVRX_BT4xx_CMAP);
    314  1.4  tsutsui 		scr->scr_gcmap[i] = bus_space_read_1(bst, bsh, EVRX_BT4xx_CMAP);
    315  1.4  tsutsui 		scr->scr_bcmap[i] = bus_space_read_1(bst, bsh, EVRX_BT4xx_CMAP);
    316  1.1  tsutsui 	}
    317  1.1  tsutsui }
    318  1.1  tsutsui 
    319  1.1  tsutsui static void
    320  1.1  tsutsui sti_evrx_setupfb(struct sti_screen *scr)
    321  1.1  tsutsui {
    322  1.1  tsutsui 
    323  1.1  tsutsui 	sti_init(scr, 0);
    324  1.1  tsutsui 	sti_evrx_resetramdac(scr);
    325  1.1  tsutsui }
    326  1.1  tsutsui 
    327  1.1  tsutsui static paddr_t
    328  1.1  tsutsui sti_m68k_mmap(void *v, void *vs, off_t offset, int prot)
    329  1.1  tsutsui {
    330  1.1  tsutsui 	struct sti_screen *scr = (struct sti_screen *)v;
    331  1.1  tsutsui 	struct sti_rom *rom = scr->scr_rom;
    332  1.1  tsutsui 	struct sti_softc *ssc = rom->rom_softc;
    333  1.1  tsutsui 	struct sti_machdep_softc *sc = device_private(ssc->sc_dev);
    334  1.1  tsutsui 	paddr_t cookie = -1;
    335  1.1  tsutsui 
    336  1.1  tsutsui 	if ((offset & PAGE_MASK) != 0)
    337  1.1  tsutsui 		return -1;
    338  1.1  tsutsui 
    339  1.1  tsutsui 	switch (scr->scr_wsmode) {
    340  1.1  tsutsui 	case WSDISPLAYIO_MODE_MAPPED:
    341  1.1  tsutsui 		/* not implemented yet; what should be shown? */
    342  1.1  tsutsui 		break;
    343  1.1  tsutsui 	case WSDISPLAYIO_MODE_DUMBFB:
    344  1.1  tsutsui 		if (offset >= 0 && offset < (scr->fbwidth * scr->fbheight))
    345  1.1  tsutsui 			cookie = m68k_btop(sc->sc_bitmap + offset);
    346  1.1  tsutsui 		break;
    347  1.1  tsutsui 	default:
    348  1.1  tsutsui 		break;
    349  1.1  tsutsui 	}
    350  1.1  tsutsui 
    351  1.1  tsutsui 	return cookie;
    352  1.1  tsutsui }
    353  1.1  tsutsui 
    354  1.1  tsutsui void
    355  1.1  tsutsui sti_machdep_cnattach(bus_space_tag_t bst, paddr_t base)
    356  1.1  tsutsui {
    357  1.1  tsutsui 	int i;
    358  1.1  tsutsui 
    359  1.1  tsutsui 	sticn_tag = *bst;
    360  1.1  tsutsui 
    361  1.1  tsutsui 	/* sticn_bases[0] will be fixed in sti_cnattach() */
    362  1.1  tsutsui 	for (i = 0; i < STI_REGION_MAX; i++)
    363  1.1  tsutsui 		sticn_bases[i] = (bus_addr_t)base;
    364  1.1  tsutsui 
    365  1.1  tsutsui 	sti_cnattach(&sticn_rom, &sticn_scr, &sticn_tag, sticn_bases,
    366  1.6  tsutsui 	    STI_CODEBASE_M68K);
    367  1.1  tsutsui }
    368