1 1.7 simonb /* $NetBSD: octeon_gmxvar.h,v 1.7 2020/06/23 05:17:13 simonb Exp $ */ 2 1.1 hikaru 3 1.1 hikaru /* 4 1.1 hikaru * Copyright (c) 2007 Internet Initiative Japan, Inc. 5 1.1 hikaru * All rights reserved. 6 1.1 hikaru * 7 1.1 hikaru * Redistribution and use in source and binary forms, with or without 8 1.1 hikaru * modification, are permitted provided that the following conditions 9 1.1 hikaru * are met: 10 1.1 hikaru * 1. Redistributions of source code must retain the above copyright 11 1.1 hikaru * notice, this list of conditions and the following disclaimer. 12 1.1 hikaru * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 hikaru * notice, this list of conditions and the following disclaimer in the 14 1.1 hikaru * documentation and/or other materials provided with the distribution. 15 1.1 hikaru * 16 1.1 hikaru * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17 1.1 hikaru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 1.1 hikaru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 1.1 hikaru * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 1.1 hikaru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 1.1 hikaru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 1.1 hikaru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 1.1 hikaru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 1.1 hikaru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 1.1 hikaru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 1.1 hikaru * SUCH DAMAGE. 27 1.1 hikaru */ 28 1.1 hikaru 29 1.1 hikaru #ifndef _OCTEON_GMXVAR_H_ 30 1.1 hikaru #define _OCTEON_GMXVAR_H_ 31 1.1 hikaru 32 1.1 hikaru #include <net/if.h> 33 1.1 hikaru #include <net/if_media.h> 34 1.1 hikaru #include <net/if_ether.h> 35 1.1 hikaru #include <dev/mii/mii.h> 36 1.1 hikaru #include <dev/mii/miivar.h> 37 1.1 hikaru 38 1.1 hikaru #define GMX_MII_PORT 1 39 1.1 hikaru #define GMX_GMII_PORT 2 40 1.1 hikaru #define GMX_RGMII_PORT 3 41 1.7 simonb #define GMX_SGMII_PORT 4 42 1.7 simonb #define GMX_SPI42_PORT 5 43 1.1 hikaru 44 1.1 hikaru #define GMX_FRM_MAX_SIZ 0x600 45 1.1 hikaru 46 1.4 simonb enum CNMAC_QUIRKS { 47 1.4 simonb CNMAC_QUIRKS_NO_RX_INBND = 1 << 0, 48 1.4 simonb CNMAC_QUIRKS_NO_PRE_ALIGN = 1 << 1, 49 1.1 hikaru }; 50 1.1 hikaru 51 1.1 hikaru #if 1 52 1.4 simonb struct octgmx_softc; 53 1.4 simonb struct octgmx_port_softc; 54 1.1 hikaru 55 1.4 simonb struct octgmx_port_softc { 56 1.4 simonb struct octgmx_softc *sc_port_gmx; 57 1.1 hikaru bus_space_handle_t sc_port_regh; 58 1.1 hikaru int sc_port_no; /* GMX0:0, GMX0:1, ... */ 59 1.1 hikaru int sc_port_type; 60 1.1 hikaru uint64_t sc_mac; 61 1.1 hikaru int sc_quirks; 62 1.1 hikaru uint64_t sc_link; 63 1.1 hikaru struct mii_data *sc_port_mii; 64 1.1 hikaru struct ethercom *sc_port_ec; 65 1.4 simonb struct octgmx_port_ops 66 1.1 hikaru *sc_port_ops; 67 1.4 simonb struct octasx_softc *sc_port_asx; 68 1.7 simonb bus_space_handle_t sc_port_pcs_regh; 69 1.4 simonb struct octipd_softc *sc_ipd; 70 1.1 hikaru int sc_port_flowflags; 71 1.1 hikaru 72 1.3 mrg int sc_clk_tx_setting; 73 1.3 mrg int sc_clk_rx_setting; 74 1.1 hikaru }; 75 1.1 hikaru 76 1.4 simonb struct octgmx_softc { 77 1.1 hikaru device_t sc_dev; 78 1.1 hikaru 79 1.1 hikaru bus_space_tag_t sc_regt; 80 1.1 hikaru bus_space_handle_t sc_regh; 81 1.1 hikaru int sc_unitno; /* GMX0, GMX1, ... */ 82 1.1 hikaru int sc_nports; 83 1.1 hikaru int sc_port_types[4/* XXX */]; 84 1.1 hikaru 85 1.4 simonb struct octgmx_port_softc 86 1.1 hikaru *sc_ports; 87 1.1 hikaru }; 88 1.1 hikaru #endif 89 1.1 hikaru 90 1.4 simonb struct octgmx_attach_args { 91 1.1 hikaru bus_space_tag_t ga_regt; 92 1.1 hikaru bus_addr_t ga_addr; 93 1.1 hikaru const char *ga_name; 94 1.1 hikaru int ga_portno; 95 1.1 hikaru int ga_port_type; 96 1.7 simonb struct octsmi_softc *ga_smi; 97 1.1 hikaru 98 1.4 simonb struct octgmx_softc *ga_gmx; 99 1.4 simonb struct octgmx_port_softc 100 1.1 hikaru *ga_gmx_port; 101 1.1 hikaru }; 102 1.1 hikaru 103 1.7 simonb int octgmx_port_enable(struct octgmx_port_softc *, int); 104 1.7 simonb int octgmx_stats_init(struct octgmx_port_softc *); 105 1.7 simonb void octgmx_stats(struct octgmx_port_softc *); 106 1.7 simonb int octgmx_set_mac_addr(struct octgmx_port_softc *, const uint8_t *); 107 1.7 simonb int octgmx_set_filter(struct octgmx_port_softc *); 108 1.4 simonb int octgmx_tx_stats_rd_clr(struct octgmx_port_softc *, int); 109 1.4 simonb int octgmx_rx_stats_rd_clr(struct octgmx_port_softc *, int); 110 1.4 simonb int octgmx_reset_speed(struct octgmx_port_softc *); 111 1.4 simonb int octgmx_reset_flowctl(struct octgmx_port_softc *); 112 1.4 simonb int octgmx_reset_timing(struct octgmx_port_softc *); 113 1.4 simonb static __inline int octgmx_link_status(struct octgmx_port_softc *); 114 1.1 hikaru 115 1.2 christos static __inline int 116 1.4 simonb octgmx_link_status(struct octgmx_port_softc *sc) 117 1.1 hikaru { 118 1.7 simonb 119 1.7 simonb return ((sc->sc_port_mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) 120 1.7 simonb == (IFM_AVALID | IFM_ACTIVE)); 121 1.1 hikaru } 122 1.1 hikaru 123 1.5 simonb #endif /* _OCTEON_GMXVAR_H_ */ 124