コード例 #1
0
static int
cs_isa_attach(device_t dev)
{
        struct cs_softc *sc = device_get_softc(dev);
        
	cs_alloc_port(dev, 0, CS_89x0_IO_PORTS);
        cs_alloc_irq(dev, sc->irq_rid);
                
        return (cs_attach(dev));
}
コード例 #2
0
void 
cs_ssextio_attach(device_t parent, device_t self, void *aux)
{
	struct cs_softc *sc = device_private(self);
	struct s3c2xx0_attach_args *sa = aux;
	vaddr_t ioaddr;
#ifdef	SMDK24X0_ETHER_ADDR_FIXED
	static uint8_t enaddr[ETHER_ADDR_LEN] = {SMDK24X0_ETHER_ADDR_FIXED};
#else
#define enaddr NULL
#endif

	sc->sc_dev = self;
	sc->sc_iot = sc->sc_memt = sa->sa_iot;
	/* sc_irq is an IRQ number in ISA world. set 10 for INTRQ0 of CS8900A */
	sc->sc_irq = 10;

	/*
	 * Map the device.
	 */
	ioaddr = IOADDR(sa->sa_addr);
	if (bus_space_map(sc->sc_iot, ioaddr, CS8900_IOSIZE, 0, &sc->sc_ioh)) {
		aprint_error(": unable to map i/o space\n");
		return;
	}

	if (bus_space_map(sc->sc_iot, sa->sa_addr, CS8900_MEMSIZE,
			  0, &sc->sc_memh))
		aprint_error(": unable to map memory space");
	else {
		sc->sc_cfgflags |= CFGFLG_MEM_MODE;
		sc->sc_pktpgaddr = sa->sa_addr;
	}

	/* CS8900A is very slow. (nOE->Data valid: 135ns max.)
	   We need to use IOCHRDY signal */
	sc->sc_cfgflags |= CFGFLG_IOCHRDY;

	sc->sc_ih = s3c2410_extint_establish(sa->sa_intr, IPL_NET, IST_EDGE_RISING,
	    cs_intr, sc);
	if (sc->sc_ih == NULL) {
		aprint_error(": unable to establish interrupt\n");
		return;
	}

	aprint_normal("\n");

	/* SMDK24X0 doesn't have EEPRMO hooked to CS8900A */
	sc->sc_cfgflags |= CFGFLG_NOT_EEPROM;

	cs_attach(sc, enaddr, cs_media, 
	    sizeof(cs_media) / sizeof(cs_media[0]), IFM_ETHER|IFM_10_T);
}
コード例 #3
0
ファイル: mi32_wrapper_pkg.c プロジェクト: macka87/haven
/*
 * Starts the MI32 transfer.
 */
int c_start_mi32_transfer(cs_addr_t hw_addr) {

    if (cs_attach(&d, file) != 0)
        return EXIT_FAILURE; // cs_attach failed

    mapsize = 4;

    if (cs_space_map(d, &s, space, mapsize, hw_addr, 0) != 0)
        return EXIT_FAILURE; // cs_space_map failed

    return EXIT_SUCCESS;
}
コード例 #4
0
static void
cs_pcmcia_attach(device_t parent, device_t self, void *aux)
{
	struct cs_pcmcia_softc *psc = device_private(self);
	struct cs_softc *sc = &psc->sc_cs;
	struct pcmcia_attach_args *pa = aux;
	struct pcmcia_config_entry *cfe;
	struct pcmcia_function *pf;
	int error;

	sc->sc_dev = self;
	pf = psc->sc_pf = pa->pf;

	error = pcmcia_function_configure(pa->pf, cs_pcmcia_validate_config);
	if (error) {
		aprint_error_dev(self, "configure failed, error=%d\n",
		    error);
		return;
	}

	cfe = pf->cfe;
	sc->sc_iot = cfe->iospace[0].handle.iot;
	sc->sc_ioh = cfe->iospace[0].handle.ioh;
	sc->sc_irq = -1;
#define CS_PCMCIA_HACK_FOR_CARDBUS
#ifdef CS_PCMCIA_HACK_FOR_CARDBUS
	/*
	 * XXX is there a generic way to know if it's a cardbus or not?
	 */
	sc->sc_cfgflags |= CFGFLG_CARDBUS_HACK;
#endif

	error = cs_pcmcia_enable(sc);
	if (error)
		goto fail;

	sc->sc_enable = cs_pcmcia_enable;
	sc->sc_disable = cs_pcmcia_disable;

	/* chip attach */
	error = cs_attach(sc, 0, 0, 0, 0);
	if (error)
		goto fail2;

	cs_pcmcia_disable(sc);
	psc->sc_state = CS_PCMCIA_ATTACHED;
	return;

fail2:
	cs_pcmcia_disable(sc);
fail:
	pcmcia_function_unconfigure(pf);
}
コード例 #5
0
ファイル: dpi_mi32_wrapper_pkg.c プロジェクト: macka87/haven
/*
 * Starts the MI32 transfer.
 */
int c_start_mi32_transfer(cs_addr_t addr) {

    if (cs_attach(&d, file) != 0) {
        printf("CS ATTACH FAILED!\n");
        return EXIT_FAILURE; // cs_attach failed
    }
    mapsize = 4;

    if (cs_space_map(d, &s, space, mapsize, addr, 0) != 0) {
        printf("CS SPACE MAP FAILED!\n");
        return EXIT_FAILURE; // cs_space_map failed
    }
    return EXIT_SUCCESS;
}
コード例 #6
0
ファイル: if_cs_pccard.c プロジェクト: edgar-pek/PerspicuOS
static int
cs_pccard_attach(device_t dev)
{
	struct cs_softc *sc = device_get_softc(dev);
	int error;

	sc->flags |= CS_NO_IRQ;
	error = cs_cs89x0_probe(dev);
	if (error != 0)
		return (error);
	error = cs_alloc_irq(dev, sc->irq_rid);
	if (error != 0)
		goto bad;

	return (cs_attach(dev));
bad:
	cs_release_resources(dev);
	return (error);
}
コード例 #7
0
ファイル: if_cs_isa.c プロジェクト: UnitedMarsupials/kame
static int
cs_isa_attach(device_t dev)
{
        struct cs_softc *sc = device_get_softc(dev);
        int flags = device_get_flags(dev);
        int error;
        
	cs_alloc_port(dev, 0, CS_89x0_IO_PORTS);
	/* XXX mem appears to not be used at all */
        if (sc->mem_used)
                cs_alloc_memory(dev, sc->mem_rid, sc->mem_used);
        cs_alloc_irq(dev, sc->irq_rid, 0);
                
        error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
	    csintr, sc, &sc->irq_handle);
        if (error) {
                cs_release_resources(dev);
                return (error);
        }              

        return (cs_attach(sc, device_get_unit(dev), flags));
}
コード例 #8
0
static int
cs_pccard_attach(device_t dev)
{
	struct cs_softc *sc = device_get_softc(dev);
	int error;

	sc->flags |= CS_NO_IRQ;
	error = cs_cs89x0_probe(dev);
	if (error != 0)
		return (error);
	error = cs_alloc_irq(dev, sc->irq_rid, 0);
	if (error != 0)
		goto bad;
	error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
	    NULL, csintr, sc, &sc->irq_handle);
	if (error != 0)
		goto bad;

	return (cs_attach(dev));
bad:
	cs_release_resources(dev);
	return (error);
}
コード例 #9
0
ファイル: if_cs.c プロジェクト: ryo/netbsd-src
void 
cs_rsbus_attach(device_t parent, device_t self, void *aux)
{
	struct cs_softc *sc = device_private(self);
	struct rsbus_attach_args *rs = aux;
	u_int iobase;

	sc->sc_dev = self;

	/* member copy */
	cs_rsbus_bs_tag = *rs->sa_iot;
	
	/* registers are normally accessed in pairs, on a 4 byte aligned */
	cs_rsbus_bs_tag.bs_cookie = (void *) 1;
	
	sc->sc_iot = sc->sc_memt = &cs_rsbus_bs_tag;

#if 0	/* Do DMA later */
	if (ia->ia_ndrq > 0)
		isc->sc_drq = ia->ia_drq[0].ir_drq;
	else
		isc->sc_drq = -1;
#endif

	/* device always interrupts on 3 but that routes to IRQ 5 */
	sc->sc_irq = 3;

	printf("\n");

	/*
	 * Map the device.
	 */
	iobase = 0x03010600;
	if (bus_space_map(sc->sc_iot, iobase, CS8900_IOSIZE * 4,
	    0, &sc->sc_ioh)) {
		printf("%s: unable to map i/o space\n", device_xname(self));
		return;
	}

#if 0
	if (bus_space_map(sc->sc_memt, iobase + 0x3A00,
				CS8900_MEMSIZE * 4, 0, &sc->sc_memh)) {
		printf("%s: unable to map memory space\n", device_xname(self));
	} else {
		sc->sc_cfgflags |= CFGFLG_MEM_MODE | CFGFLG_USE_SA;
		sc->sc_pktpgaddr = 1<<23;
		//(0x4000 >> 1)  |  (1<<23);
	}
#endif
	sc->sc_ih = intr_claim(IRQ_INT5, IPL_NET, "cs", cs_intr, sc);
	if (sc->sc_ih == NULL) {
		printf("%s: unable to establish interrupt\n",
		    device_xname(sc->sc_dev));
		return;
	}

	/* DMA is for later */
	sc->sc_dma_chipinit = NULL;
	sc->sc_dma_attach = NULL;
	sc->sc_dma_process_rx = NULL;

	sc->sc_cfgflags |= CFGFLG_PARSE_EEPROM;
	sc->sc_io_read_1 = cs_rbus_read_1;

	/* 
	 * also provide media, otherwise it attempts to read the media from
	 * the EEPROM, which again fails
	 */
	cs_attach(sc, NULL, cs_rbus_media, sizeof(cs_rbus_media) / sizeof(cs_rbus_media[0]),
			IFM_ETHER|IFM_10_T|IFM_FDX);
}
コード例 #10
0
ファイル: if_cs_isa.c プロジェクト: Tommmster/netbsd-avr32
void
cs_isa_attach(struct device *parent, struct device *self, void *aux)
{
	struct cs_softc *sc = (struct cs_softc *) self;
	struct cs_softc_isa *isc = (void *) self;
	struct isa_attach_args *ia = aux;

	isc->sc_ic = ia->ia_ic;
	sc->sc_iot = ia->ia_iot;
	sc->sc_memt = ia->ia_memt;

	if (ia->ia_ndrq > 0)
		isc->sc_drq = ia->ia_drq[0].ir_drq;
	else
		isc->sc_drq = -1;

	sc->sc_irq = ia->ia_irq[0].ir_irq;

	printf("\n");

	/*
	 * Map the device.
	 */
	if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, CS8900_IOSIZE,
	    0, &sc->sc_ioh)) {
		aprint_error_dev(&sc->sc_dev, "unable to map i/o space\n");
		return;
	}

	/*
	 * Validate IRQ.
	 */
	if (CS8900_IRQ_ISVALID(sc->sc_irq) == 0) {
		aprint_error_dev(&sc->sc_dev, "invalid IRQ %d\n", sc->sc_irq);
		return;
	}

	/*
	 * Map the memory space if it was specified.  If we can do this,
	 * we set ourselves up to use memory mode forever.  Otherwise,
	 * we fall back on I/O mode.
	 */
	if (ia->ia_iomem[0].ir_addr != ISA_UNKNOWN_IOMEM &&
	    ia->ia_iomem[0].ir_size == CS8900_MEMSIZE &&
	    CS8900_MEMBASE_ISVALID(ia->ia_iomem[0].ir_addr)) {
		if (bus_space_map(sc->sc_memt, ia->ia_iomem[0].ir_addr,
		    CS8900_MEMSIZE, 0, &sc->sc_memh)) {
			aprint_error_dev(&sc->sc_dev, "unable to map memory space\n");
		} else {
			sc->sc_cfgflags |= CFGFLG_MEM_MODE;
			sc->sc_pktpgaddr = ia->ia_iomem[0].ir_addr;
		}
	}

	sc->sc_ih = isa_intr_establish(ia->ia_ic, sc->sc_irq, IST_EDGE,
	    IPL_NET, cs_intr, sc);
	if (sc->sc_ih == NULL) {
		aprint_error_dev(&sc->sc_dev, "unable to establish interrupt\n");
		return;
	}

	sc->sc_dma_chipinit = cs_isa_dma_chipinit;
	sc->sc_dma_attach = cs_isa_dma_attach;
	sc->sc_dma_process_rx = cs_process_rx_dma;

	cs_attach(sc, NULL, NULL, 0, 0);
}
コード例 #11
0
ファイル: if_cs_pcmcia.c プロジェクト: MarginC/kame
static void
cs_pcmcia_attach(struct device *parent, struct device *self, void *aux)
{
	struct cs_pcmcia_softc *psc = (void *)self;
	struct cs_softc *sc = (void *)&psc->sc_cs;
	struct pcmcia_attach_args *pa = aux;
	struct pcmcia_config_entry *cfe;
	struct pcmcia_function *pf;
	char devinfo[256];

	/* Print out what we are. */
	pcmcia_devinfo(&pa->pf->sc->card, 0, devinfo, sizeof(devinfo));
	printf(": %s\n", devinfo);

	pf = psc->sc_pf = pa->pf;

	cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head);

	if (cfe->num_iospace != 1) {
		printf("%s: unexpected number of iospace(%d)\n",
			DEVNAME(sc), cfe->num_iospace);
		goto fail;
	}

	if (cfe->iospace[0].length < CS8900_IOSIZE) {
		printf("%s: unexpected iosize(%lu)\n",
			DEVNAME(sc), cfe->iospace[0].length);
		goto fail;
	}

	if (cfe->num_memspace != 0) {
		printf("%s: unexpected number of memspace(%d)\n",
			DEVNAME(sc), cfe->num_memspace);
		goto fail;
	}

	if (pcmcia_io_alloc(pf, cfe->iospace[0].start,
		cfe->iospace[0].length, cfe->iospace[0].length,
		&psc->sc_pcioh) != 0) {
		printf("%s: can't allocate i/o space %lx:%lx\n", DEVNAME(sc),
			cfe->iospace[0].start, cfe->iospace[0].length);
		goto fail;
	}
	psc->sc_flags |= CS_PCMCIA_FLAGS_IO_ALLOCATED;

	sc->sc_iot = psc->sc_pcioh.iot;
	sc->sc_ioh = psc->sc_pcioh.ioh;
	sc->sc_irq = -1;
#define CS_PCMCIA_HACK_FOR_CARDBUS
#ifdef CS_PCMCIA_HACK_FOR_CARDBUS
	/*
	 * XXX is there a generic way to know if it's a cardbus or not?
	 */
	sc->sc_cfgflags |= CFGFLG_CARDBUS_HACK;
#endif
	sc->sc_enable = cs_pcmcia_enable;
	sc->sc_disable = cs_pcmcia_disable;

	pcmcia_function_init(pa->pf, cfe);
	if (cs_pcmcia_enable(sc))
		goto fail;

	/* chip attach */
	if (cs_attach(sc, 0, 0, 0, 0))
		goto fail;

	cs_pcmcia_disable(sc);

	return;

fail:
	cs_pcmcia_detach((struct device *)psc, 0);

	return;
}