/* LANCE initialization block set up. */ void lememinit(struct le_softc *sc) { int i; u_char *mem; u_long a; /* * At this point we assume that the memory allocated to the Lance is * quadword aligned. If it isn't then the initialisation is going * fail later on. */ mem = sc->sc_mem; sc->sc_init = (void *)mem; sc->sc_init->mode = LE_NORMAL; for (i = 0; i < ETHER_ADDR_LEN; i++) sc->sc_init->padr[i] = sc->sc_addr[i^1]; sc->sc_init->ladrf[0] = sc->sc_init->ladrf[1] = 0; mem += sizeof(struct init_block); sc->sc_rd = (void *)mem; a = LANCE_ADDR(sc, mem); sc->sc_init->rdra = a; sc->sc_init->rlen = ((a >> 16) & 0xff) | (RLEN << 13); mem += NRBUF * sizeof(struct mds); sc->sc_td = (void *)mem; a = LANCE_ADDR(sc, mem); sc->sc_init->tdra = a; sc->sc_init->tlen = ((a >> 16) & 0xff) | (TLEN << 13); mem += NTBUF * sizeof(struct mds); /* * Set up receive ring descriptors. */ sc->sc_rbuf = mem; for (i = 0; i < NRBUF; i++) { a = LANCE_ADDR(sc, mem); sc->sc_rd[i].addr = a; sc->sc_rd[i].flags = ((a >> 16) & 0xff) | LE_OWN; sc->sc_rd[i].bcnt = -BUFSIZE; sc->sc_rd[i].mcnt = 0; mem += BUFSIZE; } /* * Set up transmit ring descriptors. */ sc->sc_tbuf = mem; for (i = 0; i < NTBUF; i++) { a = LANCE_ADDR(sc, mem); sc->sc_td[i].addr = a; sc->sc_td[i].flags = ((a >> 16) & 0xff); sc->sc_td[i].bcnt = 0xf000; sc->sc_td[i].mcnt = 0; mem += BUFSIZE; } }
void le_reset(int unit, u_char *myea) { struct le_softc *sc = &le_softc[unit]; u_long a; int timo = 100000; #ifdef LE_DEBUG if (le_debug) { printf("le%d: le_reset called\n", unit); printf(" r0=%x, r1=%x, mem=%x, addr=%x:%x:%x:%x:%x:%x\n", sc->sc_r0, sc->sc_r1, sc->sc_mem, sc->sc_addr[0], sc->sc_addr[1], sc->sc_addr[2], sc->sc_addr[3], sc->sc_addr[4], sc->sc_addr[5]); } #endif lewrcsr(sc, 0, LE_STOP); for (timo = 1000; timo; timo--); sc->sc_next_rd = sc->sc_next_td = 0; /* Set up LANCE init block. */ lememinit(sc); if (myea) bcopy(sc->sc_addr, myea, ETHER_ADDR_LEN); /* Turn on byte swapping. */ lewrcsr(sc, 3, LE_BSWP); /* Give LANCE the physical address of its init block. */ a = LANCE_ADDR(sc, sc->sc_init); lewrcsr(sc, 1, a); lewrcsr(sc, 2, (a >> 16) & 0xff); #ifdef LE_DEBUG if (le_debug) printf("le%d: before init\n", unit); #endif /* Try to initialize the LANCE. */ lewrcsr(sc, 0, LE_INIT); /* Wait for initialization to finish. */ for (timo = 100000; timo; timo--) if (lerdcsr(sc, 0) & LE_IDON) break; if (lerdcsr(sc, 0) & LE_IDON) { /* Start the LANCE. */ lewrcsr(sc, 0, LE_INEA | LE_STRT | LE_IDON); } else printf("le%d: card failed to initialize\n", unit); #ifdef LE_DEBUG if (le_debug) printf("le%d: after init\n", unit); #endif }