1 /* $NetBSD: ixdp425_led.c,v 1.3 2007/10/17 19:54:13 garbled Exp $ */
4 * Ichiro FUKUHARA <ichiro@ichiro.org>.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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
{
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
;
62 CFATTACH_DECL(ixdpled
, sizeof(struct ixdpled_softc
),
63 ixdpled_match
, ixdpled_attach
, NULL
, NULL
);
66 ixdpled_match(struct device
*parent
, struct cfdata
*match
, void *aux
)
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
;
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,
84 printf("%s: unable to map registers\n", self
->dv_xname
);
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
|
94 callout_init(&sc
->sc_co
, 0);
95 callout_reset(&sc
->sc_co
, hz
/ 5, ixdpled_callout
, sc
);
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
);