No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hpcmips / isa / plumisa_machdep.c
blob78734a4fe41862389b4be27471881664ff7d11d2
1 /* $NetBSD: plumisa_machdep.c,v 1.10 2009/08/18 17:02:00 dyoung Exp $ */
3 /*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: plumisa_machdep.c,v 1.10 2009/08/18 17:02:00 dyoung Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
38 #include <machine/bus.h>
40 #include <dev/isa/isavar.h>
41 #include <dev/isa/isareg.h>
43 #include <machine/platid.h>
44 #include <machine/platid_mask.h>
46 #include <hpcmips/tx/tx39var.h>
47 #include <hpcmips/dev/plumvar.h>
48 #include <hpcmips/dev/plumicuvar.h>
49 #include <hpcmips/dev/plumiobusvar.h>
51 #include "locators.h"
53 int plumisabprint(void *, const char *);
54 int plumisabmatch(struct device *, struct cfdata *, void *);
55 void plumisabattach(struct device *, struct device *, void *);
57 struct plumisab_softc {
58 struct device sc_dev;
59 plum_chipset_tag_t sc_pc;
60 bus_space_tag_t sc_iot;
61 int sc_irq;
62 void *sc_ih;
65 CFATTACH_DECL(plumisab, sizeof(struct plumisab_softc),
66 plumisabmatch, plumisabattach, NULL, NULL);
68 int
69 plumisabmatch(struct device *parent, struct cfdata *match, void *aux)
71 struct plumiobus_attach_args *pba = aux;
72 platid_mask_t mask;
74 if (strcmp(pba->pba_busname, match->cf_name)) {
75 return (0);
78 if (match->cf_loc[PLUMIOBUSIFCF_PLATFORM] ==
79 PLUMIOBUSIFCF_PLATFORM_DEFAULT) {
80 return (1);
83 mask = PLATID_DEREF(match->cf_loc[PLUMIOBUSIFCF_PLATFORM]);
84 if (platid_match(&platid, &mask)) {
85 return (2);
88 return (0);
91 void
92 plumisabattach(struct device *parent, struct device *self, void *aux)
94 struct plumiobus_attach_args *pba = aux;
95 struct plumisab_softc *sc = (void*)self;
96 struct isabus_attach_args iba;
98 printf("\n");
99 sc->sc_pc = pba->pba_pc;
100 sc->sc_iot = pba->pba_iot;
101 sc->sc_irq = pba->pba_irq;
102 printf(" base=%#x irq=%d\n", sc->sc_iot->t_base, sc->sc_irq);
103 #if 0
104 /* Reset I/O bus */
105 plum_power_ioreset(sc->sc_pc);
106 #endif
107 /* Dump I/O port */
108 if (0) {
109 bus_space_handle_t ioh;
110 int i;
111 bus_space_map(sc->sc_iot, 0, 0x400, 0, &ioh);
112 for(i = 0; i < 0x400; i += 4) {
113 printf("[%03x]%02x", i, bus_space_read_1(sc->sc_iot, ioh, i + 3));
114 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 2));
115 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 1));
116 printf("%02x", bus_space_read_1(sc->sc_iot, ioh, i + 0));
118 bus_space_unmap(sc->sc_iot, ioh, 0x400);
121 iba.iba_ic = sc;
122 /* Plum ISA-bus don't have memory space! */
123 /* Plum ISA port space */
124 iba.iba_iot = sc->sc_iot;
125 config_found_ia(self, "isabus", &iba, plumisabprint);
129 plumisabprint(void *aux, const char *pnp)
132 return (pnp ? QUIET : UNCONF);
135 void
136 isa_attach_hook(struct device *parent, struct device *self,
137 struct isabus_attach_args *iba)
142 void
143 isa_detach_hook(isa_chipset_tag_t, device_t self)
147 void *
148 isa_intr_establish(isa_chipset_tag_t ic, int irq, int type, int level,
149 int (*ih_fun)(void *), void *ih_arg)
151 struct plumisab_softc *sc = (void*)ic;
153 sc->sc_ih = plum_intr_establish(sc->sc_pc, sc->sc_irq, type, level,
154 ih_fun, ih_arg);
155 return (sc->sc_ih);
158 void
159 isa_intr_disestablish(isa_chipset_tag_t ic, void *arg)
161 struct plumisab_softc *sc = (void*)ic;
163 plum_intr_disestablish(sc->sc_pc, arg);
167 isa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq)
169 struct plumisab_softc *sc = (void*)ic;
171 *irq = sc->sc_irq;
173 return (0);