]>
Commit | Line | Data |
---|---|---|
48257c4f PA |
1 | #ifndef FS_ENET_H |
2 | #define FS_ENET_H | |
3 | ||
4 | #include <linux/mii.h> | |
5 | #include <linux/netdevice.h> | |
6 | #include <linux/types.h> | |
48257c4f | 7 | #include <linux/list.h> |
5b4b8454 | 8 | #include <linux/phy.h> |
d6bd3a39 | 9 | #include <linux/dma-mapping.h> |
48257c4f PA |
10 | |
11 | #include <linux/fs_enet_pd.h> | |
5427828e | 12 | #include <asm/fs_pd.h> |
48257c4f | 13 | |
48257c4f PA |
14 | #ifdef CONFIG_CPM1 |
15 | #include <asm/commproc.h> | |
5b4b8454 VB |
16 | |
17 | struct fec_info { | |
0fb300fa SW |
18 | fec_t *fecp; |
19 | u32 mii_speed; | |
5b4b8454 | 20 | }; |
48257c4f PA |
21 | #endif |
22 | ||
23 | #ifdef CONFIG_CPM2 | |
24 | #include <asm/cpm2.h> | |
25 | #endif | |
26 | ||
27 | /* hw driver ops */ | |
28 | struct fs_ops { | |
29 | int (*setup_data)(struct net_device *dev); | |
30 | int (*allocate_bd)(struct net_device *dev); | |
31 | void (*free_bd)(struct net_device *dev); | |
32 | void (*cleanup_data)(struct net_device *dev); | |
33 | void (*set_multicast_list)(struct net_device *dev); | |
5b4b8454 | 34 | void (*adjust_link)(struct net_device *dev); |
48257c4f PA |
35 | void (*restart)(struct net_device *dev); |
36 | void (*stop)(struct net_device *dev); | |
37 | void (*pre_request_irq)(struct net_device *dev, int irq); | |
38 | void (*post_free_irq)(struct net_device *dev, int irq); | |
39 | void (*napi_clear_rx_event)(struct net_device *dev); | |
40 | void (*napi_enable_rx)(struct net_device *dev); | |
41 | void (*napi_disable_rx)(struct net_device *dev); | |
42 | void (*rx_bd_done)(struct net_device *dev); | |
43 | void (*tx_kickstart)(struct net_device *dev); | |
44 | u32 (*get_int_events)(struct net_device *dev); | |
45 | void (*clear_int_events)(struct net_device *dev, u32 int_events); | |
46 | void (*ev_error)(struct net_device *dev, u32 int_events); | |
47 | int (*get_regs)(struct net_device *dev, void *p, int *sizep); | |
48 | int (*get_regs_len)(struct net_device *dev); | |
49 | void (*tx_restart)(struct net_device *dev); | |
50 | }; | |
51 | ||
52 | struct phy_info { | |
53 | unsigned int id; | |
54 | const char *name; | |
55 | void (*startup) (struct net_device * dev); | |
56 | void (*shutdown) (struct net_device * dev); | |
57 | void (*ack_int) (struct net_device * dev); | |
58 | }; | |
59 | ||
60 | /* The FEC stores dest/src/type, data, and checksum for receive packets. | |
61 | */ | |
62 | #define MAX_MTU 1508 /* Allow fullsized pppoe packets over VLAN */ | |
63 | #define MIN_MTU 46 /* this is data size */ | |
64 | #define CRC_LEN 4 | |
65 | ||
66 | #define PKT_MAXBUF_SIZE (MAX_MTU+ETH_HLEN+CRC_LEN) | |
67 | #define PKT_MINBUF_SIZE (MIN_MTU+ETH_HLEN+CRC_LEN) | |
68 | ||
69 | /* Must be a multiple of 32 (to cover both FEC & FCC) */ | |
70 | #define PKT_MAXBLR_SIZE ((PKT_MAXBUF_SIZE + 31) & ~31) | |
71 | /* This is needed so that invalidate_xxx wont invalidate too much */ | |
0d0d9c15 SW |
72 | #define ENET_RX_ALIGN 16 |
73 | #define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE + ENET_RX_ALIGN - 1) | |
48257c4f | 74 | |
48257c4f | 75 | struct fs_enet_private { |
bea3348e | 76 | struct napi_struct napi; |
48257c4f PA |
77 | struct device *dev; /* pointer back to the device (must be initialized first) */ |
78 | spinlock_t lock; /* during all ops except TX pckt processing */ | |
79 | spinlock_t tx_lock; /* during fs_start_xmit and fs_tx */ | |
976de6a8 | 80 | struct fs_platform_info *fpi; |
48257c4f PA |
81 | const struct fs_ops *ops; |
82 | int rx_ring, tx_ring; | |
83 | dma_addr_t ring_mem_addr; | |
84 | void *ring_base; | |
85 | struct sk_buff **rx_skbuff; | |
86 | struct sk_buff **tx_skbuff; | |
87 | cbd_t *rx_bd_base; /* Address of Rx and Tx buffers. */ | |
88 | cbd_t *tx_bd_base; | |
89 | cbd_t *dirty_tx; /* ring entries to be free()ed. */ | |
90 | cbd_t *cur_rx; | |
91 | cbd_t *cur_tx; | |
92 | int tx_free; | |
93 | struct net_device_stats stats; | |
94 | struct timer_list phy_timer_list; | |
95 | const struct phy_info *phy; | |
96 | u32 msg_enable; | |
97 | struct mii_if_info mii_if; | |
98 | unsigned int last_mii_status; | |
48257c4f PA |
99 | int interrupt; |
100 | ||
5b4b8454 VB |
101 | struct phy_device *phydev; |
102 | int oldduplex, oldspeed, oldlink; /* current settings */ | |
48257c4f PA |
103 | |
104 | /* event masks */ | |
105 | u32 ev_napi_rx; /* mask of NAPI rx events */ | |
106 | u32 ev_rx; /* rx event mask */ | |
107 | u32 ev_tx; /* tx event mask */ | |
108 | u32 ev_err; /* error event mask */ | |
109 | ||
110 | u16 bd_rx_empty; /* mask of BD rx empty */ | |
111 | u16 bd_rx_err; /* mask of BD rx errors */ | |
112 | ||
113 | union { | |
114 | struct { | |
115 | int idx; /* FEC1 = 0, FEC2 = 1 */ | |
116 | void *fecp; /* hw registers */ | |
117 | u32 hthi, htlo; /* state for multicast */ | |
118 | } fec; | |
119 | ||
120 | struct { | |
121 | int idx; /* FCC1-3 = 0-2 */ | |
122 | void *fccp; /* hw registers */ | |
123 | void *ep; /* parameter ram */ | |
124 | void *fcccp; /* hw registers cont. */ | |
125 | void *mem; /* FCC DPRAM */ | |
126 | u32 gaddrh, gaddrl; /* group address */ | |
127 | } fcc; | |
128 | ||
129 | struct { | |
130 | int idx; /* FEC1 = 0, FEC2 = 1 */ | |
131 | void *sccp; /* hw registers */ | |
132 | void *ep; /* parameter ram */ | |
133 | u32 hthi, htlo; /* state for multicast */ | |
134 | } scc; | |
135 | ||
136 | }; | |
137 | }; | |
138 | ||
139 | /***************************************************************************/ | |
976de6a8 | 140 | #ifndef CONFIG_PPC_CPM_NEW_BINDING |
5b4b8454 | 141 | int fs_enet_mdio_bb_init(void); |
5b4b8454 | 142 | int fs_enet_mdio_fec_init(void); |
976de6a8 | 143 | #endif |
48257c4f PA |
144 | |
145 | void fs_init_bds(struct net_device *dev); | |
146 | void fs_cleanup_bds(struct net_device *dev); | |
147 | ||
148 | /***************************************************************************/ | |
149 | ||
150 | #define DRV_MODULE_NAME "fs_enet" | |
151 | #define PFX DRV_MODULE_NAME ": " | |
152 | #define DRV_MODULE_VERSION "1.0" | |
153 | #define DRV_MODULE_RELDATE "Aug 8, 2005" | |
154 | ||
155 | /***************************************************************************/ | |
156 | ||
157 | int fs_enet_platform_init(void); | |
158 | void fs_enet_platform_cleanup(void); | |
159 | ||
160 | /***************************************************************************/ | |
48257c4f PA |
161 | /* buffer descriptor access macros */ |
162 | ||
163 | /* access macros */ | |
164 | #if defined(CONFIG_CPM1) | |
165 | /* for a a CPM1 __raw_xxx's are sufficient */ | |
166 | #define __cbd_out32(addr, x) __raw_writel(x, addr) | |
167 | #define __cbd_out16(addr, x) __raw_writew(x, addr) | |
168 | #define __cbd_in32(addr) __raw_readl(addr) | |
169 | #define __cbd_in16(addr) __raw_readw(addr) | |
170 | #else | |
171 | /* for others play it safe */ | |
172 | #define __cbd_out32(addr, x) out_be32(addr, x) | |
173 | #define __cbd_out16(addr, x) out_be16(addr, x) | |
174 | #define __cbd_in32(addr) in_be32(addr) | |
175 | #define __cbd_in16(addr) in_be16(addr) | |
176 | #endif | |
177 | ||
178 | /* write */ | |
179 | #define CBDW_SC(_cbd, _sc) __cbd_out16(&(_cbd)->cbd_sc, (_sc)) | |
180 | #define CBDW_DATLEN(_cbd, _datlen) __cbd_out16(&(_cbd)->cbd_datlen, (_datlen)) | |
181 | #define CBDW_BUFADDR(_cbd, _bufaddr) __cbd_out32(&(_cbd)->cbd_bufaddr, (_bufaddr)) | |
182 | ||
183 | /* read */ | |
184 | #define CBDR_SC(_cbd) __cbd_in16(&(_cbd)->cbd_sc) | |
185 | #define CBDR_DATLEN(_cbd) __cbd_in16(&(_cbd)->cbd_datlen) | |
186 | #define CBDR_BUFADDR(_cbd) __cbd_in32(&(_cbd)->cbd_bufaddr) | |
187 | ||
188 | /* set bits */ | |
189 | #define CBDS_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) | (_sc)) | |
190 | ||
191 | /* clear bits */ | |
192 | #define CBDC_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) & ~(_sc)) | |
193 | ||
194 | /*******************************************************************/ | |
195 | ||
196 | extern const struct fs_ops fs_fec_ops; | |
197 | extern const struct fs_ops fs_fcc_ops; | |
198 | extern const struct fs_ops fs_scc_ops; | |
199 | ||
200 | /*******************************************************************/ | |
201 | ||
202 | /* handy pointer to the immap */ | |
203 | extern void *fs_enet_immap; | |
204 | ||
205 | /*******************************************************************/ | |
206 | ||
207 | #endif |