]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/eth/powerpc/moab/v2_0/include/moab_eth_dp83816.inl
Initial revision
[karo-tx-redboot.git] / packages / devs / eth / powerpc / moab / v2_0 / include / moab_eth_dp83816.inl
1 //==========================================================================
2 //
3 //      moab_eth_dp83816.inl
4 //
5 //      MOAB 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 Red Hat, Inc.
12 // Copyright (C) 2003 Gary Thomas
13 //
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
17 //
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // 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 along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 //
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
33 //
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
36 //
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
43 //
44 // Author(s):    gthomas
45 // Contributors: 
46 // Date:         2003-09-29
47 // Purpose:      MOAB ethernet defintions
48 //####DESCRIPTIONEND####
49 //==========================================================================
50
51 #include <cyg/hal/hal_cache.h>
52 #include <cyg/io/pci.h>
53
54 #undef DP_IN
55 #undef DP_OUT
56 #define DP_IN(_b_, _o_, _d_)  HAL_READ_UINT32LE((cyg_addrword_t)(_b_)+(_o_), (_d_))
57 #define DP_OUT(_b_, _o_, _d_) HAL_WRITE_UINT32LE((cyg_addrword_t)(_b_)+(_o_), (_d_))
58
59 static cyg_bool
60 find_rtl8381x_match_func(cyg_uint16 v, cyg_uint16 d, cyg_uint32 c, void *p)
61 {
62     return ((v == 0x100B) && (d == 0x0020));
63 }
64
65 static void
66 _moab_eth_init(dp83816_priv_data_t *dp)
67 {
68     cyg_pci_device_id devid;
69     cyg_pci_device dev_info;
70
71     devid = CYG_PCI_NULL_DEVID;
72     if (cyg_pci_find_matching( &find_rtl8381x_match_func, NULL, &devid )) {
73         cyg_pci_get_device_info(devid, &dev_info);
74         cyg_pci_translate_interrupt(&dev_info, &dp->interrupt);
75         dp->base = (cyg_uint8 *)(dev_info.base_map[0] & ~1);
76         diag_printf("DP83816 at %p, interrupt: %x\n", dp->base, dp->interrupt);
77     }
78 }
79
80 #undef  CYGHWR_NS_DP83816_PLF_INIT
81 #define CYGHWR_NS_DP83816_PLF_INIT(dp) _moab_eth_init(dp)
82
83 // Align buffers on a cache boundary
84 #define RxBUFSIZE CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM*_DP83816_BUFSIZE
85 #define TxBUFSIZE CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM*_DP83816_BUFSIZE
86 static unsigned char dp83816_eth_rxbufs[RxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
87 static unsigned char dp83816_eth_txbufs[TxBUFSIZE] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
88 static dp83816_bd_t dp83816_eth_rxbd[CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
89 static dp83816_bd_t dp83816_eth_txbd[CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM] __attribute__((aligned(HAL_DCACHE_LINE_SIZE)));
90
91 extern char _moab_eth1_ESA[];
92 static dp83816_priv_data_t dp83816_eth1_priv_data = { 
93     "eth1_esa",
94     _moab_eth1_ESA,
95     CYGNUM_DEVS_ETH_MOAB_DP83816_RxNUM,    // Number of Rx buffers
96     dp83816_eth_rxbufs,                    // Rx buffer space
97     dp83816_eth_rxbd,                      // Rx buffer headers
98     CYGNUM_DEVS_ETH_MOAB_DP83816_TxNUM,    // Number of Tx buffers
99     dp83816_eth_txbufs,                    // Tx buffer space
100     dp83816_eth_txbd,                      // Tx buffer headers
101 };
102
103 ETH_DRV_SC(dp83816_sc,
104            &dp83816_eth1_priv_data, // Driver specific data
105            "eth1",
106            dp83816_start,
107            dp83816_stop,
108            dp83816_control,
109            dp83816_can_send,
110            dp83816_send,
111            dp83816_recv,
112            dp83816_deliver,     // "pseudoDSR" called from fast net thread
113            dp83816_poll,        // poll function, encapsulates ISR and DSR
114            dp83816_int_vector);
115
116 NETDEVTAB_ENTRY(dp83816_netdev, 
117                 "eth1",
118                 dp83816_init, 
119                 &dp83816_sc);
120
121 #if defined(CYGPKG_REDBOOT) 
122 #include <pkgconf/redboot.h>
123 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
124 #include <redboot.h>
125 #include <flash_config.h>
126 RedBoot_config_option("eth1 network hardware address [MAC]",
127                       eth1_esa,
128                       ALWAYS_ENABLED, true,
129                       CONFIG_ESA, _moab_eth1_ESA
130     );
131 #endif  // CYGSEM_REDBOOT_FLASH_CONFIG
132 #else
133 #ifndef CONFIG_ESA
134 #define CONFIG_ESA 6
135 #endif
136 #endif  // CYGPKG_REDBOOT
137
138
139 // EOF moab_eth_dp83816.inl