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