1 1.14 thorpej /* $NetBSD: if_mcvar.h,v 1.14 2022/09/18 10:54:52 thorpej Exp $ */ 2 1.1 tsubai 3 1.1 tsubai /*- 4 1.1 tsubai * Copyright (c) 1997 David Huang <khym (at) bga.com> 5 1.1 tsubai * All rights reserved. 6 1.1 tsubai * 7 1.1 tsubai * Redistribution and use in source and binary forms, with or without 8 1.1 tsubai * modification, are permitted provided that the following conditions 9 1.1 tsubai * are met: 10 1.1 tsubai * 1. Redistributions of source code must retain the above copyright 11 1.1 tsubai * notice, this list of conditions and the following disclaimer. 12 1.1 tsubai * 2. The name of the author may not be used to endorse or promote products 13 1.1 tsubai * derived from this software without specific prior written permission 14 1.1 tsubai * 15 1.1 tsubai * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 1.1 tsubai * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 1.1 tsubai * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 1.1 tsubai * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 1.1 tsubai * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 1.1 tsubai * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 1.1 tsubai * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 1.1 tsubai * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 1.1 tsubai * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 1.1 tsubai * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 1.1 tsubai * 26 1.1 tsubai */ 27 1.2 jonathan 28 1.1 tsubai #include <macppc/dev/dbdma.h> 29 1.1 tsubai 30 1.6 tsubai #if 1 31 1.6 tsubai #define integrate 32 1.1 tsubai #define hide 33 1.1 tsubai #else 34 1.10 perry #define integrate static /*inline*/ 35 1.1 tsubai #define hide static 36 1.1 tsubai #endif 37 1.1 tsubai 38 1.1 tsubai #define MC_REGSPACING 16 39 1.1 tsubai #define MC_REGSIZE MACE_NREGS * MC_REGSPACING 40 1.1 tsubai #define MACE_REG(x) ((x)*MC_REGSPACING) 41 1.1 tsubai 42 1.1 tsubai #define NIC_GET(sc, reg) (bus_space_read_1((sc)->sc_regt, \ 43 1.1 tsubai (sc)->sc_regh, MACE_REG(reg))) 44 1.1 tsubai #define NIC_PUT(sc, reg, val) (bus_space_write_1((sc)->sc_regt, \ 45 1.1 tsubai (sc)->sc_regh, MACE_REG(reg), (val))) 46 1.1 tsubai 47 1.1 tsubai #ifndef MC_RXDMABUFS 48 1.8 briggs #define MC_RXDMABUFS 2 49 1.1 tsubai #endif 50 1.1 tsubai #if (MC_RXDMABUFS < 2) 51 1.1 tsubai #error Must have at least two buffers for DMA! 52 1.1 tsubai #endif 53 1.1 tsubai 54 1.7 thorpej #define MC_NPAGES ((MC_RXDMABUFS * 0x800 + PAGE_SIZE - 1) / PAGE_SIZE) 55 1.1 tsubai 56 1.1 tsubai struct mc_rxframe { 57 1.11 tsutsui uint8_t rx_rcvcnt; 58 1.11 tsutsui uint8_t rx_rcvsts; 59 1.11 tsutsui uint8_t rx_rntpc; 60 1.11 tsutsui uint8_t rx_rcvcc; 61 1.11 tsutsui uint8_t *rx_frame; 62 1.1 tsubai }; 63 1.1 tsubai 64 1.1 tsubai struct mc_softc { 65 1.13 macallan device_t sc_dev; /* base device glue */ 66 1.1 tsubai struct ethercom sc_ethercom; /* Ethernet common part */ 67 1.1 tsubai #define sc_if sc_ethercom.ec_if 68 1.1 tsubai struct ifmedia sc_media; 69 1.1 tsubai 70 1.1 tsubai struct mc_rxframe sc_rxframe; 71 1.1 tsubai u_int8_t sc_biucc; 72 1.1 tsubai u_int8_t sc_fifocc; 73 1.1 tsubai u_int8_t sc_plscc; 74 1.1 tsubai u_int8_t sc_enaddr[6]; 75 1.1 tsubai u_int8_t sc_pad[2]; 76 1.1 tsubai int sc_havecarrier; /* carrier status */ 77 1.12 dsl void (*sc_bus_init)(struct mc_softc *); 78 1.12 dsl void (*sc_putpacket)(struct mc_softc *, u_int); 79 1.12 dsl int (*sc_mediachange)(struct mc_softc *); 80 1.12 dsl void (*sc_mediastatus)(struct mc_softc *, 81 1.12 dsl struct ifmediareq *); 82 1.1 tsubai 83 1.1 tsubai bus_space_tag_t sc_regt; 84 1.1 tsubai bus_space_handle_t sc_regh; 85 1.1 tsubai 86 1.1 tsubai u_char *sc_txbuf, *sc_rxbuf; 87 1.1 tsubai int sc_txbuf_phys, sc_rxbuf_phys; 88 1.1 tsubai int sc_tail; 89 1.14 thorpej bool sc_txbusy; 90 1.1 tsubai 91 1.1 tsubai int sc_node; 92 1.1 tsubai dbdma_regmap_t *sc_txdma; 93 1.1 tsubai dbdma_command_t *sc_txdmacmd; 94 1.1 tsubai dbdma_regmap_t *sc_rxdma; 95 1.1 tsubai dbdma_command_t *sc_rxdmacmd; 96 1.1 tsubai }; 97 1.1 tsubai 98 1.12 dsl int mcsetup(struct mc_softc *, u_int8_t *); 99 1.12 dsl int mcintr(void *arg); 100 1.12 dsl void mc_rint(struct mc_softc *sc); 101