Index: sys/arch/hp700/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/conf/GENERIC,v retrieving revision 1.99 diff -u -r1.99 GENERIC --- sys/arch/hp700/conf/GENERIC 8 May 2010 22:16:27 -0000 1.99 +++ sys/arch/hp700/conf/GENERIC 31 May 2010 21:17:43 -0000 @@ -226,6 +226,7 @@ # Miscellaneous pdc0 at mainbus0 # PDC/IODC wrapper for boot console power0 at mainbus0 # power/fail manager +lcd0 at mainbus0 # LCD # STI graphics sti* at mainbus0 # [H]CRX-{8,24,48}[Z] and Visualize graphics Index: sys/arch/hp700/conf/files.hp700 =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/conf/files.hp700,v retrieving revision 1.22 diff -u -r1.22 files.hp700 --- sys/arch/hp700/conf/files.hp700 28 May 2009 08:41:29 -0000 1.22 +++ sys/arch/hp700/conf/files.hp700 31 May 2010 21:17:43 -0000 @@ -77,6 +77,10 @@ attach power at gedoens file arch/hp700/dev/power.c power needs-flag +device lcd +attach lcd at gedoens +file arch/hp700/dev/lcd.c lcd needs-flag + device mem attach mem at gedoens file arch/hp700/dev/mem.c mem Index: sys/arch/hp700/dev/lcd.c =================================================================== RCS file: sys/arch/hp700/dev/lcd.c diff -N sys/arch/hp700/dev/lcd.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/arch/hp700/dev/lcd.c 31 May 2010 21:17:43 -0000 @@ -0,0 +1,145 @@ +/* $NetBSD$ */ +/* $OpenBSD: lcd.c,v 1.2 2007/07/20 22:13:45 kettenis Exp $ */ + +/* + * Copyright (c) 2007 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define LCD_CLS 0x01 +#define LCD_HOME 0x02 +#define LCD_LOCATE(X, Y) (((Y) & 1 ? 0xc0 : 0x80) | ((X) & 0x0f)) + +struct lcd_softc { + struct device sc_dv; + + bus_space_tag_t sc_iot; + bus_space_handle_t sc_cmdh, sc_datah; + + u_int sc_delay; + u_int8_t sc_heartbeat[3]; + + struct callout sc_to; + int sc_on; + struct blink_led sc_blink; +}; + +int lcd_match(device_t, cfdata_t, void *); +void lcd_attach(device_t, device_t, void *); + +CFATTACH_DECL(lcd, sizeof(struct lcd_softc), lcd_match, + lcd_attach, NULL, NULL); + +void lcd_write(struct lcd_softc *, const char *); +void lcd_blink(void *, int); +void lcd_blink_finish(void *); + +int +lcd_match(device_t parent, cfdata_t match, void *aux) +{ + struct confargs *ca = aux; + + if (strcmp(ca->ca_name, "lcd") == 0) + return (1); + + return (0); +} + +void +lcd_attach(device_t parent, device_t self, void *aux) +{ + struct lcd_softc *sc = device_private(self); + struct confargs *ca = aux; + struct pdc_chassis_lcd *pdc_lcd = (void *)ca->ca_pdc_iodc_read; + int i; + + sc->sc_iot = ca->ca_iot; + + if (bus_space_map(sc->sc_iot, pdc_lcd->cmd_addr, + 1, 0, &sc->sc_cmdh)) { + printf(": cannot map cmd register\n"); + return; + } + + if (bus_space_map(sc->sc_iot, pdc_lcd->data_addr, + 1, 0, &sc->sc_datah)) { + printf(": cannot map data register\n"); + bus_space_unmap(sc->sc_iot, sc->sc_cmdh, 1); + return; + } + + printf(": model %d\n", pdc_lcd->model); + + sc->sc_delay = pdc_lcd->delay; + for (i = 0; i < 3; i++) + sc->sc_heartbeat[i] = pdc_lcd->heartbeat[i]; + + bus_space_write_1(sc->sc_iot, sc->sc_cmdh, 0, LCD_CLS); + delay(100 * sc->sc_delay); + + bus_space_write_1(sc->sc_iot, sc->sc_cmdh, 0, LCD_LOCATE(0, 0)); + delay(sc->sc_delay); + lcd_write(sc, "NetBSD/" MACHINE); + + callout_init(&sc->sc_to, 0); + callout_setfunc(&sc->sc_to, lcd_blink_finish, sc); + + sc->sc_blink.bl_func = lcd_blink; + sc->sc_blink.bl_arg = sc; + blink_led_register(&sc->sc_blink); +} + +void +lcd_write(struct lcd_softc *sc, const char *str) +{ + while (*str) { + bus_space_write_1(sc->sc_iot, sc->sc_datah, 0, *str++); + delay(sc->sc_delay); + } +} + +void +lcd_blink(void *v, int on) +{ + struct lcd_softc *sc = v; + + sc->sc_on = on; + bus_space_write_1(sc->sc_iot, sc->sc_cmdh, 0, sc->sc_heartbeat[0]); + callout_schedule(&sc->sc_to, max(1, (sc->sc_delay * hz) / 1000000)); +} + +void +lcd_blink_finish(void *v) +{ + struct lcd_softc *sc = v; + u_int8_t data; + + if (sc->sc_on) + data = sc->sc_heartbeat[1]; + else + data = sc->sc_heartbeat[2]; + + bus_space_write_1(sc->sc_iot, sc->sc_datah, 0, data); +} Index: sys/arch/hp700/hp700/machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/hp700/machdep.c,v retrieving revision 1.84 diff -u -r1.84 machdep.c --- sys/arch/hp700/hp700/machdep.c 30 Apr 2010 15:36:45 -0000 1.84 +++ sys/arch/hp700/hp700/machdep.c 31 May 2010 21:17:44 -0000 @@ -130,6 +130,7 @@ #endif #include "ksyms.h" +#include "lcd.h" /* * Different kinds of flags used throughout the kernel. @@ -205,6 +206,10 @@ int cpu_hvers; int cpu_revision; +#if NLCD > 0 +int led_blink; +#endif + /* * exported methods for cpus */ @@ -265,6 +270,9 @@ void dumpsys(void); void cpuid(void); enum hppa_cpu_type cpu_model_cpuid(int); +#if NLCD > 0 +void blink_led_timeout(void *); +#endif /* * wide used hardware params @@ -1910,6 +1918,29 @@ return (sysctl_lookup(SYSCTLFN_CALL(&node))); } +#if NLCD > 0 +static int +sysctl_machdep_heartbeat(SYSCTLFN_ARGS) +{ + int oldval, error; + struct sysctlnode node = *rnode; + + oldval = led_blink; + /* + * If we were false and are now true, start the timer. + */ + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + + if (error || newp == NULL) + return (error); + + if (!oldval && led_blink > oldval) + blink_led_timeout(NULL); + + return (0); +} +#endif + /* * machine dependent system variables. */ @@ -1933,6 +1964,13 @@ CTLTYPE_STRING, "booted_kernel", NULL, sysctl_machdep_boot, 0, NULL, 0, CTL_MACHDEP, CPU_BOOTED_KERNEL, CTL_EOL); +#if NLCD > 0 + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_BOOL, "heartbeat", "Display heartbeat on the LCD display", + sysctl_machdep_heartbeat, 0, &led_blink, 0, + CTL_MACHDEP, CPU_LED_BLINK, CTL_EOL); +#endif } /* @@ -1973,6 +2011,56 @@ } } +#if NLCD > 0 +struct blink_led_softc { + SLIST_HEAD(, blink_led) bls_head; + int bls_on; + struct callout bls_to; +} blink_sc = { SLIST_HEAD_INITIALIZER(bls_head), 0 }; + +void +blink_led_register(struct blink_led *l) +{ + if (SLIST_EMPTY(&blink_sc.bls_head)) { + callout_init(&blink_sc.bls_to, 0); + callout_setfunc(&blink_sc.bls_to, blink_led_timeout, &blink_sc); + blink_sc.bls_on = 0; + if (led_blink) + callout_schedule(&blink_sc.bls_to, 1); + } + SLIST_INSERT_HEAD(&blink_sc.bls_head, l, bl_next); +} + +void +blink_led_timeout(void *vsc) +{ + struct blink_led_softc *sc = &blink_sc; + struct blink_led *l; + int t; + + if (SLIST_EMPTY(&sc->bls_head)) + return; + + SLIST_FOREACH(l, &sc->bls_head, bl_next) { + (*l->bl_func)(l->bl_arg, sc->bls_on); + } + sc->bls_on = !sc->bls_on; + + if (!led_blink) + return; + + /* + * Blink rate is: + * full cycle every second if completely idle (loadav = 0) + * full cycle every 2 seconds if loadav = 1 + * full cycle every 3 seconds if loadav = 2 + * etc. + */ + t = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1)); + callout_schedule(&sc->bls_to, t); +} +#endif + #ifdef MODULAR /* * Push any modules loaded by the boot loader. Index: sys/arch/hp700/hp700/mainbus.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/hp700/mainbus.c,v retrieving revision 1.69 diff -u -r1.69 mainbus.c --- sys/arch/hp700/hp700/mainbus.c 30 Apr 2010 15:49:40 -0000 1.69 +++ sys/arch/hp700/hp700/mainbus.c 31 May 2010 21:17:48 -0000 @@ -62,6 +62,7 @@ #include "locators.h" #include "power.h" +#include "lcd.h" #include #include @@ -82,6 +83,10 @@ #include static struct pdc_hpa pdc_hpa PDC_ALIGNMENT; +#if NLCD > 0 +static struct pdc_chassis_info pdc_chassis_info PDC_ALIGNMENT; +static struct pdc_chassis_lcd pdc_chassis_lcd PDC_ALIGNMENT; +#endif #ifdef MBUSDEBUG @@ -1405,6 +1410,21 @@ config_found(self, &nca, mbprint); #endif +#if NLCD > 0 + if (!pdc_call((iodcio_t)pdc, 0, PDC_CHASSIS, PDC_CHASSIS_INFO, + &pdc_chassis_info, &pdc_chassis_lcd, sizeof(pdc_chassis_lcd)) && + pdc_chassis_lcd.enabled) { + memset(&nca, 0, sizeof(nca)); + nca.ca_name = "lcd"; + nca.ca_irq = -1; + nca.ca_iot = &hppa_bustag; + nca.ca_hpa = pdc_chassis_lcd.cmd_addr; + nca.ca_pdc_iodc_read = (void *)&pdc_chassis_lcd; + + config_found(self, &nca, mbprint); + } +#endif + switch (cpu_hvers) { case HPPA_BOARD_HP809: case HPPA_BOARD_HP819: Index: sys/arch/hp700/include/cpu.h =================================================================== RCS file: /cvsroot/src/sys/arch/hp700/include/cpu.h,v retrieving revision 1.46 diff -u -r1.46 cpu.h --- sys/arch/hp700/include/cpu.h 26 Apr 2010 15:25:24 -0000 1.46 +++ sys/arch/hp700/include/cpu.h 31 May 2010 21:17:49 -0000 @@ -322,8 +322,20 @@ */ #define CPU_CONSDEV 1 /* dev_t: console terminal device */ #define CPU_BOOTED_KERNEL 2 /* string: booted kernel name */ -#define CPU_MAXID 3 /* number of valid machdep ids */ +#define CPU_LED_BLINK 3 /* int: twiddle heartbeat LED/LCD */ +#define CPU_MAXID 4 /* number of valid machdep ids */ +#ifdef _KERNEL +#include + +struct blink_led { + void (*bl_func)(void *, int); + void *bl_arg; + SLIST_ENTRY(blink_led) bl_next; +}; + +extern void blink_led_register(struct blink_led *); +#endif /* _KERNEL */ #endif /* !_LOCORE */ #endif /* _MACHINE_CPU_H_ */