1 /**************************************************************************
3 * BRIEF MODULE DESCRIPTION
4 * Definitions for IDT RC32434 on-chip ethernet controller.
6 * Copyright 2004 IDT Inc. (rischelp@idt.com)
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.
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.
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.
29 **************************************************************************
38 **************************************************************************
42 #include <asm/rc32434/rc32434.h>
43 #include <asm/rc32434/dma_v.h>
44 #include <asm/rc32434/eth_v.h>
46 #define CONFIG_IDT_USE_NAPI 1
47 #define RC32434_DEBUG 2
48 //#define RC32434_PROC_DEBUG
53 /* use 0 for production, 1 for verification, >2 for debug */
54 static int rc32434_debug
= RC32434_DEBUG
;
55 #define ASSERT(expr) \
57 printk( "Assertion failed! %s,%s,%s,line=%d\n", \
58 #expr,__FILE__,__FUNCTION__,__LINE__); }
59 #define DBG(lvl, format, arg...) if (rc32434_debug > lvl) printk(KERN_INFO "%s: " format, dev->name , ## arg)
61 #define ASSERT(expr) do {} while (0)
62 #define DBG(lvl, format, arg...) do {} while (0)
65 #define INFO(format, arg...) printk(KERN_INFO "%s: " format, dev->name , ## arg)
66 #define ERR(format, arg...) printk(KERN_ERR "%s: " format, dev->name , ## arg)
67 #define WARN(format, arg...) printk(KERN_WARNING "%s: " format, dev->name , ## arg)
69 /* the following must be powers of two */
70 #ifdef CONFIG_IDT_USE_NAPI
71 #define RC32434_NUM_RDS 64 /* number of receive descriptors */
72 #define RC32434_NUM_TDS 64 /* number of transmit descriptors */
74 #define RC32434_NUM_RDS 128 /* number of receive descriptors */
75 #define RC32434_NUM_TDS 128 /* number of transmit descriptors */
78 #define RC32434_RBSIZE 1536 /* size of one resource buffer = Ether MTU */
79 #define RC32434_RDS_MASK (RC32434_NUM_RDS-1)
80 #define RC32434_TDS_MASK (RC32434_NUM_TDS-1)
81 #define RD_RING_SIZE (RC32434_NUM_RDS * sizeof(struct DMAD_s))
82 #define TD_RING_SIZE (RC32434_NUM_TDS * sizeof(struct DMAD_s))
84 #define RC32434_TX_TIMEOUT HZ * 100
86 #define rc32434_eth0_regs ((ETH_t)(ETH0_VirtualAddress))
87 #define rc32434_eth1_regs ((ETH_t)(ETH1_VirtualAddress))
89 enum status
{ filled
, empty
};
90 #define IS_DMA_FINISHED(X) (((X) & (DMAD_f_m)) != 0)
91 #define IS_DMA_DONE(X) (((X) & (DMAD_d_m)) != 0)
94 /* Information that need to be kept for each board. */
95 struct rc32434_local
{
97 DMA_Chan_t rx_dma_regs
;
98 DMA_Chan_t tx_dma_regs
;
99 volatile DMAD_t td_ring
; /* transmit descriptor ring */
100 volatile DMAD_t rd_ring
; /* receive descriptor ring */
102 struct sk_buff
* tx_skb
[RC32434_NUM_TDS
]; /* skbuffs for pkt to trans */
103 struct sk_buff
* rx_skb
[RC32434_NUM_RDS
]; /* skbuffs for pkt to trans */
105 #ifndef CONFIG_IDT_USE_NAPI
106 struct tasklet_struct
* rx_tasklet
;
108 struct tasklet_struct
* tx_tasklet
;
113 enum status rx_chain_status
;
118 enum status tx_chain_status
;
122 struct timer_list mii_phy_timer
;
123 unsigned long duplex_mode
;
130 struct net_device_stats stats
;
133 /* debug /proc entry */
134 struct proc_dir_entry
*ps
;
135 int dma_halt_cnt
; int dma_run_cnt
;
138 extern unsigned int idt_cpu_freq
;
140 /* Index to functions, as function prototypes. */
141 static int rc32434_open(struct net_device
*dev
);
142 static int rc32434_send_packet(struct sk_buff
*skb
, struct net_device
*dev
);
143 static void rc32434_mii_handler(unsigned long data
);
144 static irqreturn_t
rc32434_und_interrupt(int irq
, void *dev_id
);
145 static irqreturn_t
rc32434_rx_dma_interrupt(int irq
, void *dev_id
);
146 static irqreturn_t
rc32434_tx_dma_interrupt(int irq
, void *dev_id
);
147 #ifdef RC32434_REVISION
148 static irqreturn_t
rc32434_ovr_interrupt(int irq
, void *dev_id
);
150 static int rc32434_close(struct net_device
*dev
);
151 static struct net_device_stats
*rc32434_get_stats(struct net_device
*dev
);
152 static void rc32434_multicast_list(struct net_device
*dev
);
153 static int rc32434_init(struct net_device
*dev
);
154 static void rc32434_tx_timeout(struct net_device
*dev
);
156 static void rc32434_tx_tasklet(unsigned long tx_data_dev
);
157 #ifdef CONFIG_IDT_USE_NAPI
158 static int rc32434_poll(struct net_device
*rx_data_dev
, int *budget
);
160 static void rc32434_rx_tasklet(unsigned long rx_data_dev
);
162 static void rc32434_cleanup_module(void);
165 static inline void rc32434_abort_dma(struct net_device
*dev
, DMA_Chan_t ch
)
167 if (__raw_readl(&ch
->dmac
) & DMAC_run_m
) {
168 __raw_writel(0x10, &ch
->dmac
);
170 while (!(__raw_readl(&ch
->dmas
) & DMAS_h_m
))
171 dev
->trans_start
= jiffies
;
173 __raw_writel(0, &ch
->dmas
);
176 __raw_writel(0, &ch
->dmadptr
);
177 __raw_writel(0, &ch
->dmandptr
);
This page took 0.051193 seconds and 5 git commands to generate.