/* * Install interface into kernel networking data structures */ static void sn_obio_attach(struct device *parent, struct device *self, void *aux) { struct obio_attach_args *oa = (struct obio_attach_args *)aux; struct sn_softc *sc = (void *)self; u_int8_t myaddr[ETHER_ADDR_LEN]; int i; sc->snr_dcr = DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->slotno = 9; switch (current_mac_model->machineid) { case MACH_MACC610: case MACH_MACC650: case MACH_MACQ610: case MACH_MACQ650: case MACH_MACQ700: case MACH_MACQ800: case MACH_MACQ900: case MACH_MACQ950: sc->snr_dcr |= DCR_EXBUS; sc->bitmode = 1; break; case MACH_MACLC575: case MACH_MACP580: case MACH_MACQ630: break; case MACH_MACPB500: sc->snr_dcr |= DCR_SYNC | DCR_LBR; sc->bitmode = 0; /* 16 bit interface */ break; default: printf(": unsupported machine type\n"); return; } sc->sc_regt = oa->oa_tag; if (bus_space_map(sc->sc_regt, SONIC_REG_BASE, SN_REGSIZE, 0, &sc->sc_regh)) { printf(": failed to map space for SONIC regs.\n"); return; } /* regs are addressed as words, big-endian. */ for (i = 0; i < SN_NREGS; i++) { sc->sc_reg_map[i] = (bus_size_t)((i * 4) + 2); } /* * Kind of kludge this. Comm-slot cards do not really * have a visible type, as far as I can tell at this time, * so assume that MacOS had it properly configured and use * that configuration. */ switch (current_mac_model->machineid) { case MACH_MACLC575: case MACH_MACP580: case MACH_MACQ630: NIC_PUT(sc, SNR_CR, CR_RST); wbflush(); i = NIC_GET(sc, SNR_DCR); sc->snr_dcr |= (i & 0xfff0); sc->bitmode = (i & DCR_DW) ? 1 : 0; break; default: break; } if (sn_obio_getaddr(sc, myaddr) && sn_obio_getaddr_kludge(sc, myaddr)) { /* XXX kludge for PB */ printf(": failed to get MAC address.\n"); bus_space_unmap(sc->sc_regt, sc->sc_regh, SN_REGSIZE); return; } printf(": integrated ethernet adapter, "); /* snsetup returns 1 if something fails */ if (snsetup(sc, myaddr)) { bus_space_unmap(sc->sc_regt, sc->sc_regh, SN_REGSIZE); return; } if (mac68k_machine.aux_interrupts) intr_establish(snintr, sc, 3, sc->sc_dev.dv_xname); else add_nubus_intr(sc->slotno, IPL_NET, snintr, sc, sc->sc_dev.dv_xname); }
void cpi_nubus_attach(device_t parent, device_t self, void *aux) { struct cpi_softc *sc; struct nubus_attach_args *na; int err, ii; sc = device_private(self); sc->sc_options = (device_cfdata(self)->cf_flags & CPI_OPTIONS_MASK); na = aux; sc->sc_bst = na->na_tag; memcpy(&sc->sc_slot, na->fmt, sizeof(nubus_slot)); sc->sc_basepa = (bus_addr_t)NUBUS_SLOT2PA(na->slot); /* * The CIO sits eight bit wide on the top byte lane of * Nubus, so map 16 byte. */ if (TRACE_CONFIG) { printf("\n"); printf("\tcpi_nubus_attach() mapping 8536 CIO at 0x%lx.\n", sc->sc_basepa + CIO_BASE_OFFSET); } err = bus_space_map(sc->sc_bst, sc->sc_basepa + CIO_BASE_OFFSET, (Z8536_IOSIZE << 4), 0, &sc->sc_bsh); if (err) { aprint_normal(": failed to map memory space.\n"); return; } sc->sc_lpstate = LP_INITIAL; sc->sc_intcount = 0; sc->sc_bytestoport = 0; if (TRACE_CONFIG) printf("\tcpi_nubus_attach() about to set up 8536 CIO.\n"); for (ii = 0; ii < sizeof(cio_reset); ii += 2) z8536_reg_set(sc->sc_bst, sc->sc_bsh, cio_reset[ii], cio_reset[ii + 1]); delay(1000); /* Give the CIO time to set itself up */ for (ii = 0; ii < sizeof(cio_init); ii += 2) { z8536_reg_set(sc->sc_bst, sc->sc_bsh, cio_init[ii], cio_init[ii + 1]); } if (TRACE_CONFIG) printf("\tcpi_nubus_attach() done with 8536 CIO setup.\n"); /* XXX Get information strings from the card ROM */ aprint_normal(": CSI Hurdler II Centronics\n"); /* Attach CIO timers 1+2 as timecounter */ if (sc->sc_options & CPI_CTC12_IS_TIMECOUNTER) { cpi_tc_initclock(sc); } callout_init(&sc->sc_wakeupchan, 0); /* XXX */ /* make sure interrupts are vectored to us */ add_nubus_intr(na->slot, cpi_nubus_intr, sc); }
/* * Install interface into kernel networking data structures */ static void sn_nubus_attach(struct device *parent, struct device *self, void *aux) { struct sn_softc *sc = (void *)self; struct nubus_attach_args *na = (struct nubus_attach_args *)aux; int i, success, offset; bus_space_tag_t bst; bus_space_handle_t bsh, tmp_bsh; u_int8_t myaddr[ETHER_ADDR_LEN]; char cardtype[INTERFACE_NAME_LEN]; /* type string */ (void)(&offset); /* Work around lame gcc initialization bug */ bst = na->na_tag; if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh)) { printf(": can't map mem space\n"); return; } sc->sc_regt = bst; strncpy(cardtype, nubus_get_card_name(bst, bsh, na->fmt), INTERFACE_NAME_LEN); success = 0; sc->slotno = na->slot; switch (sn_nb_card_vendor(bst, bsh, na)) { case SN_VENDOR_DAYNA: sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->bitmode = 1; /* 32 bit card */ if (bus_space_subregion(bst, bsh, 0x00180000, SN_REGSIZE, &sc->sc_regh)) { printf(": can't map register space\n"); break; } if (bus_space_subregion(bst, bsh, 0x00ffe004, ETHER_ADDR_LEN, &tmp_bsh)) { printf(": can't map ROM space\n"); break; } sn_get_enaddr(bst, tmp_bsh, 0, myaddr); offset = 2; success = 1; break; case SN_VENDOR_APPLE: sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->bitmode = 1; /* 32 bit card */ if (bus_space_subregion(bst, bsh, 0x0, SN_REGSIZE, &sc->sc_regh)) { printf(": failed to map register space.\n"); break; } if (bus_space_subregion(bst, bsh, 0x40000, ETHER_ADDR_LEN, &tmp_bsh)) { printf(": failed to map ROM space.\n"); break; } sn_get_enaddr(bst, tmp_bsh, 0, myaddr); offset = 0; success = 1; break; case SN_VENDOR_APPLE16: sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_EXBUS | DCR_DMABLOCK | DCR_PO1 | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->bitmode = 0; /* 16 bit card */ if (bus_space_subregion(bst, bsh, 0x0, SN_REGSIZE, &sc->sc_regh)) { printf(": failed to map register space.\n"); break; } if (bus_space_subregion(bst, bsh, 0x40000, ETHER_ADDR_LEN, &tmp_bsh)) { printf(": failed to map ROM space.\n"); break; } sn_get_enaddr(bst, tmp_bsh, 0, myaddr); offset = 0; success = 1; break; case SN_VENDOR_ASANTELC: /* Macintosh LC Ethernet Adapter */ sc->snr_dcr = DCR_ASYNC | DCR_WAIT0 | DCR_DMABLOCK | DCR_PO1 | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; sc->bitmode = 0; /* 16 bit card */ if (bus_space_subregion(bst, bsh, 0x0, SN_REGSIZE, &sc->sc_regh)) { printf(": failed to map register space.\n"); break; } if (bus_space_subregion(bst, bsh, 0x400000, ETHER_ADDR_LEN, &tmp_bsh)) { printf(": failed to map ROM space.\n"); break; } sn_get_enaddr(bst, tmp_bsh, 0, myaddr); offset = 0; success = 1; break; default: /* * You can't actually get this default, the snmatch * will fail for unknown hardware. If you're adding support * for a new card, the following defaults are a * good starting point. */ sc->snr_dcr = DCR_SYNC | DCR_WAIT0 | DCR_DW32 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; success = 0; printf(": unknown card: attachment incomplete.\n"); } if (!success) { bus_space_unmap(bst, bsh, NBMEMSIZE); return; } /* Regs are addressed as words, big endian. */ for (i = 0; i < SN_NREGS; i++) { sc->sc_reg_map[i] = (bus_size_t)((i * 4) + offset); } printf(": %s, ", cardtype); /* snsetup returns 1 if something fails */ if (snsetup(sc, myaddr)) { bus_space_unmap(bst, bsh, NBMEMSIZE); return; } add_nubus_intr(sc->slotno, IPL_NET, snintr, sc, sc->sc_dev.dv_xname); }