コード例 #1
0
ファイル: ofisascr.c プロジェクト: ryo/netbsd-src
void
ofisascrattach(device_t parent, device_t dev, void *aux)
{
	struct ofbus_attach_args *oba = aux;
	struct isa_attach_args ia;
	struct isa_io ia_io[1];
    
	printf("\n");

	/* XXX - Hard-wire the ISA attach args for now. -JJK */
	ia.ia_iot = &isa_io_bs_tag;
	ia.ia_memt = &isa_mem_bs_tag;
	ia.ia_ic = NULL;			/* not used */

	ia.ia_nio = 1;
	ia.ia_io = ia_io;
	ia.ia_io[0].ir_addr = SEQUOIA_BASE;
	ia.ia_io[0].ir_size = SEQUOIA_NPORTS;

	ia.ia_niomem = 0;
	ia.ia_nirq = 0;
	ia.ia_ndrq = 0;

	ia.ia_aux = (void *)oba->oba_phandle;
    
	config_found(dev, &ia, NULL);
}
コード例 #2
0
ファイル: uhci_pci.c プロジェクト: sofuture/bitrig
void
uhci_pci_attach_deferred(struct device *self)
{
	struct uhci_pci_softc *sc = (struct uhci_pci_softc *)self;
	char *devname = sc->sc.sc_bus.bdev.dv_xname;
	usbd_status r;
	int s;

	s = splhardusb();
	
	sc->sc.sc_bus.dying = 0;
	r = uhci_init(&sc->sc);
	if (r != USBD_NORMAL_COMPLETION) {
		printf("%s: init failed, error=%d\n", devname, r);
		goto unmap_ret;
	}
	splx(s);

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

	return;

unmap_ret:
	bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size);
	pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
	splx(s);
}
コード例 #3
0
ファイル: mms.c プロジェクト: ajinkya93/OpenBSD
void
mmsattach(struct device *parent, struct device *self, void *aux)
{
	struct mms_softc *sc = (void *)self;
	struct isa_attach_args *ia = aux;
	bus_space_tag_t iot = ia->ia_iot;
	bus_space_handle_t ioh;
	struct wsmousedev_attach_args a;

	printf("\n");

	if (bus_space_map(iot, ia->ia_iobase, MMS_NPORTS, 0, &ioh)) {
		printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
		return;
	}

	/* Other initialization was done by mmsprobe. */
	sc->sc_iot = iot;
	sc->sc_ioh = ioh;
	sc->sc_enabled = 0;

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
	    IPL_TTY, mmsintr, sc, sc->sc_dev.dv_xname);

	a.accessops = &mms_accessops;
	a.accesscookie = sc;

	/*
	 * Attach the wsmouse, saving a handle to it.
	 * Note that we don't need to check this pointer against NULL
	 * here or in psmintr, because if this fails lms_enable() will
	 * never be called, so lmsintr() will never be called.
	 */
	sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
}
コード例 #4
0
ファイル: cardslot.c プロジェクト: avsm/openbsd-xen-sys
STATIC void
cardslotattach(struct device *parent, struct device *self, void *aux)
{
	struct cardslot_softc *sc = (struct cardslot_softc *)self;
	struct cardslot_attach_args *caa = aux;

	struct cbslot_attach_args *cba = caa->caa_cb_attach;
	struct pcmciabus_attach_args *pa = caa->caa_16_attach;

	struct cardbus_softc *csc;
	struct pcmcia_softc *psc;

	sc->sc_slot = sc->sc_dev.dv_unit;
	sc->sc_cb_softc = NULL;
	sc->sc_16_softc = NULL;
	SIMPLEQ_INIT(&sc->sc_events);
	sc->sc_th_enable = 0;

	printf(" slot %d flags %x\n", sc->sc_slot,
	    sc->sc_dev.dv_cfdata->cf_flags);

	DPRINTF(("%s attaching CardBus bus...\n", sc->sc_dev.dv_xname));
	if (cba != NULL) {
		if ((csc = (void *)config_found(self, cba,
		    cardslot_cb_print)) != NULL) {
			/* cardbus found */
			DPRINTF(("cardslotattach: found cardbus on %s\n",
			    sc->sc_dev.dv_xname));
			sc->sc_cb_softc = csc;
		}
	}

	if (pa != NULL) {
		if ((psc = (void *)config_found_sm(self, pa, cardslot_16_print,
		    cardslot_16_submatch)) != NULL) {
			/* pcmcia 16-bit bus found */
			DPRINTF(("cardslotattach: found 16-bit pcmcia bus\n"));
			sc->sc_16_softc = psc;
			/* XXX: dirty.  This code should be removed
			 * to achieve MI
			 */
			caa->caa_ph->pcmcia = (struct device *)psc;
		}
	}

	if (csc != NULL || psc != NULL)
		kthread_create_deferred(create_slot_manager, (void *)sc);

	if (csc && (csc->sc_cf->cardbus_ctrl)(csc->sc_cc, CARDBUS_CD)) {
		DPRINTF(("cardslotattach: CardBus card found\n"));
		/* attach deferred */
		cardslot_event_throw(sc, CARDSLOT_EVENT_INSERTION_CB);
	}

	if (psc && (psc->pct->card_detect)(psc->pch)) {
		DPRINTF(("cardbusattach: 16-bit card found\n"));
		/* attach deferred */
		cardslot_event_throw(sc, CARDSLOT_EVENT_INSERTION_16);
	}
}
コード例 #5
0
ファイル: oj6sh.c プロジェクト: eyberg/rumpkernel-netbsd-src
static void
oj6sh_attach(device_t parent, device_t self, void *aux)
{
	struct oj6sh_softc *sc = device_private(self);
	struct spi_attach_args *sa = aux;
	struct wsmousedev_attach_args a;

	aprint_normal(": OJ6SH-T25 Optical Joystick\n");

	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);

	sc->sc_dev = self;
	sc->sc_enabled = 0;

	callout_init(&sc->sc_c, 0);

	sc->sc_sh = sa->sa_handle;

	a.accessops = &oj6sh_accessops;
	a.accesscookie = sc;

	sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);

	config_interrupts(self, oj6sh_doattach);
}
コード例 #6
0
void
sti_end_attach_screen(struct sti_softc *sc, struct sti_screen *scr, int console)
{
	struct wsemuldisplaydev_attach_args waa;

	scr->scr_wsmode = WSDISPLAYIO_MODE_EMUL;

	waa.console = console;
	waa.scrdata = &scr->scr_screenlist;
	waa.accessops = &sti_accessops;
	waa.accesscookie = scr;
	waa.defaultscreens = 0;

	/* attach as console if required */
	if (console && !ISSET(sc->sc_flags, STI_ATTACHED)) {
		long defattr;

		sti_alloc_attr(scr, 0, 0, 0, &defattr);
		wsdisplay_cnattach(&scr->scr_wsd, scr,
		    0, scr->scr_wsd.nrows - 1, defattr);
		sc->sc_flags |= STI_ATTACHED;
	}

	config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
}
コード例 #7
0
ファイル: pbridge.c プロジェクト: MarginC/kame
/*ARGSUSED*/
static void
pbridgeattach(struct device *parent, struct device *self, void *args)
{
	struct superhyway_attach_args *sa = args;
	struct pbridge_attach_args pa;
	bus_space_handle_t bh;
	u_int64_t vcr;
	int i;

	pa._pa_base = SUPERHYWAY_PPORT_TO_BUSADDR(sa->sa_pport);

	bus_space_map(sa->sa_bust, pa._pa_base, SUPERHYWAY_REG_SZ, 0, &bh);
	vcr = bus_space_read_8(sa->sa_bust, bh, SUPERHYWAY_REG_VCR);
	bus_space_unmap(sa->sa_bust, bh, SUPERHYWAY_REG_SZ);

	printf(": Peripheral Bridge, Version 0x%x\n",
	    (int)SUPERHYWAY_VCR_MOD_VERS(vcr));

	/*
	 * Attach configured children
	 */
	for (i = 0; pbridge_devices[i].pd_name != NULL; i++) {
		pa.pa_name = pbridge_devices[i].pd_name;
		pa.pa_offset = pbridge_devices[i].pd_offset + pa._pa_base;
		pa.pa_bust = sa->sa_bust;
		pa.pa_dmat = sa->sa_dmat;
		pa.pa_ipl = -1;
		pa.pa_intevt = -1;

		(void) config_found(self, &pa, pbridgeprint);
	}
}
コード例 #8
0
ファイル: pchb.c プロジェクト: SylvestreG/bitrig
void
pchb_amd64ht_attach(struct device *self, struct pci_attach_args *pa, int i)
{
	struct pcibus_attach_args pba;
	pcireg_t type, bus;
	int reg;

	reg = AMD64HT_LDT0_TYPE + i * 0x20;
	type = pci_conf_read(pa->pa_pc, pa->pa_tag, reg);
	if ((type & AMD64HT_LDT_INIT_COMPLETE) == 0 ||
	    (type & AMD64HT_LDT_NC) == 0)
		return;

	reg = AMD64HT_LDT0_BUS + i * 0x20;
	bus = pci_conf_read(pa->pa_pc, pa->pa_tag, reg);
	if (AMD64HT_LDT_SEC_BUS_NUM(bus) > 0) {
		bzero(&pba, sizeof(pba));
		pba.pba_busname = "pci";
		pba.pba_iot = pa->pa_iot;
		pba.pba_memt = pa->pa_memt;
		pba.pba_dmat = pa->pa_dmat;
		pba.pba_busex = pa->pa_busex;
		pba.pba_domain = pa->pa_domain;
		pba.pba_bus = AMD64HT_LDT_SEC_BUS_NUM(bus);
		pba.pba_pc = pa->pa_pc;
		config_found(self, &pba, pchb_print);
	}
}
コード例 #9
0
ファイル: light.c プロジェクト: lacombar/netbsd-alc
static void
light_attach(struct device *parent, struct device *self, void *aux)
{
	struct gio_attach_args *ga = aux;
	struct light_softc *sc = (void *)self;
	struct wsemuldisplaydev_attach_args wa;

	if (light_is_console && ga->ga_addr == light_console_dc.dc_addr) {
		wa.console = 1;
		sc->sc_dc = &light_console_dc;
	} else {
		wa.console = 0;
		sc->sc_dc = malloc(sizeof(struct light_devconfig), M_DEVBUF,
		    M_WAITOK | M_ZERO);
		if (sc->sc_dc == NULL)
			panic("light_attach: out of memory");

		light_attach_common(sc->sc_dc, ga);
	}

	aprint_naive(": Display adapter\n");

	aprint_normal(": SGI LG%d (board revision %d)\n",
	    LIGHT_IS_LG1(sc->sc_dc->dc_boardrev) ? 1 : 2,
	    sc->sc_dc->dc_boardrev);

	wa.scrdata = &light_screenlist;
	wa.accessops = &light_accessops;
	wa.accesscookie = sc->sc_dc;

	config_found(&sc->sc_dev, &wa, wsemuldisplaydevprint);
}
コード例 #10
0
ファイル: kbd.c プロジェクト: Tommmster/netbsd-avr32
void
kbd_enable(struct device *dev)
{
	struct kbd_softc *k = device_private(dev);
	struct wskbddev_attach_args a;

	if (k->k_isconsole)
		wskbd_cnattach(&sunkbd_wskbd_consops, k,
		    &sunkbd_wskbd_keymapdata);

	a.console = k->k_isconsole;
	a.keymap = &sunkbd_wskbd_keymapdata;
	a.accessops = &sunkbd_wskbd_accessops;
	a.accesscookie = k;

	/* XXX why? */
	k->k_wsenabled = 0;

	/* Attach the wskbd */
	k->k_wskbd = config_found(k->k_dev, &a, wskbddevprint);

	callout_init(&k->k_wsbell, 0);

	wssunkbd_enable(k,1);
	
	wssunkbd_set_leds(k, WSKBD_LED_SCROLL | WSKBD_LED_NUM | WSKBD_LED_CAPS);
	delay(100000);
	wssunkbd_set_leds(k, 0);
}
コード例 #11
0
ファイル: hyper.c プロジェクト: lacombar/netbsd-alc
void
hyperattach(struct device *parent, struct device *self, void *auxp)
{
	struct hyper_softc *hprsc;
	struct hyper_devs  *hprsd;
	struct zbus_args *zap;
	struct supio_attach_args supa;
	struct hyper_prods *hprpp;

	hprsc = (struct hyper_softc *)self;
	zap = auxp;
	hprpp = &hyperproducts[zap->prodid];

	if (parent)
		printf(": Hypercom %s\n", hprpp->name);

	hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff;
	hprsc->sc_bst.absm = &amiga_bus_stride_4;

	supa.supio_iot = &hprsc->sc_bst;
	supa.supio_ipl = 6;

	hprsd = hyperdevices;

	while (hprsd->name) {
		if (hprsd->productmask & (1 << zap->prodid)) {
			supa.supio_name = hprsd->name;
			supa.supio_iobase = hprsd->off;
			supa.supio_arg = hprsd->arg;
			config_found(self, &supa, hyperprint); /* XXX */
		}
		++hprsd;
	}
}
コード例 #12
0
ファイル: sociic.c プロジェクト: ajinkya93/OpenBSD
void
sociic_attach(struct device *parent, struct device *self, void *aux)
{
	struct sociic_softc *sc = (void *)self;
	struct obio_attach_args *oa = aux;
	struct i2cbus_attach_args iba;

	sc->sc_iot = oa->oa_iot;
	if (bus_space_map(sc->sc_iot, oa->oa_offset, 24, 0, &sc->sc_ioh)) {
		printf(": can't map registers\n");
		return;
	}

	printf("\n");

	rw_init(&sc->sc_lock, "iiclk");
	sc->sc_i2c.ic_cookie = sc;
	sc->sc_i2c.ic_acquire_bus = sociic_i2c_acquire_bus;
	sc->sc_i2c.ic_release_bus = sociic_i2c_release_bus;
	sc->sc_i2c.ic_exec = sociic_i2c_exec;

	bzero(&iba, sizeof iba);
	iba.iba_name = "iic";
	iba.iba_tag = &sc->sc_i2c;
	config_found(&sc->sc_dev, &iba, iicbus_print);
}
コード例 #13
0
void
lcd_attach(struct device *parent, struct device *self, void *aux)
{
    struct pxa2x0_lcd_softc *sc = (struct pxa2x0_lcd_softc *)self;
    struct wsemuldisplaydev_attach_args aa;
    extern int glass_console;

    printf("\n");

    pxa2x0_lcd_attach_sub(sc, aux, &lcd_bpp16_screen, CURRENT_DISPLAY,
                          glass_console);

    aa.console = glass_console;
    aa.scrdata = &lcd_screen_list;
    aa.accessops = &lcd_accessops;
    aa.accesscookie = sc;
    aa.defaultscreens = 0;

    (void)config_found(self, &aa, wsemuldisplaydevprint);

    /* Start with approximately 40% of full brightness. */
    lcd_set_brightness(3);

    (void)powerhook_establish(lcd_power, sc);
}
コード例 #14
0
void
ncr_attach(device_t parent, device_t self, void *aux)
{
	struct ncr_softc	*sc;
	int			i;

	sc = device_private(self);

	sc->sc_dev = self;
	sc->sc_adapter.adapt_dev = self;
	sc->sc_adapter.adapt_openings = 7;
	sc->sc_adapter.adapt_max_periph = 1;
	sc->sc_adapter.adapt_ioctl = NULL;
	sc->sc_adapter.adapt_minphys = ncr5380_minphys;
	sc->sc_adapter.adapt_request = ncr5380_scsi_request;

	sc->sc_channel.chan_adapter = &sc->sc_adapter;
	sc->sc_channel.chan_bustype = &scsi_bustype; 
	sc->sc_channel.chan_channel = 0;
	sc->sc_channel.chan_ntargets = 8;
	sc->sc_channel.chan_nluns = 8;
	sc->sc_channel.chan_id = 7;

	/*
	 * bitmasks
	 */
	sc->sc_noselatn = 0;
	sc->sc_selected = 0;

	/*
	 * Initialize machine-type specific things...
	 */
	scsi_mach_init(sc);
	printf("\n");

	/*
	 * Initialize request queue freelist.
	 */
	for (i = 0; i < NREQ; i++) {
		req_queue[i].next = free_head;
		free_head = &req_queue[i];
	}

	/*
	 * Initialize the host adapter
	 */
	scsi_idisable();
	ENABLE_NCR5380(sc);
	SET_5380_REG(NCR5380_ICOM, 0);
	SET_5380_REG(NCR5380_MODE, IMODE_BASE);
	SET_5380_REG(NCR5380_TCOM, 0);
	SET_5380_REG(NCR5380_IDSTAT, 0);
	scsi_ienable();

	/*
	 * attach all scsi units on us
	 */
	config_found(self, &sc->sc_channel, scsiprint);
}
コード例 #15
0
ファイル: fdc.c プロジェクト: ajinkya93/OpenBSD
void
fdcattach(struct device *parent, struct device *self, void *aux)
{
	struct fdc_softc *fdc = (void *)self;
	bus_space_tag_t iot;
	bus_space_handle_t ioh;
	bus_space_handle_t ioh_ctl;
	struct isa_attach_args *ia = aux;
	struct fdc_attach_args fa;
	int type;

	iot = ia->ia_iot;

	/* Re-map the I/O space. */
	if (bus_space_map(iot, ia->ia_iobase, FDC_NPORT, 0, &ioh) ||
	    bus_space_map(iot, ia->ia_iobase + FDCTL_OFFSET,
			  FDCTL_NPORT, 0, &ioh_ctl))
		panic("fdcattach: couldn't map I/O ports");

	fdc->sc_iot = iot;
	fdc->sc_ioh = ioh;
	fdc->sc_ioh_ctl = ioh_ctl;

	fdc->sc_drq = ia->ia_drq;
	fdc->sc_state = DEVIDLE;
	TAILQ_INIT(&fdc->sc_link.fdlink.sc_drives);	/* XXX */

	printf("\n");

	fdc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
	    IPL_BIO, fdcintr, fdc, fdc->sc_dev.dv_xname);

#if defined(__i386__) || defined(__amd64__)
	/*
	 * The NVRAM info only tells us about the first two disks on the
	 * `primary' floppy controller.
	 */
	if (fdc->sc_dev.dv_unit == 0)
		type = mc146818_read(NULL, NVRAM_DISKETTE); /* XXX softc */
	else
#endif
		type = -1;

	timeout_set(&fdc->fdcpseudointr_to, fdcpseudointr, fdc);

	/* physical limit: four drives per controller. */
	for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) {
		fa.fa_flags = 0;
		fa.fa_type = 0;
#if NFD > 0
		if (type >= 0 && fa.fa_drive < 2)
			fa.fa_deftype = fd_nvtotype(fdc->sc_dev.dv_xname,
			    type, fa.fa_drive);
		else
#endif
			fa.fa_deftype = NULL;		/* unknown */
		(void)config_found(self, (void *)&fa, fddprint);
	}
}
コード例 #16
0
/* ARGSUSED */
static void
mvusb_attach(device_t parent, device_t self, void *aux)
{
	struct mvusb_softc *sc = device_private(self);
	struct marvell_attach_args *mva = aux;
	usbd_status r;

	aprint_normal(": Marvell USB 2.0 Interface\n");
	aprint_naive("\n");

	sc->sc.sc_dev = self;
	sc->sc.sc_bus.hci_private = sc;

	sc->sc_model = mva->mva_model;
	sc->sc_rev = mva->mva_revision;
	sc->sc_iot = mva->mva_iot;

	/* Map I/O registers for marvell usb */
	if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, mva->mva_offset,
	    mva->mva_size, &sc->sc_ioh)) {
		aprint_error_dev(self, "can't map registers\n");
		return;
	}
	mvusb_init(sc, mva->mva_tags);

	/* Map I/O registers for ehci */
	sc->sc.sc_size = MARVELL_USB_EHCI_SIZE;
	if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, MARVELL_USB_EHCI_BASE,
	    sc->sc.sc_size, &sc->sc.ioh)) {
		aprint_error_dev(self, "can't subregion registers\n");
		return;
	}
	sc->sc.iot = sc->sc_iot;
	sc->sc.sc_bus.dmatag = mva->mva_dmat;

	/* Disable interrupts, so we don't get any spurious ones. */
	sc->sc.sc_offs = EREAD1(&sc->sc, EHCI_CAPLENGTH);
	DPRINTF(("%s: offs=%d\n", device_xname(self), sc->sc.sc_offs));
	EOWRITE2(&sc->sc, EHCI_USBINTR, 0);

	marvell_intr_establish(mva->mva_irq, IPL_USB, ehci_intr, sc);

	sc->sc.sc_bus.usbrev = USBREV_2_0;
	/* Figure out vendor for root hub descriptor. */
	sc->sc.sc_id_vendor = 0x0000;				/* XXXXX */
	strcpy(sc->sc.sc_vendor, "Marvell");

	sc->sc.sc_vendor_init = mvusb_vendor_init;
	sc->sc.sc_vendor_port_status = mvusb_vendor_port_status;

	r = ehci_init(&sc->sc);
	if (r != USBD_NORMAL_COMPLETION) {
		aprint_error_dev(self, "init failed, error=%d\n", r);
		return;
	}

	/* Attach usb device. */
	sc->sc.sc_child = config_found(self, &sc->sc.sc_bus, usbctlprint);
}
コード例 #17
0
ファイル: ubi.c プロジェクト: ryo/netbsd-src
void
ubi_attach(device_t parent, device_t self, void *aux)
{
	struct	sbi_attach_args sa;

	printf("\n");

        sa.sa_base = (bus_addr_t)NEX730;

#define NEXPAGES (sizeof(struct nexus) / VAX_NBPG)

#if 0
	/*
	 * Probe for memory, can be in the first 4 slots.
	 */

	for (sa.sa_nexnum = 0; sa.sa_nexnum < 4; sa.sa_nexnum++) {
		sa.sa_ioh = vax_map_physmem(NEX730 +
		    sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES);
		if (badaddr((caddr_t)sa.sa_ioh, 4)) {
			vax_unmap_physmem((vaddr_t)sa.sa_ioh, NEXPAGES);
		} else {
			sa.sa_type = NEX_MEM16;
			config_found(self, (void*)&sa, ubi_print);
		}
	}
#endif

	/* VAX 730 fixed configuration */

	/* memory */
	sa.sa_nexnum = 0;
	sa.sa_ioh = vax_map_physmem((int)NEX730 +
	   sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES);
	sa.sa_type = NEX_MEM16;
	config_found(self, (void*)&sa, ubi_print);

	printf("\n");

	/* generic UBA */
	sa.sa_nexnum = 3;
	sa.sa_ioh = vax_map_physmem((int)NEX730 +
	    sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES);
	sa.sa_type = NEX_UBA0;
	config_found(self, (void*)&sa, ubi_print);
}
コード例 #18
0
ファイル: exehci.c プロジェクト: SylvestreG/bitrig
void
exehci_attach(struct device *parent, struct device *self, void *aux)
{
	struct exehci_softc	*sc = (struct exehci_softc *)self;
	struct armv7_attach_args	*aa = aux;
	usbd_status		r;
	char *devname = sc->sc.sc_bus.bdev.dv_xname;

	sc->sc.iot = aa->aa_iot;
	sc->sc.sc_bus.dmatag = aa->aa_dmat;
	sc->sc.sc_size = aa->aa_dev->mem[0].size;

	/* Map I/O space */
	if (bus_space_map(sc->sc.iot, aa->aa_dev->mem[0].addr,
		aa->aa_dev->mem[0].size, 0, &sc->sc.ioh)) {
		printf(": cannot map mem space\n");
		goto out;
	}

	if (bus_space_map(sc->sc.iot, aa->aa_dev->mem[1].addr,
		aa->aa_dev->mem[1].size, 0, &sc->ph_ioh)) {
		printf(": cannot map mem space\n");
		goto mem0;
	}

	printf("\n");

	sc->sc_ih = arm_intr_establish(aa->aa_dev->irq[0], IPL_USB,
	    ehci_intr, &sc->sc, devname);
	if (sc->sc_ih == NULL) {
		printf(": unable to establish interrupt\n");
		goto mem1;
	}

	exehci_setup(sc);

	strlcpy(sc->sc.sc_vendor, "Exynos 5", sizeof(sc->sc.sc_vendor));
	r = ehci_init(&sc->sc);
	if (r != USBD_NORMAL_COMPLETION) {
		printf("%s: init failed, error=%d\n", devname, r);
		goto intr;
	}

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

	goto out;

intr:
	arm_intr_disestablish(sc->sc_ih);
	sc->sc_ih = NULL;
mem1:
	bus_space_unmap(sc->sc.iot, sc->ph_ioh, aa->aa_dev->mem[1].addr);
mem0:
	bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size);
	sc->sc.sc_size = 0;
out:
	return;
}
コード例 #19
0
void
gscpcib_attach(struct device *parent, struct device *self, void *aux)
{
#ifndef SMALL_KERNEL
    struct gscpcib_softc *sc = (struct gscpcib_softc *)self;
    struct pci_attach_args *pa = aux;
    struct gpiobus_attach_args gba;
    pcireg_t gpiobase;
    int i;
    int gpio_present = 0;

    /* Map GPIO I/O space */
    gpiobase = pci_conf_read(pa->pa_pc, pa->pa_tag, GSCGPIO_BASE);
    sc->sc_gpio_iot = pa->pa_iot;
    if (PCI_MAPREG_IO_ADDR(gpiobase) == 0 ||
            bus_space_map(sc->sc_gpio_iot, PCI_MAPREG_IO_ADDR(gpiobase),
                          GSCGPIO_SIZE, 0, &sc->sc_gpio_ioh)) {
        printf(": failed to map GPIO I/O space");
        goto corepcib;
    }

    /* Initialize pins array */
    for (i = 0; i < GSCGPIO_NPINS; i++) {
        sc->sc_gpio_pins[i].pin_num = i;
        sc->sc_gpio_pins[i].pin_caps = GPIO_PIN_INPUT |
                                       GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN |
                                       GPIO_PIN_PUSHPULL | GPIO_PIN_TRISTATE |
                                       GPIO_PIN_PULLUP;

        /* Read initial state */
        sc->sc_gpio_pins[i].pin_state = gscpcib_gpio_pin_read(sc, i) ?
                                        GPIO_PIN_HIGH : GPIO_PIN_LOW;
    }

    /* Create controller tag */
    sc->sc_gpio_gc.gp_cookie = sc;
    sc->sc_gpio_gc.gp_pin_read = gscpcib_gpio_pin_read;
    sc->sc_gpio_gc.gp_pin_write = gscpcib_gpio_pin_write;
    sc->sc_gpio_gc.gp_pin_ctl = gscpcib_gpio_pin_ctl;

    gba.gba_name = "gpio";
    gba.gba_gc = &sc->sc_gpio_gc;
    gba.gba_pins = sc->sc_gpio_pins;
    gba.gba_npins = GSCGPIO_NPINS;

    gpio_present = 1;

corepcib:
#endif	/* !SMALL_KERNEL */
    /* Provide core pcib(4) functionality */
    pcibattach(parent, self, aux);

#ifndef SMALL_KERNEL
    /* Attach GPIO framework */
    if (gpio_present)
        config_found(&sc->sc_dev, &gba, gpiobus_print);
#endif	/* !SMALL_KERNEL */
}
コード例 #20
0
static void
ewskbd_zsc_attach(device_t parent, device_t self, void *aux)
{
	struct ewskbd_softc *sc;
	struct zsc_softc *zsc;
	struct zs_chanstate *cs;
	struct zsc_attach_args *zsc_args;
	struct wskbddev_attach_args wskaa;
	int channel;

	sc = device_private(self);
	zsc = device_private(parent);
	sc->sc_dev = self;
	zsc_args = aux;

	/* Establish ourself with the MD z8530 driver */
	channel = zsc_args->channel;
	cs = zsc->zsc_cs[channel];

	if (ewskbd_is_console) {
		sc->sc_dc = &ewskbd_console_dc;
		wskaa.console = 1;
		sc->sc_dc->enabled = 1;
	} else {
		wskaa.console = 0;

		sc->sc_dc = malloc(sizeof(struct ewskbd_devconfig), M_DEVBUF,
		    M_WAITOK | M_ZERO);
		if (sc->sc_dc == NULL) {
			printf(": can't allocate memory\n");
			return;
		}
		sc->sc_dc->enabled = 0;
	}
	cs->cs_defspeed = EWSKBD_BAUD;
	cs->cs_ops = &ewskbd_zsops;
	cs->cs_private = sc;

	sc->sc_dc->txq_head = 0;
	sc->sc_dc->txq_tail = 0;
	sc->sc_dc->rxq_head = 0;
	sc->sc_dc->rxq_tail = 0;
	sc->sc_dc->state = TX_READY;
	sc->sc_dc->leds = 0;

	ewskbd_zsc_init(cs);

	/* set default LED */
	ewskbd_wskbd_set_leds(cs, 0);

	printf(": baud rate %d\n", EWSKBD_BAUD);

	/* attach wskbd */
	wskaa.keymap = &ews4800kbd_wskbd_keymapdata;
	wskaa.accessops = &ewskbd_wskbd_accessops;
	wskaa.accesscookie = cs;
	sc->sc_dc->wskbddev = config_found(self, &wskaa, wskbddevprint);
}
コード例 #21
0
void
apio_attach(struct device *parent, struct device *self, void *aux)
{
	struct apio_softc *sc = (void *)self;
	struct sbus_attach_args *sa = aux;
	struct apio_attach_args aaa;
	char *model;

	sc->sc_bt = sa->sa_bustag;

	model = getpropstring(sa->sa_node, "model");
	if (model == NULL) {
		printf(": empty model, unsupported\n");
		return;
	}
	if (strcmp(model, "210sj") != 0) {
		printf(": unsupported model %s\n", model);
		return;
	}

	if (sa->sa_nreg < 3) {
		printf(": %d registers expected, got %d\n",
		    3, sa->sa_nreg);
		return;
	}

	if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot,
	    sa->sa_reg[0].sbr_offset, sa->sa_reg[0].sbr_size,
	    0, 0, &sc->sc_csr_h)) {
		printf(": couldn't map csr\n");
		return;
	}

	if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[1].sbr_slot,
	    sa->sa_reg[1].sbr_offset, sa->sa_reg[1].sbr_size,
	    0, 0, &sc->sc_clk_h)) {
		printf(": couldn't map clk\n");
		return;
	}

	if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[2].sbr_slot,
	    sa->sa_reg[2].sbr_offset, sa->sa_reg[2].sbr_size,
	    0, 0, &sc->sc_lpt_h)) {
		printf(": couldn't map clk\n");
		return;
	}

	printf(": %s\n", model);

	aaa.aaa_name = "lpt";
	aaa.aaa_iot = sc->sc_bt;
	aaa.aaa_ioh = sc->sc_lpt_h;
	aaa.aaa_clkh = sc->sc_clk_h;
	aaa.aaa_inten = ASIO_CSR_SJ_PAR_INTEN;
	aaa.aaa_pri = sa->sa_intr[0].sbi_pri;
	sc->sc_port = config_found(self, &aaa, apio_print);
}
コード例 #22
0
ファイル: video.c プロジェクト: alenichev/openbsd-kernel
/*
 * Called from hardware driver. This is where the MI video driver gets
 * probed/attached to the hardware driver
 */
struct device *
video_attach_mi(struct video_hw_if *rhwp, void *hdlp, struct device *dev)
{
    struct video_attach_args arg;

    arg.hwif = rhwp;
    arg.hdl = hdlp;
    return (config_found(dev, &arg, videoprint));
}
コード例 #23
0
/*
 * Attach.. plug pointer in and print some info.
 * Then try and attach a wsdisplay or ite to us.
 * Note: self is NULL durring console init.
 */
void
grfattach(device_t parent, device_t self, void *aux)
{
#if NWSDISPLAY > 0
	struct wsemuldisplaydev_attach_args wa;
	long defattr;
#endif
	struct grf_softc *gp;
	int maj;

	gp = device_private(parent);
	gp->g_device = self;
	grfsp[gp->g_unit] = gp;

	/*
	 * find our major device number
	 */
	maj = cdevsw_lookup_major(&grf_cdevsw);

	gp->g_grfdev = makedev(maj, gp->g_unit);
	if (self != NULL) {
		printf(": width %d height %d", gp->g_display.gd_dwidth,
		    gp->g_display.gd_dheight);
		if (gp->g_display.gd_colors == 2)
			printf(" monochrome\n");
		else
			printf(" colors %d\n", gp->g_display.gd_colors);
#if NWSDISPLAY > 0
		vcons_init(&gp->g_vd, gp, gp->g_screens[0], gp->g_accessops);
		gp->g_vd.init_screen = grf_init_screen;
		if (gp->g_flags & GF_CONSOLE) {
			console_vcons.scr_flags |= VCONS_SCREEN_IS_STATIC;
			vcons_init_screen(&gp->g_vd,
			    &console_vcons, 1, &defattr);
			gp->g_screens[0]->textops =
			    &console_vcons.scr_ri.ri_ops;
			wsdisplay_cnattach(gp->g_screens[0],
			    &console_vcons.scr_ri, 0, 0, defattr);
			vcons_replay_msgbuf(&console_vcons);
		}

		/* attach wsdisplay */
		wa.console = (gp->g_flags & GF_CONSOLE) != 0;
		wa.scrdata = &gp->g_screenlist;
		wa.accessops = gp->g_accessops;
		wa.accesscookie = &gp->g_vd;
		config_found(self, &wa, wsemuldisplaydevprint);
#endif  /* NWSDISPLAY > 0 */
	}

#if NWSDISPLAY == 0
	/*
	 * try and attach an ite
	 */
	amiga_config_found(cfdata, self, gp, grfprint);
#endif
}
コード例 #24
0
ファイル: wesc.c プロジェクト: lacombar/netbsd-alc
void
wescattach(struct device *pdp, struct device *dp, void *auxp)
{
    struct siop_softc *sc = (struct siop_softc *)dp;
    struct zbus_args *zap;
    siop_regmap_p rp;
    struct scsipi_adapter *adapt = &sc->sc_adapter;
    struct scsipi_channel *chan = &sc->sc_channel;


    printf("\n");

    zap = auxp;

    sc->sc_siopp = rp = (siop_regmap_p)((char *)zap->va + 0x40000);

    /*
     * CTEST7 = SC0, TT1
     */
    sc->sc_clock_freq = 50;		/* Clock = 50 MHz */
    sc->sc_ctest7 = SIOP_CTEST7_SC0 | SIOP_CTEST7_TT1;
    sc->sc_dcntl = 0x00;

    /*
     * Fill in the scsipi_adapter.
     */
    memset(adapt, 0, sizeof(*adapt));
    adapt->adapt_dev = &sc->sc_dev;
    adapt->adapt_nchannels = 1;
    adapt->adapt_openings = 7;
    adapt->adapt_max_periph = 1;
    adapt->adapt_request = siop_scsipi_request;
    adapt->adapt_minphys = siop_minphys;

    /*
     * Fill in the scsipi_channel.
     */
    memset(chan, 0, sizeof(*chan));
    chan->chan_adapter = adapt;
    chan->chan_bustype = &scsi_bustype;
    chan->chan_channel = 0;
    chan->chan_ntargets = 8;
    chan->chan_nluns = 8;
    chan->chan_id = 7;

    siopinitialize(sc);

    sc->sc_isr.isr_intr = wesc_dmaintr;
    sc->sc_isr.isr_arg = sc;
    sc->sc_isr.isr_ipl = 2;
    add_isr (&sc->sc_isr);

    /*
     * attach all scsi units on us
     */
    config_found(dp, chan, scsiprint);
}
コード例 #25
0
ファイル: cec.c プロジェクト: MarginC/kame
void
cecattach(struct device *parent, struct device *self, void *aux)
{
	struct cec_softc *sc = (struct cec_softc *)self;
	struct isa_attach_args *ia = aux;
	struct gpibdev_attach_args ga;
	bus_size_t maxsize;

	printf("\n");

	DPRINTF(DBG_CONFIG, ("cecattach: called\n"));

	sc->sc_iot = ia->ia_iot;
	sc->sc_ic = ia->ia_ic;

	if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, CEC_IOSIZE,
	    0, &sc->sc_ioh) != 0) {
		printf("%s: unable to map I/O space\n", sc->sc_dev.dv_xname);
		return;
	}

	if (ia->ia_ndrq > 0) {
		sc->sc_flags |= CECF_USEDMA;
		sc->sc_drq = ia->ia_drq[0].ir_drq;

		(void) isa_drq_alloc(sc->sc_ic, sc->sc_drq);
		maxsize = isa_dmamaxsize(sc->sc_ic, sc->sc_drq);
		if (isa_dmamap_create(sc->sc_ic, sc->sc_drq,
		    maxsize, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW)) {
			printf("%s: unable to create map for drq %d\n",
			    sc->sc_dev.dv_xname, sc->sc_drq);
			sc->sc_flags &= ~CECF_USEDMA;
		}
	}

	sc->sc_myaddr = 15;		/* XXX */

	cecreset(sc);
	(void) nec7210_setaddress(sc, sc->sc_myaddr, -1);

	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
	    IST_EDGE, IPL_BIO, cecintr, sc);
	if (sc->sc_ih == NULL) {
		printf("%s: couldn't establish interrupt\n",
		    sc->sc_dev.dv_xname);
		return;
	}

	callout_init(&sc->sc_timeout_ch);

	/* attach MI GPIB bus */
	cec_ic.cookie = (void *)sc;
	ga.ga_ic = &cec_ic;
	ga.ga_address = sc->sc_myaddr;
	sc->sc_gpib =
	    (struct gpib_softc *)config_found(self, &ga, gpibdevprint);
}
コード例 #26
0
ファイル: radio.c プロジェクト: ryo/netbsd-src
/*
 * Called from hardware driver. This is where the MI radio driver gets
 * probed/attached to the hardware driver
 */
device_t
radio_attach_mi(const struct radio_hw_if *rhwp, void *hdlp, device_t dev)
{
	struct radio_attach_args arg;

	arg.hwif = rhwp;
	arg.hdl = hdlp;
	return (config_found(dev, &arg, radioprint));
}
コード例 #27
0
ファイル: amdiic.c プロジェクト: alenichev/openbsd-kernel
void
amdiic_attach(struct device *parent, struct device *self, void *aux)
{
	struct amdiic_softc *sc = (struct amdiic_softc *)self;
	struct pci_attach_args *pa = aux;
	struct i2cbus_attach_args iba;
	pcireg_t conf;
	bus_size_t iosize;
	pci_intr_handle_t ih;
	const char *intrstr = NULL;

	/* Map I/O space */
	if (pci_mapreg_map(pa, AMD8111_SMB_BASE, PCI_MAPREG_TYPE_IO, 0,
	    &sc->sc_iot, &sc->sc_ioh, NULL, &iosize, 0)) {
		printf(": can't map i/o space\n");
		return;
	}

	/* Read configuration */
	conf = pci_conf_read(pa->pa_pc, pa->pa_tag, AMD8111_SMB_MISC);
	DPRINTF((": conf 0x%08x", conf));

	sc->sc_poll = 1;
	if (conf & AMD8111_SMB_MISC_SCIEN) {
		/* No PCI IRQ */
		printf(": SCI");
	} else if (conf & AMD8111_SMB_MISC_INTEN) {
		/* Install interrupt handler */
		if (pci_intr_map(pa, &ih) == 0) {
			intrstr = pci_intr_string(pa->pa_pc, ih);
			sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO,
			    amdiic_intr, sc, sc->sc_dev.dv_xname);
			if (sc->sc_ih != NULL) {
				printf(": %s", intrstr);
				sc->sc_poll = 0;
			}
		}
		if (sc->sc_poll)
			printf(": polling");
	}

	printf("\n");

	/* Attach I2C bus */
	rw_init(&sc->sc_i2c_lock, "iiclk");
	sc->sc_i2c_tag.ic_cookie = sc;
	sc->sc_i2c_tag.ic_acquire_bus = amdiic_i2c_acquire_bus;
	sc->sc_i2c_tag.ic_release_bus = amdiic_i2c_release_bus;
	sc->sc_i2c_tag.ic_exec = amdiic_i2c_exec;

	bzero(&iba, sizeof(iba));
	iba.iba_name = "iic";
	iba.iba_tag = &sc->sc_i2c_tag;
	config_found(self, &iba, iicbus_print);

	return;
}
コード例 #28
0
ファイル: ts102.c プロジェクト: bradla/OpenBSD-Hammer2
void
tslot_reset(struct tslot_data *td, u_int32_t iosize)
{
	struct pcmciabus_attach_args paa;
	int ctl, status;

	paa.paa_busname = "pcmcia";
	paa.pct = (pcmcia_chipset_tag_t)td->td_parent->sc_pct;
	paa.pch = (pcmcia_chipset_handle_t)td;
	paa.iobase = 0;
	paa.iosize = iosize;

	td->td_pcmcia = config_found(&td->td_parent->sc_dev, &paa, tslot_print);

	if (td->td_pcmcia == NULL) {
		/*
		 * If no pcmcia attachment, power down the slot.
		 */
		tslot_slot_disable((pcmcia_chipset_handle_t)td);
		return;
	}

	/*
	 * Initialize the slot
	 */

	ctl = TSLOT_READ(td, TS102_REG_CARD_A_CTL);
	/* force low addresses */
	ctl &= ~(TS102_CARD_CTL_AA_MASK | TS102_CARD_CTL_IA_MASK);
	/* Put SBus and PCMCIA in their respective endian mode */
	ctl |= TS102_CARD_CTL_SBLE;	/* this is not what it looks like! */
	ctl &= ~TS102_CARD_CTL_PCMBE;
	/* disable read ahead and address increment */
	ctl &= ~TS102_CARD_CTL_RAHD;
	ctl |= TS102_CARD_CTL_INCDIS;
	/* power on */
	ctl &= ~TS102_CARD_CTL_PWRD;
	TSLOT_WRITE(td, TS102_REG_CARD_A_CTL, ctl);

	/*
	 * Enable interrupt upon insertion/removal
	 */

	TSLOT_WRITE(td, TS102_REG_CARD_A_INT,
	    TS102_CARD_INT_MASK_CARDDETECT_STATUS);

	status = TSLOT_READ(td, TS102_REG_CARD_A_STS);
	if (status & TS102_CARD_STS_PRES) {
		tadpole_set_pcmcia(td->td_slot, 1);
		td->td_status = TS_CARD;
		pcmcia_card_attach(td->td_pcmcia);
	} else {
		tadpole_set_pcmcia(td->td_slot, 0);
		td->td_status = 0;
	}
}
コード例 #29
0
static void
ehci_awinusb_attach(device_t parent, device_t self, void *aux)
{
    struct awinusb_softc * const usbsc = device_private(parent);
    struct ehci_softc * const sc = device_private(self);
    struct awinusb_attach_args * const usbaa = aux;
    int irq;

    sc->sc_dev = self;

    sc->iot = usbaa->usbaa_bst;
    sc->ioh = usbaa->usbaa_bsh;
    sc->sc_size = usbaa->usbaa_size;
    sc->sc_bus.dmatag = usbaa->usbaa_dmat;
    sc->sc_bus.hci_private = sc;
    sc->sc_bus.usbrev = USBREV_2_0;
    sc->sc_ncomp = 0;
    if (usbsc->usbsc_ohci_dev != NULL) {
        sc->sc_comps[sc->sc_ncomp++] = usbsc->usbsc_ohci_dev;
    }

    //sc->sc_id_vendor = PCI_VENDOR_ALLWINNER;
    strlcpy(sc->sc_vendor, "Allwinner", sizeof(sc->sc_vendor));

    aprint_naive(": EHCI USB controller\n");
    aprint_normal(": EHCI USB controller\n");

    int error = ehci_init(sc);
    if (error != USBD_NORMAL_COMPLETION) {
        aprint_error_dev(self, "init failed, error=%d\n", error);
        return;
    }
    /* Attach usb device. */
    sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);

    switch (awin_chip_id()) {
    case AWIN_CHIP_ID_A80:
        irq = awinusb_ehci_irqs_a80[usbaa->usbaa_port];
        break;
    case AWIN_CHIP_ID_A31:
        irq = awinusb_ehci_irqs_a31[usbaa->usbaa_port];
        break;
    default:
        irq = awinusb_ehci_irqs[usbaa->usbaa_port];
        break;
    }

    usbsc->usbsc_ehci_ih = intr_establish(irq, IPL_VM,
                                          IST_LEVEL, ehci_intr, sc);
    if (usbsc->usbsc_ehci_ih == NULL) {
        aprint_error_dev(self, "failed to establish interrupt %d\n",
                         irq);
        return;
    }
    aprint_normal_dev(self, "interrupting on irq %d\n", irq);
}
コード例 #30
0
ファイル: gpio_opb.c プロジェクト: ryo/netbsd-src
static void
gpio_opb_attach(device_t parent, device_t self, void *aux)
{
	struct gpio_opb_softc * const sc = device_private(self);
	struct opb_attach_args * const oaa = aux;
	struct gpiobus_attach_args gba;
	uint32_t reg_ir, reg_tcr, reg_odr;

	aprint_naive(": GPIO controller\n");
	aprint_normal(": On-Chip GPIO controller\n");

	sc->sc_dev = self;

	/* Map GPIO I/O space */
	sc->sc_gpio_iot = oaa->opb_bt;
	bus_space_map(sc->sc_gpio_iot, oaa->opb_addr,
		GPIO_NREG, 0, &sc->sc_gpio_ioh);

	/* Read current register status */
	reg_ir  = gpio_read(sc, GPIO_IR);
	reg_tcr = gpio_read(sc, GPIO_TCR);
	reg_odr = gpio_read(sc, GPIO_ODR);

	/* Initialize pins array */
	gpio_pin_t *pin = sc->sc_gpio_pins;
	for (u_int i = 0 ; i < GPIO_NPINS ; i++, pin++) {
		const uint32_t pin_mask = 1 << GPIO_PIN_SHIFT(i + 1);
		pin->pin_num = i;
		pin->pin_caps = GPIO_PIN_INOUT
				 | GPIO_PIN_OPENDRAIN
				 | GPIO_PIN_TRISTATE;

		/* current defaults */
		pin->pin_flags =
		    (reg_odr & pin_mask)
			? GPIO_PIN_OPENDRAIN
			: ((reg_tcr & pin_mask)
			    ? GPIO_PIN_INOUT
			    : GPIO_PIN_TRISTATE);
		pin->pin_state = (reg_ir & pin_mask) != 0;
		pin->pin_mapped = 0;
	}

	/* Create controller tag */
	sc->sc_gpio_gc.gp_cookie = sc;
	sc->sc_gpio_gc.gp_pin_read = gpio_opb_pin_read;
	sc->sc_gpio_gc.gp_pin_write = gpio_opb_pin_write;
	sc->sc_gpio_gc.gp_pin_ctl = gpio_opb_pin_ctl;

	gba.gba_gc = &sc->sc_gpio_gc;
	gba.gba_pins = sc->sc_gpio_pins;
	gba.gba_npins = GPIO_NPINS;

	/* Attach GPIO framework */
	(void) config_found(self, &gba, gpiobus_print);
}