Home | History | Annotate | Line # | Download | only in tx
txsim.c revision 1.5.8.3
      1  1.5.8.3  nathanw /*	$NetBSD: txsim.c,v 1.5.8.3 2002/02/28 04:10:03 nathanw Exp $ */
      2  1.5.8.2  nathanw 
      3  1.5.8.2  nathanw /*-
      4  1.5.8.2  nathanw  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
      5  1.5.8.2  nathanw  * All rights reserved.
      6  1.5.8.2  nathanw  *
      7  1.5.8.2  nathanw  * This code is derived from software contributed to The NetBSD Foundation
      8  1.5.8.2  nathanw  * by UCHIYAMA Yasushi.
      9  1.5.8.2  nathanw  *
     10  1.5.8.2  nathanw  * Redistribution and use in source and binary forms, with or without
     11  1.5.8.2  nathanw  * modification, are permitted provided that the following conditions
     12  1.5.8.2  nathanw  * are met:
     13  1.5.8.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     14  1.5.8.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     15  1.5.8.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.5.8.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     17  1.5.8.2  nathanw  *    documentation and/or other materials provided with the distribution.
     18  1.5.8.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     19  1.5.8.2  nathanw  *    must display the following acknowledgement:
     20  1.5.8.2  nathanw  *        This product includes software developed by the NetBSD
     21  1.5.8.2  nathanw  *        Foundation, Inc. and its contributors.
     22  1.5.8.2  nathanw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.5.8.2  nathanw  *    contributors may be used to endorse or promote products derived
     24  1.5.8.2  nathanw  *    from this software without specific prior written permission.
     25  1.5.8.2  nathanw  *
     26  1.5.8.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.5.8.2  nathanw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.5.8.2  nathanw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.5.8.2  nathanw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.5.8.2  nathanw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.5.8.2  nathanw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.5.8.2  nathanw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.5.8.2  nathanw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.5.8.2  nathanw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.5.8.2  nathanw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.5.8.2  nathanw  * POSSIBILITY OF SUCH DAMAGE.
     37  1.5.8.2  nathanw  */
     38  1.5.8.2  nathanw 
     39  1.5.8.2  nathanw #include "opt_vr41xx.h"
     40  1.5.8.2  nathanw #include "opt_tx39xx.h"
     41  1.5.8.2  nathanw /*
     42  1.5.8.2  nathanw  * TX System Internal Module.
     43  1.5.8.2  nathanw  */
     44  1.5.8.2  nathanw 
     45  1.5.8.2  nathanw #include <sys/param.h>
     46  1.5.8.2  nathanw #include <sys/systm.h>
     47  1.5.8.2  nathanw #include <sys/device.h>
     48  1.5.8.2  nathanw 
     49  1.5.8.2  nathanw #include <machine/bus.h>
     50  1.5.8.2  nathanw #include <machine/autoconf.h>
     51  1.5.8.2  nathanw #include <machine/platid.h>
     52  1.5.8.2  nathanw #include <machine/platid_mask.h>
     53  1.5.8.2  nathanw 
     54  1.5.8.2  nathanw #include <hpcmips/tx/tx39var.h>
     55  1.5.8.2  nathanw #include <hpcmips/tx/txsnd.h>
     56  1.5.8.2  nathanw 
     57  1.5.8.2  nathanw int	txsim_match(struct device *, struct cfdata *, void *);
     58  1.5.8.2  nathanw void	txsim_attach(struct device *, struct device *, void *);
     59  1.5.8.2  nathanw int	txsim_print(void *, const char*);
     60  1.5.8.2  nathanw int	txsim_search(struct device *, struct cfdata *, void *);
     61  1.5.8.2  nathanw 
     62  1.5.8.2  nathanw struct txsim_softc {
     63  1.5.8.2  nathanw 	struct	device sc_dev;
     64  1.5.8.2  nathanw 	int sc_pri; /* attaching device priority */
     65  1.5.8.2  nathanw };
     66  1.5.8.2  nathanw 
     67  1.5.8.2  nathanw struct cfattach txsim_ca = {
     68  1.5.8.2  nathanw 	sizeof(struct txsim_softc), txsim_match, txsim_attach
     69  1.5.8.2  nathanw };
     70  1.5.8.2  nathanw 
     71  1.5.8.2  nathanw int
     72  1.5.8.2  nathanw txsim_match(struct device *parent, struct cfdata *match, void *aux)
     73  1.5.8.2  nathanw {
     74  1.5.8.2  nathanw 	struct mainbus_attach_args *ma = aux;
     75  1.5.8.2  nathanw 
     76  1.5.8.2  nathanw #ifdef VR41XX
     77  1.5.8.2  nathanw 	if (platid_match(&platid, &platid_mask_CPU_MIPS_VR_41XX))
     78  1.5.8.2  nathanw 	  return (0);
     79  1.5.8.2  nathanw #endif /* VR41XX */
     80  1.5.8.2  nathanw 	if (strcmp(ma->ma_name, match->cf_driver->cd_name))
     81  1.5.8.2  nathanw 		return (0);
     82  1.5.8.2  nathanw 
     83  1.5.8.2  nathanw 	return (1);
     84  1.5.8.2  nathanw }
     85  1.5.8.2  nathanw 
     86  1.5.8.2  nathanw void
     87  1.5.8.2  nathanw txsim_attach(struct device *parent, struct device *self, void *aux)
     88  1.5.8.2  nathanw {
     89  1.5.8.2  nathanw 	struct txsim_softc *sc = (void*)self;
     90  1.5.8.2  nathanw 
     91  1.5.8.2  nathanw 	printf("\n");
     92  1.5.8.2  nathanw 
     93  1.5.8.2  nathanw 	tx_sound_init(tx_conf_get_tag());
     94  1.5.8.2  nathanw 	/*
     95  1.5.8.2  nathanw 	 * interrupt, clock module is used by other system module.
     96  1.5.8.2  nathanw 	 * so attach first.
     97  1.5.8.2  nathanw 	 */
     98  1.5.8.2  nathanw 	sc->sc_pri = ATTACH_FIRST;
     99  1.5.8.2  nathanw 	config_search(txsim_search, self, txsim_print);
    100  1.5.8.2  nathanw 	/*
    101  1.5.8.2  nathanw 	 * unified I/O manager requires all I/O capable module already
    102  1.5.8.2  nathanw 	 * attached.
    103  1.5.8.2  nathanw 	 */
    104  1.5.8.2  nathanw 	sc->sc_pri = ATTACH_NORMAL;
    105  1.5.8.2  nathanw 	config_search(txsim_search, self, txsim_print);
    106  1.5.8.2  nathanw 	/*
    107  1.5.8.2  nathanw 	 * UART module uses platform dependent config_hooks.
    108  1.5.8.2  nathanw 	 */
    109  1.5.8.2  nathanw 	sc->sc_pri = ATTACH_LAST;
    110  1.5.8.2  nathanw 	config_search(txsim_search, self, txsim_print);
    111  1.5.8.2  nathanw }
    112  1.5.8.2  nathanw 
    113  1.5.8.2  nathanw int
    114  1.5.8.2  nathanw txsim_print(void *aux, const char *pnp)
    115  1.5.8.2  nathanw {
    116  1.5.8.2  nathanw 	return (pnp ? QUIET : UNCONF);
    117  1.5.8.2  nathanw }
    118  1.5.8.2  nathanw 
    119  1.5.8.2  nathanw int
    120  1.5.8.2  nathanw txsim_search(struct device *parent, struct cfdata *cf, void *aux)
    121  1.5.8.2  nathanw {
    122  1.5.8.2  nathanw 	struct txsim_softc *sc = (void*)parent;
    123  1.5.8.2  nathanw 	struct txsim_attach_args ta;
    124  1.5.8.2  nathanw 
    125  1.5.8.2  nathanw 	ta.ta_tc = tx_conf_get_tag();
    126  1.5.8.2  nathanw 
    127  1.5.8.2  nathanw 	if ((*cf->cf_attach->ca_match)(parent, cf, &ta) == sc->sc_pri)
    128  1.5.8.2  nathanw 		config_attach(parent, cf, &ta, txsim_print);
    129  1.5.8.2  nathanw 
    130  1.5.8.2  nathanw 	return (0);
    131  1.5.8.2  nathanw }
    132