Fix up mix of man(7)/mdoc(7).
[netbsd-mini2440.git] / sys / arch / evbarm / ixdp425 / ixdp425_led.c
blob736a62981e3284bf6dd0eb220ed927c7b04b2a7c
1 /* $NetBSD: ixdp425_led.c,v 1.3 2007/10/17 19:54:13 garbled Exp $ */
2 /*
3 * Copyright (c) 2003
4 * Ichiro FUKUHARA <ichiro@ichiro.org>.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: ixdp425_led.c,v 1.3 2007/10/17 19:54:13 garbled Exp $");
32 * LED support for IXDP425
35 #include <sys/param.h>
36 #include <sys/types.h>
37 #include <sys/callout.h>
38 #include <sys/device.h>
39 #include <sys/kernel.h>
40 #include <sys/systm.h>
42 #include <machine/bus.h>
44 #include <arm/xscale/ixp425_sipvar.h>
45 #include <arm/xscale/ixp425var.h>
47 static int ixdpled_match(struct device *, struct cfdata *, void *);
48 static void ixdpled_attach(struct device *, struct device *, void *);
49 static void ixdpled_callout(void *);
51 extern void ixp425_expbus_init(void);
53 struct ixdpled_softc {
54 struct device sc_dev;
55 bus_space_tag_t sc_iot;
56 bus_space_handle_t sc_ioh;
57 bus_addr_t sc_baseaddr;
58 bus_space_handle_t sc_pos;
59 struct callout sc_co;
62 CFATTACH_DECL(ixdpled, sizeof(struct ixdpled_softc),
63 ixdpled_match, ixdpled_attach, NULL, NULL);
65 static int
66 ixdpled_match(struct device *parent, struct cfdata *match, void *aux)
68 return (1);
71 static void
72 ixdpled_attach(struct device *parent, struct device *self, void *aux)
74 struct ixdpled_softc* sc = (struct ixdpled_softc*) self;
75 struct ixpsip_attach_args* sa = aux;
77 printf("\n");
79 sc->sc_iot = sa->sa_iot;
80 sc->sc_baseaddr = sa->sa_addr;
82 if(bus_space_map(sc->sc_iot, sa->sa_addr, sa->sa_size, 0,
83 &sc->sc_ioh)) {
84 printf("%s: unable to map registers\n", self->dv_xname);
85 return;
88 IXPREG(IXP425_EXP_VBASE + EXP_TIMING_CS2_OFFSET) =
89 IXP425_EXP_ADDR_T(3) | IXP425_EXP_SETUP_T(3) |
90 IXP425_EXP_STROBE_T(15) | IXP425_EXP_HOLD_T(3) |
91 IXP425_EXP_RECOVERY_T(15) | EXP_SZ_512 | EXP_WR_EN |
92 IXP425_EXP_CS_EN;
94 callout_init(&sc->sc_co, 0);
95 callout_reset(&sc->sc_co, hz / 5, ixdpled_callout, sc);
99 static void
100 ixdpled_callout(void *arg)
102 struct ixdpled_softc* sc = arg;
104 bus_space_write_2(sc->sc_iot, sc->sc_ioh, 0,
105 0x1000 + (sc->sc_pos++ % 16));
107 callout_reset(&sc->sc_co, hz / 5, ixdpled_callout, sc);