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