1 /* $NetBSD: epled.c,v 1.1 2005/11/12 05:33:23 hamajima Exp $ */
4 * Copyright (c) 2005 HAMAJIMA Katsuomi. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: epled.c,v 1.1 2005/11/12 05:33:23 hamajima Exp $");
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/device.h>
35 #include <machine/bus.h>
36 #include <arm/ep93xx/epgpiovar.h>
37 #include <arm/ep93xx/epledvar.h>
44 struct epgpio_softc
*sc_gpio
;
47 static int epled_match(struct device
*, struct cfdata
*, void *);
48 static void epled_attach(struct device
*, struct device
*, void *);
50 CFATTACH_DECL(epled
, sizeof(struct epled_softc
),
51 epled_match
, epled_attach
, NULL
, NULL
);
53 static struct epled_softc
*the_epled_sc
= 0;
56 epled_match(struct device
*parent
, struct cfdata
*cf
, void *aux
)
62 epled_attach(struct device
*parent
, struct device
*self
, void *aux
)
64 struct epled_softc
*sc
= (struct epled_softc
*)self
;
65 struct epgpio_attach_args
*ga
= aux
;
67 sc
->sc_port
= ga
->ga_port
;
68 sc
->sc_green
= ga
->ga_bit1
;
69 sc
->sc_red
= ga
->ga_bit2
;
70 sc
->sc_gpio
= (struct epgpio_softc
*)parent
;
77 printf("%s is already configured\n", sc
->sc_dev
.dv_xname
);
80 epgpio_out(sc
->sc_gpio
, sc
->sc_port
, sc
->sc_green
);
81 epgpio_out(sc
->sc_gpio
, sc
->sc_port
, sc
->sc_red
);
87 struct epled_softc
*sc
= the_epled_sc
;
91 printf("epled not configured\n");
95 epgpio_set(sc
->sc_gpio
, sc
->sc_port
, sc
->sc_red
);
102 struct epled_softc
*sc
= the_epled_sc
;
106 printf("epled not configured\n");
110 epgpio_clear(sc
->sc_gpio
, sc
->sc_port
, sc
->sc_red
);
117 struct epled_softc
*sc
= the_epled_sc
;
121 printf("epled not configured\n");
125 epgpio_set(sc
->sc_gpio
, sc
->sc_port
, sc
->sc_green
);
130 epled_green_off(void)
132 struct epled_softc
*sc
= the_epled_sc
;
136 printf("epled not configured\n");
140 epgpio_clear(sc
->sc_gpio
, sc
->sc_port
, sc
->sc_green
);