convert aruba to the new structure
[openwrt/openwrt.git] / target / linux / aruba-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 "platform.h"
7
8 extern unsigned long mips_machtype;
9
10 #undef ETHERNET_BASE
11 #define ETHERNET_BASE ar_eth_base
12 #define ETHERNET_SIZE 0x00100000
13 #define ETHERNET_MACS 2
14
15 #undef DMA_BASE
16 #define DMA_BASE ar_dma_base
17 #define DMA_SIZE 0x00100000
18
19
20 /*
21 * probe link timer - 5 secs
22 */
23 #define LINK_TIMER (5*HZ)
24
25 /*
26 * Interrupt register base address
27 */
28 #define INTERRUPT_BASE PHYS_TO_K1(ar_int_base)
29
30 /*
31 * Reset Register
32 */
33 #define AR531X_RESET (AR531X_RESETTMR + 0x0020)
34 #define RESET_SYSTEM 0x00000001 /* cold reset full system */
35 #define RESET_PROC 0x00000002 /* cold reset MIPS core */
36 #define RESET_WLAN0 0x00000004 /* cold reset WLAN MAC and BB */
37 #define RESET_EPHY0 0x00000008 /* cold reset ENET0 phy */
38 #define RESET_EPHY1 0x00000010 /* cold reset ENET1 phy */
39 #define RESET_ENET0 0x00000020 /* cold reset ENET0 mac */
40 #define RESET_ENET1 0x00000040 /* cold reset ENET1 mac */
41
42 #define IS_DMA_TX_INT(X) (((X) & (DMA_STATUS_TI)) != 0)
43 #define IS_DMA_RX_INT(X) (((X) & (DMA_STATUS_RI)) != 0)
44 #define IS_DRIVER_OWNED(X) (((X) & (DMA_TX_OWN)) == 0)
45
46 #ifndef K1_TO_PHYS
47 // hack
48 #define K1_TO_PHYS(x) (((unsigned int)(x)) & 0x1FFFFFFF) /* kseg1 to physical */
49 #endif
50
51 #ifndef PHYS_TO_K1
52 // hack
53 #define PHYS_TO_K1(x) (((unsigned int)(x)) | 0xA0000000) /* physical to kseg1 */
54 #endif
55
56 #define AR2313_TX_TIMEOUT (HZ/4)
57
58 /*
59 * Rings
60 */
61 #define DSC_RING_ENTRIES_SIZE (AR2313_DESCR_ENTRIES * sizeof(struct desc))
62 #define DSC_NEXT(idx) ((idx + 1) & (AR2313_DESCR_ENTRIES - 1))
63
64 static inline int tx_space (u32 csm, u32 prd)
65 {
66 return (csm - prd - 1) & (AR2313_DESCR_ENTRIES - 1);
67 }
68
69 #if MAX_SKB_FRAGS
70 #define TX_RESERVED (MAX_SKB_FRAGS+1) /* +1 for message header */
71 #define tx_ring_full(csm, prd) (tx_space(csm, prd) <= TX_RESERVED)
72 #else
73 #define tx_ring_full 0
74 #endif
75
76 #define AR2313_MBGET 2
77 #define AR2313_MBSET 3
78 #define AR2313_PCI_RECONFIG 4
79 #define AR2313_PCI_DUMP 5
80 #define AR2313_TEST_PANIC 6
81 #define AR2313_TEST_NULLPTR 7
82 #define AR2313_READ_DATA 8
83 #define AR2313_WRITE_DATA 9
84 #define AR2313_GET_VERSION 10
85 #define AR2313_TEST_HANG 11
86 #define AR2313_SYNC 12
87
88
89 struct ar2313_cmd {
90 u32 cmd;
91 u32 address; /* virtual address of image */
92 u32 length; /* size of image to download */
93 u32 mailbox; /* mailbox to get/set */
94 u32 data[2]; /* contents of mailbox to read/write */
95 };
96
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 int version;
111 u32 mb[2];
112
113 volatile ETHERNET_STRUCT *eth_regs;
114 volatile DMA *dma_regs;
115 volatile u32 *int_regs;
116
117 spinlock_t lock; /* Serialise access to device */
118
119 /*
120 * RX and TX descriptors, must be adjacent
121 */
122 ar2313_descr_t *rx_ring;
123 ar2313_descr_t *tx_ring;
124
125
126 struct sk_buff **rx_skb;
127 struct sk_buff **tx_skb;
128
129 /*
130 * RX elements
131 */
132 u32 rx_skbprd;
133 u32 cur_rx;
134
135 /*
136 * TX elements
137 */
138 u32 tx_prd;
139 u32 tx_csm;
140
141 /*
142 * Misc elements
143 */
144 int board_idx;
145 char name[48];
146 struct net_device_stats stats;
147 struct {
148 u32 address;
149 u32 length;
150 char *mapping;
151 } desc;
152
153
154 struct timer_list link_timer;
155 unsigned short phy; /* merlot phy = 1, samsung phy = 0x1f */
156 unsigned short mac;
157 unsigned short link; /* 0 - link down, 1 - link up */
158 u16 phyData;
159
160 struct tasklet_struct rx_tasklet;
161 int unloading;
162 };
163
164
165 /*
166 * Prototypes
167 */
168 static int ar2313_init(struct net_device *dev);
169 #ifdef TX_TIMEOUT
170 static void ar2313_tx_timeout(struct net_device *dev);
171 #endif
172 #if 0
173 static void ar2313_multicast_list(struct net_device *dev);
174 #endif
175 static int ar2313_restart(struct net_device *dev);
176 #if DEBUG
177 static void ar2313_dump_regs(struct net_device *dev);
178 #endif
179 static void ar2313_load_rx_ring(struct net_device *dev, int bufs);
180 static irqreturn_t ar2313_interrupt(int irq, void *dev_id);
181 static int ar2313_open(struct net_device *dev);
182 static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev);
183 static int ar2313_close(struct net_device *dev);
184 static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
185 static void ar2313_init_cleanup(struct net_device *dev);
186 static int ar2313_setup_timer(struct net_device *dev);
187 static void ar2313_link_timer_fn(unsigned long data);
188 static void ar2313_check_link(struct net_device *dev);
189 static struct net_device_stats *ar2313_get_stats(struct net_device *dev);
190 #endif /* _AR2313_H_ */