1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// devs/eth/arm/uE250/..../include/devs_eth_uE250.inl
|
4 |
|
|
//
|
5 |
|
|
// NMI uE250 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, 2003 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, hmt, gthomas
|
43 |
|
|
// Contributors: jskov
|
44 |
|
|
// Date: 2001-02-28
|
45 |
|
|
// Purpose: FRV400 ethernet defintions
|
46 |
|
|
//####DESCRIPTIONEND####
|
47 |
|
|
//==========================================================================
|
48 |
|
|
|
49 |
|
|
#include // CYGNUM_HAL_INTERRUPT_ETHR
|
50 |
|
|
#include
|
51 |
|
|
#include
|
52 |
|
|
|
53 |
|
|
#ifdef __WANT_CONFIG
|
54 |
|
|
|
55 |
|
|
#define CYGHWR_NS_DP83902A_PLF_RESET(_dp_) \
|
56 |
|
|
CYG_MACRO_START \
|
57 |
|
|
cyg_uint8 _t; \
|
58 |
|
|
HAL_READ_UINT8(_dp_->reset, _t); \
|
59 |
|
|
CYGACC_CALL_IF_DELAY_US(10); \
|
60 |
|
|
HAL_WRITE_UINT8(_dp_->reset, _t); \
|
61 |
|
|
CYGACC_CALL_IF_DELAY_US(10000); \
|
62 |
|
|
CYG_MACRO_END
|
63 |
|
|
|
64 |
|
|
#define DP_IN(_b_, _o_, _d_) \
|
65 |
|
|
CYG_MACRO_START \
|
66 |
|
|
_d_ = pci_io_read_8((cyg_addrword_t)(_b_)+(_o_)); \
|
67 |
|
|
CYG_MACRO_END
|
68 |
|
|
|
69 |
|
|
#define DP_OUT(_b_, _o_, _d_) \
|
70 |
|
|
CYG_MACRO_START \
|
71 |
|
|
pci_io_write_8((cyg_addrword_t)(_b_)+(_o_), _d_); \
|
72 |
|
|
CYG_MACRO_END
|
73 |
|
|
|
74 |
|
|
#define DP_IN_DATA(_b_, _d_) \
|
75 |
|
|
CYG_MACRO_START \
|
76 |
|
|
_d_ = pci_io_read_16((cyg_addrword_t)(_b_)); \
|
77 |
|
|
CYG_MACRO_END
|
78 |
|
|
|
79 |
|
|
#define DP_OUT_DATA(_b_, _d_) \
|
80 |
|
|
CYG_MACRO_START \
|
81 |
|
|
pci_io_write_16((cyg_addrword_t)(_b_), _d_); \
|
82 |
|
|
CYG_MACRO_END
|
83 |
|
|
|
84 |
|
|
//#define CYGHWR_NS_DP83902A_PLF_16BIT_DATA
|
85 |
|
|
//#define CYGHWR_NS_DP83902A_PLF_BROKEN_TX_DMA
|
86 |
|
|
|
87 |
|
|
#endif // __WANT_CONFIG
|
88 |
|
|
|
89 |
|
|
#ifdef __WANT_DEVS
|
90 |
|
|
|
91 |
|
|
#if defined(CYGSEM_DEVS_ETH_UE250_ETH0_SET_ESA)
|
92 |
|
|
#if defined(CYGPKG_REDBOOT)
|
93 |
|
|
#include
|
94 |
|
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
95 |
|
|
#include
|
96 |
|
|
#include
|
97 |
|
|
RedBoot_config_option("Network hardware address [MAC]",
|
98 |
|
|
lan_esa,
|
99 |
|
|
ALWAYS_ENABLED, true,
|
100 |
|
|
CONFIG_ESA, 0
|
101 |
|
|
);
|
102 |
|
|
#endif // CYGSEM_REDBOOT_FLASH_CONFIG
|
103 |
|
|
#endif // CYGPKG_REDBOOT
|
104 |
|
|
#include
|
105 |
|
|
#ifndef CONFIG_ESA
|
106 |
|
|
#define CONFIG_ESA 6
|
107 |
|
|
#endif
|
108 |
|
|
#endif
|
109 |
|
|
|
110 |
|
|
static cyg_bool
|
111 |
|
|
find_rtl8029_match_func( cyg_uint16 v, cyg_uint16 d, cyg_uint32 c, void *p )
|
112 |
|
|
{
|
113 |
|
|
return ((v == 0x10EC) && (d == 0x8029));
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
static void
|
117 |
|
|
_ue250_eth_init(dp83902a_priv_data_t *dp)
|
118 |
|
|
{
|
119 |
|
|
cyg_pci_device_id devid;
|
120 |
|
|
cyg_pci_device dev_info;
|
121 |
|
|
#if defined(CYGSEM_DEVS_ETH_UE250_ETH0_SET_ESA)
|
122 |
|
|
cyg_bool esa_ok;
|
123 |
|
|
unsigned char _esa[6];
|
124 |
|
|
#else
|
125 |
|
|
unsigned char prom[32];
|
126 |
|
|
int i;
|
127 |
|
|
#endif
|
128 |
|
|
|
129 |
|
|
devid = CYG_PCI_NULL_DEVID;
|
130 |
|
|
if (cyg_pci_find_matching( &find_rtl8029_match_func, NULL, &devid )) {
|
131 |
|
|
cyg_pci_get_device_info(devid, &dev_info);
|
132 |
|
|
cyg_pci_translate_interrupt(&dev_info, &dp->interrupt);
|
133 |
|
|
dp->base = (cyg_uint8 *)(dev_info.base_map[0] & ~1);
|
134 |
|
|
dp->data = dp->base + 0x10;
|
135 |
|
|
dp->reset = dp->base + 0x1F;
|
136 |
|
|
#if 0
|
137 |
|
|
diag_printf("RTL8029 at %p, interrupt: %x\n", dp->base, dp->interrupt);
|
138 |
|
|
#endif
|
139 |
|
|
#if defined(CYGSEM_DEVS_ETH_UE250_ETH0_SET_ESA)
|
140 |
|
|
esa_ok = CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
|
141 |
|
|
"lan_esa", _esa, CONFIG_ESA);
|
142 |
|
|
if (esa_ok) {
|
143 |
|
|
memcpy(dp->esa, _esa, sizeof(_esa));
|
144 |
|
|
}
|
145 |
|
|
#else
|
146 |
|
|
// Read ESA from EEPROM
|
147 |
|
|
DP_OUT(dp->base, DP_DCR, 0x49); // Wordwide access
|
148 |
|
|
DP_OUT(dp->base, DP_RBCH, 0); // Remote byte count
|
149 |
|
|
DP_OUT(dp->base, DP_RBCL, 0);
|
150 |
|
|
DP_OUT(dp->base, DP_ISR, 0xFF); // Clear any pending interrupts
|
151 |
|
|
DP_OUT(dp->base, DP_IMR, 0x00); // Mask all interrupts
|
152 |
|
|
DP_OUT(dp->base, DP_RCR, 0x20); // Monitor
|
153 |
|
|
DP_OUT(dp->base, DP_TCR, 0x02); // loopback
|
154 |
|
|
DP_OUT(dp->base, DP_RBCH, 32); // Remote byte count
|
155 |
|
|
DP_OUT(dp->base, DP_RBCL, 0);
|
156 |
|
|
DP_OUT(dp->base, DP_RSAL, 0); // Remote address
|
157 |
|
|
DP_OUT(dp->base, DP_RSAH, 0);
|
158 |
|
|
DP_OUT(dp->base, DP_CR, DP_CR_START|DP_CR_RDMA); // Read data
|
159 |
|
|
for (i = 0; i < 32; i++) {
|
160 |
|
|
cyg_uint16 _val;
|
161 |
|
|
HAL_READ_UINT16(dp->data, _val);
|
162 |
|
|
prom[i] = _val;
|
163 |
|
|
}
|
164 |
|
|
// Set ESA into chip
|
165 |
|
|
DP_OUT(dp->base, DP_CR, DP_CR_NODMA | DP_CR_PAGE1); // Select page 1
|
166 |
|
|
for (i = 0; i < 6; i++) {
|
167 |
|
|
DP_OUT(dp->base, DP_P1_PAR0+i, prom[i]);
|
168 |
|
|
}
|
169 |
|
|
DP_OUT(dp->base, DP_CR, DP_CR_NODMA | DP_CR_PAGE0); // Select page 0
|
170 |
|
|
#endif
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
#undef CYGHWR_NS_DP83902A_PLF_INIT
|
175 |
|
|
#define CYGHWR_NS_DP83902A_PLF_INIT(dp) _ue250_eth_init(dp)
|
176 |
|
|
|
177 |
|
|
#ifndef CYGINT_IO_ETH_INT_SUPPORT_REQUIRED
|
178 |
|
|
static void
|
179 |
|
|
_ue250_eth_int_clear(dp83902a_priv_data_t *dp)
|
180 |
|
|
{
|
181 |
|
|
cyg_drv_interrupt_acknowledge(dp->interrupt);
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
#undef CYGHWR_NS_DP83902A_PLF_INT_CLEAR
|
185 |
|
|
#define CYGHWR_NS_DP83902A_PLF_INT_CLEAR(dp) _ue250_eth_int_clear(dp)
|
186 |
|
|
#endif
|
187 |
|
|
|
188 |
|
|
#ifdef CYGPKG_DEVS_ETH_UE250_ETH0
|
189 |
|
|
|
190 |
|
|
static dp83902a_priv_data_t dp83902a_eth0_priv_data = {
|
191 |
|
|
base : (cyg_uint8*) 0, //
|
192 |
|
|
data : (cyg_uint8*) 0, // Filled in at runtime
|
193 |
|
|
reset: (cyg_uint8*) 0, //
|
194 |
|
|
interrupt: 0, //
|
195 |
|
|
tx_buf1: 0x40, //
|
196 |
|
|
tx_buf2: 0x48, // Buffer layout - change with care
|
197 |
|
|
rx_buf_start: 0x50, //
|
198 |
|
|
rx_buf_end: 0x80, //
|
199 |
|
|
#ifdef CYGSEM_DEVS_ETH_UE250_ETH0_SET_ESA
|
200 |
|
|
esa : CYGDAT_DEVS_ETH_UE250_ETH0_ESA,
|
201 |
|
|
hardwired_esa : true,
|
202 |
|
|
#else
|
203 |
|
|
hardwired_esa : false,
|
204 |
|
|
#endif
|
205 |
|
|
};
|
206 |
|
|
|
207 |
|
|
ETH_DRV_SC(dp83902a_sc,
|
208 |
|
|
&dp83902a_eth0_priv_data, // Driver specific data
|
209 |
|
|
CYGDAT_DEVS_ETH_UE250_ETH0_NAME,
|
210 |
|
|
dp83902a_start,
|
211 |
|
|
dp83902a_stop,
|
212 |
|
|
dp83902a_control,
|
213 |
|
|
dp83902a_can_send,
|
214 |
|
|
dp83902a_send,
|
215 |
|
|
dp83902a_recv,
|
216 |
|
|
dp83902a_deliver, // "pseudoDSR" called from fast net thread
|
217 |
|
|
dp83902a_poll, // poll function, encapsulates ISR and DSR
|
218 |
|
|
dp83902a_int_vector);
|
219 |
|
|
|
220 |
|
|
NETDEVTAB_ENTRY(dp83902a_netdev,
|
221 |
|
|
"dp83902a_" CYGDAT_DEVS_ETH_UE250_ETH0_NAME,
|
222 |
|
|
dp83902a_init,
|
223 |
|
|
&dp83902a_sc);
|
224 |
|
|
|
225 |
|
|
#endif // CYGPKG_DEVS_ETH_UE250_ETH0
|
226 |
|
|
|
227 |
|
|
#endif // __WANT_DEVS
|
228 |
|
|
|
229 |
|
|
// --------------------------------------------------------------
|
230 |
|
|
|
231 |
|
|
// EOF devs_eth_ue250.inl
|