Home | History | Annotate | Line # | Download | only in obio
if_mc_obio.c revision 1.2
      1  1.1  briggs /*-
      2  1.1  briggs  * Copyright (c) 1997 David Huang <khym (at) bga.com>
      3  1.1  briggs  * All rights reserved.
      4  1.1  briggs  *
      5  1.1  briggs  * Portions of this code are based on code by Denton Gentry <denny1 (at) home.com>
      6  1.1  briggs  * and Yanagisawa Takeshi <yanagisw (at) aa.ap.titech.ac.jp>.
      7  1.1  briggs  *
      8  1.1  briggs  * Redistribution and use in source and binary forms, with or without
      9  1.1  briggs  * modification, are permitted provided that the following conditions
     10  1.1  briggs  * are met:
     11  1.1  briggs  * 1. Redistributions of source code must retain the above copyright
     12  1.1  briggs  *    notice, this list of conditions and the following disclaimer.
     13  1.1  briggs  * 2. The name of the author may not be used to endorse or promote products
     14  1.1  briggs  *    derived from this software without specific prior written permission
     15  1.1  briggs  *
     16  1.1  briggs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1  briggs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1  briggs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1  briggs  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.1  briggs  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  1.1  briggs  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  1.1  briggs  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  1.1  briggs  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  1.1  briggs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  1.1  briggs  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  1.1  briggs  *
     27  1.1  briggs  */
     28  1.1  briggs 
     29  1.1  briggs /*
     30  1.1  briggs  * Bus attachment and DMA routines for the mc driver (Centris/Quadra
     31  1.1  briggs  * 660av and Quadra 840av onboard ethernet, based on the AMD Am79C940
     32  1.1  briggs  * MACE ethernet chip). Also uses the PSC (Peripheral Subsystem
     33  1.1  briggs  * Controller) for DMA to and from the MACE.
     34  1.1  briggs  */
     35  1.1  briggs 
     36  1.1  briggs #include <sys/param.h>
     37  1.1  briggs #include <sys/device.h>
     38  1.1  briggs #include <sys/malloc.h>
     39  1.1  briggs #include <sys/socket.h>
     40  1.1  briggs #include <sys/systm.h>
     41  1.1  briggs 
     42  1.1  briggs #include <net/if.h>
     43  1.1  briggs #include <net/if_ether.h>
     44  1.1  briggs 
     45  1.1  briggs #include <vm/vm.h>
     46  1.1  briggs 
     47  1.1  briggs #include <machine/bus.h>
     48  1.1  briggs #include <machine/psc.h>
     49  1.1  briggs 
     50  1.1  briggs #include <mac68k/dev/obiovar.h>
     51  1.1  briggs #include <mac68k/dev/if_mcreg.h>
     52  1.1  briggs #include <mac68k/dev/if_mcvar.h>
     53  1.1  briggs 
     54  1.1  briggs #define MACE_REG_BASE	0x50F1C000
     55  1.1  briggs #define MACE_PROM_BASE	0x50F08000
     56  1.1  briggs 
     57  1.1  briggs hide int	mc_obio_match __P((struct device *, struct cfdata *, void *));
     58  1.1  briggs hide void	mc_obio_attach __P((struct device *, struct device *, void *));
     59  1.1  briggs hide void	mc_obio_init __P((struct mc_softc *sc));
     60  1.1  briggs hide void	mc_obio_put __P((struct mc_softc *sc, u_int len));
     61  1.1  briggs hide int	mc_dmaintr __P((void *arg));
     62  1.1  briggs hide void	mc_reset_rxdma __P((struct mc_softc *sc));
     63  1.1  briggs hide void	mc_reset_rxdma_set __P((struct mc_softc *, int set));
     64  1.1  briggs hide void	mc_reset_txdma __P((struct mc_softc *sc));
     65  1.1  briggs hide int	mc_obio_getaddr __P((struct mc_softc *, u_int8_t *));
     66  1.1  briggs 
     67  1.1  briggs extern int	kvtop __P((register caddr_t addr));
     68  1.1  briggs 
     69  1.1  briggs struct cfattach mc_obio_ca = {
     70  1.1  briggs 	sizeof(struct mc_softc), mc_obio_match, mc_obio_attach
     71  1.1  briggs };
     72  1.1  briggs 
     73  1.1  briggs hide int
     74  1.1  briggs mc_obio_match(parent, cf, aux)
     75  1.1  briggs 	struct device *parent;
     76  1.1  briggs 	struct cfdata *cf;
     77  1.1  briggs 	void *aux;
     78  1.1  briggs {
     79  1.1  briggs 	struct obio_attach_args *oa = aux;
     80  1.1  briggs 	bus_space_handle_t bsh;
     81  1.1  briggs 	int found = 0;
     82  1.1  briggs 
     83  1.2  briggs         if (current_mac_model->class != MACH_CLASSAV)
     84  1.1  briggs 		return 0;
     85  1.1  briggs 
     86  1.1  briggs 	if (bus_space_map(oa->oa_tag, MACE_REG_BASE, MC_REGSIZE, 0, &bsh))
     87  1.1  briggs 		return 0;
     88  1.1  briggs 
     89  1.1  briggs 	/*
     90  1.1  briggs 	 * Make sure the MACE's I/O space is readable, and if it is,
     91  1.1  briggs 	 * try to read the CHIPID register. A MACE will always have
     92  1.1  briggs 	 * 0x?940, where the ? depends on the chip version.
     93  1.1  briggs 	 */
     94  1.1  briggs 	if (bus_probe(oa->oa_tag, bsh, 0, 1)) {
     95  1.1  briggs 		if ((bus_space_read_1(
     96  1.1  briggs 			oa->oa_tag, bsh, MACE_REG(MACE_CHIPIDL)) == 0x40) &&
     97  1.1  briggs 		    ((bus_space_read_1(
     98  1.1  briggs 			oa->oa_tag, bsh, MACE_REG(MACE_CHIPIDH)) & 0xf) == 9))
     99  1.1  briggs 			found = 1;
    100  1.1  briggs 	}
    101  1.1  briggs 
    102  1.1  briggs 	bus_space_unmap(oa->oa_tag, bsh, MC_REGSIZE);
    103  1.1  briggs 
    104  1.1  briggs 	return found;
    105  1.1  briggs }
    106  1.1  briggs 
    107  1.1  briggs hide void
    108  1.1  briggs mc_obio_attach(parent, self, aux)
    109  1.1  briggs 	struct device *parent, *self;
    110  1.1  briggs 	void	*aux;
    111  1.1  briggs {
    112  1.1  briggs 	struct obio_attach_args *oa = (struct obio_attach_args *)aux;
    113  1.1  briggs 	struct mc_softc *sc = (void *)self;
    114  1.1  briggs 	u_int8_t myaddr[ETHER_ADDR_LEN];
    115  1.1  briggs 	int i, noncontig = 0;
    116  1.1  briggs 
    117  1.1  briggs 	sc->sc_regt = oa->oa_tag;
    118  1.1  briggs 	sc->sc_biucc = XMTSP_64;
    119  1.1  briggs 	sc->sc_fifocc = XMTFW_16 | RCVFW_64 | XMTFWU | RCVFWU |
    120  1.1  briggs 	    XMTBRST | RCVBRST;
    121  1.1  briggs 	sc->sc_plscc = PORTSEL_AUI;
    122  1.1  briggs 
    123  1.1  briggs 	if (bus_space_map(sc->sc_regt, MACE_REG_BASE, MC_REGSIZE, 0,
    124  1.1  briggs 	    &sc->sc_regh)) {
    125  1.1  briggs 		printf(": failed to map space for MACE regs.\n");
    126  1.1  briggs 		return;
    127  1.1  briggs 	}
    128  1.1  briggs 
    129  1.1  briggs 	if (mc_obio_getaddr(sc, myaddr)) {
    130  1.1  briggs 		printf(": failed to get MAC address.\n");
    131  1.1  briggs 		return;
    132  1.1  briggs 	}
    133  1.1  briggs 
    134  1.1  briggs 	/* allocate memory for transmit buffer and mark it non-cacheable */
    135  1.1  briggs 	sc->sc_txbuf = malloc(NBPG, M_DEVBUF, M_WAITOK);
    136  1.1  briggs 	sc->sc_txbuf_phys = kvtop(sc->sc_txbuf);
    137  1.1  briggs 	physaccess (sc->sc_txbuf, (caddr_t)sc->sc_txbuf_phys, NBPG,
    138  1.1  briggs 	    PG_V | PG_RW | PG_CI);
    139  1.1  briggs 
    140  1.1  briggs 	/*
    141  1.1  briggs 	 * allocate memory for receive buffer and mark it non-cacheable
    142  1.1  briggs 	 * XXX This should use the bus_dma interface, since the buffer
    143  1.1  briggs 	 * needs to be physically contiguous. However, it seems that
    144  1.1  briggs 	 * at least on my system, malloc() does allocate contiguous
    145  1.1  briggs 	 * memory. If it's not, suggest reducing the number of buffers
    146  1.1  briggs 	 * to 2, which will fit in one 4K page.
    147  1.1  briggs 	 */
    148  1.1  briggs 	sc->sc_rxbuf = malloc(MC_NPAGES * NBPG, M_DEVBUF, M_WAITOK);
    149  1.1  briggs 	sc->sc_rxbuf_phys = kvtop(sc->sc_rxbuf);
    150  1.1  briggs 	for (i = 0; i < MC_NPAGES; i++) {
    151  1.1  briggs 		int pa;
    152  1.1  briggs 
    153  1.1  briggs 		pa = kvtop(sc->sc_rxbuf + NBPG*i);
    154  1.1  briggs 		physaccess (sc->sc_rxbuf + NBPG*i, (caddr_t)pa, NBPG,
    155  1.1  briggs 		    PG_V | PG_RW | PG_CI);
    156  1.1  briggs 		if (pa != sc->sc_rxbuf_phys + NBPG*i)
    157  1.1  briggs 			noncontig = 1;
    158  1.1  briggs 	}
    159  1.1  briggs 
    160  1.1  briggs 	if (noncontig) {
    161  1.1  briggs 		printf("%s: receive DMA buffer not contiguous! "
    162  1.1  briggs 		    "Try compiling with \"options MC_RXDMABUFS=2\"\n",
    163  1.1  briggs 		    sc->sc_dev.dv_xname);
    164  1.1  briggs 		return;
    165  1.1  briggs 	}
    166  1.1  briggs 
    167  1.1  briggs 	sc->sc_bus_init = mc_obio_init;
    168  1.1  briggs 	sc->sc_putpacket = mc_obio_put;
    169  1.1  briggs 
    170  1.1  briggs 	/* disable receive DMA */
    171  1.1  briggs 	psc_reg2(PSC_ENETRD_CTL) = 0x8800;
    172  1.1  briggs 	psc_reg2(PSC_ENETRD_CTL) = 0x1000;
    173  1.1  briggs 	psc_reg2(PSC_ENETRD_CMD + PSC_SET0) = 0x1100;
    174  1.1  briggs 	psc_reg2(PSC_ENETRD_CMD + PSC_SET1) = 0x1100;
    175  1.1  briggs 
    176  1.1  briggs 	/* disable transmit DMA */
    177  1.1  briggs 	psc_reg2(PSC_ENETWR_CTL) = 0x8800;
    178  1.1  briggs 	psc_reg2(PSC_ENETWR_CTL) = 0x1000;
    179  1.1  briggs 	psc_reg2(PSC_ENETWR_CMD + PSC_SET0) = 0x1100;
    180  1.1  briggs 	psc_reg2(PSC_ENETWR_CMD + PSC_SET1) = 0x1100;
    181  1.1  briggs 
    182  1.1  briggs 	/* install interrupt handlers */
    183  1.1  briggs 	add_psc_lev4_intr(PSCINTR_ENET_DMA, mc_dmaintr, sc);
    184  1.1  briggs 	add_psc_lev3_intr(mcintr, sc);
    185  1.1  briggs 
    186  1.1  briggs 	/* enable MACE DMA interrupts */
    187  1.1  briggs 	psc_reg1(PSC_LEV4_IER) = 0x80 | (1 << PSCINTR_ENET_DMA);
    188  1.1  briggs 
    189  1.1  briggs 	/* don't know what this does */
    190  1.1  briggs 	psc_reg2(PSC_ENETWR_CTL) = 0x9000;
    191  1.1  briggs 	psc_reg2(PSC_ENETRD_CTL) = 0x9000;
    192  1.1  briggs 	psc_reg2(PSC_ENETWR_CTL) = 0x0400;
    193  1.1  briggs 	psc_reg2(PSC_ENETRD_CTL) = 0x0400;
    194  1.1  briggs 
    195  1.1  briggs 	/* enable MACE interrupts */
    196  1.1  briggs 	psc_reg1(PSC_LEV3_IER) = 0x80 | (1 << PSCINTR_ENET);
    197  1.1  briggs 
    198  1.1  briggs 	/* mcsetup returns 1 if something fails */
    199  1.1  briggs 	if (mcsetup(sc, myaddr)) {
    200  1.1  briggs 		/* disable interrupts */
    201  1.1  briggs 		psc_reg1(PSC_LEV4_IER) = (1 << PSCINTR_ENET_DMA);
    202  1.1  briggs 		psc_reg1(PSC_LEV3_IER) = (1 << PSCINTR_ENET);
    203  1.1  briggs 		/* remove interrupt handlers */
    204  1.1  briggs 		remove_psc_lev4_intr(PSCINTR_ENET_DMA);
    205  1.1  briggs 		remove_psc_lev3_intr();
    206  1.1  briggs 
    207  1.1  briggs 		bus_space_unmap(sc->sc_regt, sc->sc_regh, MC_REGSIZE);
    208  1.1  briggs 		return;
    209  1.1  briggs 	}
    210  1.1  briggs }
    211  1.1  briggs 
    212  1.1  briggs /* Bus-specific initialization */
    213  1.1  briggs hide void
    214  1.1  briggs mc_obio_init(sc)
    215  1.1  briggs 	struct mc_softc *sc;
    216  1.1  briggs {
    217  1.1  briggs 	mc_reset_rxdma(sc);
    218  1.1  briggs 	mc_reset_txdma(sc);
    219  1.1  briggs }
    220  1.1  briggs 
    221  1.1  briggs hide void
    222  1.1  briggs mc_obio_put(sc, len)
    223  1.1  briggs 	struct mc_softc *sc;
    224  1.1  briggs 	u_int len;
    225  1.1  briggs {
    226  1.1  briggs 	psc_reg4(PSC_ENETWR_ADDR + sc->sc_txset) = sc->sc_txbuf_phys;
    227  1.1  briggs 	psc_reg4(PSC_ENETWR_LEN + sc->sc_txset) = len;
    228  1.1  briggs 	psc_reg2(PSC_ENETWR_CMD + sc->sc_txset) = 0x9800;
    229  1.1  briggs 
    230  1.1  briggs 	sc->sc_txset ^= 0x10;
    231  1.1  briggs }
    232  1.1  briggs 
    233  1.1  briggs /*
    234  1.1  briggs  * Interrupt handler for the MACE DMA completion interrupts
    235  1.1  briggs  */
    236  1.1  briggs int
    237  1.1  briggs mc_dmaintr(arg)
    238  1.1  briggs 	void *arg;
    239  1.1  briggs {
    240  1.1  briggs 	struct mc_softc *sc = arg;
    241  1.1  briggs 	u_int16_t status;
    242  1.1  briggs 	u_int32_t bufsleft, which;
    243  1.1  briggs 	int head;
    244  1.1  briggs 
    245  1.1  briggs 	/*
    246  1.1  briggs 	 * Not sure what this does... figure out if this interrupt is
    247  1.1  briggs 	 * really ours?
    248  1.1  briggs 	 */
    249  1.1  briggs 	while ((which = psc_reg4(0x804)) != psc_reg4(0x804))
    250  1.1  briggs 		;
    251  1.1  briggs 	if ((which & 0x60000000) == 0)
    252  1.1  briggs 		return 0;
    253  1.1  briggs 
    254  1.1  briggs 	/* Get the read channel status */
    255  1.1  briggs 	status = psc_reg2(PSC_ENETRD_CTL);
    256  1.1  briggs 	if (status & 0x2000) {
    257  1.1  briggs 		/* I think this is an exceptional condition. Reset the DMA */
    258  1.1  briggs 		mc_reset_rxdma(sc);
    259  1.1  briggs #ifdef MCDEBUG
    260  1.1  briggs 		printf("%s: resetting receive DMA channel (status 0x%04x)\n",
    261  1.1  briggs 		    sc->sc_dev.dv_xname, status);
    262  1.1  briggs #endif
    263  1.1  briggs 	} else if (status & 0x100) {
    264  1.1  briggs 		/* We've received some packets from the MACE */
    265  1.1  briggs 		int offset;
    266  1.1  briggs 
    267  1.1  briggs 		/* Clear the interrupt */
    268  1.1  briggs 		psc_reg2(PSC_ENETRD_CMD + sc->sc_rxset) = 0x1100;
    269  1.1  briggs 
    270  1.1  briggs 		/* See how may receive buffers are left */
    271  1.1  briggs 		bufsleft = psc_reg4(PSC_ENETRD_LEN + sc->sc_rxset);
    272  1.1  briggs 		head = MC_RXDMABUFS - bufsleft;
    273  1.1  briggs 
    274  1.1  briggs #if 0 /* I don't think this should ever happen */
    275  1.1  briggs 		if (head == sc->sc_tail) {
    276  1.1  briggs #ifdef MCDEBUG
    277  1.1  briggs 			printf("%s: head == tail: suspending DMA?\n",
    278  1.1  briggs 			    sc->sc_dev.dv_xname);
    279  1.1  briggs #endif
    280  1.1  briggs 			psc_reg2(PSC_ENETRD_CMD + sc->sc_rxset) = 0x9000;
    281  1.1  briggs 		}
    282  1.1  briggs #endif
    283  1.1  briggs 
    284  1.1  briggs 		/* Loop through, processing each of the packets */
    285  1.1  briggs 		for (; sc->sc_tail < head; sc->sc_tail++) {
    286  1.1  briggs 			offset = sc->sc_tail * 0x800;
    287  1.1  briggs 			sc->sc_rxframe.rx_rcvcnt = sc->sc_rxbuf[offset];
    288  1.1  briggs 			sc->sc_rxframe.rx_rcvsts = sc->sc_rxbuf[offset+2];
    289  1.1  briggs 			sc->sc_rxframe.rx_rntpc = sc->sc_rxbuf[offset+4];
    290  1.1  briggs 			sc->sc_rxframe.rx_rcvcc = sc->sc_rxbuf[offset+6];
    291  1.1  briggs 			sc->sc_rxframe.rx_frame = sc->sc_rxbuf + offset + 16;
    292  1.1  briggs 
    293  1.1  briggs 			mc_rint(sc);
    294  1.1  briggs 		}
    295  1.1  briggs 
    296  1.1  briggs 		/*
    297  1.1  briggs 		 * If we're out of buffers, reset this register set
    298  1.1  briggs 		 * and switch to the other one. Otherwise, reactivate
    299  1.1  briggs 		 * this set.
    300  1.1  briggs 		 */
    301  1.1  briggs 		if (bufsleft == 0) {
    302  1.1  briggs 			mc_reset_rxdma_set(sc, sc->sc_rxset);
    303  1.1  briggs 			sc->sc_rxset ^= 0x10;
    304  1.1  briggs 		} else
    305  1.1  briggs 			psc_reg2(PSC_ENETRD_CMD + sc->sc_rxset) = 0x9800;
    306  1.1  briggs 	}
    307  1.1  briggs 
    308  1.1  briggs 	/* Get the write channel status */
    309  1.1  briggs 	status = psc_reg2(PSC_ENETWR_CTL);
    310  1.1  briggs 	if (status & 0x2000) {
    311  1.1  briggs 		/* I think this is an exceptional condition. Reset the DMA */
    312  1.1  briggs 		mc_reset_txdma(sc);
    313  1.1  briggs #ifdef MCDEBUG
    314  1.1  briggs 		printf("%s: resetting transmit DMA channel (status 0x%04x)\n",
    315  1.1  briggs 			sc->sc_dev.dv_xname, status);
    316  1.1  briggs #endif
    317  1.1  briggs 	} else if (status & 0x100) {
    318  1.1  briggs 		/* Clear the interrupt and switch register sets */
    319  1.1  briggs 		psc_reg2(PSC_ENETWR_CMD + sc->sc_txseti) = 0x100;
    320  1.1  briggs 		sc->sc_txseti ^= 0x10;
    321  1.1  briggs 	}
    322  1.1  briggs 
    323  1.1  briggs 	return 1;
    324  1.1  briggs }
    325  1.1  briggs 
    326  1.1  briggs 
    327  1.1  briggs hide void
    328  1.1  briggs mc_reset_rxdma(sc)
    329  1.1  briggs 	struct mc_softc *sc;
    330  1.1  briggs {
    331  1.1  briggs 	u_int8_t maccc;
    332  1.1  briggs 
    333  1.1  briggs 	/* Disable receiver, reset the DMA channels */
    334  1.1  briggs 	maccc = NIC_GET(sc, MACE_MACCC);
    335  1.1  briggs 	NIC_PUT(sc, MACE_MACCC, maccc & ~ENRCV);
    336  1.1  briggs 	psc_reg2(PSC_ENETRD_CTL) = 0x8800;
    337  1.1  briggs 	mc_reset_rxdma_set(sc, 0);
    338  1.1  briggs 	psc_reg2(PSC_ENETRD_CTL) = 0x400;
    339  1.1  briggs 
    340  1.1  briggs 	psc_reg2(PSC_ENETRD_CTL) = 0x8800;
    341  1.1  briggs 	mc_reset_rxdma_set(sc, 0x10);
    342  1.1  briggs 	psc_reg2(PSC_ENETRD_CTL) = 0x400;
    343  1.1  briggs 
    344  1.1  briggs 	/* Reenable receiver, reenable DMA */
    345  1.1  briggs 	NIC_PUT(sc, MACE_MACCC, maccc);
    346  1.1  briggs 	sc->sc_rxset = 0;
    347  1.1  briggs 
    348  1.1  briggs 	psc_reg2(PSC_ENETRD_CMD + PSC_SET0) = 0x9800;
    349  1.1  briggs 	psc_reg2(PSC_ENETRD_CMD + PSC_SET1) = 0x9800;
    350  1.1  briggs }
    351  1.1  briggs 
    352  1.1  briggs hide void
    353  1.1  briggs mc_reset_rxdma_set(sc, set)
    354  1.1  briggs 	struct mc_softc *sc;
    355  1.1  briggs 	int set;
    356  1.1  briggs {
    357  1.1  briggs 	/* disable DMA while modifying the registers, then reenable DMA */
    358  1.1  briggs 	psc_reg2(PSC_ENETRD_CMD + set) = 0x0100;
    359  1.1  briggs 	psc_reg4(PSC_ENETRD_ADDR + set) = sc->sc_rxbuf_phys;
    360  1.1  briggs 	psc_reg4(PSC_ENETRD_LEN + set) = MC_RXDMABUFS;
    361  1.1  briggs 	psc_reg2(PSC_ENETRD_CMD + set) = 0x9800;
    362  1.1  briggs 	sc->sc_tail = 0;
    363  1.1  briggs }
    364  1.1  briggs 
    365  1.1  briggs hide void
    366  1.1  briggs mc_reset_txdma(sc)
    367  1.1  briggs 	struct mc_softc *sc;
    368  1.1  briggs {
    369  1.1  briggs 	u_int8_t maccc;
    370  1.1  briggs 
    371  1.1  briggs 	psc_reg2(PSC_ENETWR_CTL) = 0x8800;
    372  1.1  briggs 	maccc = NIC_GET(sc, MACE_MACCC);
    373  1.1  briggs 	NIC_PUT(sc, MACE_MACCC, maccc & ~ENXMT);
    374  1.1  briggs 	sc->sc_txset = sc->sc_txseti = 0;
    375  1.1  briggs 	psc_reg2(PSC_ENETWR_CTL) = 0x400;
    376  1.1  briggs 	NIC_PUT(sc, MACE_MACCC, maccc);
    377  1.1  briggs }
    378  1.1  briggs 
    379  1.1  briggs hide int
    380  1.1  briggs mc_obio_getaddr(sc, lladdr)
    381  1.1  briggs 	struct mc_softc *sc;
    382  1.1  briggs 	u_int8_t *lladdr;
    383  1.1  briggs {
    384  1.1  briggs 	bus_space_handle_t bsh;
    385  1.1  briggs 	u_char csum;
    386  1.1  briggs 
    387  1.1  briggs 	if (bus_space_map(sc->sc_regt, MACE_PROM_BASE, 8*16, 0, &bsh)) {
    388  1.1  briggs 		printf(": failed to map space to read MACE address.\n%s",
    389  1.1  briggs 		    sc->sc_dev.dv_xname);
    390  1.1  briggs 		return (-1);
    391  1.1  briggs 	}
    392  1.1  briggs 
    393  1.1  briggs 	if (!bus_probe(sc->sc_regt, bsh, 0, 1)) {
    394  1.1  briggs 		bus_space_unmap(sc->sc_regt, bsh, 8*16);
    395  1.1  briggs 		return (-1);
    396  1.1  briggs 	}
    397  1.1  briggs 
    398  1.1  briggs 	csum = mc_get_enaddr(sc->sc_regt, bsh, 1, lladdr);
    399  1.1  briggs 	if (csum != 0xff)
    400  1.1  briggs 		printf(": ethernet PROM checksum failed (0x%x != 0xff)\n%s",
    401  1.1  briggs 		    (int)csum, sc->sc_dev.dv_xname);
    402  1.1  briggs 
    403  1.1  briggs 	bus_space_unmap(sc->sc_regt, bsh, 8*16);
    404  1.1  briggs 
    405  1.1  briggs 	return (csum == 0xff ? 0 : -1);
    406  1.1  briggs }
    407