diff options
-rw-r--r-- | sys/arch/hppa/conf/files.hppa | 6 | ||||
-rw-r--r-- | sys/arch/hppa/dev/lcd.c | 105 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/mainbus.c | 28 |
3 files changed, 134 insertions, 5 deletions
diff --git a/sys/arch/hppa/conf/files.hppa b/sys/arch/hppa/conf/files.hppa index aa2dc90202d..25585478f21 100644 --- a/sys/arch/hppa/conf/files.hppa +++ b/sys/arch/hppa/conf/files.hppa @@ -1,4 +1,4 @@ -# $OpenBSD: files.hppa,v 1.70 2007/07/15 19:25:49 kettenis Exp $ +# $OpenBSD: files.hppa,v 1.71 2007/07/15 20:11:12 kettenis Exp $ # # hppa-specific configuration info @@ -105,6 +105,10 @@ device power attach power at gedoens file arch/hppa/dev/power.c power needs-flag +device lcd +attach lcd at gedoens +file arch/hppa/dev/lcd.c lcd needs-flag + device mem attach mem at gedoens file arch/hppa/dev/mem.c mem diff --git a/sys/arch/hppa/dev/lcd.c b/sys/arch/hppa/dev/lcd.c new file mode 100644 index 00000000000..0444c12aa8b --- /dev/null +++ b/sys/arch/hppa/dev/lcd.c @@ -0,0 +1,105 @@ +/* $OpenBSD: lcd.c,v 1.1 2007/07/15 20:11:12 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 <sys/param.h> +#include <sys/device.h> +#include <sys/kernel.h> +#include <sys/systm.h> + +#include <machine/autoconf.h> +#include <machine/bus.h> +#include <machine/pdc.h> + +#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_dev; + + bus_space_tag_t sc_iot; + bus_space_handle_t sc_cmdh, sc_datah; + + u_int sc_delay; +}; + +int lcd_match(struct device *, void *, void *); +void lcd_attach(struct device *, struct device *, void *); + +struct cfattach lcd_ca = { + sizeof(struct lcd_softc), lcd_match, lcd_attach +}; + +struct cfdriver lcd_cd = { + NULL, "lcd", DV_DULL +}; + +void lcd_write(struct lcd_softc *, const char *); + +int +lcd_match(struct device *parent, void *match, void *aux) +{ + struct confargs *ca = aux; + + if (strcmp(ca->ca_name, "lcd") == 0) + return (1); + + return (0); +} + +void +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; + + 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; + } + + sc->sc_delay = pdc_lcd->delay; + + 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, "OpenBSD/" MACHINE); + + printf("\n"); +} + +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); + } +} diff --git a/sys/arch/hppa/hppa/mainbus.c b/sys/arch/hppa/hppa/mainbus.c index 8bdc954fa84..f828a035190 100644 --- a/sys/arch/hppa/hppa/mainbus.c +++ b/sys/arch/hppa/hppa/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.65 2007/05/29 21:00:50 jason Exp $ */ +/* $OpenBSD: mainbus.c,v 1.66 2007/07/15 20:11:12 kettenis Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -26,6 +26,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include "lcd.h" #include "power.h" #undef BTLBDEBUG @@ -40,6 +41,7 @@ #include <uvm/uvm.h> #include <uvm/uvm_page.h> +#include <machine/bus.h> #include <machine/pdc.h> #include <machine/iomod.h> #include <machine/autoconf.h> @@ -65,6 +67,8 @@ struct cfdriver mainbus_cd = { struct pdc_hpa pdc_hpa PDC_ALIGNMENT; struct pdc_power_info pdc_power_info PDC_ALIGNMENT; +struct pdc_chassis_info pdc_chassis_info PDC_ALIGNMENT; +struct pdc_chassis_lcd pdc_chassis_lcd PDC_ALIGNMENT; /* from machdep.c */ extern struct extent *hppa_ex; @@ -1031,7 +1035,7 @@ mbattach(parent, self, aux) sc->sc_hpa = pdc_hpa.hpa; /* PDC first */ - bzero (&nca, sizeof(nca)); + bzero(&nca, sizeof(nca)); nca.ca_name = "pdc"; nca.ca_iot = &hppa_bustag; nca.ca_dmatag = &hppa_dmatag; @@ -1039,7 +1043,7 @@ mbattach(parent, self, aux) #if NPOWER > 0 /* get some power */ - bzero (&nca, sizeof(nca)); + bzero(&nca, sizeof(nca)); nca.ca_name = "power"; nca.ca_irq = -1; if (!pdc_call((iodcio_t)pdc, 0, PDC_SOFT_POWER, @@ -1051,7 +1055,23 @@ mbattach(parent, self, aux) config_found(self, &nca, mbprint); #endif - bzero (&nca, sizeof(nca)); +#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) { + bzero(&nca, 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_hpamask = HPPA_IOBEGIN; + nca.ca_pdc_iodc_read = (void *)&pdc_chassis_lcd; + + config_found(self, &nca, mbprint); + } +#endif + + bzero(&nca, sizeof(nca)); nca.ca_hpa = 0; nca.ca_irq = -1; nca.ca_hpamask = HPPA_IOBEGIN; |