hil_gsc.c revision 1.1.6.2 1 1.1.6.2 yamt /* $NetBSD: hil_gsc.c,v 1.1.6.2 2014/05/22 11:39:50 yamt Exp $ */
2 1.1.6.2 yamt /* $OpenBSD: hil_gsc.c,v 1.5 2005/12/22 07:09:52 miod Exp $ */
3 1.1.6.2 yamt /*
4 1.1.6.2 yamt * Copyright (c) 2003, Miodrag Vallat.
5 1.1.6.2 yamt * All rights reserved.
6 1.1.6.2 yamt *
7 1.1.6.2 yamt * Redistribution and use in source and binary forms, with or without
8 1.1.6.2 yamt * modification, are permitted provided that the following conditions
9 1.1.6.2 yamt * are met:
10 1.1.6.2 yamt * 1. Redistributions of source code must retain the above copyright
11 1.1.6.2 yamt * notice, this list of conditions and the following disclaimer.
12 1.1.6.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.6.2 yamt * notice, this list of conditions and the following disclaimer in the
14 1.1.6.2 yamt * documentation and/or other materials provided with the distribution.
15 1.1.6.2 yamt *
16 1.1.6.2 yamt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1.6.2 yamt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 1.1.6.2 yamt * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 1.1.6.2 yamt * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 1.1.6.2 yamt * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 1.1.6.2 yamt * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 1.1.6.2 yamt * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1.6.2 yamt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 1.1.6.2 yamt * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 1.1.6.2 yamt * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1.6.2 yamt * POSSIBILITY OF SUCH DAMAGE.
27 1.1.6.2 yamt *
28 1.1.6.2 yamt */
29 1.1.6.2 yamt
30 1.1.6.2 yamt #include <sys/param.h>
31 1.1.6.2 yamt #include <sys/systm.h>
32 1.1.6.2 yamt #include <sys/device.h>
33 1.1.6.2 yamt #include <sys/cpu.h>
34 1.1.6.2 yamt #include <sys/bus.h>
35 1.1.6.2 yamt
36 1.1.6.2 yamt #include <machine/intr.h>
37 1.1.6.2 yamt #include <machine/iomod.h>
38 1.1.6.2 yamt #include <machine/autoconf.h>
39 1.1.6.2 yamt
40 1.1.6.2 yamt #include <hppa/dev/cpudevs.h>
41 1.1.6.2 yamt #include <hppa/gsc/gscbusvar.h>
42 1.1.6.2 yamt #include <hppa/hppa/machdep.h>
43 1.1.6.2 yamt
44 1.1.6.2 yamt #include <machine/hil_machdep.h>
45 1.1.6.2 yamt
46 1.1.6.2 yamt #include <dev/hil/hilvar.h>
47 1.1.6.2 yamt
48 1.1.6.2 yamt static int hil_gsc_match(device_t, cfdata_t, void *);
49 1.1.6.2 yamt static void hil_gsc_attach(device_t, device_t, void *);
50 1.1.6.2 yamt
51 1.1.6.2 yamt struct hil_gsc_softc {
52 1.1.6.2 yamt struct hil_softc sc_hs;
53 1.1.6.2 yamt int sc_hil_console;
54 1.1.6.2 yamt void *sc_ih;
55 1.1.6.2 yamt };
56 1.1.6.2 yamt
57 1.1.6.2 yamt CFATTACH_DECL_NEW(hil_gsc, sizeof(struct hil_gsc_softc),
58 1.1.6.2 yamt hil_gsc_match, hil_gsc_attach, NULL, NULL);
59 1.1.6.2 yamt
60 1.1.6.2 yamt int
61 1.1.6.2 yamt hil_gsc_match(device_t parent, cfdata_t cf, void *aux)
62 1.1.6.2 yamt {
63 1.1.6.2 yamt struct gsc_attach_args *ga = aux;
64 1.1.6.2 yamt
65 1.1.6.2 yamt if (ga->ga_type.iodc_type != HPPA_TYPE_FIO ||
66 1.1.6.2 yamt ga->ga_type.iodc_sv_model != HPPA_FIO_HIL)
67 1.1.6.2 yamt return 0;
68 1.1.6.2 yamt
69 1.1.6.2 yamt return 1;
70 1.1.6.2 yamt }
71 1.1.6.2 yamt
72 1.1.6.2 yamt void
73 1.1.6.2 yamt hil_gsc_attach(device_t parent, device_t self, void *aux)
74 1.1.6.2 yamt {
75 1.1.6.2 yamt struct hil_gsc_softc *gsc = device_private(self);
76 1.1.6.2 yamt struct hil_softc *sc = &gsc->sc_hs;
77 1.1.6.2 yamt struct gsc_attach_args *ga = aux;
78 1.1.6.2 yamt int pagezero_cookie;
79 1.1.6.2 yamt
80 1.1.6.2 yamt sc->sc_dev = self;
81 1.1.6.2 yamt sc->sc_bst = ga->ga_iot;
82 1.1.6.2 yamt if (bus_space_map(ga->ga_iot, ga->ga_hpa,
83 1.1.6.2 yamt HILMAPSIZE, 0, &sc->sc_bsh)) {
84 1.1.6.2 yamt aprint_error(": couldn't map hil controller\n");
85 1.1.6.2 yamt return;
86 1.1.6.2 yamt }
87 1.1.6.2 yamt
88 1.1.6.2 yamt pagezero_cookie = hppa_pagezero_map();
89 1.1.6.2 yamt gsc->sc_hil_console = ga->ga_dp.dp_mod == PAGE0->mem_kbd.pz_dp.dp_mod &&
90 1.1.6.2 yamt memcmp(ga->ga_dp.dp_bc, PAGE0->mem_kbd.pz_dp.dp_bc, 6) == 0;
91 1.1.6.2 yamt hppa_pagezero_unmap(pagezero_cookie);
92 1.1.6.2 yamt
93 1.1.6.2 yamt hil_attach(sc, &gsc->sc_hil_console);
94 1.1.6.2 yamt
95 1.1.6.2 yamt gsc->sc_ih = hppa_intr_establish(IPL_TTY, hil_intr, sc,
96 1.1.6.2 yamt ga->ga_ir, ga->ga_irq);
97 1.1.6.2 yamt
98 1.1.6.2 yamt config_interrupts(self, hil_attach_deferred);
99 1.1.6.2 yamt }
100