5 #include <linux/netdevice.h>
6 #include <linux/types.h>
7 #include <linux/version.h>
8 #include <linux/list.h>
10 #include <linux/fs_enet_pd.h>
12 #include <asm/dma-mapping.h>
15 #include <asm/commproc.h>
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);
49 void (*startup) (struct net_device * dev);
50 void (*shutdown) (struct net_device * dev);
51 void (*ack_int) (struct net_device * dev);
54 /* The FEC stores dest/src/type, data, and checksum for receive packets.
56 #define MAX_MTU 1508 /* Allow fullsized pppoe packets over VLAN */
57 #define MIN_MTU 46 /* this is data size */
60 #define PKT_MAXBUF_SIZE (MAX_MTU+ETH_HLEN+CRC_LEN)
61 #define PKT_MINBUF_SIZE (MIN_MTU+ETH_HLEN+CRC_LEN)
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)
68 struct fs_enet_mii_bus {
69 struct list_head list;
71 const struct fs_mii_bus_info *bus_info;
75 int (*mii_read)(struct fs_enet_mii_bus *bus,
76 int phy_id, int location);
78 void (*mii_write)(struct fs_enet_mii_bus *bus,
79 int phy_id, int location, int value);
83 unsigned int mii_speed;
88 /* note that the actual port size may */
89 /* be different; cpm(s) handle it OK */
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);
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;
117 struct sk_buff **rx_skbuff;
118 struct sk_buff **tx_skbuff;
119 cbd_t *rx_bd_base; /* Address of Rx and Tx buffers. */
121 cbd_t *dirty_tx; /* ring entries to be free()ed. */
125 struct net_device_stats stats;
126 struct timer_list phy_timer_list;
127 const struct phy_info *phy;
129 struct mii_if_info mii_if;
130 unsigned int last_mii_status;
131 struct fs_enet_mii_bus *mii_bus;
134 int duplex, speed; /* current settings */
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 */
142 u16 bd_rx_empty; /* mask of BD rx empty */
143 u16 bd_rx_err; /* mask of BD rx errors */
147 int idx; /* FEC1 = 0, FEC2 = 1 */
148 void *fecp; /* hw registers */
149 u32 hthi, htlo; /* state for multicast */
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 */
162 int idx; /* FEC1 = 0, FEC2 = 1 */
163 void *sccp; /* hw registers */
164 void *ep; /* parameter ram */
165 u32 hthi, htlo; /* state for multicast */
171 /***************************************************************************/
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);
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);
180 void fs_mii_link_status_change_check(struct net_device *dev, int init_media);
182 void fs_init_bds(struct net_device *dev);
183 void fs_cleanup_bds(struct net_device *dev);
185 /***************************************************************************/
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"
192 /***************************************************************************/
194 int fs_enet_platform_init(void);
195 void fs_enet_platform_cleanup(void);
197 /***************************************************************************/
199 /* buffer descriptor 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)
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)
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))
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)
227 #define CBDS_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) | (_sc))
230 #define CBDC_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) & ~(_sc))
232 /*******************************************************************/
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;
238 /*******************************************************************/
240 /* handy pointer to the immap */
241 extern void *fs_enet_immap;
243 /*******************************************************************/