diff -urN mpc860.org/conf/MPC860 mpc860/conf/MPC860 --- mpc860.org/conf/MPC860 Sun Oct 6 22:54:38 2002 +++ mpc860/conf/MPC860 Tue Dec 24 03:42:29 2002 @@ -69,3 +69,5 @@ pseudo-device loop # network loopback pseudo-device pty # pseudo-terminals pseudo-device rnd # /dev/random and in-kernel generator + +pseudo-device led diff -urN mpc860.org/conf/files.mpc860 mpc860/conf/files.mpc860 --- mpc860.org/conf/files.mpc860 Wed Sep 11 22:40:01 2002 +++ mpc860/conf/files.mpc860 Fri Dec 20 08:51:07 2002 @@ -71,4 +71,7 @@ attach wdc at pbus with wdc_pbus file arch/mpc860/dev/wdc_pbus.c wdc_pbus +defpseudo led +file arch/mpc860/dev/led.c led needs-flag + include "arch/mpc860/conf/majors.mpc860" diff -urN mpc860.org/conf/majors.mpc860 mpc860/conf/majors.mpc860 --- mpc860.org/conf/majors.mpc860 Wed Sep 11 22:40:01 2002 +++ mpc860/conf/majors.mpc860 Fri Dec 20 08:52:27 2002 @@ -25,3 +25,5 @@ device-major wd char 23 block 6 wd device-major scc char 25 scc + +device-major led char 26 led diff -urN mpc860.org/dev/led.c mpc860/dev/led.c --- mpc860.org/dev/led.c Thu Jan 1 09:00:00 1970 +++ mpc860/dev/led.c Sun Dec 22 10:48:29 2002 @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2001, by Hiroshi TOKUDA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. The name of the developer may NOT be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * OpenBlockS LED Driver + * + * LED layout + * + * --(1)-- + * | | + * (6) (2) + * | | + * --(7)-- + * | | + * (5) (3) + * | | + * --(4)-- .(0) + * + * (Code Examples) + * 0xEE A + * 0xF8 b + * 0x72 C + * 0xB0 c + * 0xBC d + * 0xF2 E + * 0xE2 F + * 0xEC H + * 0xE8 h + * 0x60 I + * 0x3C J + * 0x70 L + * 0x7E O + * 0xB8 o + * 0xE6 P + * 0xCE q + * 0xDA S + * 0x7C U + * 0x38 u + * 0xDC y + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +struct led_softc { + struct device led_dev; +}; + + + +void led_attach(struct device *, struct device *, void *); +int ledopen(dev_t, int, int, struct proc *); +int ledclose(dev_t, int, int, struct proc *); +int ledioctl(dev_t, u_long, caddr_t, int, struct proc *); + +dev_type_open(ledopen); +dev_type_close(ledclose); +dev_type_ioctl(ledioctl); + + +const struct cdevsw led_cdevsw = { + ledopen, ledclose, noread, nowrite, ledioctl, + nostop, notty, nopoll, nommap, NULL +}; + +void led(int); + +void +ledattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + printf("OpenBlockS LED Driver\n"); +} + +int +ledopen(dev, flags, fmt, p) + dev_t dev; + int flags, fmt; + struct proc *p; +{ + return 0; /* this always succeeds */ +} + +int +ledclose(dev, flags, fmt, p) + dev_t dev; + int flags, fmt; + struct proc *p; +{ + return 0; /* again this always succeeds */ +} + +int +ledioctl(dev, cmd, data, flags, p) + dev_t dev; + u_long cmd; + caddr_t data; + int flags; + struct proc *p; +{ + led(cmd); + return 0; +} + +void +led(n) + int n; +{ + int i; + unsigned long pbdat; + unsigned long led_seg[] = {0x00000004,0x00004000,0x00008000,0x00020000, + 0x00000001,0x00000002,0x00010000,0x00000008}; + volatile struct mpc860dev *immr = get_immr(); + + immr->cpm_pbpar &= ~0x0003c00f; + immr->cpm_pbdir |= 0x0003c00f; + + immr->cpm_pbdat |= 0x0003c00f; + + pbdat = 0; + for (i = 0; i < 8; i++) { + if (n & (1 << i)) + pbdat += led_seg[i]; + } + + if (pbdat != 0) + immr->cpm_pbdat &= ~pbdat; +}