summaryrefslogtreecommitdiffstats
path: root/src/include/hw/net/imx_fec.h
blob: cbf86509e86de77e2f32f1a4a805d1a0163140ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * i.MX Fast Ethernet Controller emulation.
 *
 * Copyright (c) 2013 Jean-Christophe Dubois. <jcd@tribudubois.net>
 *
 * Based on Coldfire Fast Ethernet Controller emulation.
 *
 * Copyright (c) 2007 CodeSourcery.
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef IMX_FEC_H
#define IMX_FEC_H

#define TYPE_IMX_FEC "imx.fec"
#define IMX_FEC(obj) OBJECT_CHECK(IMXFECState, (obj), TYPE_IMX_FEC)

#include "hw/sysbus.h"
#include "net/net.h"

#define FEC_MAX_FRAME_SIZE 2032

#define FEC_INT_HB      (1 << 31)
#define FEC_INT_BABR    (1 << 30)
#define FEC_INT_BABT    (1 << 29)
#define FEC_INT_GRA     (1 << 28)
#define FEC_INT_TXF     (1 << 27)
#define FEC_INT_TXB     (1 << 26)
#define FEC_INT_RXF     (1 << 25)
#define FEC_INT_RXB     (1 << 24)
#define FEC_INT_MII     (1 << 23)
#define FEC_INT_EBERR   (1 << 22)
#define FEC_INT_LC      (1 << 21)
#define FEC_INT_RL      (1 << 20)
#define FEC_INT_UN      (1 << 19)

#define FEC_EN      2
#define FEC_RESET   1

/* Buffer Descriptor.  */
typedef struct {
    uint16_t length;
    uint16_t flags;
    uint32_t data;
} IMXFECBufDesc;

#define FEC_BD_R    (1 << 15)
#define FEC_BD_E    (1 << 15)
#define FEC_BD_O1   (1 << 14)
#define FEC_BD_W    (1 << 13)
#define FEC_BD_O2   (1 << 12)
#define FEC_BD_L    (1 << 11)
#define FEC_BD_TC   (1 << 10)
#define FEC_BD_ABC  (1 << 9)
#define FEC_BD_M    (1 << 8)
#define FEC_BD_BC   (1 << 7)
#define FEC_BD_MC   (1 << 6)
#define FEC_BD_LG   (1 << 5)
#define FEC_BD_NO   (1 << 4)
#define FEC_BD_CR   (1 << 2)
#define FEC_BD_OV   (1 << 1)
#define FEC_BD_TR   (1 << 0)

typedef struct IMXFECState {
    /*< private >*/
    SysBusDevice parent_obj;

    /*< public >*/
    NICState *nic;
    NICConf conf;
    qemu_irq irq;
    MemoryRegion iomem;

    uint32_t irq_state;
    uint32_t eir;
    uint32_t eimr;
    uint32_t rx_enabled;
    uint32_t rx_descriptor;
    uint32_t tx_descriptor;
    uint32_t ecr;
    uint32_t mmfr;
    uint32_t mscr;
    uint32_t mibc;
    uint32_t rcr;
    uint32_t tcr;
    uint32_t tfwr;
    uint32_t frsr;
    uint32_t erdsr;
    uint32_t etdsr;
    uint32_t emrbr;
    uint32_t miigsk_cfgr;
    uint32_t miigsk_enr;

    uint32_t phy_status;
    uint32_t phy_control;
    uint32_t phy_advertise;
    uint32_t phy_int;
    uint32_t phy_int_mask;
} IMXFECState;

#endif
OpenPOWER on IntegriCloud