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