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