1 /* $OpenBSD: arcofi_gsc.c,v 1.1 2011/12/21 23:12:03 miod Exp $ */
2
3 /*
4 * Copyright (c) 2011 Miodrag Vallat.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <sys/param.h>
20 #include <sys/systm.h>
21 #include <sys/device.h>
22
23 #include <machine/autoconf.h>
24 #include <machine/bus.h>
25 #include <machine/cpu.h>
26 #include <machine/intr.h>
27 #include <machine/iomod.h>
28
29 #include <sys/audioio.h>
30 #include <dev/audio_if.h>
31 #include <dev/ic/arcofivar.h>
32
33 #include <hppa/dev/cpudevs.h>
34 #include <hppa/gsc/gscbusvar.h>
35
36 int arcofi_gsc_match(struct device *, void *, void *);
37 void arcofi_gsc_attach(struct device *, struct device *, void *);
38
39 const struct cfattach arcofi_gsc_ca = {
40 sizeof(struct arcofi_softc),
41 arcofi_gsc_match,
42 arcofi_gsc_attach
43 };
44
45 int
arcofi_gsc_match(struct device * parent,void * match,void * vaa)46 arcofi_gsc_match(struct device *parent, void *match, void *vaa)
47 {
48 struct gsc_attach_args *ga = vaa;
49
50 if (ga->ga_type.iodc_type == HPPA_TYPE_FIO &&
51 (ga->ga_type.iodc_sv_model == HPPA_FIO_A1 ||
52 ga->ga_type.iodc_sv_model == HPPA_FIO_A1NB))
53 return 1;
54
55 return 0;
56 }
57
58 void
arcofi_gsc_attach(struct device * parent,struct device * self,void * vaa)59 arcofi_gsc_attach(struct device *parent, struct device *self, void *vaa)
60 {
61 struct arcofi_softc *sc = (struct arcofi_softc *)self;
62 struct gsc_attach_args *ga = vaa;
63 unsigned int u;
64
65 for (u = 0; u < ARCOFI_NREGS; u++)
66 sc->sc_reg[u] = (u << 2) | 0x01;
67
68 sc->sc_iot = ga->ga_iot;
69 if (bus_space_map(sc->sc_iot, ga->ga_hpa, ARCOFI_NREGS << 2, 0,
70 &sc->sc_ioh) != 0) {
71 printf(": can't map registers\n");
72 return;
73 }
74
75 /* XXX no generic IPL_SOFT level available */
76 sc->sc_sih = softintr_establish(IPL_SOFTTTY, &arcofi_swintr, sc);
77 if (sc->sc_sih == NULL) {
78 printf(": can't register soft interrupt\n");
79 return;
80 }
81 gsc_intr_establish((struct gsc_softc *)parent, ga->ga_irq,
82 IPL_AUDIO, arcofi_hwintr, sc, sc->sc_dev.dv_xname);
83
84 printf("\n");
85
86 arcofi_attach(sc, "gsc");
87 }
88