gio.c revision 1.11 1 1.11 keihan /* $NetBSD: gio.c,v 1.11 2003/11/17 10:07:58 keihan 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.11 keihan * 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.10 lukem
35 1.10 lukem #include <sys/cdefs.h>
36 1.11 keihan __KERNEL_RCSID(0, "$NetBSD: gio.c,v 1.11 2003/11/17 10:07:58 keihan Exp $");
37 1.1 soren
38 1.1 soren #include "opt_ddb.h"
39 1.1 soren
40 1.1 soren #include <sys/param.h>
41 1.1 soren #include <sys/systm.h>
42 1.1 soren #include <sys/device.h>
43 1.1 soren
44 1.1 soren #include <sgimips/gio/gioreg.h>
45 1.1 soren #include <sgimips/gio/giovar.h>
46 1.1 soren
47 1.1 soren #include "locators.h"
48 1.1 soren
49 1.1 soren struct gio_softc {
50 1.1 soren struct device sc_dev;
51 1.1 soren };
52 1.1 soren
53 1.1 soren static int gio_match(struct device *, struct cfdata *, void *);
54 1.1 soren static void gio_attach(struct device *, struct device *, void *);
55 1.1 soren static int gio_print(void *, const char *);
56 1.1 soren static int gio_search(struct device *, struct cfdata *, void *);
57 1.1 soren
58 1.6 thorpej CFATTACH_DECL(gio, sizeof(struct gio_softc),
59 1.7 thorpej gio_match, gio_attach, NULL, NULL);
60 1.1 soren
61 1.1 soren static int
62 1.1 soren gio_match(parent, match, aux)
63 1.1 soren struct device *parent;
64 1.1 soren struct cfdata *match;
65 1.2 simonb void *aux;
66 1.1 soren {
67 1.1 soren struct giobus_attach_args *gba = aux;
68 1.1 soren
69 1.3 thorpej if (strcmp(gba->gba_busname, match->cf_name) != 0)
70 1.1 soren return 0;
71 1.1 soren
72 1.2 simonb return 1;
73 1.1 soren }
74 1.1 soren
75 1.1 soren static void
76 1.1 soren gio_attach(parent, self, aux)
77 1.1 soren struct device *parent;
78 1.1 soren struct device *self;
79 1.1 soren void *aux;
80 1.1 soren {
81 1.1 soren struct gio_attach_args ga;
82 1.1 soren
83 1.1 soren printf("\n");
84 1.1 soren
85 1.1 soren config_search(gio_search, self, &ga);
86 1.1 soren }
87 1.1 soren
88 1.1 soren static int
89 1.1 soren gio_print(aux, pnp)
90 1.1 soren void *aux;
91 1.1 soren const char *pnp;
92 1.1 soren {
93 1.1 soren struct gio_attach_args *ga = aux;
94 1.1 soren
95 1.1 soren if (pnp != 0)
96 1.1 soren return QUIET;
97 1.1 soren
98 1.1 soren if (ga->ga_slot != GIOCF_SLOT_DEFAULT)
99 1.9 thorpej aprint_normal(" slot %d", ga->ga_slot);
100 1.8 thorpej if (ga->ga_addr != (uint32_t) GIOCF_ADDR_DEFAULT)
101 1.9 thorpej aprint_normal(" addr 0x%x", ga->ga_addr);
102 1.1 soren
103 1.1 soren return UNCONF;
104 1.1 soren }
105 1.1 soren
106 1.1 soren static int
107 1.1 soren gio_search(parent, cf, aux)
108 1.1 soren struct device *parent;
109 1.2 simonb struct cfdata *cf;
110 1.1 soren void *aux;
111 1.2 simonb {
112 1.1 soren struct gio_attach_args *ga = aux;
113 1.1 soren
114 1.1 soren do {
115 1.1 soren ga->ga_slot = cf->cf_loc[GIOCF_SLOT];
116 1.1 soren ga->ga_addr = cf->cf_loc[GIOCF_ADDR];
117 1.1 soren ga->ga_iot = 0;
118 1.1 soren ga->ga_ioh = MIPS_PHYS_TO_KSEG1(ga->ga_addr);
119 1.4 thorpej if (config_match(parent, cf, ga) > 0)
120 1.1 soren config_attach(parent, cf, ga, gio_print);
121 1.1 soren } while (cf->cf_fstate == FSTATE_STAR);
122 1.1 soren
123 1.1 soren return 0;
124 1.1 soren }
125