xref: /netbsd-src/sys/arch/hpcmips/tx/txsim.c (revision 4472dbe5e3bd91ef2540bada7a7ca7384627ff9b)
1 /*	$NetBSD: txsim.c,v 1.2 2000/01/12 14:56:20 uch Exp $ */
2 
3 /*
4  * Copyright (c) 1999, by UCHIYAMA Yasushi
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. The name of the developer may NOT be used to endorse or promote products
13  *    derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 
29 /*
30  * TX System Internal Module.
31  */
32 #include "opt_tx39_debug.h"
33 
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
37 
38 #include <machine/bus.h>
39 #include <machine/autoconf.h>
40 
41 #include <hpcmips/tx/tx39var.h>
42 #include <hpcmips/tx/txsnd.h>
43 
44 int	txsim_match __P((struct device*, struct cfdata*, void*));
45 void	txsim_attach __P((struct device*, struct device*, void*));
46 int	txsim_print __P((void*, const char*));
47 int	txsim_search __P((struct device*, struct cfdata*, void*));
48 
49 struct txsim_softc {
50 	struct	device sc_dev;
51 	int sc_pri; /* attaching device priority */
52 };
53 
54 struct cfattach txsim_ca = {
55 	sizeof(struct txsim_softc), txsim_match, txsim_attach
56 };
57 
58 int
59 txsim_match(parent, match, aux)
60 	struct device *parent;
61 	struct cfdata *match;
62 	void *aux;
63 {
64 	struct mainbus_attach_args *ma = aux;
65 
66 	if (strcmp(ma->ma_name, match->cf_driver->cd_name))
67 		return 0;
68 	return 1;
69 }
70 
71 void
72 txsim_attach(parent, self, aux)
73 	struct device *parent;
74 	struct device *self;
75 	void *aux;
76 {
77 	struct txsim_softc *sc = (void*)self;
78 
79 	printf("\n");
80 
81 	tx_sound_init(tx_conf_get_tag());
82 	/*
83 	 *	interrupt, clock module is used by other system module.
84 	 *	so attach first.
85 	 */
86 	sc->sc_pri = 2;
87 	config_search(txsim_search, self, txsim_print);
88 	/*
89 	 *	Other system module.
90 	 */
91 	sc->sc_pri = 1;
92 	config_search(txsim_search, self, txsim_print);
93 }
94 
95 int
96 txsim_print(aux, pnp)
97 	void *aux;
98 	const char *pnp;
99 {
100 	return pnp ? QUIET : UNCONF;
101 }
102 
103 int
104 txsim_search(parent, cf, aux)
105 	struct device *parent;
106 	struct cfdata *cf;
107 	void *aux;
108 {
109 	struct txsim_softc *sc = (void*)parent;
110 	struct txsim_attach_args ta;
111 
112 	ta.ta_tc = tx_conf_get_tag();
113 
114 	if ((*cf->cf_attach->ca_match)(parent, cf, &ta) == sc->sc_pri) {
115 		config_attach(parent, cf, &ta, txsim_print);
116 	}
117 
118 	return 0;
119 }
120