FreeBSD/sys/dev/ed/if_ed_pccard.c
/*
 * Probe and vendor-specific initialization routine for ax88x90 boards
 */
Probe and vendor-specific initialization routine for ax88x90 boards
Probe and vendor - specific initialization routine for ax88x90 boards
static int
ed_probe_ax88x90_generic(device_t dev, int flags)
{
	struct ed_softc *sc = device_get_softc(dev);
	u_int   memsize;
	static char test_pattern[32] = "THIS is A memory TEST pattern";
	char    test_buffer[32];
	ed_pccard_ax88x90_reset(sc);
	DELAY(10*1000);
	if (!ed_probe_generic8390(sc))
		return (ENXIO);
	sc->vendor = ED_VENDOR_NOVELL;
	sc->mem_shared = 0;
	sc->cr_proto = ED_CR_RD2;
	sc->isa16bit = 1;
	ed_nic_outb(sc, ED_P0_RCR, ED_RCR_MON);
	ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
	ed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern));
	ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern));
	if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)) != 0)
		return (ENXIO);
	sc->type = ED_TYPE_NE2000;
	memsize = sc->mem_size = 16*1024;
	sc->mem_start = 16 * 1024;
	if (ed_asic_inb(sc, ED_AX88X90_TEST) != 0)
		sc->chip_type = ED_CHIP_TYPE_AX88790;
	else {
		sc->chip_type = ED_CHIP_TYPE_AX88190;
		ed_pio_writemem(sc, test_pattern, 32768, sizeof(test_pattern));
		ed_pio_readmem(sc, 32768, test_buffer, sizeof(test_pattern));
		if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)) == 0) {
			sc->mem_start = 2*1024;
			memsize = sc->mem_size = 62 * 1024;
		}
	}
	sc->mem_end = sc->mem_start + memsize;
	sc->tx_page_start = memsize / ED_PAGE_SIZE;
	if (sc->mem_size > 16 * 1024)
		sc->txb_cnt = 3;
	else
		sc->txb_cnt = 2;
	sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
	sc->rec_page_stop = sc->tx_page_start + memsize / ED_PAGE_SIZE;
	sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE;
	ed_nic_outb(sc, ED_P0_PSTART, sc->mem_start / ED_PAGE_SIZE);
	ed_nic_outb(sc, ED_P0_PSTOP, sc->mem_end / ED_PAGE_SIZE);
	ed_pio_readmem(sc, 0x400, sc->enaddr, ETHER_ADDR_LEN);
	ed_nic_outb(sc, ED_P0_ISR, 0xff);
	sc->sc_write_mbufs = ed_pio_write_mbufs;
	return (0);
}
static int ed_probe_ax88x90_generic ( device_t dev , int flags ) { struct ed_softc * sc = device_get_softc ( dev ) ; u_int memsize ; static char test_pattern [ 32 ] = " " ; char test_buffer [ 32 ] ; ed_pccard_ax88x90_reset ( sc ) ; DELAY ( 10 * 1000 ) ; if ( ! ed_probe_generic8390 ( sc ) ) return ( ENXIO ) ; sc -> vendor = ED_VENDOR_NOVELL ; sc -> mem_shared = 0 ; sc -> cr_proto = ED_CR_RD2 ; sc -> isa16bit = 1 ; ed_nic_outb ( sc , ED_P0_RCR , ED_RCR_MON ) ; ed_nic_outb ( sc , ED_P0_DCR , ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS ) ; ed_pio_writemem ( sc , test_pattern , 16384 , sizeof ( test_pattern ) ) ; ed_pio_readmem ( sc , 16384 , test_buffer , sizeof ( test_pattern ) ) ; if ( bcmp ( test_pattern , test_buffer , sizeof ( test_pattern ) ) != 0 ) return ( ENXIO ) ; sc -> type = ED_TYPE_NE2000 ; memsize = sc -> mem_size = 16 * 1024 ; sc -> mem_start = 16 * 1024 ; if ( ed_asic_inb ( sc , ED_AX88X90_TEST ) != 0 ) sc -> chip_type = ED_CHIP_TYPE_AX88790 ; else { sc -> chip_type = ED_CHIP_TYPE_AX88190 ; ed_pio_writemem ( sc , test_pattern , 32768 , sizeof ( test_pattern ) ) ; ed_pio_readmem ( sc , 32768 , test_buffer , sizeof ( test_pattern ) ) ; if ( bcmp ( test_pattern , test_buffer , sizeof ( test_pattern ) ) == 0 ) { sc -> mem_start = 2 * 1024 ; memsize = sc -> mem_size = 62 * 1024 ; } } sc -> mem_end = sc -> mem_start + memsize ; sc -> tx_page_start = memsize / ED_PAGE_SIZE ; if ( sc -> mem_size > 16 * 1024 ) sc -> txb_cnt = 3 ; else sc -> txb_cnt = 2 ; sc -> rec_page_start = sc -> tx_page_start + sc -> txb_cnt * ED_TXBUF_SIZE ; sc -> rec_page_stop = sc -> tx_page_start + memsize / ED_PAGE_SIZE ; sc -> mem_ring = sc -> mem_start + sc -> txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE ; ed_nic_outb ( sc , ED_P0_PSTART , sc -> mem_start / ED_PAGE_SIZE ) ; ed_nic_outb ( sc , ED_P0_PSTOP , sc -> mem_end / ED_PAGE_SIZE ) ; ed_pio_readmem ( sc , 0x400 , sc -> enaddr , ETHER_ADDR_LEN ) ; ed_nic_outb ( sc , ED_P0_ISR , 0xff ) ; sc -> sc_write_mbufs = ed_pio_write_mbufs ; return ( 0 ) ; }
Probe and vendor-specific initialization routine for ax88x90 boards
Probe and vendor - specific initialization routine for ax88x90 boards
/* Make sure that we really have an 8390 based board */ /*
	 * This prevents packets from being stored in the NIC memory when the
	 * readmem routine turns on the start bit in the CR.  We write some
	 * bytes in word mode and verify we can read them back.  If we can't
	 * then we don't have an AX88x90 chip here.
	 */ /*
	 * Hard code values based on the datasheet.  We're NE-2000 compatible
	 * NIC with 16kb of packet memory starting at 16k offset.
	 */ /*
		 * The AX88190 (not A) has external 64k SRAM.  Probe for this
		 * here.  Most of the cards I have either use the AX88190A
		 * part, or have only 32k SRAM for some reason, so I don't
		 * know if this works or not.
		 */ /* Get the mac before we go -- It's just at 0x400 in "SRAM" */ /* clear any pending interrupts that might have occurred above */