5 #include <linux/netdevice.h>
6 #include <linux/types.h>
7 #include <linux/list.h>
9 #include <linux/fs_enet_pd.h>
11 #include <asm/dma-mapping.h>
14 #include <asm/commproc.h>
23 int (*setup_data
)(struct net_device
*dev
);
24 int (*allocate_bd
)(struct net_device
*dev
);
25 void (*free_bd
)(struct net_device
*dev
);
26 void (*cleanup_data
)(struct net_device
*dev
);
27 void (*set_multicast_list
)(struct net_device
*dev
);
28 void (*restart
)(struct net_device
*dev
);
29 void (*stop
)(struct net_device
*dev
);
30 void (*pre_request_irq
)(struct net_device
*dev
, int irq
);
31 void (*post_free_irq
)(struct net_device
*dev
, int irq
);
32 void (*napi_clear_rx_event
)(struct net_device
*dev
);
33 void (*napi_enable_rx
)(struct net_device
*dev
);
34 void (*napi_disable_rx
)(struct net_device
*dev
);
35 void (*rx_bd_done
)(struct net_device
*dev
);
36 void (*tx_kickstart
)(struct net_device
*dev
);
37 u32 (*get_int_events
)(struct net_device
*dev
);
38 void (*clear_int_events
)(struct net_device
*dev
, u32 int_events
);
39 void (*ev_error
)(struct net_device
*dev
, u32 int_events
);
40 int (*get_regs
)(struct net_device
*dev
, void *p
, int *sizep
);
41 int (*get_regs_len
)(struct net_device
*dev
);
42 void (*tx_restart
)(struct net_device
*dev
);
48 void (*startup
) (struct net_device
* dev
);
49 void (*shutdown
) (struct net_device
* dev
);
50 void (*ack_int
) (struct net_device
* dev
);
53 /* The FEC stores dest/src/type, data, and checksum for receive packets.
55 #define MAX_MTU 1508 /* Allow fullsized pppoe packets over VLAN */
56 #define MIN_MTU 46 /* this is data size */
59 #define PKT_MAXBUF_SIZE (MAX_MTU+ETH_HLEN+CRC_LEN)
60 #define PKT_MINBUF_SIZE (MIN_MTU+ETH_HLEN+CRC_LEN)
62 /* Must be a multiple of 32 (to cover both FEC & FCC) */
63 #define PKT_MAXBLR_SIZE ((PKT_MAXBUF_SIZE + 31) & ~31)
64 /* This is needed so that invalidate_xxx wont invalidate too much */
65 #define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE)
67 struct fs_enet_mii_bus
{
68 struct list_head list
;
70 const struct fs_mii_bus_info
*bus_info
;
74 int (*mii_read
)(struct fs_enet_mii_bus
*bus
,
75 int phy_id
, int location
);
77 void (*mii_write
)(struct fs_enet_mii_bus
*bus
,
78 int phy_id
, int location
, int value
);
82 unsigned int mii_speed
;
87 /* note that the actual port size may */
88 /* be different; cpm(s) handle it OK */
103 int fs_mii_bitbang_init(struct fs_enet_mii_bus
*bus
);
104 int fs_mii_fixed_init(struct fs_enet_mii_bus
*bus
);
105 int fs_mii_fec_init(struct fs_enet_mii_bus
*bus
);
107 struct fs_enet_private
{
108 struct device
*dev
; /* pointer back to the device (must be initialized first) */
109 spinlock_t lock
; /* during all ops except TX pckt processing */
110 spinlock_t tx_lock
; /* during fs_start_xmit and fs_tx */
111 const struct fs_platform_info
*fpi
;
112 const struct fs_ops
*ops
;
113 int rx_ring
, tx_ring
;
114 dma_addr_t ring_mem_addr
;
116 struct sk_buff
**rx_skbuff
;
117 struct sk_buff
**tx_skbuff
;
118 cbd_t
*rx_bd_base
; /* Address of Rx and Tx buffers. */
120 cbd_t
*dirty_tx
; /* ring entries to be free()ed. */
124 struct net_device_stats stats
;
125 struct timer_list phy_timer_list
;
126 const struct phy_info
*phy
;
128 struct mii_if_info mii_if
;
129 unsigned int last_mii_status
;
130 struct fs_enet_mii_bus
*mii_bus
;
133 int duplex
, speed
; /* current settings */
136 u32 ev_napi_rx
; /* mask of NAPI rx events */
137 u32 ev_rx
; /* rx event mask */
138 u32 ev_tx
; /* tx event mask */
139 u32 ev_err
; /* error event mask */
141 u16 bd_rx_empty
; /* mask of BD rx empty */
142 u16 bd_rx_err
; /* mask of BD rx errors */
146 int idx
; /* FEC1 = 0, FEC2 = 1 */
147 void *fecp
; /* hw registers */
148 u32 hthi
, htlo
; /* state for multicast */
152 int idx
; /* FCC1-3 = 0-2 */
153 void *fccp
; /* hw registers */
154 void *ep
; /* parameter ram */
155 void *fcccp
; /* hw registers cont. */
156 void *mem
; /* FCC DPRAM */
157 u32 gaddrh
, gaddrl
; /* group address */
161 int idx
; /* FEC1 = 0, FEC2 = 1 */
162 void *sccp
; /* hw registers */
163 void *ep
; /* parameter ram */
164 u32 hthi
, htlo
; /* state for multicast */
170 /***************************************************************************/
172 int fs_mii_read(struct net_device
*dev
, int phy_id
, int location
);
173 void fs_mii_write(struct net_device
*dev
, int phy_id
, int location
, int value
);
175 void fs_mii_startup(struct net_device
*dev
);
176 void fs_mii_shutdown(struct net_device
*dev
);
177 void fs_mii_ack_int(struct net_device
*dev
);
179 void fs_mii_link_status_change_check(struct net_device
*dev
, int init_media
);
181 void fs_init_bds(struct net_device
*dev
);
182 void fs_cleanup_bds(struct net_device
*dev
);
184 /***************************************************************************/
186 #define DRV_MODULE_NAME "fs_enet"
187 #define PFX DRV_MODULE_NAME ": "
188 #define DRV_MODULE_VERSION "1.0"
189 #define DRV_MODULE_RELDATE "Aug 8, 2005"
191 /***************************************************************************/
193 int fs_enet_platform_init(void);
194 void fs_enet_platform_cleanup(void);
196 /***************************************************************************/
198 /* buffer descriptor access macros */
201 #if defined(CONFIG_CPM1)
202 /* for a a CPM1 __raw_xxx's are sufficient */
203 #define __cbd_out32(addr, x) __raw_writel(x, addr)
204 #define __cbd_out16(addr, x) __raw_writew(x, addr)
205 #define __cbd_in32(addr) __raw_readl(addr)
206 #define __cbd_in16(addr) __raw_readw(addr)
208 /* for others play it safe */
209 #define __cbd_out32(addr, x) out_be32(addr, x)
210 #define __cbd_out16(addr, x) out_be16(addr, x)
211 #define __cbd_in32(addr) in_be32(addr)
212 #define __cbd_in16(addr) in_be16(addr)
216 #define CBDW_SC(_cbd, _sc) __cbd_out16(&(_cbd)->cbd_sc, (_sc))
217 #define CBDW_DATLEN(_cbd, _datlen) __cbd_out16(&(_cbd)->cbd_datlen, (_datlen))
218 #define CBDW_BUFADDR(_cbd, _bufaddr) __cbd_out32(&(_cbd)->cbd_bufaddr, (_bufaddr))
221 #define CBDR_SC(_cbd) __cbd_in16(&(_cbd)->cbd_sc)
222 #define CBDR_DATLEN(_cbd) __cbd_in16(&(_cbd)->cbd_datlen)
223 #define CBDR_BUFADDR(_cbd) __cbd_in32(&(_cbd)->cbd_bufaddr)
226 #define CBDS_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) | (_sc))
229 #define CBDC_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) & ~(_sc))
231 /*******************************************************************/
233 extern const struct fs_ops fs_fec_ops
;
234 extern const struct fs_ops fs_fcc_ops
;
235 extern const struct fs_ops fs_scc_ops
;
237 /*******************************************************************/
239 /* handy pointer to the immap */
240 extern void *fs_enet_immap
;
242 /*******************************************************************/