1 /* $NetBSD: vga_ofbus.c,v 1.1 2002/02/10 07:07:07 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 1995, 1996 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30 #include <sys/param.h> 31 #include <sys/systm.h> 32 #include <sys/kernel.h> 33 #include <sys/device.h> 34 #include <sys/malloc.h> 35 36 #include <dev/isa/isavar.h> 37 38 #include <dev/ic/mc6845reg.h> 39 #include <dev/ic/pcdisplayvar.h> 40 #include <dev/ic/vgareg.h> 41 #include <dev/ic/vgavar.h> 42 43 #include <dev/wscons/wsconsio.h> 44 #include <dev/wscons/wsdisplayvar.h> 45 46 #include <dev/ofw/openfirm.h> 47 #if 0 48 #include <dnard/ofw/vga_ofisavar.h> 49 #endif 50 51 struct vga_ofbus_softc { 52 struct vga_softc sc_vga; 53 54 int sc_phandle; 55 }; 56 57 int vga_ofbus_match (struct device *, struct cfdata *, void *); 58 void vga_ofbus_attach (struct device *, struct device *, void *); 59 60 struct cfattach vga_ofbus_ca = { 61 sizeof(struct vga_ofbus_softc), vga_ofbus_match, vga_ofbus_attach, 62 }; 63 64 static const char *compat_strings[] = { "pnpPNP,900", 0 }; 65 66 int 67 vga_ofbus_match(struct device *parent, struct cfdata *match, void *aux) 68 { 69 struct ofbus_attach_args *oba = aux; 70 71 if (of_compatible(oba->oba_phandle, compat_strings) == -1) 72 return (0); 73 74 if (!vga_is_console(&isa_io_bs_tag, WSDISPLAY_TYPE_ISAVGA) && 75 !vga_common_probe(&isa_io_bs_tag, &isa_mem_bs_tag)) 76 return (0); 77 78 return (2); /* more than generic pcdisplay */ 79 } 80 81 void 82 vga_ofbus_attach(struct device *parent, struct device *self, void *aux) 83 { 84 struct vga_ofbus_softc *osc = (void *) self; 85 struct vga_softc *sc = &osc->sc_vga; 86 struct ofbus_attach_args *oba = aux; 87 88 printf("\n"); 89 osc->sc_phandle = oba->oba_phandle; 90 91 vga_common_attach(sc, &isa_io_bs_tag, &isa_mem_bs_tag, 92 WSDISPLAY_TYPE_ISAVGA, NULL); 93 } 94 95 int 96 vga_ofbus_cnattach(int phandle, bus_space_tag_t iot, bus_space_tag_t memt) 97 { 98 if (OF_call_method("text-mode3", phandle, 0, 0) != 0) { 99 printf("vga_ofbus_match: text-mode3 method invocation on VGA " 100 "screen device failed\n"); 101 } 102 103 return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1)); 104 } 105