more cleanup
[openwrt/openwrt.git] / target / linux / atheros-2.6 / files / drivers / net / ar2313 / ar2313.h
1 #ifndef _AR2313_H_
2 #define _AR2313_H_
3
4 #include <linux/autoconf.h>
5 #include <asm/bootinfo.h>
6 #include <ar531x_platform.h>
7
8 /*
9 * probe link timer - 5 secs
10 */
11 #define LINK_TIMER (5*HZ)
12
13 #define IS_DMA_TX_INT(X) (((X) & (DMA_STATUS_TI)) != 0)
14 #define IS_DMA_RX_INT(X) (((X) & (DMA_STATUS_RI)) != 0)
15 #define IS_DRIVER_OWNED(X) (((X) & (DMA_TX_OWN)) == 0)
16
17 #define AR2313_TX_TIMEOUT (HZ/4)
18
19 /*
20 * Rings
21 */
22 #define DSC_RING_ENTRIES_SIZE (AR2313_DESCR_ENTRIES * sizeof(struct desc))
23 #define DSC_NEXT(idx) ((idx + 1) & (AR2313_DESCR_ENTRIES - 1))
24
25 static inline int tx_space (u32 csm, u32 prd)
26 {
27 return (csm - prd - 1) & (AR2313_DESCR_ENTRIES - 1);
28 }
29
30 #if MAX_SKB_FRAGS
31 #define TX_RESERVED (MAX_SKB_FRAGS+1) /* +1 for message header */
32 #define tx_ring_full(csm, prd) (tx_space(csm, prd) <= TX_RESERVED)
33 #else
34 #define tx_ring_full 0
35 #endif
36
37 #define AR2313_MBGET 2
38 #define AR2313_MBSET 3
39 #define AR2313_PCI_RECONFIG 4
40 #define AR2313_PCI_DUMP 5
41 #define AR2313_TEST_PANIC 6
42 #define AR2313_TEST_NULLPTR 7
43 #define AR2313_READ_DATA 8
44 #define AR2313_WRITE_DATA 9
45 #define AR2313_GET_VERSION 10
46 #define AR2313_TEST_HANG 11
47 #define AR2313_SYNC 12
48
49
50 //
51 // New Combo structure for Both Eth0 AND eth1
52 //
53 typedef struct {
54 volatile unsigned int mac_control; /* 0x00 */
55 volatile unsigned int mac_addr[2]; /* 0x04 - 0x08*/
56 volatile unsigned int mcast_table[2]; /* 0x0c - 0x10 */
57 volatile unsigned int mii_addr; /* 0x14 */
58 volatile unsigned int mii_data; /* 0x18 */
59 volatile unsigned int flow_control; /* 0x1c */
60 volatile unsigned int vlan_tag; /* 0x20 */
61 volatile unsigned int pad[7]; /* 0x24 - 0x3c */
62 volatile unsigned int ucast_table[8]; /* 0x40-0x5c */
63
64 } ETHERNET_STRUCT;
65
66 /********************************************************************
67 * Interrupt controller
68 ********************************************************************/
69
70 typedef struct {
71 volatile unsigned int wdog_control; /* 0x08 */
72 volatile unsigned int wdog_timer; /* 0x0c */
73 volatile unsigned int misc_status; /* 0x10 */
74 volatile unsigned int misc_mask; /* 0x14 */
75 volatile unsigned int global_status; /* 0x18 */
76 volatile unsigned int reserved; /* 0x1c */
77 volatile unsigned int reset_control; /* 0x20 */
78 } INTERRUPT;
79
80 /********************************************************************
81 * DMA controller
82 ********************************************************************/
83 typedef struct {
84 volatile unsigned int bus_mode; /* 0x00 (CSR0) */
85 volatile unsigned int xmt_poll; /* 0x04 (CSR1) */
86 volatile unsigned int rcv_poll; /* 0x08 (CSR2) */
87 volatile unsigned int rcv_base; /* 0x0c (CSR3) */
88 volatile unsigned int xmt_base; /* 0x10 (CSR4) */
89 volatile unsigned int status; /* 0x14 (CSR5) */
90 volatile unsigned int control; /* 0x18 (CSR6) */
91 volatile unsigned int intr_ena; /* 0x1c (CSR7) */
92 volatile unsigned int rcv_missed; /* 0x20 (CSR8) */
93 volatile unsigned int reserved[11]; /* 0x24-0x4c (CSR9-19) */
94 volatile unsigned int cur_tx_buf_addr; /* 0x50 (CSR20) */
95 volatile unsigned int cur_rx_buf_addr; /* 0x50 (CSR21) */
96 } DMA;
97
98 /*
99 * Struct private for the Sibyte.
100 *
101 * Elements are grouped so variables used by the tx handling goes
102 * together, and will go into the same cache lines etc. in order to
103 * avoid cache line contention between the rx and tx handling on SMP.
104 *
105 * Frequently accessed variables are put at the beginning of the
106 * struct to help the compiler generate better/shorter code.
107 */
108 struct ar2313_private
109 {
110 struct net_device *dev;
111 int version;
112 u32 mb[2];
113
114 volatile ETHERNET_STRUCT *phy_regs;
115 volatile ETHERNET_STRUCT *eth_regs;
116 volatile DMA *dma_regs;
117 volatile u32 *int_regs;
118 struct ar531x_eth *cfg;
119
120 spinlock_t lock; /* Serialise access to device */
121
122 /*
123 * RX and TX descriptors, must be adjacent
124 */
125 ar2313_descr_t *rx_ring;
126 ar2313_descr_t *tx_ring;
127
128
129 struct sk_buff **rx_skb;
130 struct sk_buff **tx_skb;
131
132 /*
133 * RX elements
134 */
135 u32 rx_skbprd;
136 u32 cur_rx;
137
138 /*
139 * TX elements
140 */
141 u32 tx_prd;
142 u32 tx_csm;
143
144 /*
145 * Misc elements
146 */
147 int board_idx;
148 char name[48];
149 struct net_device_stats stats;
150 struct {
151 u32 address;
152 u32 length;
153 char *mapping;
154 } desc;
155
156
157 struct timer_list link_timer;
158 unsigned short phy; /* merlot phy = 1, samsung phy = 0x1f */
159 unsigned short mac;
160 unsigned short link; /* 0 - link down, 1 - link up */
161 u16 phyData;
162
163 struct tasklet_struct rx_tasklet;
164 int unloading;
165 };
166
167
168 /*
169 * Prototypes
170 */
171 static int ar2313_init(struct net_device *dev);
172 #ifdef TX_TIMEOUT
173 static void ar2313_tx_timeout(struct net_device *dev);
174 #endif
175 #if 0
176 static void ar2313_multicast_list(struct net_device *dev);
177 #endif
178 static int ar2313_restart(struct net_device *dev);
179 #if DEBUG
180 static void ar2313_dump_regs(struct net_device *dev);
181 #endif
182 static void ar2313_load_rx_ring(struct net_device *dev, int bufs);
183 static irqreturn_t ar2313_interrupt(int irq, void *dev_id);
184 static int ar2313_open(struct net_device *dev);
185 static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev);
186 static int ar2313_close(struct net_device *dev);
187 static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
188 static void ar2313_init_cleanup(struct net_device *dev);
189 static int ar2313_setup_timer(struct net_device *dev);
190 static void ar2313_link_timer_fn(unsigned long data);
191 static void ar2313_check_link(struct net_device *dev);
192 static struct net_device_stats *ar2313_get_stats(struct net_device *dev);
193 #endif /* _AR2313_H_ */