void
sm_obio_attach(device_t parent, device_t self, void *aux)
{
	struct sm_obio_softc *isc = device_private(self);
	struct smc91cxx_softc *sc = &isc->sc_smc;
	struct obio_attach_args *oba = aux;
	bus_space_handle_t ioh;
#ifdef LUBBOCK_SMC91C96_16BIT
	bus_space_tag_t iot = &pxa2x0_a4x_bs_tag;
#else
	bus_space_tag_t iot = &smobio8_bs_tag;
#endif


	printf("\n");

	/* Map i/o space. */
	if (bus_space_map(iot, oba->oba_addr, SMC_IOSIZE, 0, &ioh))
		panic("sm_obio_attach: can't map i/o space");

#ifdef LUBBOCK_SMC91C96_16BIT
	/* RedBoot initializes on-board SMSC91C96 in 8-bit mode.
	   we take it back to 16-bit by clearing ECSR.IOIs8 */
	{
		int tmp;

		bus_space_write_1(&smobio8_bs_tag, ioh, BANK_SELECT_REG_W, 4);
		tmp = bus_space_read_1(&smobio8_bs_tag, ioh, ECSR_REG_B);
		bus_space_write_1(&smobio8_bs_tag, ioh, 
		    ECSR_REG_B, tmp & ~ECSR_IOIS8);
	}

	obio16_write(LUBBOCK_MISCWR, 
	    obio16_read(LUBBOCK_MISCWR) & ~MISCWR_ENETEN16 );

#else
	/* Force 8bit mode */
	obio16_write(LUBBOCK_MISCWR, 
	    obio16_read(LUBBOCK_MISCWR) | MISCWR_ENETEN16);

#endif /* LUBBOCK_SMC91C96_16BIT */

	sc->sc_dev = self;
	sc->sc_bst = iot;
	sc->sc_bsh = ioh;

	/* should always be enabled */
	sc->sc_flags |= SMC_FLAGS_ENABLED;

	/* Perform generic intialization. */
	smc91cxx_attach(sc, NULL);

	/* Establish the interrupt handler. */
	isc->sc_ih = obio_intr_establish(device_private(parent),
					 oba->oba_intr, IPL_NET, smintr, sc);

	if (isc->sc_ih == NULL)
		aprint_normal_dev(self, "couldn't establish interrupt handler\n");
}
Example #2
0
static void
slhci_opio_attach(struct device *parent, struct device *self, void *aux)
{
	struct slhci_opio_softc *sc = (struct slhci_opio_softc *)self;
	struct obio_attach_args *oba = aux;
	struct opio_softc *psc =
	    (struct opio_softc *)device_parent(self);
	struct obio_softc *bsc =
	    (struct obio_softc *)device_parent(&psc->sc_dev);
	bus_space_tag_t iot = oba->oba_iot;
	bus_space_handle_t ioh;

	printf("\n");

	/* Map I/O space */
	if (bus_space_map(iot, oba->oba_addr, PORTSIZE, 0, &ioh)) {
		printf("%s: can't map I/O space\n",
			sc->sc_sc.sc_bus.bdev.dv_xname);
		return;
	}

	/* Initialize sc */
	sc->sc_sc.sc_iot = iot;
	sc->sc_sc.sc_ioh = ioh;
	sc->sc_sc.sc_dmat = &pxa2x0_bus_dma_tag;	/* XXX */
	sc->sc_sc.sc_enable_power = slhci_opio_enable_power;
	sc->sc_sc.sc_enable_intr  = slhci_opio_enable_intr;
	sc->sc_sc.sc_arg = sc;

	/* Establish the interrupt handler */
	sc->sc_ih = obio_intr_establish(bsc, oba->oba_intr, IPL_BIO, 
	    IST_LEVEL_HIGH, slhci_opio_intr, sc);
	if( sc->sc_ih == NULL) {
		printf("%s: can't establish interrupt\n",
			sc->sc_sc.sc_bus.bdev.dv_xname);
		return;
	}

#if 0
	/* Reset controller */
	obio_peripheral_reset(bsc, 2, 1);
	delay(100);
	obio_peripheral_reset(bsc, 2, 0);
	delay(40000);
#endif

	bus_space_write_1(iot, ioh, SL11_IDX_ADDR, SL11_CTRL);
	bus_space_write_1(iot, ioh, SL11_IDX_DATA, 0x01);

	/* Attach SL811HS/T */
	if (slhci_attach(&sc->sc_sc, self))
		return;
}
Example #3
0
static void
wdc_obio_attach(device_t parent, device_t self, void *aux)
{
	struct wdc_obio_softc *sc = device_private(self);
	struct obio_attach_args *oa = aux;
	struct wdc_regs *wdr;
	int i;

	aprint_naive("\n");
	aprint_normal("\n");

	sc->sc_wdcdev.sc_atac.atac_dev = self;
	sc->sc_wdcdev.regs = wdr = &sc->sc_wdc_regs;

	wdr->cmd_iot = oa->oa_iot;
	wdr->ctl_iot = oa->oa_iot;
	if (bus_space_map(wdr->cmd_iot, oa->oa_io[0].or_addr,
	    WDC_OBIO_REG_SIZE, 0, &wdr->cmd_baseioh)
	 || bus_space_map(wdr->ctl_iot,
	    oa->oa_io[0].or_addr + WDC_OBIO_AUXREG_OFFSET,
	    WDC_OBIO_AUXREG_SIZE, 0, &wdr->ctl_ioh)) {
		aprint_error_dev(self, "couldn't map registers\n");
		return;
	}

	for (i = 0; i < WDC_OBIO_REG_NPORTS; i++) {
		if (bus_space_subregion(wdr->cmd_iot,
		      wdr->cmd_baseioh, i * 2, (i == 0) ? 2 : 1,
		      &wdr->cmd_iohs[i]) != 0) {
			aprint_error_dev(self,
			    "couldn't subregion registers\n");
			return;
		}
	}

	sc->sc_ih = obio_intr_establish(oa->oa_irq[0].or_irq, IPL_BIO, wdcintr,
	    &sc->sc_channel);

	sc->sc_wdcdev.cap |= WDC_CAPABILITY_PREATA;
	sc->sc_wdcdev.sc_atac.atac_cap |= ATAC_CAP_DATA16;
	sc->sc_wdcdev.sc_atac.atac_pio_cap = 0;
	sc->sc_chanlist[0] = &sc->sc_channel;
	sc->sc_wdcdev.sc_atac.atac_channels = sc->sc_chanlist;
	sc->sc_wdcdev.sc_atac.atac_nchannels = 1;
	sc->sc_channel.ch_channel = 0;
	sc->sc_channel.ch_atac = &sc->sc_wdcdev.sc_atac;
	sc->sc_channel.ch_queue = &sc->sc_chqueue;
	sc->sc_channel.ch_ndrive = 2;

	wdc_init_shadow_regs(&sc->sc_channel);

	wdcattach(&sc->sc_channel);
}
Example #4
0
static int
ne_obio_enable(struct dp8390_softc *dsc)
{
    struct ne_obio_softc *sc = (struct ne_obio_softc *)dsc;
    struct obio_softc *psc;

    aprint_normal_dev(dsc->sc_dev, "enabled\n");

    psc = device_private(device_parent(dsc->sc_dev));

    /* Establish the interrupt handler. */
    sc->sc_ih = obio_intr_establish(psc, sc->intr_no, IPL_NET,
                                    IST_LEVEL_LOW,
                                    intr_handler,
                                    sc);

    return 0;
}
Example #5
0
void
wdc_obio_attach(struct device *parent, struct device *self, void *aux)
{
	struct wdc_obio_softc *sc = (void *)self;
	struct obio_attach_args *oa = aux;
	struct channel_softc *chp = &sc->sc_channel;

	printf("\n");

	chp->cmd_iot = chp->ctl_iot = oa->oa_iot;
	chp->_vtbl = &wdc_obio_vtbl;

	if (bus_space_map(chp->cmd_iot, oa->oa_io[0].or_addr,
	    WDC_OBIO_REG_SIZE, 0, &chp->cmd_ioh)
	 || bus_space_map(chp->ctl_iot,
	    oa->oa_io[0].or_addr + WDC_OBIO_AUXREG_OFFSET,
	    WDC_OBIO_AUXREG_SIZE, 0, &chp->ctl_ioh)) {
		printf(": couldn't map registers\n");
		return;
	}

	sc->sc_ih = obio_intr_establish(oa->oa_irq[0].or_irq, IPL_BIO, wdcintr,
	    chp, self->dv_xname);

	sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_PREATA;
	sc->sc_wdcdev.PIO_cap = 0;
	sc->sc_chanptr = chp;
	sc->sc_wdcdev.channels = &sc->sc_chanptr;
	sc->sc_wdcdev.nchannels = 1;
	chp->channel = 0;
	chp->wdc = &sc->sc_wdcdev;

	chp->ch_queue = wdc_alloc_queue();
	if (chp->ch_queue == NULL) {
		printf("%s: cannot allocate channel queue\n",
		    self->dv_xname);
		obio_intr_disestablish(sc->sc_ih);
		return;
	}

	wdcattach(chp);
	wdc_print_current_modes(chp);
}
Example #6
0
void *
octeon_pcibus_pci_intr_establish(void *cookie, pci_intr_handle_t ih, int level,
    int (*cb)(void *), void *cbarg, char *name)
{
	return obio_intr_establish(ih, level, cb, cbarg, name);
}
Example #7
0
static void
obioohci_attach(struct device *parent, struct device *self, void *aux)
{
	struct obioohci_softc *sc = (struct obioohci_softc *)self;
	struct obio_attach_args *obio = aux;
	usbd_status r;

	sc->sc.sc_size = 0;
	sc->sc_ih = NULL;
	sc->sc.sc_bus.dmatag = 0;

	/* Map I/O space */
	if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size, 0,
	    &sc->sc.ioh)) {
		aprint_error(": couldn't map memory space\n");
		return;
	}
	sc->sc.iot = obio->obio_iot;
	sc->sc_addr = obio->obio_addr;
	sc->sc.sc_size = obio->obio_size;
	sc->sc.sc_bus.dmatag = obio->obio_dmac;

	/* XXX copied from ohci_pci.c. needed? */
	bus_space_barrier(sc->sc.iot, sc->sc.ioh, 0, sc->sc.sc_size,
	    BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE);

	/* start the usb clock */
#ifdef NOTYET
	pxa2x0_clkman_config(CKEN_USBHC, 1);
#endif
	obioohci_enable(sc);

	/* Disable interrupts, so we don't get any spurious ones. */
	bus_space_write_4(sc->sc.iot, sc->sc.ioh, OHCI_INTERRUPT_DISABLE,
	    OHCI_MIE);

#ifdef NOTYET
	sc->sc_ih = obio_intr_establish(obio->obio_intr, IPL_USB,
		sc->sc.sc_bus.bdev.dv_xname, ohci_intr, &sc->sc);
	if (sc->sc_ih == NULL) {
		aprint_error(": unable to establish interrupt\n");
		goto free_map;
	}
#else
	sc->sc_ih = obioohci_fake_intr_establish(ohci_intr, &sc->sc);
#endif

	strlcpy(sc->sc.sc_vendor, "OMAP2", sizeof(sc->sc.sc_vendor));
	r = ohci_init(&sc->sc);
	if (r != USBD_NORMAL_COMPLETION) {
		aprint_error("%s: init failed, error=%d\n",
		    sc->sc.sc_bus.bdev.dv_xname, r);
		goto free_intr;
	}

	sc->sc.sc_powerhook = powerhook_establish(sc->sc.sc_bus.bdev.dv_xname,
	    obioohci_power, sc);
	if (sc->sc.sc_powerhook == NULL) {
		aprint_error("%s: cannot establish powerhook\n",
		    sc->sc.sc_bus.bdev.dv_xname);
	}

	sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, usbctlprint);

	return;

free_intr:
#ifdef NOTYET
	obio_gpio_intr_disestablish(sc->sc_ih);
#endif
	sc->sc_ih = NULL;
#ifdef NOTYET
free_map:
#endif
	obioohci_disable(sc);
#ifdef NOTYET
	pxa2x0_clkman_config(CKEN_USBHC, 0);
#endif
	bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size);
	sc->sc.sc_size = 0;
}