]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/eth/powerpc/fcc/v2_0/src/fcc.h
Initial revision
[karo-tx-redboot.git] / packages / devs / eth / powerpc / fcc / v2_0 / src / fcc.h
1 //==========================================================================
2 //
3 //      fcc.h
4 //
5 //      PowerPC MPC8xxx fast ethernet (FCC)
6 //
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Copyright (C) 2002, 2003, 2004 Gary Thomas
13 //
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
17 //
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21 // for more details.
22 //
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 //
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
33 //
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
36 //
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
43 //
44 // Author(s):    gthomas
45 // Contributors: pfine, mtek
46 // Date:         2003-08-19
47 // Purpose:      
48 // Description:  
49 //              
50 //
51 //####DESCRIPTIONEND####
52 //
53 //==========================================================================
54
55 #include <pkgconf/devs_eth_powerpc_fcc.h>
56 // The port connected to the ethernet
57 #define FCC1  0
58 #define FCC2  1
59 #define FCC3  2
60
61 /* ------------------------ */
62 /* FCC REGISTER CONSTANTS   */
63 /* ------------------------ */
64
65 // GFMR masks (RESET: 0x00000000)
66 #define FCC_GFMR_EN_Rx   0x00000020   // Receive enable  
67 #define FCC_GFMR_EN_Tx   0x00000010   // Transmit enable
68 #define FCC_GFMR_INIT    0x0000000C   // mode=ethernet
69
70 //PSMR masks (RESET: 0x00000000)
71 #define FCC_PSMR_INIT    0x00000080   // 32-bit CRC
72
73 //TODR masks (RESET: 0x0000)
74 #define FCC_TOD_INIT     0x0000
75 #define FCC_TOD_SET      0x8000
76
77 //DSR masks (RESET: 0x7E7E)
78 #define FCC_DSR_INIT     0xD555
79
80 //FCCE & FCCM (RESET: 0x0000) 
81 #define FCC_EV_GRA   0x0080  // Graceful stop
82 #define FCC_EV_RXC   0x0040  // A control frame has been received
83 #define FCC_EV_TXC   0x0020  // Out of sequence frame sent 
84 #define FCC_EV_TXE   0x0010  // Error in transmission channel
85 #define FCC_EV_RXF   0x0008  // A complete frame received
86 #define FCC_EV_BSY   0x0004  // A received frame discarded due to lack
87                              // of buffers
88 #define FCC_EV_TXB   0x0002  // A buffer sent to ethernet
89 #define FCC_EV_RXB   0x0001  // A buffer that is a non-complete frame
90                              // is received
91
92 /* ------------------------------ */
93 /* FCC PARAMETER RAM CONSTANTS    */
94 /* ------------------------------ */
95
96 #define FCC_FCR_INIT     0x00000000  // Clear the reserved bits
97 #define FCC_FCR_MOT_BO   0x10000000  // Motorola byte ordering
98 #define FCC_PRAM_C_MASK  0xDEBB20E3  // Constant MASK for CRC
99 #define FCC_PRAM_C_PRES  0xFFFFFFFF  // CRC Preset
100 #define FCC_PRAM_RETLIM  15          // Retry limit
101 #define FCC_PRAM_PER_LO  5           // Persistance
102 #define FCC_PRAM_PER_HI  0       
103 #define FCC_PRAM_MRBLR   1536    
104 #define FCC_MAX_FLR      1518        // Max frame length
105 #define FCC_MIN_FLR      64          // Min frame length
106 #define FCC_PRAM_PAD_CH  0x8888
107 #define FCC_PRAM_MAXD    1520
108 #define FCC1_PRAM_OFFSET  0x8400      // Offset of t_Fcc_Pram in 82xx 
109 #define FCC2_PRAM_OFFSET  0x8500      // Offset of t_Fcc_Pram in 82xx 
110 #define FCC3_PRAM_OFFSET  0x8600      // Offset of t_Fcc_Pram in 82xx
111
112 /* ------------------------------ */
113 /* BUFFER DESCRIPTOR CONSTANTS    */
114 /* ------------------------------ */
115 #define FCC_BD_Rx_Empty      0x8000  // Buffer is empty, FCC can fill
116 #define FCC_BD_Rx_Wrap       0x2000  // Wrap: Last buffer in ring
117 #define FCC_BD_Rx_Int        0x1000  // Interrupt
118 #define FCC_BD_Rx_Last       0x0800  // Last buffer in frame
119 #define FCC_BD_Rx_Miss       0x0100  // Miss: promiscious mode
120 #define FCC_BD_Rx_BC         0x0080  // Broadcast address
121 #define FCC_BD_Rx_MC         0x0040  // Multicast address
122 #define FCC_BD_Rx_LG         0x0020  // Frame length violation
123 #define FCC_BD_Rx_NO         0x0010  // Non-octet aligned frame
124 #define FCC_BD_Rx_SH         0x0008  // Short frame
125 #define FCC_BD_Rx_CR         0x0004  // CRC error
126 #define FCC_BD_Rx_OV         0x0002  // Overrun
127 #define FCC_BD_Rx_TR         0x0001  // Frame truncated. late collision
128 #define FCC_BD_Rx_ERRORS     (FCC_BD_Rx_LG|FCC_BD_Rx_NO|FCC_BD_Rx_SH|FCC_BD_Rx_CR|FCC_BD_Rx_OV|FCC_BD_Rx_TR)
129
130 #define FCC_BD_Tx_Ready      0x8000  // Frame ready
131 #define FCC_BD_Tx_Pad        0x4000  // Pad short frames
132 #define FCC_BD_Tx_Wrap       0x2000  // Wrap: Last buffer in ring
133 #define FCC_BD_Tx_Int        0x1000  // Interrupt
134 #define FCC_BD_Tx_Last       0x0800  // Last buffer in frame
135 #define FCC_BD_Tx_TC         0x0400  // Send CRC after data
136 #define FCC_BD_Tx_DEF        0x0200  // Defer indication
137 #define FCC_BD_Tx_HB         0x0100  // Heartbeat
138 #define FCC_BD_Tx_LC         0x0080  // Late collision
139 #define FCC_BD_Tx_RL         0x0040  // Retransmission limit
140 #define FCC_BD_Tx_RC         0x003C  // Retry count 
141 #define FCC_BD_Tx_UN         0x0002  // Underrun
142 #define FCC_BD_Tx_CSL        0x0001  // Carrier sense lost
143 #define FCC_BD_Tx_ERRORS     (FCC_BD_Tx_LC|FCC_BD_Tx_RL|FCC_BD_Tx_RC|FCC_BD_Tx_UN|FCC_BD_Tx_CSL)
144
145
146 // Buffer descriptor
147 struct fcc_bd {
148     volatile unsigned short  ctrl;
149     volatile unsigned short  length;
150     volatile unsigned char  *buffer;
151 };
152
153 //
154 // Info kept about each interface
155 //
156 struct fcc_eth_info { 
157     // These fields should be defined by the implementation
158     int                       int_vector;
159     char                     *esa_key;        // RedBoot 'key' for device ESA
160     unsigned char             enaddr[6];
161     int                       rxnum;          // Number of Rx buffers
162     unsigned char            *rxbuf;          // Rx buffer space
163     int                       txnum;          // Number of Tx buffers
164     unsigned char            *txbuf;          // Tx buffer space
165 #ifdef CYGPKG_DEVS_ETH_PHY
166     eth_phy_access_t         *phy;            // Routines to access PHY
167 #endif
168     // The rest of the structure is set up at runtime
169     volatile struct fcc_regs *fcc_reg;        // See "mpc8260.h"
170     struct fcc_bd            *txbd, *rxbd;    // Next Tx,Rx descriptor to use
171     struct fcc_bd            *tbase, *rbase;  // First Tx,Rx descriptor
172     struct fcc_bd            *tnext, *rnext;  // Next descriptor to check for interrupt
173     int                       txsize, rxsize; // Length of individual buffers
174     unsigned long             txkey[CYGNUM_DEVS_ETH_POWERPC_FCC_TxNUM];
175 #ifdef CYGPKG_NET
176     cyg_interrupt             fcc_eth_interrupt;
177     cyg_handle_t              fcc_eth_interrupt_handle;
178 #endif
179 };
180
181 // CPM_CPCR masks 
182 #define CPCR_GRSTOP_TX          0x00000005
183 #define CPCR_MCN_FCC            0x00000300
184 #define CPCR_READY_TO_RX_CMD   0  /* Ready to receive a command */