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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [devs/] [eth/] [powerpc/] [ec555/] [current/] [include/] [devs_eth_powerpc_ec555.inl] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      devs_eth_powerpc_ec555.inl
4
//
5
//      ec555 ethernet I/O definitions.
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 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later
16
// version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT
19
// ANY 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
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
//
27
// As a special exception, if other files instantiate templates or use
28
// macros or inline functions from this file, or you compile this file
29
// and link it with other works to produce a work based on this file,
30
// this file does not by itself cause the resulting work to be covered by
31
// the GNU General Public License. However the source code for this file
32
// must still be made available in accordance with section (3) of the GNU
33
// General Public License v2.
34
//
35
// This exception does not invalidate any other reasons why a work based
36
// on this file might be covered by the GNU General Public License.
37
// -------------------------------------------
38
// ####ECOSGPLCOPYRIGHTEND####
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):   Bob Koninckx
43
// Contributors:Bob Koninckx
44
// Date:        2002-11-20
45
// Purpose:     ec555 ethernet defintions
46
//
47
//####DESCRIPTIONEND####
48
//==========================================================================
49
 
50
#include 
51
#include 
52
 
53
#ifdef CYGPKG_REDBOOT
54
# include 
55
# ifdef CYGSEM_REDBOOT_FLASH_CONFIG
56
#  include 
57
#  include 
58
# endif
59
#endif
60
 
61
#ifdef __WANT_CONFIG
62
# define CS8900A_step 2
63
#endif
64
 
65
#ifdef __WANT_DEVS
66
 
67
#ifdef CYGPKG_DEVS_ETH_POWERPC_EC555_ETH0
68
 
69
#ifndef CYGSEM_DEVS_ETH_POWERPC_EC555_ETH0_SET_ESA
70
# if defined(CYGPKG_REDBOOT) && defined(CYGSEM_REDBOOT_FLASH_CONFIG)
71
RedBoot_config_option("Set " CYGDAT_DEVS_ETH_POWERPC_EC555_ETH0_NAME " network hardware address [MAC]",
72
                      eth0_esa,
73
                      ALWAYS_ENABLED, true,
74
                      CONFIG_BOOL, false
75
    );
76
RedBoot_config_option(CYGDAT_DEVS_ETH_POWERPC_EC555_ETH0_NAME " network hardware address [MAC]",
77
                      eth0_esa_data,
78
                      "eth0_esa", true,
79
                      CONFIG_ESA, 0
80
    );
81
# endif // CYGPKG_REDBOOT && CYGSEM_REDBOOT_FLASH_CONFIG
82
 
83
# ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
84
// Note that this section *is* active in an application, outside RedBoot,
85
// where the above section is not included.
86
 
87
#  include 
88
 
89
#  ifndef CONFIG_ESA
90
#   define CONFIG_ESA (6)
91
#  endif
92
#  ifndef CONFIG_BOOL
93
#   define CONFIG_BOOL (1)
94
#  endif
95
 
96
cyg_bool
97
_ec555_provide_eth0_esa(struct cs8900a_priv_data* cpd)
98
{
99
    cyg_bool set_esa;
100
    int ok;
101
    ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,
102
                                      "eth0_esa", &set_esa, CONFIG_BOOL);
103
    if (ok && set_esa) {
104
        ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,
105
                                          "eth0_esa_data", cpd->esa, CONFIG_ESA);
106
    }
107
    return ok && set_esa;
108
}
109
 
110
# endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
111
#endif // ! CYGSEM_DEVS_ETH_POWERPC_EC555_ETH0_SET_ESA
112
 
113
// ------------------------------------------------------------------------
114
// EEPROM access functions
115
// These are byte swapped
116
#ifdef CYGIMP_DEVS_ETH_CL_CS8900A_DATABUS_BYTE_SWAPPED
117
#define PP_ECR          0x4000    // EEPROM Command Register
118
#define PP_EE_READ_CMD  0x0002
119
#define PP_EE_WRITE_CMD 0x0001
120
#define PP_EE_DATA              0x4200
121
#else
122
#define PP_ECR          0x0040    // EEPROM Command Register
123
#define PP_EE_READ_CMD  0x0200
124
#define PP_EE_WRITE_CMD 0x0100
125
#define PP_EE_DATA      0x0042
126
#endif
127
 
128
#define PP_EE_ADDR_W0   0x001C    // Notice that the EEPROM is not programmed when you got the
129
#define PP_EE_ADDR_W1   0x001D    // Module from Wuerz. Make sure to program the address to these
130
#define PP_EE_ADDR_W2   0x001E    // locations before using the adapter. This is fairly easy using GDB
131
 
132
// The example below programs the MAC address 0050 c4ff fc07 to the eeprom, supposed that the module
133
// is mapped to adresses 0x0400 0000, and supposed that the data bus is _not_ byte swapped
134
//
135
// set *(unsigned short *)0x0400030a = 0x0040        Make the eeprom writable / erasable
136
// set *(unsigned short *)0x0400030c = 0x0030
137
//
138
// set *(unsigned short *)0x0400030a = 0x0040        erase the old esa
139
// set *(unsigned short *)0x0400030c = 0x031c
140
// set *(unsigned short *)0x0400030c = 0x031d
141
// set *(unsigned short *)0x0400030c = 0x031e
142
//
143
// set *(unsigned short *)0x0400030a = 0x0042        program the new esa
144
// set *(unsigned short *)0x0400030c = 0x5000
145
// set *(unsigned short *)0x0400030a = 0x0040
146
// set *(unsigned short *)0x0400030c = 0x011c
147
// set *(unsigned short *)0x0400030a = 0x0042
148
// set *(unsigned short *)0x0400030c = 0xffc4
149
// set *(unsigned short *)0x0400030a = 0x0040
150
// set *(unsigned short *)0x0400030c = 0x011d
151
// set *(unsigned short *)0x0400030a = 0x0042
152
// set *(unsigned short *)0x0400030c = 0x07fc
153
// set *(unsigned short *)0x0400030a = 0x0040
154
// set *(unsigned short *)0x0400030c = 0x011e
155
//
156
// set *(unsigned short *)0x0400030a = 0x0040        Write protect the eeprom
157
// set *(unsigned short *)0x0400030c = 0x0030
158
 
159
static __inline__ cyg_uint16
160
read_eeprom(cyg_addrword_t base, cyg_uint16 offset)
161
{
162
    while (get_reg(base, PP_SelfStat) & PP_SelfStat_SIBSY)
163
        ;
164
 
165
#ifdef CYGIMP_DEVS_ETH_CL_CS8900A_DATABUS_BYTE_SWAPPED
166
    put_reg(base, PP_ECR, (CYG_SWAP16(offset) | PP_EE_READ_CMD));
167
#else
168
    put_reg(base, PP_ECR, (offset | PP_EE_READ_CMD));
169
#endif
170
 
171
    while (get_reg(base, PP_SelfStat) & PP_SelfStat_SIBSY)
172
        ;
173
 
174
    return get_reg(base, PP_EE_DATA);
175
}
176
 
177
static __inline__ void
178
copy_eeprom(cyg_addrword_t base)
179
{
180
    volatile cyg_uint16 esa_word;
181
    cyg_uint16 i;
182
    for (i = 0;  i < 6;  i += 2)
183
    {    // Offset in the eeprom is WORD oriented, in the packetpage BYTE oriented
184
         esa_word = read_eeprom(base, PP_EE_ADDR_W0 + (i/2));
185
#ifdef CYGIMP_DEVS_ETH_CL_CS8900A_DATABUS_BYTE_SWAPPED
186
         put_reg(base, (PP_IA + CYG_SWAP16(i)), esa_word);
187
#else
188
         put_reg(base, (PP_IA + i), esa_word);
189
#endif
190
    }
191
}
192
 
193
// Not so nice, but reading these will never conflict on the ec555
194
// They certainly differ in A18
195
#define FIRSTRAM 0x01000000
196
#define LASTRAM  0x010ffffe
197
 
198
static __inline__ void
199
post_reset(cyg_addrword_t base)
200
{
201
   cyg_uint16 tmp;
202
 
203
        // The following must toggle Address line 18, connected to SBHE on the CS8900a
204
        HAL_READ_UINT16( LASTRAM,  tmp);
205
        HAL_READ_UINT16( FIRSTRAM, tmp);
206
        HAL_READ_UINT16( LASTRAM,  tmp);
207
        HAL_READ_UINT16( FIRSTRAM, tmp);
208
}
209
 
210
#undef  CYGHWR_CL_CS8900A_PLF_POST_RESET
211
#define CYGHWR_CL_CS8900A_PLF_POST_RESET(base) post_reset(base)
212
 
213
#undef  CYGHWR_CL_CS8900A_PLF_RESET
214
#define CYGHWR_CL_CS8900A_PLF_RESET(base) copy_eeprom(base)
215
 
216
static cs8900a_priv_data_t cs8900a_eth0_priv_data = {
217
    base : (cyg_addrword_t) (CYGNUM_DEVS_ETH_POWERPC_EC555_ETH0_BASE + 0x300),
218
    interrupt:((CYGNUM_DEVS_ETH_POWERPC_EC555_ETH0_IRQ*2)+1),
219
#ifdef CYGSEM_DEVS_ETH_POWERPC_EC555_ETH0_SET_ESA
220
    esa : CYGDAT_DEVS_ETH_POWERPC_EC555_ETH0_ESA,
221
    hardwired_esa : true,
222
#else
223
    hardwired_esa : false,
224
# ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
225
    provide_esa : &_ec555_provide_eth0_esa,
226
# else
227
    provide_esa : NULL,
228
# endif
229
#endif
230
 
231
};
232
 
233
 
234
ETH_DRV_SC(cs8900a_sc,
235
           &cs8900a_eth0_priv_data, // Driver specific data
236
           CYGDAT_DEVS_ETH_POWERPC_EC555_ETH0_NAME,
237
           cs8900a_start,
238
           cs8900a_stop,
239
           cs8900a_control,
240
           cs8900a_can_send,
241
           cs8900a_send,
242
           cs8900a_recv,
243
           cs8900a_deliver,     // "pseudoDSR" called from fast net thread
244
           cs8900a_poll,        // poll function, encapsulates ISR and DSR
245
           cs8900a_int_vector);
246
 
247
NETDEVTAB_ENTRY(cs8900a_netdev,
248
                "cs8900a_" CYGDAT_DEVS_ETH_POWERPC_EC555_ETH0_NAME,
249
                cs8900a_init,
250
                &cs8900a_sc);
251
 
252
#endif // CYGPKG_DEVS_ETH_POWERPC_EC555_ETH0
253
 
254
#endif // __WANT_DEVS
255
 
256
// EOF devs_eth_powerpc_ec555.inl

powered by: WebSVN 2.1.0

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