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