diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-10-31 00:20:48 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-10-31 00:20:48 +0000 |
commit | 02fab4817aacc24a79a7b5eb0146d3355922638c (patch) | |
tree | 92418c92967fc9f9c64c41bdabc65f0ce7fc0dc0 /sys/arch/sgi | |
parent | e195bae85004d9f4b23c726c5602edbdbc22eabe (diff) |
Blinkenlichten on Octane.
Diffstat (limited to 'sys/arch/sgi')
-rw-r--r-- | sys/arch/sgi/sgi/ip30.h | 6 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/ip30_machdep.c | 40 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/xheart.c | 8 |
3 files changed, 46 insertions, 8 deletions
diff --git a/sys/arch/sgi/sgi/ip30.h b/sys/arch/sgi/sgi/ip30.h index 9013b8f5d85..e9f2c6f2e4b 100644 --- a/sys/arch/sgi/sgi/ip30.h +++ b/sys/arch/sgi/sgi/ip30.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip30.h,v 1.4 2009/10/30 08:13:57 syuu Exp $ */ +/* $OpenBSD: ip30.h,v 1.5 2009/10/31 00:20:46 miod Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -38,8 +38,8 @@ * On-board IOC3 specific GPIO registers wiring */ -/* LED bar control: 0 to dim, 1 to lit */ -#define IP30_GPIO_WHITE_LED 0 +/* Light bar control: 0 to dim, 1 to lit */ +#define IP30_GPIO_WHITE_LED 0 /* actually lightbulbs */ #define IP30_GPIO_RED_LED 1 /* Classic Octane (1) vs Octane 2 (0), read only */ #define IP30_GPIO_CLASSIC 2 diff --git a/sys/arch/sgi/sgi/ip30_machdep.c b/sys/arch/sgi/sgi/ip30_machdep.c index 2708b6d6baa..b6c7b897802 100644 --- a/sys/arch/sgi/sgi/ip30_machdep.c +++ b/sys/arch/sgi/sgi/ip30_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip30_machdep.c,v 1.14 2009/10/30 08:13:57 syuu Exp $ */ +/* $OpenBSD: ip30_machdep.c,v 1.15 2009/10/31 00:20:46 miod Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -47,11 +47,14 @@ extern char *hw_prod; extern int mbprint(void *, const char *); +uint32_t ip30_lights_frob(uint32_t, struct trap_frame *); paddr_t ip30_widget_short(int16_t, u_int); paddr_t ip30_widget_long(int16_t, u_int); paddr_t ip30_widget_map(int16_t, u_int, bus_addr_t *, bus_size_t *); int ip30_widget_id(int16_t, u_int, uint32_t *); +static paddr_t ip30_iocbase; + #ifdef MULTIPROCESSOR static const paddr_t mpconf = PHYS_TO_XKPHYS(MPCONF_BASE, CCA_COHERENT_EXCLWRITE); @@ -68,7 +71,6 @@ ip30_setup() uint32_t memcfg; uint64_t start, count; #endif - paddr_t iocbase; u_long cpuspeed; /* @@ -142,8 +144,9 @@ ip30_setup() * Octane and Octane2 can be told apart with a GPIO source bit * in the onboard IOC3. */ - iocbase = ip30_widget_short(0, 15) + 0x500000; - if (*(volatile uint32_t *)(iocbase + IOC3_GPPR(IP30_GPIO_CLASSIC)) != 0) + ip30_iocbase = sys_config.console_io.bus_base + 0x500000; + if (*(volatile uint32_t *) + (ip30_iocbase + IOC3_GPPR(IP30_GPIO_CLASSIC)) != 0) hw_prod = "Octane"; else hw_prod = "Octane2"; @@ -235,6 +238,35 @@ ip30_widget_id(int16_t nasid, u_int widget, uint32_t *wid) return 0; } +/* + * Fun with the lightbar + */ +uint32_t +ip30_lights_frob(uint32_t hwpend, struct trap_frame *cf) +{ + uint32_t gpioold, gpio; + + /* Light bar status: idle - white, user - red, system - both */ + + gpio = gpioold = *(volatile uint32_t *)(ip30_iocbase + IOC3_GPDR); + gpio &= ~((1 << IP30_GPIO_WHITE_LED) | (1 << IP30_GPIO_RED_LED)); + + if (cf->sr & SR_KSU_USER) + gpio |= (1 << IP30_GPIO_RED_LED); + else { + gpio |= (1 << IP30_GPIO_WHITE_LED); + + /* XXX SMP check other CPU is unidle */ + if (curproc != curcpu()->ci_schedstate.spc_idleproc) + gpio |= (1 << IP30_GPIO_RED_LED); + } + + if (gpio != gpioold) + *(volatile uint32_t *)(ip30_iocbase + IOC3_GPDR) = gpio; + + return 0; /* Real clock int handler will claim the interrupt. */ +} + #ifdef MULTIPROCESSOR static int ip30_cpu_exists(int cpuid) diff --git a/sys/arch/sgi/xbow/xheart.c b/sys/arch/sgi/xbow/xheart.c index abdff45dc6f..07a11015b31 100644 --- a/sys/arch/sgi/xbow/xheart.c +++ b/sys/arch/sgi/xbow/xheart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xheart.c,v 1.14 2009/10/26 18:11:27 miod Exp $ */ +/* $OpenBSD: xheart.c,v 1.15 2009/10/31 00:20:47 miod Exp $ */ /* * Copyright (c) 2008 Miodrag Vallat. @@ -73,6 +73,8 @@ void xheart_intr_makemasks(void); void xheart_setintrmask(int); void xheart_splx(int); +extern uint32_t ip30_lights_frob(uint32_t, struct trap_frame *); + /* * HEART interrupt handling declarations: 64 sources; 5 levels. */ @@ -89,6 +91,7 @@ struct intrhand *xheart_intrhand[HEART_NINTS]; #define INTPRI_HEART_2 (INTPRI_CLOCK + 1) #define INTPRI_HEART_0 (INTPRI_HEART_2 + 1) #endif +#define INTPRI_HEART_LEDS (INTPRI_HEART_0 + 1) uint64_t xheart_intem; uint64_t xheart_imask[NIPLS]; @@ -163,6 +166,9 @@ xheart_attach(struct device *parent, struct device *self, void *aux) set_intr(INTPRI_HEART_1, CR_INT_1, xheart_intr_handler); #endif set_intr(INTPRI_HEART_0, CR_INT_0, xheart_intr_handler); + + set_intr(INTPRI_HEART_LEDS, CR_INT_5, ip30_lights_frob); + register_splx_handler(xheart_splx); } } |