diff -urN mpc860.org/conf/MPC860 mpc860/conf/MPC860 --- mpc860.org/conf/MPC860 Thu Mar 15 23:00:17 2001 +++ mpc860/conf/MPC860 Wed Nov 14 00:20:39 2001 @@ -45,6 +45,8 @@ fec* at pbus? ipl 1 scc* at pbus? ipl 1 +pseudo-device led # OpenBlockS LED + lxtphy* at mii? phy ? # Level One LXT-970 PHYs tqphy* at mii? phy ? # TDK Semiconductor PHYs #ukphy* at mii? phy ? # generic unknown PHYs diff -urN mpc860.org/conf/files.mpc860 mpc860/conf/files.mpc860 --- mpc860.org/conf/files.mpc860 Sat Feb 24 02:13:34 2001 +++ mpc860/conf/files.mpc860 Wed Nov 14 00:20:39 2001 @@ -79,6 +79,10 @@ attach fec at pbus file arch/mpc860/dev/if_fec.c fec +defpseudo led +file arch/mpc860/dev/led.c led needs-flag + + # XXX dev/pcmcia needs fdc #device fdc {drive = -1} 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 Wed Nov 14 00:20:44 2001 @@ -0,0 +1,151 @@ +/* + * 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 + +struct led_softc { + struct device led_dev; +}; + +void led_attach(struct device *, struct device *, void *); +int led_open(dev_t, int, int, struct proc *); +int led_close(dev_t, int, int, struct proc *); +int led_ioctl(dev_t, u_long, caddr_t, int, struct proc *); + +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; +} diff -urN mpc860.org/mpc860/conf.c mpc860/mpc860/conf.c --- mpc860.org/mpc860/conf.c Wed Feb 21 22:46:37 2001 +++ mpc860/mpc860/conf.c Wed Nov 14 00:21:23 2001 @@ -40,6 +40,9 @@ cdev_decl(scc); +#include "led.h" +cdev_decl(led); + struct cdevsw cdevsw[] = { cdev_cn_init(1,cn), /* 0: virtual console */ cdev_ctty_init(1,ctty), /* 1: control tty */ @@ -65,7 +68,7 @@ cdev_disk_init(NRAID,raid), /* 21: RAIDframe disk driver */ cdev_disk_init(NMD,md), /* 22: memory disk driver */ cdev_lkm_dummy(), /* 23: */ - cdev_lkm_dummy(), /* 24: */ + cdev__oci_init(NLED,led), /* 24: LED driver */ cdev_tty_init(1,scc), /* 25: SCC RS-232C */ }; int nchrdev = sizeof cdevsw / sizeof cdevsw[0];