示例#1
0
void
mmeyepcmcia_attach(struct device *parent, struct device *self, void *aux)
{
	struct mainbus_attach_args *ma = aux;
	struct mmeyepcmcia_softc *sc = (void *)self;

	sc->subregionmask = 1;	/* 1999.05.17 T.Horiuchi for R1.4 */

	sc->pct = (pcmcia_chipset_tag_t)&mmeyepcmcia_functions;
	sc->iot = 0;
	sc->ioh = ma->ma_addr1;
	sc->memt = 0;
	sc->memh = ma->ma_addr2;
	sc->controller_irq = ma->ma_irq1;
	sc->card_irq = ma->ma_irq2;

	printf(": using MMTA irq %d\n", sc->controller_irq);

	sc->handle[0].sc = sc;
	sc->handle[0].flags = MMEYEPCMCIA_FLAG_SOCKETP;
	sc->handle[0].laststate = MMEYEPCMCIA_LASTSTATE_EMPTY;

	SIMPLEQ_INIT(&sc->handle[0].events);

	mmeye_intr_establish(sc->controller_irq,
	    IST_LEVEL, IPL_TTY, mmeyepcmcia_intr, sc);

	mmeyepcmcia_attach_sockets(sc);
}
void
ne_mainbus_attach(device_t parent, device_t self, void *aux)
{
	struct ne2000_softc *sc = device_private(self);
	struct dp8390_softc *dsc = &sc->sc_dp8390;
	struct mainbus_attach_args *ma = aux;
	bus_space_tag_t nict, asict;
	bus_space_handle_t nich, asich;
	int netype;
	const char *typestr;
	void *ih;

	dsc->sc_dev = self;
	aprint_normal("\n");

	/* Map i/o space. */
	nict = SH3_BUS_SPACE_PCMCIA_IO;
	if (bus_space_map(nict, ma->ma_addr1, NE2000_NPORTS, 0, &nich)) {
		aprint_error_dev(self, "can't map i/o space\n");
		return;
	}

	if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET,
	    NE2000_ASIC_NPORTS, &asich)) {
		aprint_error_dev(self, "can't subregion i/o space\n");
		return;
	}
	asict = nict;

	dsc->sc_regt = nict;
	dsc->sc_regh = nich;

	sc->sc_asict = asict;
	sc->sc_asich = asich;

	/*
	 * Detect it again, so we can print some information about the
	 * interface.
	 */
	netype = ne2000_detect(nict, nich, asict, asich);
	switch (netype) {
	case NE2000_TYPE_RTL8019:
		typestr = "NE2000 (RTL8019)";
		break;

	case NE2000_TYPE_NE1000:
	case NE2000_TYPE_NE2000:
	default:
		aprint_error_dev(self, "where did the card go?!\n");
		return;
	}

	aprint_normal_dev(self, "%s Ethernet\n", typestr);

	/* This interface is always enabled. */
	dsc->sc_enabled = 1;

	/*
	 * Do generic NE2000 attach.  This will read the station address
	 * from the EEPROM.
	 */
	ne2000_attach(sc, NULL);

	/* Establish the interrupt handler. */
	ih = mmeye_intr_establish(ma->ma_irq1, IST_LEVEL, IPL_NET,
	    dp8390_intr, dsc);
	if (ih == NULL)
		aprint_error_dev(self,
		    "couldn't establish interrupt handler\n");
}