diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-07-20 22:13:46 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-07-20 22:13:46 +0000 |
commit | f26a9fa12a59729d7234abc92315f872dc2bcd02 (patch) | |
tree | 1ca501ea5b1c9fcda63efdd72d33a925b0780b32 | |
parent | 6298f8081cdbdf58691888a6606e39839e69a499 (diff) |
Make lcd(4) "blink" when machdep.led_blink is set.
-rw-r--r-- | sys/arch/hppa/dev/lcd.c | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/sys/arch/hppa/dev/lcd.c b/sys/arch/hppa/dev/lcd.c index 0444c12aa8b..7e303170a2e 100644 --- a/sys/arch/hppa/dev/lcd.c +++ b/sys/arch/hppa/dev/lcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lcd.c,v 1.1 2007/07/15 20:11:12 kettenis Exp $ */ +/* $OpenBSD: lcd.c,v 1.2 2007/07/20 22:13:45 kettenis Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -20,9 +20,11 @@ #include <sys/device.h> #include <sys/kernel.h> #include <sys/systm.h> +#include <sys/timeout.h> #include <machine/autoconf.h> #include <machine/bus.h> +#include <machine/cpu.h> #include <machine/pdc.h> #define LCD_CLS 0x01 @@ -30,12 +32,17 @@ #define LCD_LOCATE(X, Y) (((Y) & 1 ? 0xc0 : 0x80) | ((X) & 0x0f)) struct lcd_softc { - struct device sc_dev; + struct device sc_dv; - bus_space_tag_t sc_iot; - bus_space_handle_t sc_cmdh, sc_datah; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_cmdh, sc_datah; - u_int sc_delay; + u_int sc_delay; + u_int8_t sc_heartbeat[3]; + + struct timeout sc_to; + int sc_on; + struct blink_led sc_blink; }; int lcd_match(struct device *, void *, void *); @@ -50,6 +57,8 @@ struct cfdriver lcd_cd = { }; void lcd_write(struct lcd_softc *, const char *); +void lcd_blink(void *, int); +void lcd_blink_finish(void *); int lcd_match(struct device *parent, void *match, void *aux) @@ -68,6 +77,7 @@ lcd_attach(struct device *parent, struct device *self, void *aux) struct lcd_softc *sc = (struct lcd_softc *)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, @@ -83,7 +93,11 @@ lcd_attach(struct device *parent, struct device *self, void *aux) 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); @@ -92,7 +106,11 @@ lcd_attach(struct device *parent, struct device *self, void *aux) delay(sc->sc_delay); lcd_write(sc, "OpenBSD/" MACHINE); - printf("\n"); + timeout_set(&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 @@ -103,3 +121,27 @@ lcd_write(struct lcd_softc *sc, const char *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]); + timeout_add(&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); +} |