Home | History | Annotate | Line # | Download | only in iomd
vidc20.c revision 1.2
      1  1.2    bjh21 /*	$NetBSD: vidc20.c,v 1.2 2002/06/06 21:03:28 bjh21 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.1  reinoud #include <sys/types.h>
     46  1.1  reinoud #include <sys/param.h>
     47  1.1  reinoud #include <sys/systm.h>
     48  1.1  reinoud #include <sys/device.h>
     49  1.1  reinoud 
     50  1.1  reinoud #include <machine/bus.h>
     51  1.1  reinoud #include <arm/iomd/vidc.h>
     52  1.1  reinoud #include <machine/io.h>
     53  1.1  reinoud #include <arm/iomd/iomdreg.h>
     54  1.1  reinoud #include <arm/iomd/iomdvar.h>
     55  1.1  reinoud #include <arm/mainbus/mainbus.h>
     56  1.1  reinoud 
     57  1.1  reinoud #include "locators.h"
     58  1.1  reinoud 
     59  1.1  reinoud struct vidc20_softc {
     60  1.1  reinoud 	struct device	sc_dev;
     61  1.1  reinoud 	bus_space_tag_t	sc_iot;
     62  1.1  reinoud };
     63  1.1  reinoud 
     64  1.1  reinoud static int  vidcmatch  __P((struct device *self, struct cfdata *cf, void *aux));
     65  1.1  reinoud static void vidcattach __P((struct device *parent, struct device *self, void *aux));
     66  1.1  reinoud static int  vidcprint  __P((void *aux, const char *name));
     67  1.1  reinoud static int  vidcsearch __P((struct device *, struct cfdata *, void *));
     68  1.1  reinoud 
     69  1.1  reinoud /*
     70  1.1  reinoud  * vidc_base gives the base of the VIDC chip in memory; this is for the rest isnt
     71  1.1  reinoud  * busspaceified yet. Initialised with VIDC_BASE for backwards compatibility.
     72  1.1  reinoud  */
     73  1.1  reinoud int *vidc_base = (int *) VIDC_BASE;
     74  1.1  reinoud 
     75  1.1  reinoud 
     76  1.1  reinoud /*
     77  1.1  reinoud  * vidc_fref is the reference frequency in Mhz of the detected VIDC (dependent on IOMD/IOC)
     78  1.1  reinoud  * XXX default is RPC600 ?
     79  1.1  reinoud  */
     80  1.1  reinoud int  vidc_fref = 24000000;
     81  1.1  reinoud 
     82  1.1  reinoud 
     83  1.1  reinoud struct cfattach vidc_ca = {
     84  1.1  reinoud 	sizeof (struct vidc20_softc), vidcmatch, vidcattach
     85  1.1  reinoud };
     86  1.1  reinoud 
     87  1.1  reinoud /*
     88  1.1  reinoud  * vidcmatch()
     89  1.1  reinoud  *
     90  1.1  reinoud  * VIDC20 is a write only device so we cannot probe it
     91  1.1  reinoud  * We must assume things are ok.
     92  1.1  reinoud  */
     93  1.1  reinoud static int
     94  1.1  reinoud vidcmatch(parent, cf, aux)
     95  1.1  reinoud 	struct device *parent;
     96  1.1  reinoud 	struct cfdata *cf;
     97  1.1  reinoud 	void *aux;
     98  1.1  reinoud {
     99  1.1  reinoud /*	struct mainbus_attach_args *mb = aux;*/
    100  1.1  reinoud 
    101  1.1  reinoud 	return(1);
    102  1.1  reinoud }
    103  1.1  reinoud 
    104  1.1  reinoud /*
    105  1.1  reinoud  * vidcprint()
    106  1.1  reinoud  *
    107  1.1  reinoud  * print routine used during config of children
    108  1.1  reinoud  */
    109  1.1  reinoud 
    110  1.1  reinoud static int
    111  1.1  reinoud vidcprint(aux, name)
    112  1.1  reinoud 	void *aux;
    113  1.1  reinoud 	const char *name;
    114  1.1  reinoud {
    115  1.1  reinoud 	struct mainbus_attach_args *mb = aux;
    116  1.1  reinoud 
    117  1.1  reinoud 	if (mb->mb_iobase != MAINBUSCF_BASE_DEFAULT)
    118  1.1  reinoud 		printf(" base 0x%x", mb->mb_iobase);
    119  1.1  reinoud 	if (mb->mb_iosize > 1)
    120  1.1  reinoud 		printf("-0x%x", mb->mb_iobase + mb->mb_iosize - 1);
    121  1.1  reinoud 	if (mb->mb_irq != -1)
    122  1.1  reinoud 		printf(" irq %d", mb->mb_irq);
    123  1.1  reinoud 	if (mb->mb_drq != -1)
    124  1.1  reinoud 		printf(" drq 0x%08x", mb->mb_drq);
    125  1.1  reinoud 
    126  1.1  reinoud /* XXXX print flags */
    127  1.1  reinoud 	return (QUIET);
    128  1.1  reinoud }
    129  1.1  reinoud 
    130  1.1  reinoud /*
    131  1.1  reinoud  * vidcsearch()
    132  1.1  reinoud  *
    133  1.1  reinoud  * search routine used during the config of children
    134  1.1  reinoud  */
    135  1.1  reinoud 
    136  1.1  reinoud static int
    137  1.1  reinoud vidcsearch(parent, cf, aux)
    138  1.1  reinoud 	struct device *parent;
    139  1.1  reinoud 	struct cfdata *cf;
    140  1.1  reinoud 	void *aux;
    141  1.1  reinoud {
    142  1.1  reinoud 	struct vidc20_softc *sc = (struct vidc20_softc *)parent;
    143  1.1  reinoud 	struct mainbus_attach_args mb;
    144  1.1  reinoud 	int tryagain;
    145  1.1  reinoud 
    146  1.1  reinoud 	do {
    147  1.1  reinoud 		if (cf->cf_loc[MAINBUSCF_BASE] == MAINBUSCF_BASE_DEFAULT) {
    148  1.1  reinoud 			mb.mb_iobase = MAINBUSCF_BASE_DEFAULT;
    149  1.1  reinoud 			mb.mb_iosize = 0;
    150  1.1  reinoud 			mb.mb_drq = MAINBUSCF_DACK_DEFAULT;
    151  1.1  reinoud 			mb.mb_irq = MAINBUSCF_IRQ_DEFAULT;
    152  1.1  reinoud 		} else {
    153  1.1  reinoud 			mb.mb_iobase = cf->cf_loc[MAINBUSCF_BASE] + IO_CONF_BASE;
    154  1.1  reinoud 			mb.mb_iosize = 0;
    155  1.1  reinoud 			mb.mb_drq = cf->cf_loc[MAINBUSCF_DACK];
    156  1.1  reinoud 			mb.mb_irq = cf->cf_loc[MAINBUSCF_IRQ];
    157  1.1  reinoud 		}
    158  1.1  reinoud 		mb.mb_iot = sc->sc_iot;
    159  1.1  reinoud 
    160  1.1  reinoud 		tryagain = 0;
    161  1.1  reinoud 		if ((*cf->cf_attach->ca_match)(parent, cf, &mb) > 0) {
    162  1.1  reinoud 			config_attach(parent, cf, &mb, vidcprint);
    163  1.1  reinoud /*			tryagain = (cf->cf_fstate == FSTATE_STAR);*/
    164  1.1  reinoud 		}
    165  1.1  reinoud 	} while (tryagain);
    166  1.1  reinoud 
    167  1.1  reinoud 	return (0);
    168  1.1  reinoud }
    169  1.1  reinoud 
    170  1.1  reinoud /*
    171  1.1  reinoud  * vidcattach()
    172  1.1  reinoud  *
    173  1.1  reinoud  * Configure all the child devices of the VIDC
    174  1.1  reinoud  */
    175  1.1  reinoud static void
    176  1.1  reinoud vidcattach(parent, self, aux)
    177  1.1  reinoud 	struct device *parent;
    178  1.1  reinoud 	struct device *self;
    179  1.1  reinoud 	void *aux;
    180  1.1  reinoud {
    181  1.1  reinoud 	struct vidc20_softc *sc = (struct vidc20_softc *)self;
    182  1.1  reinoud 	struct mainbus_attach_args *mb = aux;
    183  1.1  reinoud 
    184  1.1  reinoud 	sc->sc_iot = mb->mb_iot;
    185  1.1  reinoud 
    186  1.2    bjh21 	/*
    187  1.2    bjh21 	 * Since the VIDC is write-only, infer the type of VIDC from the
    188  1.2    bjh21 	 * type of IOMD.
    189  1.2    bjh21 	 */
    190  1.1  reinoud 	switch (IOMD_ID) {
    191  1.1  reinoud 	case ARM7500_IOC_ID:
    192  1.2    bjh21 		printf(": ARM7500 video and sound macrocell\n");
    193  1.2    bjh21 		vidc_fref = 32000000;
    194  1.2    bjh21 		break;
    195  1.1  reinoud 	case ARM7500FE_IOC_ID:
    196  1.2    bjh21 		printf(": ARM7500FE video and sound macrocell\n");
    197  1.1  reinoud 		vidc_fref = 32000000;
    198  1.1  reinoud 		break;
    199  1.1  reinoud 	default:				/* XXX default? */
    200  1.1  reinoud 	case RPC600_IOMD_ID:
    201  1.2    bjh21 		printf(": VIDC20\n");
    202  1.1  reinoud 		vidc_fref = 24000000;
    203  1.1  reinoud 		break;
    204  1.1  reinoud 	};
    205  1.1  reinoud 
    206  1.1  reinoud 	config_search(vidcsearch, self, NULL);
    207  1.1  reinoud }
    208  1.1  reinoud 
    209  1.1  reinoud /* End of vidc20.c */
    210