OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [devs/] [eth/] [powerpc/] [rattler/] [current/] [include/] [rattler_eth.inl] - Blame information for rev 817

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_DEVS_RATTLER_ETH_INL
2
#define CYGONCE_DEVS_RATTLER_ETH_INL
3
//==========================================================================
4
//
5
//      rattler_eth.inl
6
//
7
//      Hardware specifics for A&M Rattler ethernet support
8
//
9
//==========================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later
18
// version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
28
//
29
// As a special exception, if other files instantiate templates or use
30
// macros or inline functions from this file, or you compile this file
31
// and link it with other works to produce a work based on this file,
32
// this file does not by itself cause the resulting work to be covered by
33
// the GNU General Public License. However the source code for this file
34
// must still be made available in accordance with section (3) of the GNU
35
// General Public License v2.
36
//
37
// This exception does not invalidate any other reasons why a work based
38
// on this file might be covered by the GNU General Public License.
39
// -------------------------------------------
40
// ####ECOSGPLCOPYRIGHTEND####
41
//==========================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):    gthomas
45
// Contributors: gthomas,F.Robbins
46
// Date:         2003-08-19
47
// Purpose:
48
// Description:
49
//
50
//####DESCRIPTIONEND####
51
//
52
//==========================================================================
53
 
54
//
55
// Pin layout for PHY connections
56
//
57
#define FCC1_PHY_RESET 0x01000000
58
#define FCC1_PHY_DATA  0x10000000
59
#define FCC1_PHY_CLOCK 0x20000000
60
#define FCC2_PHY_RESET 0x02000000
61
#define FCC2_PHY_DATA  0x04000000
62
#define FCC2_PHY_CLOCK 0x08000000
63
 
64
#ifdef CYGHWR_DEVS_ETH_POWERPC_RATTLER_FCC1
65
//
66
// Initialize the PHY associated with FCC1/eth0
67
//
68
static void
69
fcc1_phy_init(void)
70
{
71
    // Set up PHY reset line
72
    IMM->io_regs[PORT_B].pdat |= FCC1_PHY_RESET;
73
    IMM->io_regs[PORT_C].pdir |= FCC1_PHY_CLOCK;
74
}
75
 
76
//
77
// Reset the PHY associated with FCC1/eth0
78
//
79
static void
80
fcc1_phy_reset(void)
81
{
82
    // Toggle PHY reset line
83
    IMM->io_regs[PORT_B].pdat &= ~FCC1_PHY_RESET;
84
    IMM->io_regs[PORT_B].pdat |= FCC1_PHY_RESET;
85
}
86
 
87
//
88
// Set up a particular data bit for FCC1/eth0
89
//
90
static void
91
fcc1_phy_set_data(int val)
92
{
93
    if (val) {
94
        // Output
95
        IMM->io_regs[PORT_C].pdat |= FCC1_PHY_DATA;
96
    } else {
97
        // Input
98
        IMM->io_regs[PORT_C].pdat &= ~FCC1_PHY_DATA;
99
    }
100
}
101
 
102
//
103
// Read the current data bit for FCC1/eth0
104
//
105
static int
106
fcc1_phy_get_data(void)
107
{
108
    if ((IMM->io_regs[PORT_C].pdat & FCC1_PHY_DATA) != 0) {
109
        return 1;
110
    } else {
111
        return 0;
112
    }
113
}
114
 
115
//
116
// Set the clock bit for FCC1/eth0
117
//
118
static void
119
fcc1_phy_set_clock(int val)
120
{
121
    if (val) {
122
        // Output
123
        IMM->io_regs[PORT_C].pdat |= FCC1_PHY_CLOCK;
124
    } else {
125
        // Input
126
        IMM->io_regs[PORT_C].pdat &= ~FCC1_PHY_CLOCK;
127
    }
128
}
129
 
130
//
131
// Set the clock/data direction for FCC1/eth0
132
// Note: always forces clock to be an output
133
//
134
static void
135
fcc1_phy_set_dir(int data_dir)
136
{
137
    if (data_dir) {
138
        // Output
139
        IMM->io_regs[PORT_C].pdir |= FCC1_PHY_DATA;
140
    } else {
141
        // Input
142
        IMM->io_regs[PORT_C].pdir &= ~FCC1_PHY_DATA;
143
    }
144
}
145
 
146
ETH_PHY_BIT_LEVEL_ACCESS_FUNS(fcc1_phy,
147
                    fcc1_phy_init,
148
                    fcc1_phy_reset,
149
                    fcc1_phy_set_data,
150
                    fcc1_phy_get_data,
151
                    fcc1_phy_set_clock,
152
                    fcc1_phy_set_dir);
153
 
154
static unsigned char fcc_eth0_rxbufs[CYGNUM_DEVS_ETH_POWERPC_FCC_RxNUM *
155
                                    (CYGNUM_DEVS_ETH_POWERPC_FCC_BUFSIZE + 32)];
156
static unsigned char fcc_eth0_txbufs[CYGNUM_DEVS_ETH_POWERPC_FCC_TxNUM *
157
                                    (CYGNUM_DEVS_ETH_POWERPC_FCC_BUFSIZE + 32)];
158
 
159
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
160
RedBoot_config_option("FCC1/eth0 Network hardware address [MAC]",
161
                      fcc1_esa,
162
                      ALWAYS_ENABLED, true,
163
                      CONFIG_ESA, 0
164
    );
165
#endif
166
 
167
static struct fcc_eth_info fcc_eth0_info = {
168
    CYGNUM_HAL_INTERRUPT_FCC1,               // Interrupt
169
    "fcc1_esa",                              // ESA 'key'
170
    { 0x00, 0x08, 0xe5, 0x11, 0x22, 0x33 },  // Fallback ESA
171
    CYGNUM_DEVS_ETH_POWERPC_FCC_RxNUM,       // Number of Rx buffers
172
    fcc_eth0_rxbufs,                         // Pointer to buffers
173
    CYGNUM_DEVS_ETH_POWERPC_FCC_TxNUM,       // Number of Tx buffers
174
    fcc_eth0_txbufs,                         // Pointer to buffers
175
    &fcc1_phy,
176
};
177
 
178
ETH_DRV_SC(fcc_eth0_sc,
179
           &fcc_eth0_info,     // Driver specific data
180
           "eth0",             // Name for this interface
181
           fcc_eth_start,
182
           fcc_eth_stop,
183
           fcc_eth_control,
184
           fcc_eth_can_send,
185
           fcc_eth_send,
186
           fcc_eth_recv,
187
           fcc_eth_deliver,
188
           fcc_eth_int,
189
           fcc_eth_int_vector);
190
 
191
NETDEVTAB_ENTRY(fcc_eth0_netdev,
192
                "fcc_eth0",
193
                fcc_eth_init,
194
                &fcc_eth0_sc);
195
#endif // CYGHWR_DEVS_ETH_POWERPC_RATTLER_FCC1
196
 
197
#ifdef CYGHWR_DEVS_ETH_POWERPC_RATTLER_FCC2
198
//
199
// Initialize the PHY associated with FCC2/eth1
200
//
201
static void
202
fcc2_phy_init(void)
203
{
204
    // Set up PHY reset line
205
    IMM->io_regs[PORT_B].pdat |= FCC2_PHY_RESET;
206
    IMM->io_regs[PORT_C].pdir |= FCC2_PHY_CLOCK;
207
}
208
 
209
//
210
// Reset the PHY associated with FCC2/eth1
211
//
212
static void
213
fcc2_phy_reset(void)
214
{
215
    // Toggle the PHY reset line
216
    IMM->io_regs[PORT_B].pdat &= ~FCC2_PHY_RESET;
217
    IMM->io_regs[PORT_B].pdat |= FCC2_PHY_RESET;
218
}
219
 
220
//
221
// Set up a particular data bit for FCC2/eth1
222
//
223
static void
224
fcc2_phy_set_data(int val)
225
{
226
    if (val) {
227
        // Output
228
        IMM->io_regs[PORT_C].pdat |= FCC2_PHY_DATA;
229
    } else {
230
        // Input
231
        IMM->io_regs[PORT_C].pdat &= ~FCC2_PHY_DATA;
232
    }
233
}
234
 
235
//
236
// Read the current data bit for FCC2/eth1
237
//
238
static int
239
fcc2_phy_get_data(void)
240
{
241
    if ((IMM->io_regs[PORT_C].pdat & FCC2_PHY_DATA) != 0) {
242
        return 1;
243
    } else {
244
        return 0;
245
    }
246
}
247
 
248
//
249
// Set the clock bit for FCC2/eth1
250
//
251
static void
252
fcc2_phy_set_clock(int val)
253
{
254
    if (val) {
255
        // Output
256
        IMM->io_regs[PORT_C].pdat |= FCC2_PHY_CLOCK;
257
    } else {
258
        // Input
259
        IMM->io_regs[PORT_C].pdat &= ~FCC2_PHY_CLOCK;
260
    }
261
}
262
 
263
//
264
// Set the clock/data direction for FCC2/eth1
265
// Note: always forces clock to be an output
266
//
267
static void
268
fcc2_phy_set_dir(int data_dir)
269
{
270
    if (data_dir) {
271
        // Output
272
        IMM->io_regs[PORT_C].pdir |= FCC2_PHY_DATA;
273
    } else {
274
        // Input
275
        IMM->io_regs[PORT_C].pdir &= ~FCC2_PHY_DATA;
276
    }
277
}
278
 
279
ETH_PHY_BIT_LEVEL_ACCESS_FUNS(fcc2_phy,
280
                    fcc2_phy_init,
281
                    fcc2_phy_reset,
282
                    fcc2_phy_set_data,
283
                    fcc2_phy_get_data,
284
                    fcc2_phy_set_clock,
285
                    fcc2_phy_set_dir);
286
 
287
static unsigned char fcc_eth1_rxbufs[CYGNUM_DEVS_ETH_POWERPC_FCC_RxNUM *
288
                                    (CYGNUM_DEVS_ETH_POWERPC_FCC_BUFSIZE + 32)];
289
static unsigned char fcc_eth1_txbufs[CYGNUM_DEVS_ETH_POWERPC_FCC_TxNUM *
290
                                    (CYGNUM_DEVS_ETH_POWERPC_FCC_BUFSIZE + 32)];
291
 
292
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
293
RedBoot_config_option("FCC2/eth1 Network hardware address [MAC]",
294
                      fcc2_esa,
295
                      ALWAYS_ENABLED, true,
296
                      CONFIG_ESA, 0
297
    );
298
#endif
299
 
300
static struct fcc_eth_info fcc_eth1_info = {
301
    CYGNUM_HAL_INTERRUPT_FCC2,               // Interrupt
302
    "fcc2_esa",                              // ESA 'key'
303
    { 0x00, 0x08, 0xe5, 0x11, 0x22, 0x33 },  // Fallback ESA
304
    CYGNUM_DEVS_ETH_POWERPC_FCC_RxNUM,       // Number of Rx buffers
305
    fcc_eth1_rxbufs,                         // Pointer to buffers
306
    CYGNUM_DEVS_ETH_POWERPC_FCC_TxNUM,       // Number of Tx buffers
307
    fcc_eth1_txbufs,                         // Pointer to buffers
308
    &fcc2_phy,
309
};
310
 
311
ETH_DRV_SC(fcc_eth1_sc,
312
           &fcc_eth1_info,     // Driver specific data
313
           "eth1",             // Name for this interface
314
           fcc_eth_start,
315
           fcc_eth_stop,
316
           fcc_eth_control,
317
           fcc_eth_can_send,
318
           fcc_eth_send,
319
           fcc_eth_recv,
320
           fcc_eth_deliver,
321
           fcc_eth_int,
322
           fcc_eth_int_vector);
323
 
324
NETDEVTAB_ENTRY(fcc_eth1_netdev,
325
                "fcc_eth1",
326
                fcc_eth_init,
327
                &fcc_eth1_sc);
328
#endif // CYGHWR_DEVS_ETH_POWERPC_RATTLER_FCC2
329
 
330
#endif  // CYGONCE_DEVS_RATTLER_ETH_INL
331
// ------------------------------------------------------------------------

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.