remove unused empty files
[openwrt/openwrt.git] / target / linux / aruba-2.6 / files / drivers / net / rc32434_eth.h
1 /**************************************************************************
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Definitions for IDT RC32434 on-chip ethernet controller.
5 *
6 * Copyright 2004 IDT Inc. (rischelp@idt.com)
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 *
28 *
29 **************************************************************************
30 * May 2004 rkt, neb
31 *
32 * Initial Release
33 *
34 * Aug 2004
35 *
36 * Added NAPI
37 *
38 **************************************************************************
39 */
40
41
42 #include <asm/idt-boards/rc32434/rc32434.h>
43 #include <asm/idt-boards/rc32434/rc32434_dma_v.h>
44 #include <asm/idt-boards/rc32434/rc32434_eth_v.h>
45
46 #define RC32434_DEBUG 2
47 //#define RC32434_PROC_DEBUG
48 #undef RC32434_DEBUG
49
50 #ifdef RC32434_DEBUG
51
52 /* use 0 for production, 1 for verification, >2 for debug */
53 static int rc32434_debug = RC32434_DEBUG;
54 #define ASSERT(expr) \
55 if(!(expr)) { \
56 printk( "Assertion failed! %s,%s,%s,line=%d\n", \
57 #expr,__FILE__,__FUNCTION__,__LINE__); }
58 #define DBG(lvl, format, arg...) if (rc32434_debug > lvl) printk(KERN_INFO "%s: " format, dev->name , ## arg)
59 #else
60 #define ASSERT(expr) do {} while (0)
61 #define DBG(lvl, format, arg...) do {} while (0)
62 #endif
63
64 #define INFO(format, arg...) printk(KERN_INFO "%s: " format, dev->name , ## arg)
65 #define ERR(format, arg...) printk(KERN_ERR "%s: " format, dev->name , ## arg)
66 #define WARN(format, arg...) printk(KERN_WARNING "%s: " format, dev->name , ## arg)
67
68 #define ETH0_DMA_RX_IRQ GROUP1_IRQ_BASE + 0
69 #define ETH0_DMA_TX_IRQ GROUP1_IRQ_BASE + 1
70 #define ETH0_RX_OVR_IRQ GROUP3_IRQ_BASE + 9
71 #define ETH0_TX_UND_IRQ GROUP3_IRQ_BASE + 10
72
73 #define ETH0_RX_DMA_ADDR (DMA0_PhysicalAddress + 0*DMA_CHAN_OFFSET)
74 #define ETH0_TX_DMA_ADDR (DMA0_PhysicalAddress + 1*DMA_CHAN_OFFSET)
75
76 /* the following must be powers of two */
77 #ifdef CONFIG_IDT_USE_NAPI
78 #define RC32434_NUM_RDS 64 /* number of receive descriptors */
79 #define RC32434_NUM_TDS 64 /* number of transmit descriptors */
80 #else
81 #define RC32434_NUM_RDS 128 /* number of receive descriptors */
82 #define RC32434_NUM_TDS 128 /* number of transmit descriptors */
83 #endif
84
85 #define RC32434_RBSIZE 1536 /* size of one resource buffer = Ether MTU */
86 #define RC32434_RDS_MASK (RC32434_NUM_RDS-1)
87 #define RC32434_TDS_MASK (RC32434_NUM_TDS-1)
88 #define RD_RING_SIZE (RC32434_NUM_RDS * sizeof(struct DMAD_s))
89 #define TD_RING_SIZE (RC32434_NUM_TDS * sizeof(struct DMAD_s))
90
91 #define RC32434_TX_TIMEOUT HZ * 100
92
93 #define rc32434_eth0_regs ((ETH_t)(ETH0_VirtualAddress))
94 #define rc32434_eth1_regs ((ETH_t)(ETH1_VirtualAddress))
95
96 enum status { filled, empty};
97 #define IS_DMA_FINISHED(X) (((X) & (DMAD_f_m)) != 0)
98 #define IS_DMA_DONE(X) (((X) & (DMAD_d_m)) != 0)
99
100
101 /* Information that need to be kept for each board. */
102 struct rc32434_local {
103 ETH_t eth_regs;
104 DMA_Chan_t rx_dma_regs;
105 DMA_Chan_t tx_dma_regs;
106 volatile DMAD_t td_ring; /* transmit descriptor ring */
107 volatile DMAD_t rd_ring; /* receive descriptor ring */
108
109 struct sk_buff* tx_skb[RC32434_NUM_TDS]; /* skbuffs for pkt to trans */
110 struct sk_buff* rx_skb[RC32434_NUM_RDS]; /* skbuffs for pkt to trans */
111
112 #ifndef CONFIG_IDT_USE_NAPI
113 struct tasklet_struct * rx_tasklet;
114 #endif
115 struct tasklet_struct * tx_tasklet;
116
117 int rx_next_done;
118 int rx_chain_head;
119 int rx_chain_tail;
120 enum status rx_chain_status;
121
122 int tx_next_done;
123 int tx_chain_head;
124 int tx_chain_tail;
125 enum status tx_chain_status;
126 int tx_count;
127 int tx_full;
128
129 struct timer_list mii_phy_timer;
130 unsigned long duplex_mode;
131
132 int rx_irq;
133 int tx_irq;
134 int ovr_irq;
135 int und_irq;
136
137 struct net_device_stats stats;
138 spinlock_t lock;
139
140 /* debug /proc entry */
141 struct proc_dir_entry *ps;
142 int dma_halt_cnt; int dma_run_cnt;
143 };
144
145 extern unsigned int idt_cpu_freq;
146
147 /* Index to functions, as function prototypes. */
148 static int rc32434_open(struct net_device *dev);
149 static int rc32434_send_packet(struct sk_buff *skb, struct net_device *dev);
150 static void rc32434_mii_handler(unsigned long data);
151 static irqreturn_t rc32434_und_interrupt(int irq, void *dev_id);
152 static irqreturn_t rc32434_rx_dma_interrupt(int irq, void *dev_id);
153 static irqreturn_t rc32434_tx_dma_interrupt(int irq, void *dev_id);
154 #ifdef RC32434_REVISION
155 static irqreturn_t rc32434_ovr_interrupt(int irq, void *dev_id);
156 #endif
157 static int rc32434_close(struct net_device *dev);
158 static struct net_device_stats *rc32434_get_stats(struct net_device *dev);
159 static void rc32434_multicast_list(struct net_device *dev);
160 static int rc32434_init(struct net_device *dev);
161 static void rc32434_tx_timeout(struct net_device *dev);
162
163 static void rc32434_tx_tasklet(unsigned long tx_data_dev);
164 #ifdef CONFIG_IDT_USE_NAPI
165 static int rc32434_poll(struct net_device *rx_data_dev, int *budget);
166 #else
167 static void rc32434_rx_tasklet(unsigned long rx_data_dev);
168 #endif
169 static void rc32434_cleanup_module(void);
170 static int rc32434_probe(int port_num);
171 int rc32434_init_module(void);
172
173
174 static inline void rc32434_abort_dma(struct net_device *dev, DMA_Chan_t ch)
175 {
176 if (rc32434_readl(&ch->dmac) & DMAC_run_m) {
177 rc32434_writel(0x10, &ch->dmac);
178
179 while (!(rc32434_readl(&ch->dmas) & DMAS_h_m))
180 dev->trans_start = jiffies;
181
182 rc32434_writel(0, &ch->dmas);
183 }
184
185 rc32434_writel(0, &ch->dmadptr);
186 rc32434_writel(0, &ch->dmandptr);
187 }