gecko.c revision 1.1.4.2 1 1.1.4.2 rmind /* $OpenBSD: gecko.c,v 1.1 2008/04/27 14:39:51 kettenis Exp $ */
2 1.1.4.2 rmind
3 1.1.4.2 rmind /*
4 1.1.4.2 rmind * Copyright (c) 2007 Mark Kettenis
5 1.1.4.2 rmind *
6 1.1.4.2 rmind * Permission to use, copy, modify, and distribute this software for any
7 1.1.4.2 rmind * purpose with or without fee is hereby granted, provided that the above
8 1.1.4.2 rmind * copyright notice and this permission notice appear in all copies.
9 1.1.4.2 rmind *
10 1.1.4.2 rmind * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 1.1.4.2 rmind * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 1.1.4.2 rmind * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 1.1.4.2 rmind * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 1.1.4.2 rmind * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 1.1.4.2 rmind * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 1.1.4.2 rmind * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 1.1.4.2 rmind */
18 1.1.4.2 rmind
19 1.1.4.2 rmind #include <sys/param.h>
20 1.1.4.2 rmind #include <sys/device.h>
21 1.1.4.2 rmind #include <sys/kernel.h>
22 1.1.4.2 rmind #include <sys/systm.h>
23 1.1.4.2 rmind
24 1.1.4.2 rmind #include <machine/autoconf.h>
25 1.1.4.2 rmind #include <sys/bus.h>
26 1.1.4.2 rmind #include <machine/cpu.h>
27 1.1.4.2 rmind #include <machine/iomod.h>
28 1.1.4.2 rmind #include <machine/pdc.h>
29 1.1.4.2 rmind
30 1.1.4.2 rmind #include <hppa/dev/cpudevs.h>
31 1.1.4.2 rmind
32 1.1.4.2 rmind struct gecko_softc {
33 1.1.4.2 rmind device_t sc_dv;
34 1.1.4.2 rmind
35 1.1.4.2 rmind bus_space_tag_t sc_iot;
36 1.1.4.2 rmind bus_space_handle_t sc_ioh;
37 1.1.4.2 rmind };
38 1.1.4.2 rmind
39 1.1.4.2 rmind int gecko_match(device_t, cfdata_t, void *);
40 1.1.4.2 rmind void gecko_attach(device_t, device_t, void *);
41 1.1.4.2 rmind static device_t gecko_callback(device_t, struct confargs *);
42 1.1.4.2 rmind
43 1.1.4.2 rmind CFATTACH_DECL_NEW(gecko, sizeof(struct gecko_softc), gecko_match,
44 1.1.4.2 rmind gecko_attach, NULL, NULL);
45 1.1.4.2 rmind
46 1.1.4.2 rmind int
47 1.1.4.2 rmind gecko_match(device_t parent, cfdata_t match, void *aux)
48 1.1.4.2 rmind {
49 1.1.4.2 rmind struct confargs *ca = aux;
50 1.1.4.2 rmind
51 1.1.4.2 rmind if (ca->ca_type.iodc_type != HPPA_TYPE_BCPORT ||
52 1.1.4.2 rmind ca->ca_type.iodc_sv_model != HPPA_BCPORT_PORT)
53 1.1.4.2 rmind return (0);
54 1.1.4.2 rmind
55 1.1.4.2 rmind if (ca->ca_type.iodc_model == 0x50 &&
56 1.1.4.2 rmind ca->ca_type.iodc_revision == 0x00)
57 1.1.4.2 rmind return (1);
58 1.1.4.2 rmind
59 1.1.4.2 rmind return (0);
60 1.1.4.2 rmind }
61 1.1.4.2 rmind
62 1.1.4.2 rmind void
63 1.1.4.2 rmind gecko_attach(device_t parent, device_t self, void *aux)
64 1.1.4.2 rmind {
65 1.1.4.2 rmind struct gecko_softc *sc = device_private(self);
66 1.1.4.2 rmind struct confargs *ca = aux, nca;
67 1.1.4.2 rmind volatile struct iomod *regs;
68 1.1.4.2 rmind
69 1.1.4.2 rmind sc->sc_dv = self;
70 1.1.4.2 rmind sc->sc_iot = ca->ca_iot;
71 1.1.4.2 rmind if (bus_space_map(sc->sc_iot, ca->ca_hpa, IOMOD_HPASIZE, 0,
72 1.1.4.2 rmind &sc->sc_ioh)) {
73 1.1.4.2 rmind aprint_error(": can't map IO space\n");
74 1.1.4.2 rmind return;
75 1.1.4.2 rmind }
76 1.1.4.2 rmind regs = bus_space_vaddr(ca->ca_iot, sc->sc_ioh);
77 1.1.4.2 rmind
78 1.1.4.2 rmind aprint_verbose(": %x-%x", regs->io_io_low, regs->io_io_high);
79 1.1.4.2 rmind
80 1.1.4.2 rmind aprint_normal("\n");
81 1.1.4.2 rmind
82 1.1.4.2 rmind nca = *ca;
83 1.1.4.2 rmind nca.ca_hpabase = regs->io_io_low;
84 1.1.4.2 rmind nca.ca_nmodules = MAXMODBUS;
85 1.1.4.2 rmind
86 1.1.4.2 rmind pdc_scanbus(self, &nca, gecko_callback);
87 1.1.4.2 rmind }
88 1.1.4.2 rmind
89 1.1.4.2 rmind static device_t
90 1.1.4.2 rmind gecko_callback(device_t self, struct confargs *ca)
91 1.1.4.2 rmind {
92 1.1.4.2 rmind
93 1.1.4.2 rmind return config_found_sm_loc(self, "gedoens", NULL, ca, mbprint,
94 1.1.4.2 rmind mbsubmatch);
95 1.1.4.2 rmind }
96 1.1.4.2 rmind
97