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