blob: f24f529a7934c7fa2aec08b91cf0dee525b10d64 [file] [log] [blame]
Rafal Jaworowski8993e542007-07-27 14:43:59 +02001/*
Wolfgang Denka927e492009-05-16 10:47:44 +02002 * (C) Copyright 2003 - 2009
Rafal Jaworowski8993e542007-07-27 14:43:59 +02003 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * Derived from the MPC8xx driver's header file.
6 */
7
8#ifndef __MPC512X_FEC_H
9#define __MPC512X_FEC_H
10
11#include <common.h>
12#include <mpc512x.h>
13
14typedef unsigned long uint32;
15typedef unsigned short uint16;
16typedef unsigned char uint8;
17
Rafal Jaworowski8993e542007-07-27 14:43:59 +020018/* Receive & Transmit Buffer Descriptor definitions */
19typedef struct BufferDescriptor {
20 uint16 status;
21 uint16 dataLength;
22 uint32 dataPointer;
23} FEC_RBD;
24
25typedef struct {
26 uint16 status;
27 uint16 dataLength;
28 uint32 dataPointer;
29} FEC_TBD;
30
31/* private structure */
32typedef enum {
33 SEVENWIRE, /* 7-wire */
34 MII10, /* MII 10Mbps */
35 MII100 /* MII 100Mbps */
36} xceiver_type;
37
38/* BD Numer definitions */
39#define FEC_TBD_NUM 48 /* The user can adjust this value */
40#define FEC_RBD_NUM 32 /* The user can adjust this value */
41
42/* packet size limit */
Grzegorz Bernacki7a888d62007-09-10 17:39:08 +020043#define FEC_MAX_FRAME_LEN 1522 /* recommended default value */
44
45/* Buffer size must be evenly divisible by 16 */
46#define FEC_BUFFER_SIZE ((FEC_MAX_FRAME_LEN + 0x10) & (~0xf))
Rafal Jaworowski8993e542007-07-27 14:43:59 +020047
48typedef struct {
Grzegorz Bernacki7a888d62007-09-10 17:39:08 +020049 uint8 frame[FEC_BUFFER_SIZE];
Rafal Jaworowski8993e542007-07-27 14:43:59 +020050} mpc512x_frame;
51
52typedef struct {
53 FEC_RBD rbd[FEC_RBD_NUM]; /* RBD ring */
54 FEC_TBD tbd[FEC_TBD_NUM]; /* TBD ring */
55 mpc512x_frame recv_frames[FEC_RBD_NUM]; /* receive buff */
56} mpc512x_buff_descs;
57
58typedef struct {
Wolfgang Denka927e492009-05-16 10:47:44 +020059 volatile fec512x_t *eth;
Rafal Jaworowski8993e542007-07-27 14:43:59 +020060 xceiver_type xcv_type; /* transceiver type */
61 mpc512x_buff_descs *bdBase; /* BD rings and recv buffer */
62 uint16 rbdIndex; /* next receive BD to read */
63 uint16 tbdIndex; /* next transmit BD to send */
64 uint16 usedTbdIndex; /* next transmit BD to clean */
65 uint16 cleanTbdNum; /* the number of available transmit BDs */
66} mpc512x_fec_priv;
67
68/* RBD bits definitions */
69#define FEC_RBD_EMPTY 0x8000 /* Buffer is empty */
70#define FEC_RBD_WRAP 0x2000 /* Last BD in ring */
71#define FEC_RBD_LAST 0x0800 /* Buffer is last in frame(useless) */
72#define FEC_RBD_MISS 0x0100 /* Miss bit for prom mode */
73#define FEC_RBD_BC 0x0080 /* The received frame is broadcast frame */
74#define FEC_RBD_MC 0x0040 /* The received frame is multicast frame */
75#define FEC_RBD_LG 0x0020 /* Frame length violation */
76#define FEC_RBD_NO 0x0010 /* Nonoctet align frame */
77#define FEC_RBD_SH 0x0008 /* Short frame */
78#define FEC_RBD_CR 0x0004 /* CRC error */
79#define FEC_RBD_OV 0x0002 /* Receive FIFO overrun */
80#define FEC_RBD_TR 0x0001 /* Frame is truncated */
81#define FEC_RBD_ERR (FEC_RBD_LG | FEC_RBD_NO | FEC_RBD_CR | \
82 FEC_RBD_OV | FEC_RBD_TR)
83
84/* TBD bits definitions */
85#define FEC_TBD_READY 0x8000 /* Buffer is ready */
86#define FEC_TBD_WRAP 0x2000 /* Last BD in ring */
87#define FEC_TBD_LAST 0x0800 /* Buffer is last in frame */
88#define FEC_TBD_TC 0x0400 /* Transmit the CRC */
89#define FEC_TBD_ABC 0x0200 /* Append bad CRC */
90
91/* MII-related definitios */
92#define FEC_MII_DATA_ST 0x40000000 /* Start of frame delimiter */
93#define FEC_MII_DATA_OP_RD 0x20000000 /* Perform a read operation */
94#define FEC_MII_DATA_OP_WR 0x10000000 /* Perform a write operation */
95#define FEC_MII_DATA_PA_MSK 0x0f800000 /* PHY Address field mask */
96#define FEC_MII_DATA_RA_MSK 0x007c0000 /* PHY Register field mask */
97#define FEC_MII_DATA_TA 0x00020000 /* Turnaround */
98#define FEC_MII_DATA_DATAMSK 0x0000ffff /* PHY data field */
99
100#define FEC_MII_DATA_RA_SHIFT 18 /* MII Register address bits */
101#define FEC_MII_DATA_PA_SHIFT 23 /* MII PHY address bits */
102
103#endif /* __MPC512X_FEC_H */