uint32_t ofw_pci_read_config_common(device_t dev, u_int regmax, u_long offset, u_int bus, u_int slot, u_int func, u_int reg, int width) { struct ofw_pci_softc *sc; bus_space_handle_t bh; uint32_t r, wrd; int i; uint16_t shrt; uint8_t byte; sc = device_get_softc(dev); if (bus < sc->sc_pci_secbus || bus > sc->sc_pci_subbus || slot > PCI_SLOTMAX || func > PCI_FUNCMAX || reg > regmax) return (-1); bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG]; switch (width) { case 1: i = bus_space_peek_1(sc->sc_pci_cfgt, bh, offset, &byte); r = byte; break; case 2: i = bus_space_peek_2(sc->sc_pci_cfgt, bh, offset, &shrt); r = shrt; break; case 4: i = bus_space_peek_4(sc->sc_pci_cfgt, bh, offset, &wrd); r = wrd; break; default: panic("%s: bad width %d", __func__, width); /* NOTREACHED */ } if (i) { #ifdef OFW_PCI_DEBUG printf("%s: read data error reading: %d.%d.%d: 0x%x\n", __func__, bus, slot, func, reg); #endif r = -1; } return (r); }
int vmetwo_probe(bus_space_tag_t bt, bus_addr_t offset) { bus_space_handle_t bh; bus_space_map(bt, offset + VME2REG_LCSR_OFFSET, VME2LCSR_SIZE, 0, &bh); if (bus_space_peek_4(bt, bh, VME2LCSR_MISC_STATUS, NULL) != 0) { #if defined(MVME162) || defined(MVME172) #if defined(MVME167) || defined(MVME177) if (machineid == MVME_162 || machineid == MVME_172) #endif { /* * No VMEChip2 on mvme162/172 is not too big a * deal; we can fall back on timer4 in the * mcchip for h/w assisted soft interrupts... */ extern void pcctwosoftintrinit(void); bus_space_unmap(bt, bh, VME2LCSR_SIZE); vmetwo_not_present = 1; pcctwosoftintrinit(); return (0); } #endif #if defined(MVME167) || defined(MVME177) || defined(MVME88K) /* * No VMEChip2 on mvme167/177, however, is a Big Deal. * In fact, it means the hardware's shot since the * VMEChip2 is not a `build-option' on those boards. */ panic("VMEChip2 not responding! Faulty board?"); /* NOTREACHED */ #endif #if defined(MVMEPPC) /* * No VMEChip2 on mvmeppc is no big deal. */ bus_space_unmap(bt, bh, VME2LCSR_SIZE); vmetwo_not_present = 1; return (0); #endif } #if NVMETWO == 0 else { /* * The kernel config file has no `vmetwo0' device, but * there is a VMEChip2 on the board. Fix up things * just enough to hook VMEChip2 local interrupts. */ struct vmetwo_softc *sc; /* XXX Should check sc != NULL here... */ sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); sc->sc_mvmebus.sc_bust = bt; sc->sc_lcrh = bh; vmetwo_intr_init(sc); return 0; } #else bus_space_unmap(bt, bh, VME2LCSR_SIZE); return (1); #endif }