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