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