summaryrefslogtreecommitdiffstats
path: root/arch/m68k/mach-mcfv4e/include/proc/fecbd.h
blob: d7551c6587b119e2c0810c40cc8542d656317128 (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
114
115
/*
 * Copyright (c) 2008 Carsten Schlote <c.schlote@konzeptpark.de>
 * See file CREDITS for list of people who contributed to this project.
 *
 * This file is part of barebox.
 *
 * barebox 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 3 of the License, or
 * (at your option) any later version.
 *
 * barebox 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 barebox.  If not, see <http://www.gnu.org/licenses/>.
 */

/** @file
 *  Provide a simple buffer management driver
 */

#ifndef _FECBD_H_
#define _FECBD_H_

/********************************************************************/

#define Rx  1
#define Tx  0

/*
 * Buffer sizes in bytes
 */
#ifndef RX_BUF_SZ
#define RX_BUF_SZ  NBUF_SZ
#endif
#ifndef TX_BUF_SZ
#define TX_BUF_SZ  NBUF_SZ
#endif

/*
 * Number of Rx and Tx Buffers and Buffer Descriptors
 */
#ifndef NRXBD
#define NRXBD   10
#endif
#ifndef NTXBD
#define NTXBD   4
#endif

/*
 * Buffer Descriptor Format
 */
typedef struct
{
    uint16_t status;  /* control and status */
    uint16_t length;  /* transfer length */
    uint8_t  *data;   /* buffer address */
} FECBD;

/*
 * Bit level definitions for status field of buffer descriptors
 */
#define TX_BD_R         0x8000
#define TX_BD_TO1       0x4000
#define TX_BD_W         0x2000
#define TX_BD_TO2       0x1000
#define TX_BD_INTERRUPT 0x1000  /* MCF547x/8x Only */
#define TX_BD_L         0x0800
#define TX_BD_TC        0x0400
#define TX_BD_DEF       0x0200  /* MCF5272 Only */
#define TX_BD_ABC       0x0200
#define TX_BD_HB        0x0100  /* MCF5272 Only */
#define TX_BD_LC        0x0080  /* MCF5272 Only */
#define TX_BD_RL        0x0040  /* MCF5272 Only */
#define TX_BD_UN        0x0002  /* MCF5272 Only */
#define TX_BD_CSL       0x0001  /* MCF5272 Only */

#define RX_BD_E         0x8000
#define RX_BD_R01       0x4000
#define RX_BD_W         0x2000
#define RX_BD_R02       0x1000
#define RX_BD_INTERRUPT 0x1000  /* MCF547x/8x Only */
#define RX_BD_L         0x0800
#define RX_BD_M         0x0100
#define RX_BD_BC        0x0080
#define RX_BD_MC        0x0040
#define RX_BD_LG        0x0020
#define RX_BD_NO        0x0010
#define RX_BD_CR        0x0004
#define RX_BD_OV        0x0002
#define RX_BD_TR        0x0001
#define RX_BD_ERROR     (RX_BD_NO | RX_BD_CR | RX_BD_OV | RX_BD_TR)

/*
 * Functions provided in fec_bd.c
 */
void
fecbd_init(uint8_t);

uint32_t
fecbd_get_start(uint8_t, uint8_t);

FECBD *
fecbd_rx_alloc(uint8_t);

FECBD *
fecbd_tx_alloc(uint8_t);

FECBD *
fecbd_tx_free(uint8_t);

#endif /* _FECBD_H_ */