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