Home | History | Annotate | Line # | Download | only in jazz
vga_jazzio.c revision 1.1
      1  1.1  soda /* $NetBSD: vga_jazzio.c,v 1.1 2000/06/17 07:17:37 soda Exp $ */
      2  1.1  soda /* NetBSD: vga_isa.c,v 1.3 1998/06/12 18:45:48 drochner Exp  */
      3  1.1  soda 
      4  1.1  soda /*
      5  1.1  soda  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      6  1.1  soda  * All rights reserved.
      7  1.1  soda  *
      8  1.1  soda  * Author: Chris G. Demetriou
      9  1.1  soda  *
     10  1.1  soda  * Permission to use, copy, modify and distribute this software and
     11  1.1  soda  * its documentation is hereby granted, provided that both the copyright
     12  1.1  soda  * notice and this permission notice appear in all copies of the
     13  1.1  soda  * software, derivative works or modified versions, and any portions
     14  1.1  soda  * thereof, and that both notices appear in supporting documentation.
     15  1.1  soda  *
     16  1.1  soda  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     17  1.1  soda  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     18  1.1  soda  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     19  1.1  soda  *
     20  1.1  soda  * Carnegie Mellon requests users of this software to return to
     21  1.1  soda  *
     22  1.1  soda  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     23  1.1  soda  *  School of Computer Science
     24  1.1  soda  *  Carnegie Mellon University
     25  1.1  soda  *  Pittsburgh PA 15213-3890
     26  1.1  soda  *
     27  1.1  soda  * any improvements or extensions that they make and grant Carnegie the
     28  1.1  soda  * rights to redistribute these changes.
     29  1.1  soda  */
     30  1.1  soda 
     31  1.1  soda #include <sys/param.h>
     32  1.1  soda #include <sys/systm.h>
     33  1.1  soda #include <sys/kernel.h>
     34  1.1  soda #include <sys/device.h>
     35  1.1  soda #include <sys/malloc.h>
     36  1.1  soda 
     37  1.1  soda #include <machine/autoconf.h>
     38  1.1  soda #include <machine/bus.h>
     39  1.1  soda 
     40  1.1  soda #include <dev/ic/mc6845reg.h>
     41  1.1  soda #include <dev/ic/pcdisplayvar.h>
     42  1.1  soda #include <dev/ic/vgareg.h>
     43  1.1  soda #include <dev/ic/vgavar.h>
     44  1.1  soda #include <arc/pica/pica.h>
     45  1.1  soda #include <arc/jazz/vga_jazziovar.h>
     46  1.1  soda 
     47  1.1  soda #include <dev/wscons/wsconsio.h>
     48  1.1  soda #include <dev/wscons/wsdisplayvar.h>
     49  1.1  soda 
     50  1.1  soda #define WSDISPLAY_TYPE_JAZZVGA	WSDISPLAY_TYPE_PCIVGA	/* XXX not really */
     51  1.1  soda 
     52  1.1  soda struct vga_jazzio_softc {
     53  1.1  soda 	struct device sc_dev;
     54  1.1  soda #if 0
     55  1.1  soda 	struct vga_config *sc_vc;	/* VGA configuration */
     56  1.1  soda #endif
     57  1.1  soda };
     58  1.1  soda 
     59  1.1  soda void	vga_jazzio_init_tag __P((bus_space_tag_t *, bus_space_tag_t *));
     60  1.1  soda int	vga_jazzio_mmap __P((void *, off_t, int));
     61  1.1  soda int	vga_jazzio_match __P((struct device *, struct cfdata *, void *));
     62  1.1  soda void	vga_jazzio_attach __P((struct device *, struct device *, void *));
     63  1.1  soda 
     64  1.1  soda struct cfattach vga_jazzio_ca = {
     65  1.1  soda 	sizeof(struct vga_jazzio_softc), vga_jazzio_match, vga_jazzio_attach,
     66  1.1  soda };
     67  1.1  soda 
     68  1.1  soda void
     69  1.1  soda vga_jazzio_init_tag(iotp, memtp)
     70  1.1  soda 	bus_space_tag_t *iotp, *memtp;
     71  1.1  soda {
     72  1.1  soda 	static int initialized = 0;
     73  1.1  soda 	static struct arc_bus_space vga_io, vga_mem;
     74  1.1  soda 
     75  1.1  soda 	if (!initialized) {
     76  1.1  soda 		initialized = 1;
     77  1.1  soda 		arc_bus_space_init(&vga_io, "vga_jazzio_io",
     78  1.1  soda 		    PICA_P_LOCAL_VIDEO_CTRL, PICA_V_LOCAL_VIDEO_CTRL,
     79  1.1  soda 		    0, PICA_S_LOCAL_VIDEO_CTRL);
     80  1.1  soda 		arc_bus_space_init(&vga_mem, "vga_jazzio_mem",
     81  1.1  soda 		    PICA_P_LOCAL_VIDEO, PICA_V_LOCAL_VIDEO,
     82  1.1  soda 		    0, PICA_S_LOCAL_VIDEO);
     83  1.1  soda 	}
     84  1.1  soda 	*iotp = &vga_io;
     85  1.1  soda 	*memtp = &vga_mem;
     86  1.1  soda }
     87  1.1  soda 
     88  1.1  soda int
     89  1.1  soda vga_jazzio_mmap(v, offset, prot)
     90  1.1  soda 	void *v;
     91  1.1  soda 	off_t offset;
     92  1.1  soda 	int prot;
     93  1.1  soda {
     94  1.1  soda 	if (offset >= 0xa0000 && offset < 0xc0000)
     95  1.1  soda 		return mips_btop(PICA_P_LOCAL_VIDEO + offset);
     96  1.1  soda 	if (offset >= 0x0000 && offset < 0x10000)
     97  1.1  soda 		return mips_btop(PICA_P_LOCAL_VIDEO_CTRL + offset);
     98  1.1  soda 	if (offset >= 0x40000000 && offset < 0x40800000)
     99  1.1  soda 		return mips_btop(PICA_P_LOCAL_VIDEO + offset - 0x40000000);
    100  1.1  soda 	return -1;
    101  1.1  soda }
    102  1.1  soda 
    103  1.1  soda int
    104  1.1  soda vga_jazzio_match(parent, match, aux)
    105  1.1  soda 	struct device *parent;
    106  1.1  soda 	struct cfdata *match;
    107  1.1  soda 	void *aux;
    108  1.1  soda {
    109  1.1  soda 	struct confargs *ca = aux;
    110  1.1  soda 	bus_space_tag_t iot, memt;
    111  1.1  soda 
    112  1.1  soda 	if(!BUS_MATCHNAME(ca, "vga"))
    113  1.1  soda 		return(0);
    114  1.1  soda 
    115  1.1  soda 	vga_jazzio_init_tag(&iot, &memt);
    116  1.1  soda 	if (!vga_is_console(iot, WSDISPLAY_TYPE_JAZZVGA) &&
    117  1.1  soda 	    !vga_common_probe(iot, memt))
    118  1.1  soda 		return (0);
    119  1.1  soda 
    120  1.1  soda 	return (1);
    121  1.1  soda }
    122  1.1  soda 
    123  1.1  soda void
    124  1.1  soda vga_jazzio_attach(parent, self, aux)
    125  1.1  soda 	struct device *parent, *self;
    126  1.1  soda 	void *aux;
    127  1.1  soda {
    128  1.1  soda #if 0
    129  1.1  soda 	struct vga_jazzio_softc *sc = (struct vga_jazzio_softc *)self;
    130  1.1  soda #endif
    131  1.1  soda 	bus_space_tag_t iot, memt;
    132  1.1  soda 
    133  1.1  soda 	printf("\n");
    134  1.1  soda 
    135  1.1  soda 	vga_jazzio_init_tag(&iot, &memt);
    136  1.1  soda 	vga_extended_attach(self, iot, memt, WSDISPLAY_TYPE_JAZZVGA,
    137  1.1  soda 	    vga_jazzio_mmap);
    138  1.1  soda }
    139  1.1  soda 
    140  1.1  soda int
    141  1.1  soda vga_jazzio_cnattach()
    142  1.1  soda {
    143  1.1  soda 	bus_space_tag_t iot, memt;
    144  1.1  soda 
    145  1.1  soda 	vga_jazzio_init_tag(&iot, &memt);
    146  1.1  soda 	return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_JAZZVGA, 1));
    147  1.1  soda }
    148