fdc_gsc.c revision 1.1.4.2 1 1.1.4.2 rmind /* $NetBSD: fdc_gsc.c,v 1.1.4.2 2014/05/18 17:45:11 rmind Exp $ */
2 1.1.4.2 rmind
3 1.1.4.2 rmind /* $OpenBSD: fdc_gsc.c,v 1.1 1998/09/30 04:45:46 mickey Exp $ */
4 1.1.4.2 rmind
5 1.1.4.2 rmind /*
6 1.1.4.2 rmind * Copyright (c) 1998 Michael Shalayeff
7 1.1.4.2 rmind * All rights reserved.
8 1.1.4.2 rmind *
9 1.1.4.2 rmind * Redistribution and use in source and binary forms, with or without
10 1.1.4.2 rmind * modification, are permitted provided that the following conditions
11 1.1.4.2 rmind * are met:
12 1.1.4.2 rmind * 1. Redistributions of source code must retain the above copyright
13 1.1.4.2 rmind * notice, this list of conditions and the following disclaimer.
14 1.1.4.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
15 1.1.4.2 rmind * notice, this list of conditions and the following disclaimer in the
16 1.1.4.2 rmind * documentation and/or other materials provided with the distribution.
17 1.1.4.2 rmind *
18 1.1.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.1.4.2 rmind * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.1.4.2 rmind * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.1.4.2 rmind * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 1.1.4.2 rmind * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 1.1.4.2 rmind * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 1.1.4.2 rmind * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 1.1.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 1.1.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 1.1.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 1.1.4.2 rmind * THE POSSIBILITY OF SUCH DAMAGE.
29 1.1.4.2 rmind */
30 1.1.4.2 rmind
31 1.1.4.2 rmind #include <sys/cdefs.h>
32 1.1.4.2 rmind __KERNEL_RCSID(0, "$NetBSD: fdc_gsc.c,v 1.1.4.2 2014/05/18 17:45:11 rmind Exp $");
33 1.1.4.2 rmind
34 1.1.4.2 rmind #include <sys/param.h>
35 1.1.4.2 rmind #include <sys/systm.h>
36 1.1.4.2 rmind #include <sys/device.h>
37 1.1.4.2 rmind
38 1.1.4.2 rmind #include <machine/iomod.h>
39 1.1.4.2 rmind #include <sys/bus.h>
40 1.1.4.2 rmind #include <machine/intr.h>
41 1.1.4.2 rmind #include <machine/autoconf.h>
42 1.1.4.2 rmind
43 1.1.4.2 rmind #include <dev/ic/fdreg.h>
44 1.1.4.2 rmind #include <dev/ic/fdlink.h>
45 1.1.4.2 rmind
46 1.1.4.2 rmind #include <hppa/dev/cpudevs.h>
47 1.1.4.2 rmind
48 1.1.4.2 rmind /* controller driver configuration */
49 1.1.4.2 rmind int fdc_gsc_probe(device_t, cfdata_t, void *);
50 1.1.4.2 rmind void fdc_gsc_attach(device_t, device_t, void *);
51 1.1.4.2 rmind
52 1.1.4.2 rmind CFATTACH_DECL_NEW(fdc_gsc, sizeof(struct fdc_softc),
53 1.1.4.2 rmind fdc_gsc_probe, fdc_gsc_attach, NULL, NULL);
54 1.1.4.2 rmind
55 1.1.4.2 rmind int
56 1.1.4.2 rmind fdc_gsc_probe(device_t parent, cfdata_t match, void *aux)
57 1.1.4.2 rmind {
58 1.1.4.2 rmind struct confargs *ca = aux;
59 1.1.4.2 rmind bus_space_handle_t ioh;
60 1.1.4.2 rmind int rv;
61 1.1.4.2 rmind
62 1.1.4.2 rmind if (ca->ca_type.iodc_type != HPPA_TYPE_FIO ||
63 1.1.4.2 rmind ca->ca_type.iodc_sv_model != HPPA_FIO_GPCFD)
64 1.1.4.2 rmind return 0;
65 1.1.4.2 rmind
66 1.1.4.2 rmind /* Map the i/o space. */
67 1.1.4.2 rmind if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh))
68 1.1.4.2 rmind return 0;
69 1.1.4.2 rmind
70 1.1.4.2 rmind rv = fdcprobe1(ca->ca_iot, ioh | IOMOD_DEVOFFSET);
71 1.1.4.2 rmind bus_space_unmap(ca->ca_iot, ioh, IOMOD_HPASIZE);
72 1.1.4.2 rmind return rv;
73 1.1.4.2 rmind }
74 1.1.4.2 rmind
75 1.1.4.2 rmind void
76 1.1.4.2 rmind fdc_gsc_attach(device_t parent, device_t self, void *aux)
77 1.1.4.2 rmind {
78 1.1.4.2 rmind struct fdc_softc *sc = device_private(self);
79 1.1.4.2 rmind bus_space_handle_t ioh;
80 1.1.4.2 rmind struct confargs *ca = aux;
81 1.1.4.2 rmind
82 1.1.4.2 rmind sc->sc_dev = self;
83 1.1.4.2 rmind
84 1.1.4.2 rmind /* Re-map the I/O space. */
85 1.1.4.2 rmind if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) {
86 1.1.4.2 rmind aprint_error(": can't map I/O ports\n");
87 1.1.4.2 rmind return;
88 1.1.4.2 rmind }
89 1.1.4.2 rmind
90 1.1.4.2 rmind ioh |= IOMOD_DEVOFFSET;
91 1.1.4.2 rmind sc->sc_iot = ca->ca_iot;
92 1.1.4.2 rmind sc->sc_ioh = ioh;
93 1.1.4.2 rmind sc->sc_ioh_ctl = ioh + FDCTL_OFFSET;
94 1.1.4.2 rmind
95 1.1.4.2 rmind fdc_attach_subr(sc);
96 1.1.4.2 rmind }
97