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