4 #include <linux/autoconf.h>
5 #include <asm/bootinfo.h>
6 #include <ar531x_platform.h>
9 * probe link timer - 5 secs
11 #define LINK_TIMER (5*HZ)
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)
17 #define AR2313_TX_TIMEOUT (HZ/4)
22 #define DSC_RING_ENTRIES_SIZE (AR2313_DESCR_ENTRIES * sizeof(struct desc))
23 #define DSC_NEXT(idx) ((idx + 1) & (AR2313_DESCR_ENTRIES - 1))
25 static inline int tx_space(u32 csm
, u32 prd
)
27 return (csm
- prd
- 1) & (AR2313_DESCR_ENTRIES
- 1);
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)
34 #define tx_ring_full 0
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
51 // New Combo structure for Both Eth0 AND eth1
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 */
66 /********************************************************************
67 * Interrupt controller
68 ********************************************************************/
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 */
80 /********************************************************************
82 ********************************************************************/
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) */
99 * Struct private for the Sibyte.
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.
105 * Frequently accessed variables are put at the beginning of the
106 * struct to help the compiler generate better/shorter code.
108 struct ar2313_private
{
109 struct net_device
*dev
;
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
;
119 spinlock_t lock
; /* Serialise access to device */
122 * RX and TX descriptors, must be adjacent
124 ar2313_descr_t
*rx_ring
;
125 ar2313_descr_t
*tx_ring
;
128 struct sk_buff
**rx_skb
;
129 struct sk_buff
**tx_skb
;
148 struct net_device_stats stats
;
156 struct timer_list link_timer
;
157 unsigned short phy
; /* merlot phy = 1, samsung phy = 0x1f */
159 unsigned short link
; /* 0 - link down, 1 - link up */
162 struct tasklet_struct rx_tasklet
;
165 struct phy_device
*phy_dev
;
166 struct mii_bus mii_bus
;
173 static int ar2313_init(struct net_device
*dev
);
175 static void ar2313_tx_timeout(struct net_device
*dev
);
178 static void ar2313_multicast_list(struct net_device
*dev
);
180 static int ar2313_restart(struct net_device
*dev
);
182 static void ar2313_dump_regs(struct net_device
*dev
);
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
,
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 static struct net_device_stats
*ar2313_get_stats(struct net_device
*dev
);
196 #endif /* _AR2313_H_ */