static void panel_attach(device_t parent, device_t self, void *aux) { struct panel_softc *sc = device_private(self); struct mainbus_attach_args *maa = aux; struct hd44780_io io; static struct lcdkp_xlate keys[] = { { 0xfa, 'h' }, { 0xf6, 'k' }, { 0xde, 'l' }, { 0xee, 'j' }, { 0x7e, 's' }, { 0xbe, 'e' } }; sc->sc_lcd.sc_dev = self; sc->sc_lcd.sc_iot = maa->ma_iot; if (bus_space_map(sc->sc_lcd.sc_iot, maa->ma_addr, PANEL_REGION, 0, &sc->sc_lcd.sc_ioir)) { aprint_error(": unable to map registers\n"); return; } bus_space_subregion(sc->sc_lcd.sc_iot, sc->sc_lcd.sc_ioir, DATA_OFFSET, 1, &sc->sc_lcd.sc_iodr); printf("\n"); sc->sc_lcd.sc_dev_ok = 1; sc->sc_lcd.sc_cols = PANEL_COLS; sc->sc_lcd.sc_vcols = PANEL_VCOLS; sc->sc_lcd.sc_flags = HD_8BIT | HD_MULTILINE | HD_KEYPAD; sc->sc_lcd.sc_writereg = panel_cbt_hdwritereg; sc->sc_lcd.sc_readreg = panel_cbt_hdreadreg; hd44780_attach_subr(&sc->sc_lcd); /* Hello World */ io.dat = 0; io.len = PANEL_VCOLS * PANEL_ROWS; memcpy(io.buf, &startup_message, io.len); hd44780_ddram_io(&sc->sc_lcd, sc->sc_lcd.sc_curchip, &io, HD_DDRAM_WRITE); pmf_device_register1(self, NULL, NULL, panel_shutdown); sc->sc_kp.sc_iot = maa->ma_iot; sc->sc_kp.sc_ioh = MIPS_PHYS_TO_KSEG1(PANEL_BASE); /* XXX */ sc->sc_kp.sc_knum = sizeof(keys) / sizeof(struct lcdkp_xlate); sc->sc_kp.sc_kpad = keys; sc->sc_kp.sc_rread = panel_cbt_kprread; lcdkp_attach_subr(&sc->sc_kp); callout_init(&sc->sc_callout, 0); selinit(&sc->sc_selq); }
static void panel_shutdown(void *arg) { struct panel_softc *sc = arg; struct hd44780_io io; /* Goodbye World */ io.dat = 0; io.len = PANEL_VCOLS * PANEL_ROWS; memcpy(io.buf, &shutdown_message, io.len); hd44780_ddram_io(&sc->sc_lcd, sc->sc_lcd.sc_curchip, &io, HD_DDRAM_WRITE); }
static bool panel_shutdown(device_t self, int howto) { struct panel_softc *sc = device_private(self); struct hd44780_io io; /* Goodbye World */ io.dat = 0; io.len = PANEL_VCOLS * PANEL_ROWS; if (howto & RB_HALT) memcpy(io.buf, &halt_message, io.len); else memcpy(io.buf, &reboot_message, io.len); hd44780_ddram_io(&sc->sc_lcd, sc->sc_lcd.sc_curchip, &io, HD_DDRAM_WRITE); return true; }