Home | History | Annotate | Line # | Download | only in vr
ite8181_vrip.c revision 1.1.2.4
      1  1.1.2.4  bouyer /*	$NetBSD: ite8181_vrip.c,v 1.1.2.4 2001/04/21 17:53:46 bouyer Exp $	*/
      2  1.1.2.2  bouyer 
      3  1.1.2.2  bouyer /*-
      4  1.1.2.2  bouyer  * Copyright (c) 2000 SATO Kazumi
      5  1.1.2.2  bouyer  * All rights reserved.
      6  1.1.2.2  bouyer  *
      7  1.1.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
      8  1.1.2.2  bouyer  * modification, are permitted provided that the following conditions
      9  1.1.2.2  bouyer  * are met:
     10  1.1.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     11  1.1.2.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     12  1.1.2.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.2.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.2.2  bouyer  *    documentation and/or other materials provided with the distribution.
     15  1.1.2.2  bouyer  * 3. The name of the author may not be used to endorse or promote products
     16  1.1.2.2  bouyer  *    derived from this software without specific prior written permission.
     17  1.1.2.2  bouyer  *
     18  1.1.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     19  1.1.2.2  bouyer  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  1.1.2.2  bouyer  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  1.1.2.2  bouyer  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     22  1.1.2.2  bouyer  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  1.1.2.2  bouyer  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  1.1.2.2  bouyer  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  1.1.2.2  bouyer  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  1.1.2.2  bouyer  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  1.1.2.2  bouyer  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  1.1.2.2  bouyer  * SUCH DAMAGE.
     29  1.1.2.2  bouyer  *
     30  1.1.2.2  bouyer  */
     31  1.1.2.2  bouyer 
     32  1.1.2.2  bouyer #include <sys/param.h>
     33  1.1.2.2  bouyer #include <sys/systm.h>
     34  1.1.2.2  bouyer #include <sys/device.h>
     35  1.1.2.2  bouyer 
     36  1.1.2.2  bouyer #include <machine/bus.h>
     37  1.1.2.2  bouyer 
     38  1.1.2.4  bouyer #include "opt_vr41xx.h"
     39  1.1.2.4  bouyer #include <hpcmips/vr/vrcpudef.h>
     40  1.1.2.2  bouyer #include <hpcmips/vr/vripreg.h>
     41  1.1.2.2  bouyer #include <hpcmips/vr/vripvar.h>
     42  1.1.2.2  bouyer #include <hpcmips/vr/vrgiureg.h>
     43  1.1.2.2  bouyer #include <hpcmips/dev/ite8181var.h>
     44  1.1.2.2  bouyer #include "bivideo.h"
     45  1.1.2.2  bouyer #if NBIVIDEO > 0
     46  1.1.2.3  bouyer #include <dev/hpc/bivideovar.h>
     47  1.1.2.2  bouyer #endif
     48  1.1.2.2  bouyer 
     49  1.1.2.2  bouyer #include "locators.h"
     50  1.1.2.2  bouyer 
     51  1.1.2.2  bouyer struct ite8181_vrip_softc {
     52  1.1.2.2  bouyer 	struct ite8181_softc	sc_ite8181;
     53  1.1.2.2  bouyer };
     54  1.1.2.2  bouyer 
     55  1.1.2.2  bouyer static int	ite8181_vrip_probe __P((struct device *, struct cfdata *,
     56  1.1.2.2  bouyer 				      void *));
     57  1.1.2.2  bouyer static void	ite8181_vrip_attach __P((struct device *, struct device *,
     58  1.1.2.2  bouyer 				       void *));
     59  1.1.2.2  bouyer 
     60  1.1.2.2  bouyer struct cfattach ite8181video_vrip_ca = {
     61  1.1.2.2  bouyer 	sizeof(struct ite8181_vrip_softc), ite8181_vrip_probe, ite8181_vrip_attach
     62  1.1.2.2  bouyer };
     63  1.1.2.2  bouyer 
     64  1.1.2.2  bouyer static int
     65  1.1.2.2  bouyer ite8181_vrip_probe(parent, cf, aux)
     66  1.1.2.2  bouyer 	struct device *parent;
     67  1.1.2.2  bouyer 	struct cfdata *cf;
     68  1.1.2.2  bouyer 	void *aux;
     69  1.1.2.2  bouyer {
     70  1.1.2.2  bouyer 	struct vrip_attach_args *va = aux;
     71  1.1.2.2  bouyer 	bus_space_handle_t ioh;
     72  1.1.2.2  bouyer 	int res;
     73  1.1.2.2  bouyer 
     74  1.1.2.2  bouyer 	if (va->va_addr == VRIPCF_ADDR_DEFAULT)
     75  1.1.2.2  bouyer 		return (0);
     76  1.1.2.2  bouyer 
     77  1.1.2.2  bouyer #if NBIVIDEO > 0
     78  1.1.2.2  bouyer 	if (bivideo_dont_attach) /* already attach video driver */
     79  1.1.2.2  bouyer 		return 0;
     80  1.1.2.2  bouyer #endif /* NBIVIDEO > 0 */
     81  1.1.2.2  bouyer 
     82  1.1.2.2  bouyer 	if (bus_space_map(va->va_iot, va->va_addr, va->va_size, 0, &ioh)) {
     83  1.1.2.2  bouyer 		printf("ite8181_vrip_probe: can't map i/o space\n");
     84  1.1.2.2  bouyer 		return 0;
     85  1.1.2.2  bouyer 	}
     86  1.1.2.2  bouyer 	res = ite8181_probe(va->va_iot, ioh);
     87  1.1.2.2  bouyer 	bus_space_unmap(va->va_iot, ioh, va->va_size);
     88  1.1.2.2  bouyer 
     89  1.1.2.2  bouyer 	return (res);
     90  1.1.2.2  bouyer }
     91  1.1.2.2  bouyer 
     92  1.1.2.2  bouyer 
     93  1.1.2.2  bouyer static void
     94  1.1.2.2  bouyer ite8181_vrip_attach(parent, self, aux)
     95  1.1.2.2  bouyer 	struct device *parent, *self;
     96  1.1.2.2  bouyer 	void *aux;
     97  1.1.2.2  bouyer {
     98  1.1.2.2  bouyer 	struct ite8181_vrip_softc *vsc = (void *)self;
     99  1.1.2.2  bouyer 	struct ite8181_softc *sc = &vsc->sc_ite8181;
    100  1.1.2.2  bouyer 	struct vrip_attach_args *va = aux;
    101  1.1.2.2  bouyer 
    102  1.1.2.2  bouyer 	sc->sc_baseaddr = va->va_addr;
    103  1.1.2.2  bouyer 	sc->sc_iot = va->va_iot;
    104  1.1.2.2  bouyer 	if (bus_space_map(va->va_iot, va->va_addr, va->va_size, 0,
    105  1.1.2.2  bouyer 			  &sc->sc_ioh)) {
    106  1.1.2.2  bouyer 		printf(": can't map bus space\n");
    107  1.1.2.2  bouyer 		return;
    108  1.1.2.2  bouyer 	}
    109  1.1.2.2  bouyer 
    110  1.1.2.2  bouyer 	ite8181_attach(sc);
    111  1.1.2.2  bouyer }
    112