diff options
Diffstat (limited to 'drivers/net/fs_enet/fs_enet.h')
-rw-r--r-- | drivers/net/fs_enet/fs_enet.h | 245 |
1 files changed, 245 insertions, 0 deletions
diff --git a/drivers/net/fs_enet/fs_enet.h b/drivers/net/fs_enet/fs_enet.h new file mode 100644 index 000000000000..1105543b9d88 --- /dev/null +++ b/drivers/net/fs_enet/fs_enet.h | |||
@@ -0,0 +1,245 @@ | |||
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> | ||
7 | #include <linux/version.h> | ||
8 | #include <linux/list.h> | ||
9 | |||
10 | #include <linux/fs_enet_pd.h> | ||
11 | |||
12 | #include <asm/dma-mapping.h> | ||
13 | |||
14 | #ifdef CONFIG_CPM1 | ||
15 | #include <asm/commproc.h> | ||
16 | #endif | ||
17 | |||
18 | #ifdef CONFIG_CPM2 | ||
19 | #include <asm/cpm2.h> | ||
20 | #endif | ||
21 | |||
22 | /* hw driver ops */ | ||
23 | struct fs_ops { | ||
24 | int (*setup_data)(struct net_device *dev); | ||
25 | int (*allocate_bd)(struct net_device *dev); | ||
26 | void (*free_bd)(struct net_device *dev); | ||
27 | void (*cleanup_data)(struct net_device *dev); | ||
28 | void (*set_multicast_list)(struct net_device *dev); | ||
29 | void (*restart)(struct net_device *dev); | ||
30 | void (*stop)(struct net_device *dev); | ||
31 | void (*pre_request_irq)(struct net_device *dev, int irq); | ||
32 | void (*post_free_irq)(struct net_device *dev, int irq); | ||
33 | void (*napi_clear_rx_event)(struct net_device *dev); | ||
34 | void (*napi_enable_rx)(struct net_device *dev); | ||
35 | void (*napi_disable_rx)(struct net_device *dev); | ||
36 | void (*rx_bd_done)(struct net_device *dev); | ||
37 | void (*tx_kickstart)(struct net_device *dev); | ||
38 | u32 (*get_int_events)(struct net_device *dev); | ||
39 | void (*clear_int_events)(struct net_device *dev, u32 int_events); | ||
40 | void (*ev_error)(struct net_device *dev, u32 int_events); | ||
41 | int (*get_regs)(struct net_device *dev, void *p, int *sizep); | ||
42 | int (*get_regs_len)(struct net_device *dev); | ||
43 | void (*tx_restart)(struct net_device *dev); | ||
44 | }; | ||
45 | |||
46 | struct phy_info { | ||
47 | unsigned int id; | ||
48 | const char *name; | ||
49 | void (*startup) (struct net_device * dev); | ||
50 | void (*shutdown) (struct net_device * dev); | ||
51 | void (*ack_int) (struct net_device * dev); | ||
52 | }; | ||
53 | |||
54 | /* The FEC stores dest/src/type, data, and checksum for receive packets. | ||
55 | */ | ||
56 | #define MAX_MTU 1508 /* Allow fullsized pppoe packets over VLAN */ | ||
57 | #define MIN_MTU 46 /* this is data size */ | ||
58 | #define CRC_LEN 4 | ||
59 | |||
60 | #define PKT_MAXBUF_SIZE (MAX_MTU+ETH_HLEN+CRC_LEN) | ||
61 | #define PKT_MINBUF_SIZE (MIN_MTU+ETH_HLEN+CRC_LEN) | ||
62 | |||
63 | /* Must be a multiple of 32 (to cover both FEC & FCC) */ | ||
64 | #define PKT_MAXBLR_SIZE ((PKT_MAXBUF_SIZE + 31) & ~31) | ||
65 | /* This is needed so that invalidate_xxx wont invalidate too much */ | ||
66 | #define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE) | ||
67 | |||
68 | struct fs_enet_mii_bus { | ||
69 | struct list_head list; | ||
70 | spinlock_t mii_lock; | ||
71 | const struct fs_mii_bus_info *bus_info; | ||
72 | int refs; | ||
73 | u32 usage_map; | ||
74 | |||
75 | int (*mii_read)(struct fs_enet_mii_bus *bus, | ||
76 | int phy_id, int location); | ||
77 | |||
78 | void (*mii_write)(struct fs_enet_mii_bus *bus, | ||
79 | int phy_id, int location, int value); | ||
80 | |||
81 | union { | ||
82 | struct { | ||
83 | unsigned int mii_speed; | ||
84 | void *fecp; | ||
85 | } fec; | ||
86 | |||
87 | struct { | ||
88 | /* note that the actual port size may */ | ||
89 | /* be different; cpm(s) handle it OK */ | ||
90 | u8 mdio_msk; | ||
91 | u8 *mdio_dir; | ||
92 | u8 *mdio_dat; | ||
93 | u8 mdc_msk; | ||
94 | u8 *mdc_dir; | ||
95 | u8 *mdc_dat; | ||
96 | } bitbang; | ||
97 | |||
98 | struct { | ||
99 | u16 lpa; | ||
100 | } fixed; | ||
101 | }; | ||
102 | }; | ||
103 | |||
104 | int fs_mii_bitbang_init(struct fs_enet_mii_bus *bus); | ||
105 | int fs_mii_fixed_init(struct fs_enet_mii_bus *bus); | ||
106 | int fs_mii_fec_init(struct fs_enet_mii_bus *bus); | ||
107 | |||
108 | struct fs_enet_private { | ||
109 | struct device *dev; /* pointer back to the device (must be initialized first) */ | ||
110 | spinlock_t lock; /* during all ops except TX pckt processing */ | ||
111 | spinlock_t tx_lock; /* during fs_start_xmit and fs_tx */ | ||
112 | const struct fs_platform_info *fpi; | ||
113 | const struct fs_ops *ops; | ||
114 | int rx_ring, tx_ring; | ||
115 | dma_addr_t ring_mem_addr; | ||
116 | void *ring_base; | ||
117 | struct sk_buff **rx_skbuff; | ||
118 | struct sk_buff **tx_skbuff; | ||
119 | cbd_t *rx_bd_base; /* Address of Rx and Tx buffers. */ | ||
120 | cbd_t *tx_bd_base; | ||
121 | cbd_t *dirty_tx; /* ring entries to be free()ed. */ | ||
122 | cbd_t *cur_rx; | ||
123 | cbd_t *cur_tx; | ||
124 | int tx_free; | ||
125 | struct net_device_stats stats; | ||
126 | struct timer_list phy_timer_list; | ||
127 | const struct phy_info *phy; | ||
128 | u32 msg_enable; | ||
129 | struct mii_if_info mii_if; | ||
130 | unsigned int last_mii_status; | ||
131 | struct fs_enet_mii_bus *mii_bus; | ||
132 | int interrupt; | ||
133 | |||
134 | int duplex, speed; /* current settings */ | ||
135 | |||
136 | /* event masks */ | ||
137 | u32 ev_napi_rx; /* mask of NAPI rx events */ | ||
138 | u32 ev_rx; /* rx event mask */ | ||
139 | u32 ev_tx; /* tx event mask */ | ||
140 | u32 ev_err; /* error event mask */ | ||
141 | |||
142 | u16 bd_rx_empty; /* mask of BD rx empty */ | ||
143 | u16 bd_rx_err; /* mask of BD rx errors */ | ||
144 | |||
145 | union { | ||
146 | struct { | ||
147 | int idx; /* FEC1 = 0, FEC2 = 1 */ | ||
148 | void *fecp; /* hw registers */ | ||
149 | u32 hthi, htlo; /* state for multicast */ | ||
150 | } fec; | ||
151 | |||
152 | struct { | ||
153 | int idx; /* FCC1-3 = 0-2 */ | ||
154 | void *fccp; /* hw registers */ | ||
155 | void *ep; /* parameter ram */ | ||
156 | void *fcccp; /* hw registers cont. */ | ||
157 | void *mem; /* FCC DPRAM */ | ||
158 | u32 gaddrh, gaddrl; /* group address */ | ||
159 | } fcc; | ||
160 | |||
161 | struct { | ||
162 | int idx; /* FEC1 = 0, FEC2 = 1 */ | ||
163 | void *sccp; /* hw registers */ | ||
164 | void *ep; /* parameter ram */ | ||
165 | u32 hthi, htlo; /* state for multicast */ | ||
166 | } scc; | ||
167 | |||
168 | }; | ||
169 | }; | ||
170 | |||
171 | /***************************************************************************/ | ||
172 | |||
173 | int fs_mii_read(struct net_device *dev, int phy_id, int location); | ||
174 | void fs_mii_write(struct net_device *dev, int phy_id, int location, int value); | ||
175 | |||
176 | void fs_mii_startup(struct net_device *dev); | ||
177 | void fs_mii_shutdown(struct net_device *dev); | ||
178 | void fs_mii_ack_int(struct net_device *dev); | ||
179 | |||
180 | void fs_mii_link_status_change_check(struct net_device *dev, int init_media); | ||
181 | |||
182 | void fs_init_bds(struct net_device *dev); | ||
183 | void fs_cleanup_bds(struct net_device *dev); | ||
184 | |||
185 | /***************************************************************************/ | ||
186 | |||
187 | #define DRV_MODULE_NAME "fs_enet" | ||
188 | #define PFX DRV_MODULE_NAME ": " | ||
189 | #define DRV_MODULE_VERSION "1.0" | ||
190 | #define DRV_MODULE_RELDATE "Aug 8, 2005" | ||
191 | |||
192 | /***************************************************************************/ | ||
193 | |||
194 | int fs_enet_platform_init(void); | ||
195 | void fs_enet_platform_cleanup(void); | ||
196 | |||
197 | /***************************************************************************/ | ||
198 | |||
199 | /* buffer descriptor access macros */ | ||
200 | |||
201 | /* access macros */ | ||
202 | #if defined(CONFIG_CPM1) | ||
203 | /* for a a CPM1 __raw_xxx's are sufficient */ | ||
204 | #define __cbd_out32(addr, x) __raw_writel(x, addr) | ||
205 | #define __cbd_out16(addr, x) __raw_writew(x, addr) | ||
206 | #define __cbd_in32(addr) __raw_readl(addr) | ||
207 | #define __cbd_in16(addr) __raw_readw(addr) | ||
208 | #else | ||
209 | /* for others play it safe */ | ||
210 | #define __cbd_out32(addr, x) out_be32(addr, x) | ||
211 | #define __cbd_out16(addr, x) out_be16(addr, x) | ||
212 | #define __cbd_in32(addr) in_be32(addr) | ||
213 | #define __cbd_in16(addr) in_be16(addr) | ||
214 | #endif | ||
215 | |||
216 | /* write */ | ||
217 | #define CBDW_SC(_cbd, _sc) __cbd_out16(&(_cbd)->cbd_sc, (_sc)) | ||
218 | #define CBDW_DATLEN(_cbd, _datlen) __cbd_out16(&(_cbd)->cbd_datlen, (_datlen)) | ||
219 | #define CBDW_BUFADDR(_cbd, _bufaddr) __cbd_out32(&(_cbd)->cbd_bufaddr, (_bufaddr)) | ||
220 | |||
221 | /* read */ | ||
222 | #define CBDR_SC(_cbd) __cbd_in16(&(_cbd)->cbd_sc) | ||
223 | #define CBDR_DATLEN(_cbd) __cbd_in16(&(_cbd)->cbd_datlen) | ||
224 | #define CBDR_BUFADDR(_cbd) __cbd_in32(&(_cbd)->cbd_bufaddr) | ||
225 | |||
226 | /* set bits */ | ||
227 | #define CBDS_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) | (_sc)) | ||
228 | |||
229 | /* clear bits */ | ||
230 | #define CBDC_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) & ~(_sc)) | ||
231 | |||
232 | /*******************************************************************/ | ||
233 | |||
234 | extern const struct fs_ops fs_fec_ops; | ||
235 | extern const struct fs_ops fs_fcc_ops; | ||
236 | extern const struct fs_ops fs_scc_ops; | ||
237 | |||
238 | /*******************************************************************/ | ||
239 | |||
240 | /* handy pointer to the immap */ | ||
241 | extern void *fs_enet_immap; | ||
242 | |||
243 | /*******************************************************************/ | ||
244 | |||
245 | #endif | ||