Home | History | Annotate | Line # | Download | only in ofw
vga_ofbus.c revision 1.5
      1 /* $NetBSD: vga_ofbus.c,v 1.5 2003/07/15 03:36:02 lukem 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/cdefs.h>
     31 __KERNEL_RCSID(0, "$NetBSD: vga_ofbus.c,v 1.5 2003/07/15 03:36:02 lukem Exp $");
     32 
     33 #include <sys/param.h>
     34 #include <sys/systm.h>
     35 #include <sys/kernel.h>
     36 #include <sys/device.h>
     37 #include <sys/malloc.h>
     38 
     39 #include <dev/isa/isavar.h>
     40 
     41 #include <dev/ic/mc6845reg.h>
     42 #include <dev/ic/pcdisplayvar.h>
     43 #include <dev/ic/vgareg.h>
     44 #include <dev/ic/vgavar.h>
     45 
     46 #include <dev/wscons/wsconsio.h>
     47 #include <dev/wscons/wsdisplayvar.h>
     48 
     49 #include <dev/ofw/openfirm.h>
     50 #if 0
     51 #include <dnard/ofw/vga_ofisavar.h>
     52 #endif
     53 
     54 struct vga_ofbus_softc {
     55 	struct vga_softc sc_vga;
     56 
     57 	int sc_phandle;
     58 };
     59 
     60 int	vga_ofbus_match (struct device *, struct cfdata *, void *);
     61 void	vga_ofbus_attach (struct device *, struct device *, void *);
     62 
     63 CFATTACH_DECL(vga_ofbus, sizeof(struct vga_ofbus_softc),
     64     vga_ofbus_match, vga_ofbus_attach, NULL, NULL);
     65 
     66 static const char *compat_strings[] = { "pnpPNP,900", 0 };
     67 
     68 int
     69 vga_ofbus_match(struct device *parent, struct cfdata *match, void *aux)
     70 {
     71 	struct ofbus_attach_args *oba = aux;
     72 
     73 	if (of_compatible(oba->oba_phandle, compat_strings) == -1)
     74 		return (0);
     75 
     76 	if (!vga_is_console(&isa_io_bs_tag, WSDISPLAY_TYPE_ISAVGA) &&
     77 	    !vga_common_probe(&isa_io_bs_tag, &isa_mem_bs_tag))
     78 		return (0);
     79 
     80 	return (2);	/* more than generic pcdisplay */
     81 }
     82 
     83 void
     84 vga_ofbus_attach(struct device *parent, struct device *self, void *aux)
     85 {
     86 	struct vga_ofbus_softc *osc = (void *) self;
     87 	struct vga_softc *sc = &osc->sc_vga;
     88 	struct ofbus_attach_args *oba = aux;
     89 
     90 	printf("\n");
     91 	osc->sc_phandle = oba->oba_phandle;
     92 
     93 	vga_common_attach(sc, &isa_io_bs_tag, &isa_mem_bs_tag,
     94 	    WSDISPLAY_TYPE_ISAVGA, NULL);
     95 }
     96 
     97 int
     98 vga_ofbus_cnattach(int phandle, bus_space_tag_t iot, bus_space_tag_t memt)
     99 {
    100 	if (OF_call_method("text-mode3", phandle, 0, 0) != 0) {
    101 		printf("vga_ofbus_match: text-mode3 method invocation on VGA "
    102 		       "screen device failed\n");
    103 	}
    104 
    105 	return (vga_cnattach(iot, memt, WSDISPLAY_TYPE_ISAVGA, 1));
    106 }
    107