1fcbd8018SJean-Christophe Dubois /* 2fcbd8018SJean-Christophe Dubois * i.MX Fast Ethernet Controller emulation. 3fcbd8018SJean-Christophe Dubois * 4fcbd8018SJean-Christophe Dubois * Copyright (c) 2013 Jean-Christophe Dubois. <jcd@tribudubois.net> 5fcbd8018SJean-Christophe Dubois * 6fcbd8018SJean-Christophe Dubois * Based on Coldfire Fast Ethernet Controller emulation. 7fcbd8018SJean-Christophe Dubois * 8fcbd8018SJean-Christophe Dubois * Copyright (c) 2007 CodeSourcery. 9fcbd8018SJean-Christophe Dubois * 10fcbd8018SJean-Christophe Dubois * This program is free software; you can redistribute it and/or modify it 11fcbd8018SJean-Christophe Dubois * under the terms of the GNU General Public License as published by the 12fcbd8018SJean-Christophe Dubois * Free Software Foundation; either version 2 of the License, or 13fcbd8018SJean-Christophe Dubois * (at your option) any later version. 14fcbd8018SJean-Christophe Dubois * 15fcbd8018SJean-Christophe Dubois * This program is distributed in the hope that it will be useful, but WITHOUT 16fcbd8018SJean-Christophe Dubois * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17fcbd8018SJean-Christophe Dubois * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18fcbd8018SJean-Christophe Dubois * for more details. 19fcbd8018SJean-Christophe Dubois * 20fcbd8018SJean-Christophe Dubois * You should have received a copy of the GNU General Public License along 21fcbd8018SJean-Christophe Dubois * with this program; if not, see <http://www.gnu.org/licenses/>. 22fcbd8018SJean-Christophe Dubois */ 23fcbd8018SJean-Christophe Dubois 24fcbd8018SJean-Christophe Dubois #ifndef IMX_FEC_H 25fcbd8018SJean-Christophe Dubois #define IMX_FEC_H 26fcbd8018SJean-Christophe Dubois 27fcbd8018SJean-Christophe Dubois #define TYPE_IMX_FEC "imx.fec" 28fcbd8018SJean-Christophe Dubois #define IMX_FEC(obj) OBJECT_CHECK(IMXFECState, (obj), TYPE_IMX_FEC) 29fcbd8018SJean-Christophe Dubois 30fcbd8018SJean-Christophe Dubois #include "hw/sysbus.h" 31fcbd8018SJean-Christophe Dubois #include "net/net.h" 32fcbd8018SJean-Christophe Dubois 33*1bb3c371SJean-Christophe Dubois #define ENET_MAX_FRAME_SIZE 2032 34fcbd8018SJean-Christophe Dubois 35*1bb3c371SJean-Christophe Dubois #define ENET_INT_HB (1 << 31) 36*1bb3c371SJean-Christophe Dubois #define ENET_INT_BABR (1 << 30) 37*1bb3c371SJean-Christophe Dubois #define ENET_INT_BABT (1 << 29) 38*1bb3c371SJean-Christophe Dubois #define ENET_INT_GRA (1 << 28) 39*1bb3c371SJean-Christophe Dubois #define ENET_INT_TXF (1 << 27) 40*1bb3c371SJean-Christophe Dubois #define ENET_INT_TXB (1 << 26) 41*1bb3c371SJean-Christophe Dubois #define ENET_INT_RXF (1 << 25) 42*1bb3c371SJean-Christophe Dubois #define ENET_INT_RXB (1 << 24) 43*1bb3c371SJean-Christophe Dubois #define ENET_INT_MII (1 << 23) 44*1bb3c371SJean-Christophe Dubois #define ENET_INT_EBERR (1 << 22) 45*1bb3c371SJean-Christophe Dubois #define ENET_INT_LC (1 << 21) 46*1bb3c371SJean-Christophe Dubois #define ENET_INT_RL (1 << 20) 47*1bb3c371SJean-Christophe Dubois #define ENET_INT_UN (1 << 19) 48fcbd8018SJean-Christophe Dubois 49*1bb3c371SJean-Christophe Dubois #define ENET_ECR_RESET (1 << 0) 50*1bb3c371SJean-Christophe Dubois #define ENET_ECR_ETHEREN (1 << 1) 51fcbd8018SJean-Christophe Dubois 52fcbd8018SJean-Christophe Dubois /* Buffer Descriptor. */ 53fcbd8018SJean-Christophe Dubois typedef struct { 54fcbd8018SJean-Christophe Dubois uint16_t length; 55fcbd8018SJean-Christophe Dubois uint16_t flags; 56fcbd8018SJean-Christophe Dubois uint32_t data; 57fcbd8018SJean-Christophe Dubois } IMXFECBufDesc; 58fcbd8018SJean-Christophe Dubois 59*1bb3c371SJean-Christophe Dubois #define ENET_BD_R (1 << 15) 60*1bb3c371SJean-Christophe Dubois #define ENET_BD_E (1 << 15) 61*1bb3c371SJean-Christophe Dubois #define ENET_BD_O1 (1 << 14) 62*1bb3c371SJean-Christophe Dubois #define ENET_BD_W (1 << 13) 63*1bb3c371SJean-Christophe Dubois #define ENET_BD_O2 (1 << 12) 64*1bb3c371SJean-Christophe Dubois #define ENET_BD_L (1 << 11) 65*1bb3c371SJean-Christophe Dubois #define ENET_BD_TC (1 << 10) 66*1bb3c371SJean-Christophe Dubois #define ENET_BD_ABC (1 << 9) 67*1bb3c371SJean-Christophe Dubois #define ENET_BD_M (1 << 8) 68*1bb3c371SJean-Christophe Dubois #define ENET_BD_BC (1 << 7) 69*1bb3c371SJean-Christophe Dubois #define ENET_BD_MC (1 << 6) 70*1bb3c371SJean-Christophe Dubois #define ENET_BD_LG (1 << 5) 71*1bb3c371SJean-Christophe Dubois #define ENET_BD_NO (1 << 4) 72*1bb3c371SJean-Christophe Dubois #define ENET_BD_CR (1 << 2) 73*1bb3c371SJean-Christophe Dubois #define ENET_BD_OV (1 << 1) 74*1bb3c371SJean-Christophe Dubois #define ENET_BD_TR (1 << 0) 75fcbd8018SJean-Christophe Dubois 76fcbd8018SJean-Christophe Dubois typedef struct IMXFECState { 77fcbd8018SJean-Christophe Dubois /*< private >*/ 78fcbd8018SJean-Christophe Dubois SysBusDevice parent_obj; 79fcbd8018SJean-Christophe Dubois 80fcbd8018SJean-Christophe Dubois /*< public >*/ 81fcbd8018SJean-Christophe Dubois NICState *nic; 82fcbd8018SJean-Christophe Dubois NICConf conf; 83fcbd8018SJean-Christophe Dubois qemu_irq irq; 84fcbd8018SJean-Christophe Dubois MemoryRegion iomem; 85fcbd8018SJean-Christophe Dubois 86fcbd8018SJean-Christophe Dubois uint32_t irq_state; 87fcbd8018SJean-Christophe Dubois uint32_t eir; 88fcbd8018SJean-Christophe Dubois uint32_t eimr; 89fcbd8018SJean-Christophe Dubois uint32_t rx_enabled; 90fcbd8018SJean-Christophe Dubois uint32_t rx_descriptor; 91fcbd8018SJean-Christophe Dubois uint32_t tx_descriptor; 92fcbd8018SJean-Christophe Dubois uint32_t ecr; 93fcbd8018SJean-Christophe Dubois uint32_t mmfr; 94fcbd8018SJean-Christophe Dubois uint32_t mscr; 95fcbd8018SJean-Christophe Dubois uint32_t mibc; 96fcbd8018SJean-Christophe Dubois uint32_t rcr; 97fcbd8018SJean-Christophe Dubois uint32_t tcr; 98fcbd8018SJean-Christophe Dubois uint32_t tfwr; 99fcbd8018SJean-Christophe Dubois uint32_t frsr; 100fcbd8018SJean-Christophe Dubois uint32_t erdsr; 101fcbd8018SJean-Christophe Dubois uint32_t etdsr; 102fcbd8018SJean-Christophe Dubois uint32_t emrbr; 103fcbd8018SJean-Christophe Dubois uint32_t miigsk_cfgr; 104fcbd8018SJean-Christophe Dubois uint32_t miigsk_enr; 105fcbd8018SJean-Christophe Dubois 106fcbd8018SJean-Christophe Dubois uint32_t phy_status; 107fcbd8018SJean-Christophe Dubois uint32_t phy_control; 108fcbd8018SJean-Christophe Dubois uint32_t phy_advertise; 109fcbd8018SJean-Christophe Dubois uint32_t phy_int; 110fcbd8018SJean-Christophe Dubois uint32_t phy_int_mask; 111fcbd8018SJean-Christophe Dubois } IMXFECState; 112fcbd8018SJean-Christophe Dubois 113fcbd8018SJean-Christophe Dubois #endif 114