int com_arbus_match(device_t parent, cfdata_t cf, void *aux) { struct arbus_attach_args *aa = aux; struct com_regs regs; int rv; if (strcmp(aa->aa_name, cf->cf_name) != 0) return 0; if (com_is_console(aa->aa_bst, aa->aa_addr, ®s.cr_ioh)) return 1; if (bus_space_map(aa->aa_bst, aa->aa_addr, aa->aa_size, 0, ®s.cr_ioh)) return 0; regs.cr_iot = aa->aa_bst; regs.cr_iobase = aa->aa_addr; regs.cr_nports = aa->aa_size; com_arbus_initmap(®s); rv = com_probe_subr(®s); bus_space_unmap(aa->aa_bst, regs.cr_ioh, aa->aa_size); return rv; }
STATIC void hd64461uart_attach(device_t parent, device_t self, void *aux) { struct hd64461_attach_args *ha = aux; struct hd64461uart_softc *sc = device_private(self); struct com_softc *csc = &sc->sc_com; uint16_t r16, or16; bus_space_handle_t ioh; csc->sc_dev = self; sc->sc_chip = &hd64461uart_chip; sc->sc_module_id = ha->ha_module_id; if (!sc->sc_chip->console) hd64461uart_init(); bus_space_map(sc->sc_chip->io_tag, 0x0, 8, 0, &ioh); csc->sc_frequency = COM_FREQ; HD64461UART_INIT_REGS(csc->sc_regs, sc->sc_chip->io_tag, ioh, 0x0); /* switch port to UART */ /* supply clock */ r16 = or16 = hd64461_reg_read_2(HD64461_SYSSTBCR_REG16); r16 &= ~HD64461_SYSSTBCR_SURTSD; if (platid_match(&platid, &platid_mask_MACH_HITACHI_PERSONA)) r16 &= ~(HD64461_SYSSTBCR_SAFECKE_IST | HD64461_SYSSTBCR_SAFECKE_OST); hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, r16); /* sanity check */ if (!com_probe_subr(&csc->sc_regs)) { aprint_error(": device problem. don't attach.\n"); /* restore old clock */ hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, or16); return; } com_attach_subr(csc); hd6446x_intr_establish(HD64461_INTC_UART, IST_LEVEL, IPL_TTY, comintr, csc); }
void com_pnpbios_attach(device_t parent, device_t self, void *aux) { struct com_pnpbios_softc *psc = device_private(self); struct com_softc *sc = &psc->sc_com; struct pnpbiosdev_attach_args *aa = aux; bus_space_tag_t iot; bus_space_handle_t ioh; int iobase; sc->sc_dev = self; if (pnpbios_getiobase(aa->pbt, aa->resc, 0, &iot, &iobase)) { aprint_error(": can't get iobase\n"); return; } if ((!com_is_console(iot, iobase, &ioh)) && pnpbios_io_map(aa->pbt, aa->resc, 0, &iot, &ioh)) { aprint_error(": can't map i/o space\n"); return; } COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase); aprint_normal("\n"); pnpbios_print_devres(self, aa); aprint_normal("%s", device_xname(self)); /* * if the chip isn't something we recognise skip it. */ if (com_probe_subr(&sc->sc_regs) == 0) { aprint_error(": com probe failed\n"); return; } sc->sc_frequency = 115200 * 16; com_attach_subr(sc); psc->sc_ih = pnpbios_intr_establish(aa->pbt, aa->resc, 0, IPL_SERIAL, comintr, sc); }
void hd64465uart_attach(device_t parent, device_t self, void *aux) { struct hd64465_attach_args *ha = aux; struct hd64465uart_softc *sc = device_private(self); struct com_softc *csc = &sc->sc_com; bus_space_handle_t ioh; csc->sc_dev = self; sc->sc_chip = &hd64465uart_chip; sc->sc_module_id = ha->ha_module_id; if (!sc->sc_chip->console) hd64465uart_init(); bus_space_map(sc->sc_chip->io_tag, 0, 8, 0, &ioh); COM_INIT_REGS(csc->sc_regs, sc->sc_chip->io_tag, ioh, 0); csc->sc_frequency = COM_FREQ; /* supply clock XXX notyet */ /* sanity check */ if (!com_probe_subr(&csc->sc_regs)) { aprint_error(": device problem. don't attach.\n"); /* stop clock XXX notyet */ return; } com_attach_subr(csc); /* register interrupt handler */ hd64465_intr_establish(HD64465_UART, IST_LEVEL, IPL_TTY, comintr, self); }
static void com_obio_attach(device_t parent, device_t self, void *aux) { struct com_obio_softc *osc = device_private(self); struct com_softc *sc = &osc->osc_com; union obio_attach_args *uoba = aux; struct sbus_attach_args *sa = &uoba->uoba_sbus; bus_space_handle_t ioh; bus_space_tag_t iot; bus_addr_t iobase; sc->sc_dev = self; if (strcmp("modem", sa->sa_name) == 0) { osc->osc_tadpole = 1; } /* * We're living on an obio that looks like an sbus slot. */ iot = sa->sa_bustag; iobase = sa->sa_offset; sc->sc_frequency = COM_FREQ; /* * XXX: It would be nice to be able to split console input and * output to different devices. For now switch to serial * console if PROM stdin is on serial (so that we can use DDB). */ if (prom_instance_to_package(prom_stdin()) == sa->sa_node) comcnattach(iot, iobase, B9600, sc->sc_frequency, COM_TYPE_NORMAL, (CLOCAL | CREAD | CS8)); if (!com_is_console(iot, iobase, &ioh) && sbus_bus_map(iot, sa->sa_slot, iobase, sa->sa_size, BUS_SPACE_MAP_LINEAR, &ioh) != 0) { aprint_error(": can't map registers\n"); return; } COM_INIT_REGS(sc->sc_regs, iot, ioh, iobase); if (osc->osc_tadpole) { *AUXIO4M_REG |= (AUXIO4M_LED|AUXIO4M_LTE); do { DELAY(100); } while (!com_probe_subr(&sc->sc_regs)); #if 0 printf("modem: attach: lcr=0x%02x iir=0x%02x\n", bus_space_read_1(sc->sc_regs.iot, sc->sc_regs.ioh, 3), bus_space_read_1(sc->sc_regs.iot, sc->sc_regs.ioh, 2)); #endif } com_attach_subr(sc); if (sa->sa_nintr != 0) { (void)bus_intr_establish(sc->sc_regs.cr_iot, sa->sa_pri, IPL_SERIAL, comintr, sc); evcnt_attach_dynamic(&osc->osc_intrcnt, EVCNT_TYPE_INTR, NULL, device_xname(self), "intr"); } if (!pmf_device_register1(self, com_suspend, com_resume, com_cleanup)) { aprint_error_dev(self, "could not establish shutdown hook"); } }