Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbppc Add OpenBlockS266 GPIO LED Driver.
details: https://anonhg.NetBSD.org/src/rev/cabf9a90cfcc
branches: trunk
changeset: 573283:cabf9a90cfcc
user: shige <shige%NetBSD.org@localhost>
date: Mon Jan 24 18:47:37 2005 +0000
description:
Add OpenBlockS266 GPIO LED Driver.
diffstat:
sys/arch/evbppc/conf/OPENBLOCKS266 | 7 +-
sys/arch/evbppc/conf/files.obs405 | 6 +-
sys/arch/evbppc/include/obs405.h | 20 ++++++-
sys/arch/evbppc/obs405/dev/obsled.c | 111 ++++++++++++++++++++++++++++++++++++
sys/arch/evbppc/obs405/md_machdep.c | 10 ++-
5 files changed, 149 insertions(+), 5 deletions(-)
diffs (244 lines):
diff -r 9917a3f38fb7 -r cabf9a90cfcc sys/arch/evbppc/conf/OPENBLOCKS266
--- a/sys/arch/evbppc/conf/OPENBLOCKS266 Mon Jan 24 16:57:32 2005 +0000
+++ b/sys/arch/evbppc/conf/OPENBLOCKS266 Mon Jan 24 18:47:37 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: OPENBLOCKS266,v 1.12 2004/11/24 20:49:20 bouyer Exp $
+# $NetBSD: OPENBLOCKS266,v 1.13 2005/01/24 18:47:37 shige Exp $
#
# GENERIC -- everything that's currently supported
#
@@ -149,6 +149,11 @@
iic0 at gpiic? # I2C bus
xrtc0 at iic? addr 0x6f # RTC
+gpio0 at opb? addr ? irq ? # On-chip GPIO controller
+obsled0 at gpio? addr 0x0c # OBS LED connected GPIO
+obsled1 at gpio? addr 0x0d # OBS LED connected GPIO
+obsled2 at gpio? addr 0x0e # OBS LED connected GPIO
+
pchb0 at plb? # PCI-Host bridges
pci* at pchb?
diff -r 9917a3f38fb7 -r cabf9a90cfcc sys/arch/evbppc/conf/files.obs405
--- a/sys/arch/evbppc/conf/files.obs405 Mon Jan 24 16:57:32 2005 +0000
+++ b/sys/arch/evbppc/conf/files.obs405 Mon Jan 24 18:47:37 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.obs405,v 1.8 2005/01/18 17:57:41 shige Exp $
+# $NetBSD: files.obs405,v 1.9 2005/01/24 18:47:37 shige Exp $
#
# obs405-specific configuration info
@@ -14,6 +14,10 @@
file arch/evbppc/obs405/consinit.c
file arch/evbppc/obs405/md_machdep.c
+device obsled
+attach obsled at gpio
+file arch/evbppc/obs405/dev/obsled.c obsled
+
# Memory Disk for install kernel
file dev/md_root.c memory_disk_hooks
diff -r 9917a3f38fb7 -r cabf9a90cfcc sys/arch/evbppc/include/obs405.h
--- a/sys/arch/evbppc/include/obs405.h Mon Jan 24 16:57:32 2005 +0000
+++ b/sys/arch/evbppc/include/obs405.h Mon Jan 24 18:47:37 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: obs405.h,v 1.3 2005/01/21 19:24:11 shige Exp $ */
+/* $NetBSD: obs405.h,v 1.4 2005/01/24 18:47:37 shige Exp $ */
/*
* Copyright 2004 Shigeyuki Fukushima.
@@ -65,13 +65,31 @@
#include <dev/ic/comreg.h>
+/*
+ * Device Properties for OpenBlockS
+ */
+
+/* UART Clock */
#define OBS405_COM_FREQ (COM_FREQ * 4) /* UART CLK 7.3728 MHz */
+/* GPIO LED */
+/* XXX: support only OpenBlockS266 LED */
+#define OBS405_LED1 (1)
+#define OBS405_LED2 (2)
+#define OBS405_LED4 (4)
+#define OBS405_LED_ON (OBS405_LED1 | OBS405_LED2 | OBS405_LED4)
+#define OBS405_LED_OFF (~OBS405_LED1 & ~OBS405_LED2 & ~OBS405_LED4)
+
+#define OBS405_GPIO_LED1 (12)
+#define OBS405_GPIO_LED2 (13)
+#define OBS405_GPIO_LED4 (14)
+
/*
* extern variables and functions
*/
extern void obs405_consinit(void);
extern void obs405_cpu_startup(void);
extern void obs405_device_register(struct device *dev, void *aux);
+extern void obs405_led_set(int led);
#endif /* _EVBPPC_OBS405_H_ */
diff -r 9917a3f38fb7 -r cabf9a90cfcc sys/arch/evbppc/obs405/dev/obsled.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbppc/obs405/dev/obsled.c Mon Jan 24 18:47:37 2005 +0000
@@ -0,0 +1,111 @@
+/* $NetBSD: obsled.c,v 1.1 2005/01/24 18:47:37 shige Exp $ */
+
+/*
+ * Copyright (c) 2004 Shigeyuki Fukushima.
+ * 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. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. The name of the author 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 ``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 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: obsled.c,v 1.1 2005/01/24 18:47:37 shige Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/queue.h>
+#include <sys/systm.h>
+
+#include <machine/obs405.h>
+
+#include <powerpc/ibm4xx/dev/gpiovar.h>
+
+struct obsled_softc {
+ struct device sc_dev;
+ gpio_tag_t sc_tag;
+ int sc_addr;
+};
+
+static void obsled_attach(struct device *, struct device *, void *);
+static int obsled_match(struct device *, struct cfdata *, void *);
+
+CFATTACH_DECL(obsled, sizeof(struct obsled_softc),
+ obsled_match, obsled_attach, NULL, NULL);
+
+static int
+obsled_match(struct device *parent, struct cfdata *cf, void *aux)
+{
+ struct gpio_attach_args *ga = aux;
+
+ /* XXX: support only OpenBlockS266 LED */
+ if (ga->ga_addr == OBS405_GPIO_LED1)
+ return (1);
+ else if (ga->ga_addr == OBS405_GPIO_LED2)
+ return (1);
+ else if (ga->ga_addr == OBS405_GPIO_LED4)
+ return (1);
+
+ return (0);
+}
+
+static void
+obsled_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct obsled_softc *sc = (struct obsled_softc *)self;
+ struct gpio_attach_args *ga = aux;
+ int led = (1 << sc->sc_dev.dv_unit);
+
+ aprint_naive(": OpenBlockS LED%d\n", led);
+ aprint_normal(": OpenBlockS LED%d\n", led);
+
+ sc->sc_tag = ga->ga_tag;
+ sc->sc_addr = ga->ga_addr;
+
+ obs405_led_set(OBS405_LED_OFF);
+#if 0
+ {
+ gpio_tag_t tag = sc->sc_tag;
+ (*(tag)->io_or_write)((tag)->cookie, sc->sc_addr, 0);
+ }
+#endif
+}
+
+void
+obs405_led_set(int led)
+{
+ struct device *dp = NULL;
+ struct devicelist *dlp = &alldevs;
+
+ for (dp = TAILQ_FIRST(dlp); dp != NULL; dp = TAILQ_NEXT(dp, dv_list)) {
+ if (dp->dv_cfdata != NULL
+ && strcmp(dp->dv_cfdata->cf_name, "obsled") == 0) {
+ struct obsled_softc *sc = (struct obsled_softc *)dp;
+ gpio_tag_t tag = sc->sc_tag;
+ int bit = (led & (1 << dp->dv_unit)) >> dp->dv_unit;
+ (*(tag)->io_or_write)((tag)->cookie,
+ sc->sc_addr, (~bit & 1));
+ }
+ }
+}
diff -r 9917a3f38fb7 -r cabf9a90cfcc sys/arch/evbppc/obs405/md_machdep.c
--- a/sys/arch/evbppc/obs405/md_machdep.c Mon Jan 24 16:57:32 2005 +0000
+++ b/sys/arch/evbppc/obs405/md_machdep.c Mon Jan 24 18:47:37 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md_machdep.c,v 1.2 2005/01/21 19:24:11 shige Exp $ */
+/* $NetBSD: md_machdep.c,v 1.3 2005/01/24 18:47:37 shige Exp $ */
/* Original: machdep.c,v 1.3 2005/01/17 17:24:09 shige Exp $ */
/*
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md_machdep.c,v 1.2 2005/01/21 19:24:11 shige Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md_machdep.c,v 1.3 2005/01/24 18:47:37 shige Exp $");
#include "opt_compat_netbsd.h"
#include "opt_ddb.h"
@@ -212,6 +212,8 @@
static char str[256];
char *ap = str, *ap1 = ap;
+ obs405_led_set(OBS405_LED_ON);
+
boothowto = howto;
if (!cold && !(howto & RB_NOSYNC) && !syncing) {
syncing = 1;
@@ -233,7 +235,9 @@
if (howto & RB_HALT) {
printf("halted\n\n");
+#if 0
goto reboot; /* XXX for now... */
+#endif
#ifdef DDB
printf("dropping to debugger\n");
@@ -264,7 +268,9 @@
/* flush cache for msgbuf */
__syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE));
+#if 0
reboot:
+#endif
ppc4xx_reset();
printf("ppc4xx_reset() failed!\n");
Home |
Main Index |
Thread Index |
Old Index