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/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>
46 #define RC32434_DEBUG 2
47 //#define RC32434_PROC_DEBUG
52 /* use 0 for production, 1 for verification, >2 for debug */
53 static int rc32434_debug
= RC32434_DEBUG
;
54 #define ASSERT(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)
60 #define ASSERT(expr) do {} while (0)
61 #define DBG(lvl, format, arg...) do {} while (0)
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)
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
73 #define ETH0_RX_DMA_ADDR (DMA0_PhysicalAddress + 0*DMA_CHAN_OFFSET)
74 #define ETH0_TX_DMA_ADDR (DMA0_PhysicalAddress + 1*DMA_CHAN_OFFSET)
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 */
81 #define RC32434_NUM_RDS 128 /* number of receive descriptors */
82 #define RC32434_NUM_TDS 128 /* number of transmit descriptors */
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))
91 #define RC32434_TX_TIMEOUT HZ * 100
93 #define rc32434_eth0_regs ((ETH_t)(ETH0_VirtualAddress))
94 #define rc32434_eth1_regs ((ETH_t)(ETH1_VirtualAddress))
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)
101 /* Information that need to be kept for each board. */
102 struct rc32434_local
{
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 */
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 */
112 #ifndef CONFIG_IDT_USE_NAPI
113 struct tasklet_struct
* rx_tasklet
;
115 struct tasklet_struct
* tx_tasklet
;
120 enum status rx_chain_status
;
125 enum status tx_chain_status
;
129 struct timer_list mii_phy_timer
;
130 unsigned long duplex_mode
;
137 struct net_device_stats stats
;
140 /* debug /proc entry */
141 struct proc_dir_entry
*ps
;
142 int dma_halt_cnt
; int dma_run_cnt
;
145 extern unsigned int idt_cpu_freq
;
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
);
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
);
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
);
167 static void rc32434_rx_tasklet(unsigned long rx_data_dev
);
169 static void rc32434_cleanup_module(void);
170 static int rc32434_probe(int port_num
);
171 int rc32434_init_module(void);
174 static inline void rc32434_abort_dma(struct net_device
*dev
, DMA_Chan_t ch
)
176 if (rc32434_readl(&ch
->dmac
) & DMAC_run_m
) {
177 rc32434_writel(0x10, &ch
->dmac
);
179 while (!(rc32434_readl(&ch
->dmas
) & DMAS_h_m
))
180 dev
->trans_start
= jiffies
;
182 rc32434_writel(0, &ch
->dmas
);
185 rc32434_writel(0, &ch
->dmadptr
);
186 rc32434_writel(0, &ch
->dmandptr
);
This page took 0.071914 seconds and 5 git commands to generate.