gio.c revision 1.1.6.2 1 1.1.6.2 bouyer /* $NetBSD: gio.c,v 1.1.6.2 2000/11/20 20:23:42 bouyer Exp $ */
2 1.1.6.2 bouyer
3 1.1.6.2 bouyer /*
4 1.1.6.2 bouyer * Copyright (c) 2000 Soren S. Jorvang
5 1.1.6.2 bouyer * All rights reserved.
6 1.1.6.2 bouyer *
7 1.1.6.2 bouyer * Redistribution and use in source and binary forms, with or without
8 1.1.6.2 bouyer * modification, are permitted provided that the following conditions
9 1.1.6.2 bouyer * are met:
10 1.1.6.2 bouyer * 1. Redistributions of source code must retain the above copyright
11 1.1.6.2 bouyer * notice, this list of conditions and the following disclaimer.
12 1.1.6.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.6.2 bouyer * notice, this list of conditions and the following disclaimer in the
14 1.1.6.2 bouyer * documentation and/or other materials provided with the distribution.
15 1.1.6.2 bouyer * 3. All advertising materials mentioning features or use of this software
16 1.1.6.2 bouyer * must display the following acknowledgement:
17 1.1.6.2 bouyer * This product includes software developed for the
18 1.1.6.2 bouyer * NetBSD Project. See http://www.netbsd.org/ for
19 1.1.6.2 bouyer * information about NetBSD.
20 1.1.6.2 bouyer * 4. The name of the author may not be used to endorse or promote products
21 1.1.6.2 bouyer * derived from this software without specific prior written permission.
22 1.1.6.2 bouyer *
23 1.1.6.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.1.6.2 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1.6.2 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1.6.2 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.1.6.2 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.1.6.2 bouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.1.6.2 bouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.1.6.2 bouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.1.6.2 bouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.1.6.2 bouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1.6.2 bouyer */
34 1.1.6.2 bouyer
35 1.1.6.2 bouyer #include "opt_ddb.h"
36 1.1.6.2 bouyer
37 1.1.6.2 bouyer #include <sys/param.h>
38 1.1.6.2 bouyer #include <sys/systm.h>
39 1.1.6.2 bouyer #include <sys/device.h>
40 1.1.6.2 bouyer
41 1.1.6.2 bouyer #include <sgimips/gio/gioreg.h>
42 1.1.6.2 bouyer #include <sgimips/gio/giovar.h>
43 1.1.6.2 bouyer
44 1.1.6.2 bouyer #include "locators.h"
45 1.1.6.2 bouyer
46 1.1.6.2 bouyer struct gio_softc {
47 1.1.6.2 bouyer struct device sc_dev;
48 1.1.6.2 bouyer };
49 1.1.6.2 bouyer
50 1.1.6.2 bouyer static int gio_match(struct device *, struct cfdata *, void *);
51 1.1.6.2 bouyer static void gio_attach(struct device *, struct device *, void *);
52 1.1.6.2 bouyer static int gio_print(void *, const char *);
53 1.1.6.2 bouyer static int gio_search(struct device *, struct cfdata *, void *);
54 1.1.6.2 bouyer
55 1.1.6.2 bouyer struct cfattach gio_ca = {
56 1.1.6.2 bouyer sizeof(struct gio_softc), gio_match, gio_attach
57 1.1.6.2 bouyer };
58 1.1.6.2 bouyer
59 1.1.6.2 bouyer static int
60 1.1.6.2 bouyer gio_match(parent, match, aux)
61 1.1.6.2 bouyer struct device *parent;
62 1.1.6.2 bouyer struct cfdata *match;
63 1.1.6.2 bouyer void *aux;
64 1.1.6.2 bouyer {
65 1.1.6.2 bouyer struct giobus_attach_args *gba = aux;
66 1.1.6.2 bouyer
67 1.1.6.2 bouyer if (strcmp(gba->gba_busname, match->cf_driver->cd_name) != 0)
68 1.1.6.2 bouyer return 0;
69 1.1.6.2 bouyer
70 1.1.6.2 bouyer return 1;
71 1.1.6.2 bouyer }
72 1.1.6.2 bouyer
73 1.1.6.2 bouyer static void
74 1.1.6.2 bouyer gio_attach(parent, self, aux)
75 1.1.6.2 bouyer struct device *parent;
76 1.1.6.2 bouyer struct device *self;
77 1.1.6.2 bouyer void *aux;
78 1.1.6.2 bouyer {
79 1.1.6.2 bouyer struct gio_attach_args ga;
80 1.1.6.2 bouyer
81 1.1.6.2 bouyer printf("\n");
82 1.1.6.2 bouyer
83 1.1.6.2 bouyer config_search(gio_search, self, &ga);
84 1.1.6.2 bouyer }
85 1.1.6.2 bouyer
86 1.1.6.2 bouyer static int
87 1.1.6.2 bouyer gio_print(aux, pnp)
88 1.1.6.2 bouyer void *aux;
89 1.1.6.2 bouyer const char *pnp;
90 1.1.6.2 bouyer {
91 1.1.6.2 bouyer struct gio_attach_args *ga = aux;
92 1.1.6.2 bouyer
93 1.1.6.2 bouyer if (pnp != 0)
94 1.1.6.2 bouyer return QUIET;
95 1.1.6.2 bouyer
96 1.1.6.2 bouyer if (ga->ga_slot != GIOCF_SLOT_DEFAULT)
97 1.1.6.2 bouyer printf(" slot %d", ga->ga_slot);
98 1.1.6.2 bouyer if (ga->ga_addr != GIOCF_ADDR_DEFAULT)
99 1.1.6.2 bouyer printf(" addr 0x%x", ga->ga_addr);
100 1.1.6.2 bouyer
101 1.1.6.2 bouyer return UNCONF;
102 1.1.6.2 bouyer }
103 1.1.6.2 bouyer
104 1.1.6.2 bouyer static int
105 1.1.6.2 bouyer gio_search(parent, cf, aux)
106 1.1.6.2 bouyer struct device *parent;
107 1.1.6.2 bouyer struct cfdata *cf;
108 1.1.6.2 bouyer void *aux;
109 1.1.6.2 bouyer {
110 1.1.6.2 bouyer struct gio_attach_args *ga = aux;
111 1.1.6.2 bouyer
112 1.1.6.2 bouyer do {
113 1.1.6.2 bouyer ga->ga_slot = cf->cf_loc[GIOCF_SLOT];
114 1.1.6.2 bouyer ga->ga_addr = cf->cf_loc[GIOCF_ADDR];
115 1.1.6.2 bouyer ga->ga_iot = 0;
116 1.1.6.2 bouyer ga->ga_ioh = MIPS_PHYS_TO_KSEG1(ga->ga_addr);
117 1.1.6.2 bouyer if ((*cf->cf_attach->ca_match)(parent, cf, ga) > 0)
118 1.1.6.2 bouyer config_attach(parent, cf, ga, gio_print);
119 1.1.6.2 bouyer } while (cf->cf_fstate == FSTATE_STAR);
120 1.1.6.2 bouyer
121 1.1.6.2 bouyer return 0;
122 1.1.6.2 bouyer }
123