No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / arm / gemini / obio_lpchc.c
blobcd5539617dfec65b97dd463f3154e378bc48b695
1 /* $NetBSD: obio_lpchc.c,v 1.1 2008/11/09 09:15:42 cliff Exp $ */
3 /*
4 * obio attachment for GEMINI LPC Host Controller
5 */
6 #include "opt_gemini.h"
7 #include "locators.h"
9 #include <sys/cdefs.h>
10 __KERNEL_RCSID(0, "$NetBSD: obio_lpchc.c,v 1.1 2008/11/09 09:15:42 cliff Exp $");
12 #include <sys/param.h>
13 #include <sys/callout.h>
14 #include <sys/cdefs.h>
15 #include <sys/device.h>
16 #include <sys/kernel.h>
17 #include <sys/systm.h>
19 #include <machine/param.h>
20 #include <machine/bus.h>
22 #include <arm/gemini/gemini_obiovar.h>
23 #include <arm/gemini/gemini_lpcvar.h>
24 #include <arm/gemini/gemini_lpchcvar.h>
25 #include <arm/gemini/gemini_reg.h>
27 static int gemini_lpchc_match(struct device *, struct cfdata *, void *);
28 static void gemini_lpchc_attach(struct device *, struct device *, void *);
29 static int gemini_lpchc_print(void *, const char *);
31 CFATTACH_DECL_NEW(obio_lpchc, sizeof(struct gemini_lpchc_softc),
32 gemini_lpchc_match, gemini_lpchc_attach, NULL, NULL);
35 static int
36 gemini_lpchc_match(struct device *parent, struct cfdata *cf, void *aux)
38 struct obio_attach_args *obio = aux;
40 if (obio->obio_addr == OBIOCF_ADDR_DEFAULT)
41 panic("geminilpchc must have addr specified in config.");
43 if (obio->obio_addr == GEMINI_LPCHC_BASE)
44 return 1;
46 return 0;
49 static void
50 gemini_lpchc_attach(struct device *parent, struct device *self, void *aux)
52 gemini_lpchc_softc_t *sc = device_private(self);
53 struct obio_attach_args *obio = aux;
54 struct gemini_lpchc_attach_args lpchc;
55 uint32_t r;
56 void *ih=NULL;
58 sc->sc_dev = self;
59 sc->sc_addr = obio->obio_addr;
60 sc->sc_size = (obio->obio_size == OBIOCF_SIZE_DEFAULT)
61 ? GEMINI_LPCHC_SIZE : obio->obio_size;
63 sc->sc_iot = obio->obio_iot;
65 if (bus_space_map(sc->sc_iot, sc->sc_addr, sc->sc_size, 0, &sc->sc_ioh))
66 panic("%s: Cannot map registers", device_xname(self));
68 r = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GEMINI_LPCHC_ID);
69 aprint_normal("\n%s: device %d, rev %#x ",
70 device_xname(self), _LPCHC_ID_DEVICE(r), _LPCHC_ID_REV(r));
73 sc->sc_intr = obio->obio_intr;
74 if (obio->obio_intr != OBIOCF_INTR_DEFAULT) {
75 ih = intr_establish(obio->obio_intr, IPL_SERIAL,
76 IST_LEVEL_HIGH, gemini_lpchc_intr, sc);
77 if (ih == NULL)
78 panic("%s: cannot register intr %d",
79 device_xname(self), obio->obio_intr);
81 sc->sc_ih = ih;
83 gemini_lpchc_init(sc);
85 aprint_normal("\n");
86 aprint_naive("\n");
88 lpchc.lpchc_iot = obio->obio_iot;
89 lpchc.lpchc_addr = GEMINI_LPCIO_BASE; /* XXX sc_addr+offset */
90 lpchc.lpchc_size = LPCCF_SIZE_DEFAULT; /* XXX placeholder */
91 lpchc.lpchc_tag = sc;
93 (void)config_found_ia(sc->sc_dev, "lpcbus", &lpchc, gemini_lpchc_print);
96 int
97 gemini_lpchc_print(void *aux, const char *name)
99 struct gemini_lpchc_attach_args *lpchc = aux;
101 if (lpchc->lpchc_addr != LPCCF_ADDR_DEFAULT)
102 aprint_normal(" addr %#lx", lpchc->lpchc_addr);
104 return UNCONF;