Home | History | Annotate | Line # | Download | only in iomd
vidc20.c revision 1.3
      1 /*	$NetBSD: vidc20.c,v 1.3 2002/06/16 13:20:15 bjh21 Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997 Mark Brinicombe
      5  * Copyright (c) 1997 Causality Limited
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by Mark Brinicombe
     19  * 4. The name of the company nor the name of the author may be used to
     20  *    endorse or promote products derived from this software without specific
     21  *    prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     24  * OR IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     25  * WARRANTIES OF  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
     27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     33  * THE POSSIBILITY OF SUCH DAMAGE.
     34  *
     35  * RiscBSD kernel project
     36  *
     37  * vidc20.c
     38  *
     39  * VIDC20 driver
     40  *
     41  * Created      : 22/02/97
     42  */
     43 
     44 #include <sys/cdefs.h>
     45 #include <sys/types.h>
     46 #include <sys/param.h>
     47 #include <sys/systm.h>
     48 #include <sys/device.h>
     49 
     50 #include <machine/bus.h>
     51 #include <arm/iomd/vidc.h>
     52 #include <machine/io.h>
     53 #include <arm/iomd/iomdreg.h>
     54 #include <arm/iomd/iomdvar.h>
     55 #include <arm/mainbus/mainbus.h>
     56 
     57 #include "locators.h"
     58 
     59 struct vidc20_softc {
     60 	struct device	sc_dev;
     61 	bus_space_tag_t	sc_iot;
     62 };
     63 
     64 static int  vidcmatch  __P((struct device *self, struct cfdata *cf, void *aux));
     65 static void vidcattach __P((struct device *parent, struct device *self, void *aux));
     66 static int  vidcsearch __P((struct device *, struct cfdata *, void *));
     67 
     68 /*
     69  * vidc_base gives the base of the VIDC chip in memory; this is for the rest isnt
     70  * busspaceified yet. Initialised with VIDC_BASE for backwards compatibility.
     71  */
     72 int *vidc_base = (int *) VIDC_BASE;
     73 
     74 
     75 /*
     76  * vidc_fref is the reference frequency in Mhz of the detected VIDC (dependent on IOMD/IOC)
     77  * XXX default is RPC600 ?
     78  */
     79 int  vidc_fref = 24000000;
     80 
     81 
     82 struct cfattach vidc_ca = {
     83 	sizeof (struct vidc20_softc), vidcmatch, vidcattach
     84 };
     85 
     86 /*
     87  * vidcmatch()
     88  *
     89  * VIDC20 is a write only device so we cannot probe it
     90  * We must assume things are ok.
     91  */
     92 static int
     93 vidcmatch(parent, cf, aux)
     94 	struct device *parent;
     95 	struct cfdata *cf;
     96 	void *aux;
     97 {
     98 /*	struct mainbus_attach_args *mb = aux;*/
     99 
    100 	return(1);
    101 }
    102 
    103 /*
    104  * vidcsearch()
    105  *
    106  * search routine used during the config of children
    107  */
    108 
    109 static int
    110 vidcsearch(parent, cf, aux)
    111 	struct device *parent;
    112 	struct cfdata *cf;
    113 	void *aux;
    114 {
    115 
    116 	if ((*cf->cf_attach->ca_match)(parent, cf, NULL) > 0)
    117 		config_attach(parent, cf, NULL, NULL);
    118 
    119 	return (0);
    120 }
    121 
    122 /*
    123  * vidcattach()
    124  *
    125  * Configure all the child devices of the VIDC
    126  */
    127 static void
    128 vidcattach(parent, self, aux)
    129 	struct device *parent;
    130 	struct device *self;
    131 	void *aux;
    132 {
    133 	struct vidc20_softc *sc = (struct vidc20_softc *)self;
    134 	struct mainbus_attach_args *mb = aux;
    135 
    136 	sc->sc_iot = mb->mb_iot;
    137 
    138 	/*
    139 	 * Since the VIDC is write-only, infer the type of VIDC from the
    140 	 * type of IOMD.
    141 	 */
    142 	switch (IOMD_ID) {
    143 	case ARM7500_IOC_ID:
    144 		printf(": ARM7500 video and sound macrocell\n");
    145 		vidc_fref = 32000000;
    146 		break;
    147 	case ARM7500FE_IOC_ID:
    148 		printf(": ARM7500FE video and sound macrocell\n");
    149 		vidc_fref = 32000000;
    150 		break;
    151 	default:				/* XXX default? */
    152 	case RPC600_IOMD_ID:
    153 		printf(": VIDC20\n");
    154 		vidc_fref = 24000000;
    155 		break;
    156 	};
    157 
    158 	config_search(vidcsearch, self, NULL);
    159 }
    160 
    161 /* End of vidc20.c */
    162