1 /* $NetBSD: vga_jazzio.c,v 1.6 2001/09/14 01:10:12 thorpej 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@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 #include <uvm/uvm_extern.h> 37 38 #include <machine/autoconf.h> 39 #include <machine/bus.h> 40 41 #include <mips/pte.h> 42 43 #include <dev/ic/mc6845reg.h> 44 #include <dev/ic/pcdisplayvar.h> 45 #include <dev/ic/vgareg.h> 46 #include <dev/ic/vgavar.h> 47 48 #include <arc/arc/wired_map.h> 49 #include <arc/jazz/jazziovar.h> 50 #include <arc/jazz/pica.h> 51 #include <arc/jazz/vga_jazziovar.h> 52 53 #include <dev/wscons/wsconsio.h> 54 #include <dev/wscons/wsdisplayvar.h> 55 56 #define WSDISPLAY_TYPE_JAZZVGA WSDISPLAY_TYPE_PCIVGA /* XXX not really */ 57 58 int vga_jazzio_init_tag __P((char*, bus_space_tag_t *, bus_space_tag_t *)); 59 paddr_t vga_jazzio_mmap __P((void *, off_t, int)); 60 int vga_jazzio_match __P((struct device *, struct cfdata *, void *)); 61 void vga_jazzio_attach __P((struct device *, struct device *, void *)); 62 63 struct cfattach vga_jazzio_ca = { 64 sizeof(struct vga_softc), vga_jazzio_match, vga_jazzio_attach, 65 }; 66 67 const struct vga_funcs vga_jazzio_funcs = { 68 NULL, 69 vga_jazzio_mmap, 70 }; 71 72 int 73 vga_jazzio_init_tag(name, iotp, memtp) 74 char *name; 75 bus_space_tag_t *iotp, *memtp; 76 { 77 static int initialized = 0; 78 static struct arc_bus_space vga_io, vga_mem; 79 80 if (strcmp(name, "ALI_S3") != 0) 81 return(ENXIO); 82 83 if (!initialized) { 84 initialized = 1; 85 86 arc_bus_space_init(&vga_io, "vga_jazzio_io", 87 PICA_P_LOCAL_VIDEO_CTRL, PICA_V_LOCAL_VIDEO_CTRL, 88 0, PICA_S_LOCAL_VIDEO_CTRL); 89 arc_bus_space_init(&vga_mem, "vga_jazzio_mem", 90 PICA_P_LOCAL_VIDEO, PICA_V_LOCAL_VIDEO, 91 0, PICA_S_LOCAL_VIDEO); 92 93 arc_enter_wired(PICA_V_LOCAL_VIDEO_CTRL, 94 PICA_P_LOCAL_VIDEO_CTRL, 95 PICA_P_LOCAL_VIDEO_CTRL + PICA_S_LOCAL_VIDEO_CTRL/2, 96 MIPS3_PG_SIZE_1M); 97 arc_enter_wired(PICA_V_LOCAL_VIDEO, 98 PICA_P_LOCAL_VIDEO, 99 PICA_P_LOCAL_VIDEO + PICA_S_LOCAL_VIDEO/2, 100 MIPS3_PG_SIZE_4M); 101 #if 0 102 arc_enter_wired(PICA_V_EXTND_VIDEO_CTRL, 103 PICA_P_EXTND_VIDEO_CTRL, 104 PICA_P_EXTND_VIDEO_CTRL + PICA_S_EXTND_VIDEO_CTRL/2, 105 MIPS3_PG_SIZE_1M); 106 #endif 107 } 108 *iotp = &vga_io; 109 *memtp = &vga_mem; 110 return (0); 111 } 112 113 paddr_t 114 vga_jazzio_mmap(v, offset, prot) 115 void *v; 116 off_t offset; 117 int prot; 118 { 119 if (offset >= 0xa0000 && offset < 0xc0000) 120 return mips_btop(PICA_P_LOCAL_VIDEO + offset); 121 if (offset >= 0x0000 && offset < 0x10000) 122 return mips_btop(PICA_P_LOCAL_VIDEO_CTRL + offset); 123 if (offset >= 0x40000000 && offset < 0x40800000) 124 return mips_btop(PICA_P_LOCAL_VIDEO + offset - 0x40000000); 125 return -1; 126 } 127 128 int 129 vga_jazzio_match(parent, match, aux) 130 struct device *parent; 131 struct cfdata *match; 132 void *aux; 133 { 134 struct jazzio_attach_args *ja = aux; 135 bus_space_tag_t iot, memt; 136 137 if (vga_jazzio_init_tag(ja->ja_name, &iot, &memt)) 138 return (0); 139 140 if (!vga_is_console(iot, WSDISPLAY_TYPE_JAZZVGA) && 141 !vga_common_probe(iot, memt)) 142 return (0); 143 144 return (1); 145 } 146 147 void 148 vga_jazzio_attach(parent, self, aux) 149 struct device *parent, *self; 150 void *aux; 151 { 152 struct vga_softc *sc = (void *) self; 153 struct jazzio_attach_args *ja = aux; 154 bus_space_tag_t iot, memt; 155 156 printf("\n"); 157 158 vga_jazzio_init_tag(ja->ja_name, &iot, &memt); 159 vga_common_attach(sc, iot, memt, WSDISPLAY_TYPE_JAZZVGA, 160 &vga_jazzio_funcs); 161 } 162 163 int 164 vga_jazzio_cnattach(name) 165 char *name; 166 { 167 bus_space_tag_t iot, memt; 168 169 if (vga_jazzio_init_tag(name, &iot, &memt)) 170 return (ENXIO); 171 return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_JAZZVGA, 1)); 172 } 173