[ALSA] oxygen: more initialization
[zen-stable.git] / drivers / net / fs_enet / fs_enet.h
blobe05389c49bbb141e253bbeed681fe763aec7a2a8
1 #ifndef FS_ENET_H
2 #define FS_ENET_H
4 #include <linux/mii.h>
5 #include <linux/netdevice.h>
6 #include <linux/types.h>
7 #include <linux/list.h>
8 #include <linux/phy.h>
9 #include <linux/dma-mapping.h>
11 #include <linux/fs_enet_pd.h>
12 #include <asm/fs_pd.h>
14 #ifdef CONFIG_CPM1
15 #include <asm/cpm1.h>
17 struct fec_info {
18 fec_t __iomem *fecp;
19 u32 mii_speed;
21 #endif
23 #ifdef CONFIG_CPM2
24 #include <asm/cpm2.h>
25 #endif
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);
34 void (*adjust_link)(struct net_device *dev);
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);
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);
60 /* The FEC stores dest/src/type, data, and checksum for receive packets.
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
66 #define PKT_MAXBUF_SIZE (MAX_MTU+ETH_HLEN+CRC_LEN)
67 #define PKT_MINBUF_SIZE (MIN_MTU+ETH_HLEN+CRC_LEN)
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 */
72 #define ENET_RX_ALIGN 16
73 #define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE + ENET_RX_ALIGN - 1)
75 struct fs_enet_private {
76 struct napi_struct napi;
77 struct device *dev; /* pointer back to the device (must be initialized first) */
78 struct net_device *ndev;
79 spinlock_t lock; /* during all ops except TX pckt processing */
80 spinlock_t tx_lock; /* during fs_start_xmit and fs_tx */
81 struct fs_platform_info *fpi;
82 const struct fs_ops *ops;
83 int rx_ring, tx_ring;
84 dma_addr_t ring_mem_addr;
85 void __iomem *ring_base;
86 struct sk_buff **rx_skbuff;
87 struct sk_buff **tx_skbuff;
88 cbd_t __iomem *rx_bd_base; /* Address of Rx and Tx buffers. */
89 cbd_t __iomem *tx_bd_base;
90 cbd_t __iomem *dirty_tx; /* ring entries to be free()ed. */
91 cbd_t __iomem *cur_rx;
92 cbd_t __iomem *cur_tx;
93 int tx_free;
94 struct net_device_stats stats;
95 struct timer_list phy_timer_list;
96 const struct phy_info *phy;
97 u32 msg_enable;
98 struct mii_if_info mii_if;
99 unsigned int last_mii_status;
100 int interrupt;
102 struct phy_device *phydev;
103 int oldduplex, oldspeed, oldlink; /* current settings */
105 /* event masks */
106 u32 ev_napi_rx; /* mask of NAPI rx events */
107 u32 ev_rx; /* rx event mask */
108 u32 ev_tx; /* tx event mask */
109 u32 ev_err; /* error event mask */
111 u16 bd_rx_empty; /* mask of BD rx empty */
112 u16 bd_rx_err; /* mask of BD rx errors */
114 union {
115 struct {
116 int idx; /* FEC1 = 0, FEC2 = 1 */
117 void __iomem *fecp; /* hw registers */
118 u32 hthi, htlo; /* state for multicast */
119 } fec;
121 struct {
122 int idx; /* FCC1-3 = 0-2 */
123 void __iomem *fccp; /* hw registers */
124 void __iomem *ep; /* parameter ram */
125 void __iomem *fcccp; /* hw registers cont. */
126 void __iomem *mem; /* FCC DPRAM */
127 u32 gaddrh, gaddrl; /* group address */
128 } fcc;
130 struct {
131 int idx; /* FEC1 = 0, FEC2 = 1 */
132 void __iomem *sccp; /* hw registers */
133 void __iomem *ep; /* parameter ram */
134 u32 hthi, htlo; /* state for multicast */
135 } scc;
140 /***************************************************************************/
141 #ifndef CONFIG_PPC_CPM_NEW_BINDING
142 int fs_enet_mdio_bb_init(void);
143 int fs_enet_mdio_fec_init(void);
144 #endif
146 void fs_init_bds(struct net_device *dev);
147 void fs_cleanup_bds(struct net_device *dev);
149 /***************************************************************************/
151 #define DRV_MODULE_NAME "fs_enet"
152 #define PFX DRV_MODULE_NAME ": "
153 #define DRV_MODULE_VERSION "1.0"
154 #define DRV_MODULE_RELDATE "Aug 8, 2005"
156 /***************************************************************************/
158 int fs_enet_platform_init(void);
159 void fs_enet_platform_cleanup(void);
161 /***************************************************************************/
162 /* buffer descriptor access macros */
164 /* access macros */
165 #if defined(CONFIG_CPM1)
166 /* for a a CPM1 __raw_xxx's are sufficient */
167 #define __cbd_out32(addr, x) __raw_writel(x, addr)
168 #define __cbd_out16(addr, x) __raw_writew(x, addr)
169 #define __cbd_in32(addr) __raw_readl(addr)
170 #define __cbd_in16(addr) __raw_readw(addr)
171 #else
172 /* for others play it safe */
173 #define __cbd_out32(addr, x) out_be32(addr, x)
174 #define __cbd_out16(addr, x) out_be16(addr, x)
175 #define __cbd_in32(addr) in_be32(addr)
176 #define __cbd_in16(addr) in_be16(addr)
177 #endif
179 /* write */
180 #define CBDW_SC(_cbd, _sc) __cbd_out16(&(_cbd)->cbd_sc, (_sc))
181 #define CBDW_DATLEN(_cbd, _datlen) __cbd_out16(&(_cbd)->cbd_datlen, (_datlen))
182 #define CBDW_BUFADDR(_cbd, _bufaddr) __cbd_out32(&(_cbd)->cbd_bufaddr, (_bufaddr))
184 /* read */
185 #define CBDR_SC(_cbd) __cbd_in16(&(_cbd)->cbd_sc)
186 #define CBDR_DATLEN(_cbd) __cbd_in16(&(_cbd)->cbd_datlen)
187 #define CBDR_BUFADDR(_cbd) __cbd_in32(&(_cbd)->cbd_bufaddr)
189 /* set bits */
190 #define CBDS_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) | (_sc))
192 /* clear bits */
193 #define CBDC_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) & ~(_sc))
195 /*******************************************************************/
197 extern const struct fs_ops fs_fec_ops;
198 extern const struct fs_ops fs_fcc_ops;
199 extern const struct fs_ops fs_scc_ops;
201 /*******************************************************************/
203 /* handy pointer to the immap */
204 extern void __iomem *fs_enet_immap;
206 /*******************************************************************/
208 #endif