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