Home | History | Annotate | Line # | Download | only in jazz
pccons_jazzio.c revision 1.3
      1 /* $NetBSD: pccons_jazzio.c,v 1.3 2002/10/02 04:59:49 thorpej Exp $ */
      2 /* NetBSD: vga_isa.c,v 1.4 2000/08/14 20:14:51 thorpej 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/device.h>
     34 #include <uvm/uvm_extern.h>
     35 
     36 #include <machine/autoconf.h>
     37 #include <machine/bus.h>
     38 
     39 #include <mips/pte.h>
     40 
     41 #include <arc/arc/wired_map.h>
     42 #include <arc/dev/pcconsvar.h>
     43 #include <arc/jazz/jazziovar.h>
     44 #include <arc/jazz/pica.h>
     45 #include <arc/jazz/pccons_jazziovar.h>
     46 
     47 #define PCKBD_INTR 6	/* XXX - should be obtained from firmware */
     48 
     49 int	pccons_jazzio_match __P((struct device *, struct cfdata *, void *));
     50 void	pccons_jazzio_attach __P((struct device *, struct device *, void *));
     51 
     52 CFATTACH_DECL(pc_jazzio, sizeof(struct pc_softc),
     53     pccons_jazzio_match, pccons_jazzio_attach, NULL, NULL);
     54 
     55 /*
     56  * chipset-dependent pccons configuration
     57  */
     58 
     59 void pccons_jazzio_init __P((void));
     60 
     61 struct pccons_config pccons_jazzio_conf = {
     62 	0x3b4, 0xb0000,	/* mono: iobase, memaddr */
     63 	0x3d4, 0xb8000,	/* cga:  iobase, memaddr */
     64 	PICA_SYS_KBD + 0x61, PICA_SYS_KBD + 0x60, /* kbdc: cmdport, dataport */
     65 	pccons_jazzio_init
     66 };
     67 
     68 void
     69 pccons_jazzio_init()
     70 {
     71 	/* nothing to do */
     72 }
     73 
     74 int	pccons_jazzio_init_tag __P((char*, bus_space_tag_t*,bus_space_tag_t*));
     75 
     76 int
     77 pccons_jazzio_init_tag(name, iotp, memtp)
     78 	char *name;
     79 	bus_space_tag_t *iotp, *memtp;
     80 {
     81 	static int initialized = 0;
     82 	static struct arc_bus_space vga_io, vga_mem;
     83 
     84 	if (strcmp(name, "ALI_S3") != 0)
     85 		return(ENXIO);
     86 
     87 	if (!initialized) {
     88 		initialized = 1;
     89 
     90 		arc_bus_space_init(&vga_io, "vga_jazzio_io",
     91 		    PICA_P_LOCAL_VIDEO_CTRL, PICA_V_LOCAL_VIDEO_CTRL,
     92 		    0, PICA_S_LOCAL_VIDEO_CTRL);
     93 		arc_bus_space_init(&vga_mem, "vga_jazzio_mem",
     94 		    PICA_P_LOCAL_VIDEO, PICA_V_LOCAL_VIDEO,
     95 		    0, PICA_S_LOCAL_VIDEO);
     96 
     97 		arc_enter_wired(PICA_V_LOCAL_VIDEO_CTRL,
     98 		    PICA_P_LOCAL_VIDEO_CTRL,
     99 		    PICA_P_LOCAL_VIDEO_CTRL + PICA_S_LOCAL_VIDEO_CTRL/2,
    100 		    MIPS3_PG_SIZE_1M);
    101 		arc_enter_wired(PICA_V_LOCAL_VIDEO,
    102 		    PICA_P_LOCAL_VIDEO,
    103 		    PICA_P_LOCAL_VIDEO + PICA_S_LOCAL_VIDEO/2,
    104 		    MIPS3_PG_SIZE_4M);
    105 #if 0
    106 		arc_enter_wired(PICA_V_EXTND_VIDEO_CTRL,
    107 		    PICA_P_EXTND_VIDEO_CTRL,
    108 		    PICA_P_EXTND_VIDEO_CTRL + PICA_S_EXTND_VIDEO_CTRL/2,
    109 		    MIPS3_PG_SIZE_1M);
    110 #endif
    111 	}
    112 	*iotp = &vga_io;
    113 	*memtp = &vga_mem;
    114 	return (0);
    115 }
    116 
    117 int
    118 pccons_jazzio_match(parent, match, aux)
    119 	struct device *parent;
    120 	struct cfdata *match;
    121 	void *aux;
    122 {
    123 	struct jazzio_attach_args *ja = aux;
    124 	bus_space_tag_t crt_iot, crt_memt;
    125 
    126 	if (pccons_jazzio_init_tag(ja->ja_name, &crt_iot, &crt_memt))
    127 		return (0);
    128 
    129 	if (!pccons_common_match(crt_iot, crt_memt, ja->ja_bust,
    130 	    &pccons_jazzio_conf))
    131 		return (0);
    132 
    133 	return (1);
    134 }
    135 
    136 void
    137 pccons_jazzio_attach(parent, self, aux)
    138 	struct device *parent, *self;
    139 	void *aux;
    140 {
    141 	struct pc_softc *sc = (struct pc_softc *)self;
    142 	struct jazzio_attach_args *ja = aux;
    143 	bus_space_tag_t crt_iot, crt_memt;
    144 
    145 	pccons_jazzio_init_tag(ja->ja_name, &crt_iot, &crt_memt);
    146 	jazzio_intr_establish(PCKBD_INTR, pcintr, self);
    147 	pccons_common_attach(sc, crt_iot, crt_memt, ja->ja_bust,
    148 	    &pccons_jazzio_conf);
    149 }
    150 
    151 int
    152 pccons_jazzio_cnattach(name, kbd_iot)
    153 	char *name;
    154 	bus_space_tag_t kbd_iot;
    155 {
    156 	bus_space_tag_t crt_iot, crt_memt;
    157 
    158 	if (pccons_jazzio_init_tag(name, &crt_iot, &crt_memt))
    159 		return (ENXIO);
    160 	pccons_common_cnattach(crt_iot, crt_memt, kbd_iot,
    161 	    &pccons_jazzio_conf);
    162 	return (0);
    163 }
    164 
    165