swconfig: treat struct switch_attr as constant
[openwrt.git] / target / linux / atheros / files-2.6.26 / 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 struct net_device *dev;
110 int version;
111 u32 mb[2];
112
113 volatile ETHERNET_STRUCT *phy_regs;
114 volatile ETHERNET_STRUCT *eth_regs;
115 volatile DMA *dma_regs;
116 volatile u32 *int_regs;
117 struct ar531x_eth *cfg;
118
119 spinlock_t lock; /* Serialise access to device */
120
121 /*
122 * RX and TX descriptors, must be adjacent
123 */
124 ar2313_descr_t *rx_ring;
125 ar2313_descr_t *tx_ring;
126
127
128 struct sk_buff **rx_skb;
129 struct sk_buff **tx_skb;
130
131 /*
132 * RX elements
133 */
134 u32 rx_skbprd;
135 u32 cur_rx;
136
137 /*
138 * TX elements
139 */
140 u32 tx_prd;
141 u32 tx_csm;
142
143 /*
144 * Misc elements
145 */
146 int board_idx;
147 char name[48];
148 struct {
149 u32 address;
150 u32 length;
151 char *mapping;
152 } desc;
153
154
155 struct timer_list link_timer;
156 unsigned short phy; /* merlot phy = 1, samsung phy = 0x1f */
157 unsigned short mac;
158 unsigned short link; /* 0 - link down, 1 - link up */
159 u16 phyData;
160
161 struct tasklet_struct rx_tasklet;
162 int unloading;
163
164 struct phy_device *phy_dev;
165 struct mii_bus mii_bus;
166 int oldduplex;
167 };
168
169
170 /*
171 * Prototypes
172 */
173 static int ar2313_init(struct net_device *dev);
174 #ifdef TX_TIMEOUT
175 static void ar2313_tx_timeout(struct net_device *dev);
176 #endif
177 #if 0
178 static void ar2313_multicast_list(struct net_device *dev);
179 #endif
180 static int ar2313_restart(struct net_device *dev);
181 #if DEBUG
182 static void ar2313_dump_regs(struct net_device *dev);
183 #endif
184 static void ar2313_load_rx_ring(struct net_device *dev, int bufs);
185 static irqreturn_t ar2313_interrupt(int irq, void *dev_id);
186 static int ar2313_open(struct net_device *dev);
187 static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev);
188 static int ar2313_close(struct net_device *dev);
189 static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr,
190 int cmd);
191 static void ar2313_init_cleanup(struct net_device *dev);
192 static int ar2313_setup_timer(struct net_device *dev);
193 static void ar2313_link_timer_fn(unsigned long data);
194 static void ar2313_check_link(struct net_device *dev);
195 #endif /* _AR2313_H_ */
This page took 0.06079 seconds and 5 git commands to generate.