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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [devs/] [eth/] [arm/] [cerf/] [current/] [include/] [devs_eth_arm_cerf.inl] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      devs_eth_arm_cerf.inl
4
//
5
//      CERF 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):   jskov
43
// Contributors:jskov
44
// Date:        2001-11-14
45
// Purpose:     CERF ethernet defintions
46
//
47
//####DESCRIPTIONEND####
48
//==========================================================================
49
 
50
#include 
51
#include 
52
#include 
53
 
54
#ifdef CYGPKG_REDBOOT
55
# include 
56
# ifdef CYGSEM_REDBOOT_FLASH_CONFIG
57
#  include 
58
#  include 
59
# endif
60
#endif
61
 
62
#ifdef __WANT_CONFIG
63
# define CS8900A_step 2
64
#endif
65
 
66
#ifdef __WANT_DEVS
67
 
68
#ifdef CYGPKG_DEVS_ETH_ARM_CERF_ETH0
69
 
70
#ifndef CYGSEM_DEVS_ETH_ARM_CERF_ETH0_SET_ESA
71
# if defined(CYGPKG_REDBOOT) && defined(CYGSEM_REDBOOT_FLASH_CONFIG)
72
RedBoot_config_option("Set " CYGDAT_DEVS_ETH_ARM_CERF_ETH0_NAME " network hardware address [MAC]",
73
                      eth0_esa,
74
                      ALWAYS_ENABLED, true,
75
                      CONFIG_BOOL, false
76
    );
77
RedBoot_config_option(CYGDAT_DEVS_ETH_ARM_CERF_ETH0_NAME " network hardware address [MAC]",
78
                      eth0_esa_data,
79
                      "eth0_esa", true,
80
                      CONFIG_ESA, 0
81
    );
82
# endif // CYGPKG_REDBOOT && CYGSEM_REDBOOT_FLASH_CONFIG
83
 
84
# ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
85
// Note that this section *is* active in an application, outside RedBoot,
86
// where the above section is not included.
87
 
88
#  include 
89
 
90
#  ifndef CONFIG_ESA
91
#   define CONFIG_ESA (6)
92
#  endif
93
#  ifndef CONFIG_BOOL
94
#   define CONFIG_BOOL (1)
95
#  endif
96
 
97
cyg_bool
98
_cerf_provide_eth0_esa(struct cs8900a_priv_data* cpd)
99
{
100
    cyg_bool set_esa;
101
    int ok;
102
    ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,
103
                                      "eth0_esa", &set_esa, CONFIG_BOOL);
104
    if (ok && set_esa) {
105
        ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET,
106
                                          "eth0_esa_data", cpd->esa, CONFIG_ESA);
107
    }
108
    return ok && set_esa;
109
}
110
 
111
# endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
112
#endif // ! CYGSEM_DEVS_ETH_ARM_CERF_ETH0_SET_ESA
113
 
114
// ------------------------------------------------------------------------
115
// EEPROM access functions
116
//
117
#define PP_ECR          0x0040
118
#define PP_EE_READ_CMD  0x0200
119
#define PP_EE_WRITE_CMD 0x0100
120
#define PP_EE_DATA              0x0042
121
#define PP_EE_ADDR_W0   0x001C
122
#define PP_EE_ADDR_W1   0x001D
123
#define PP_EE_ADDR_W2   0x001E
124
 
125
static __inline__ cyg_uint16
126
read_eeprom(cyg_addrword_t base, cyg_uint16 offset)
127
{
128
    while (get_reg(base, PP_SelfStat) & PP_SelfStat_SIBSY)
129
        ;
130
 
131
    put_reg(base, PP_ECR, (offset | PP_EE_READ_CMD));
132
 
133
    while (get_reg(base, PP_SelfStat) & PP_SelfStat_SIBSY)
134
        ;
135
 
136
    return get_reg(base, PP_EE_DATA);
137
}
138
 
139
static __inline__ void
140
copy_eeprom(cyg_addrword_t base)
141
{
142
    cyg_uint16 esa_word;
143
    int i;
144
    for (i = 0;  i < 6;  i += 2)
145
    {
146
         esa_word = read_eeprom(base, PP_EE_ADDR_W0 + (i/2));
147
         put_reg(base, PP_IA+(i/2), esa_word);
148
    }
149
}
150
 
151
static __inline__ void
152
post_reset(cyg_addrword_t base)
153
{
154
    // Toggle A0 connected to the SBHE line on the Crystal chip.
155
    *(char*)(0x20000000) = 1;
156
    *(char*)(0x20000001) = 2;
157
    *(char*)(0x20000000) = 3;
158
    *(char*)(0x20000001) = 0;
159
}
160
 
161
#undef  CYGHWR_CL_CS8900A_PLF_POST_RESET
162
#define CYGHWR_CL_CS8900A_PLF_POST_RESET(base) post_reset(base)
163
 
164
#undef  CYGHWR_CL_CS8900A_PLF_RESET
165
#define CYGHWR_CL_CS8900A_PLF_RESET(base) copy_eeprom(base)
166
 
167
static cs8900a_priv_data_t cs8900a_eth0_priv_data = {
168
    base : (cyg_addrword_t) 0xf0000300,
169
    interrupt:SA1110_IRQ_GPIO_ETH,
170
#ifdef CYGSEM_DEVS_ETH_ARM_CERF_ETH0_SET_ESA
171
    esa : CYGDAT_DEVS_ETH_ARM_CERF_ETH0_ESA,
172
    hardwired_esa : true,
173
#else
174
    hardwired_esa : false,
175
# ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
176
    provide_esa : &_cerf_provide_eth0_esa,
177
# else
178
    provide_esa : NULL,
179
# endif
180
#endif
181
 
182
};
183
 
184
 
185
ETH_DRV_SC(cs8900a_sc,
186
           &cs8900a_eth0_priv_data, // Driver specific data
187
           CYGDAT_DEVS_ETH_ARM_CERF_ETH0_NAME,
188
           cs8900a_start,
189
           cs8900a_stop,
190
           cs8900a_control,
191
           cs8900a_can_send,
192
           cs8900a_send,
193
           cs8900a_recv,
194
           cs8900a_deliver,     // "pseudoDSR" called from fast net thread
195
           cs8900a_poll,        // poll function, encapsulates ISR and DSR
196
           cs8900a_int_vector);
197
 
198
NETDEVTAB_ENTRY(cs8900a_netdev,
199
                "cs8900a_" CYGDAT_DEVS_ETH_ARM_CERF_ETH0_NAME,
200
                cs8900a_init,
201
                &cs8900a_sc);
202
 
203
#endif // CYGPKG_DEVS_ETH_ARM_CERF_ETH0
204
 
205
#endif // __WANT_DEVS
206
 
207
// EOF devs_eth_arm_cerf.inl

powered by: WebSVN 2.1.0

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