xref: /openbsd/sys/arch/hppa/dev/gecko.c (revision a6445c1d)
1 /*	$OpenBSD: gecko.c,v 1.1 2008/04/27 14:39:51 kettenis Exp $	*/
2 
3 /*
4  * Copyright (c) 2007 Mark Kettenis
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/device.h>
21 #include <sys/kernel.h>
22 #include <sys/systm.h>
23 
24 #include <machine/autoconf.h>
25 #include <machine/bus.h>
26 #include <machine/cpu.h>
27 #include <machine/iomod.h>
28 #include <machine/pdc.h>
29 
30 #include <hppa/dev/cpudevs.h>
31 
32 struct gecko_softc {
33 	struct device		sc_dv;
34 
35 	bus_space_tag_t		sc_iot;
36 	bus_space_handle_t 	sc_ioh;
37 };
38 
39 int	gecko_match(struct device *, void *, void *);
40 void	gecko_attach(struct device *, struct device *, void *);
41 
42 struct cfattach gecko_ca = {
43 	sizeof(struct gecko_softc), gecko_match, gecko_attach
44 };
45 
46 struct cfdriver gecko_cd = {
47 	NULL, "gecko", DV_DULL
48 };
49 
50 int
51 gecko_match(struct device *parent, void *match, void *aux)
52 {
53 	struct confargs *ca = aux;
54 
55 	if (ca->ca_type.iodc_type != HPPA_TYPE_BCPORT ||
56 	    ca->ca_type.iodc_sv_model != HPPA_BCPORT_PORT)
57 		return (0);
58 
59 	if (ca->ca_type.iodc_model == 0x50 &&
60 	    ca->ca_type.iodc_revision == 0x00)
61 		return (1);
62 
63 	return (0);
64 }
65 
66 void
67 gecko_attach(struct device *parent, struct device *self, void *aux)
68 {
69 	struct gecko_softc *sc = (struct gecko_softc *)self;
70 	struct confargs *ca = aux, nca;
71 	bus_space_handle_t ioh;
72 	volatile struct iomod *regs;
73 
74 	sc->sc_iot = ca->ca_iot;
75 	if (bus_space_map(sc->sc_iot, ca->ca_hpa, IOMOD_HPASIZE, 0,
76 	    &sc->sc_ioh)) {
77 		printf(": can't map IO space\n");
78 		return;
79 	}
80 	regs = bus_space_vaddr(ca->ca_iot, ioh);
81 
82 #if 1
83 	printf(": %x-%x", regs->io_io_low, regs->io_io_high);
84 #endif
85 
86 	printf("\n");
87 
88 	nca = *ca;
89 	nca.ca_hpamask = HPPA_IOBEGIN;
90 	pdc_scanbus(self, &nca, MAXMODBUS, regs->io_io_low);
91 }
92