Home | History | Annotate | Line # | Download | only in ofw
vga_ofbus.c revision 1.4
      1 /* $NetBSD: vga_ofbus.c,v 1.4 2002/10/02 15:52:39 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 (at) 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 CFATTACH_DECL(vga_ofbus, sizeof(struct vga_ofbus_softc),
     61     vga_ofbus_match, vga_ofbus_attach, NULL, NULL);
     62 
     63 static const char *compat_strings[] = { "pnpPNP,900", 0 };
     64 
     65 int
     66 vga_ofbus_match(struct device *parent, struct cfdata *match, void *aux)
     67 {
     68 	struct ofbus_attach_args *oba = aux;
     69 
     70 	if (of_compatible(oba->oba_phandle, compat_strings) == -1)
     71 		return (0);
     72 
     73 	if (!vga_is_console(&isa_io_bs_tag, WSDISPLAY_TYPE_ISAVGA) &&
     74 	    !vga_common_probe(&isa_io_bs_tag, &isa_mem_bs_tag))
     75 		return (0);
     76 
     77 	return (2);	/* more than generic pcdisplay */
     78 }
     79 
     80 void
     81 vga_ofbus_attach(struct device *parent, struct device *self, void *aux)
     82 {
     83 	struct vga_ofbus_softc *osc = (void *) self;
     84 	struct vga_softc *sc = &osc->sc_vga;
     85 	struct ofbus_attach_args *oba = aux;
     86 
     87 	printf("\n");
     88 	osc->sc_phandle = oba->oba_phandle;
     89 
     90 	vga_common_attach(sc, &isa_io_bs_tag, &isa_mem_bs_tag,
     91 	    WSDISPLAY_TYPE_ISAVGA, NULL);
     92 }
     93 
     94 int
     95 vga_ofbus_cnattach(int phandle, bus_space_tag_t iot, bus_space_tag_t memt)
     96 {
     97 	if (OF_call_method("text-mode3", phandle, 0, 0) != 0) {
     98 		printf("vga_ofbus_match: text-mode3 method invocation on VGA "
     99 		       "screen device failed\n");
    100 	}
    101 
    102 	return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1));
    103 }
    104