55 12/20/2007 -Modify TX timeout routine(+)check TCR&0x01
56
57 */
58
59 /* 主要就是修改基地址,位宽,中断引脚等 */
60
61 //#define CHECKSUM
62 //#define TDBUG /* check TX FIFO pointer */
63 //#define RDBUG /* check RX FIFO pointer */
64 //#define DM8606
65
66 #define DRV_NAME 'dm9KS'
67 #define DRV_VERSION '2.09'
68 #define DRV_RELDATE '2007-11-22'
69
70 #ifdef MODVERSIONS
71 #include 72 #endif 73 74 //#include 75 #include 76 #include 77 #include 78 #include 79 #include 80 #include 81 #include 82 #include 83 #include 84 #include 85 #include 86 #include 87 #include 88 #include 89 90 #ifdef CONFIG_ARCH_MAINSTONE 91 #include 92 #include 93 #include 94 #endif 95 96 #include 97 #include 98 #include 99 #include 100 101 /* Board/System/Debug information/definition ---------------- */ 102 103 #define DM9KS_ID 0x90000A46 104 #define DM9010_ID 0x90100A46 105 /*-------register name-----------------------*/ 106 #define DM9KS_NCR 0x00 /* Network control Reg.*/ 107 #define DM9KS_NSR 0x01 /* Network Status Reg.*/ 108 #define DM9KS_TCR 0x02 /* TX control Reg.*/ 109 #define DM9KS_RXCR 0x05 /* RX control Reg.*/ 110 #define DM9KS_BPTR 0x08 111 #define DM9KS_FCTR 0x09 112 #define DM9KS_FCR 0x0a 113 #define DM9KS_EPCR 0x0b 114 #define DM9KS_EPAR 0x0c 115 #define DM9KS_EPDRL 0x0d 116 #define DM9KS_EPDRH 0x0e 117 #define DM9KS_GPR 0x1f /* General purpose register */ 118 #define DM9KS_CHIPR 0x2c 119 #define DM9KS_TCR2 0x2d 120 #define DM9KS_SMCR 0x2f /* Special Mode Control Reg.*/ 121 #define DM9KS_ETXCSR 0x30 /* Early Transmit control/status Reg.*/ 122 #define DM9KS_TCCR 0x31 /* Checksum cntrol Reg. */ 123 #define DM9KS_RCSR 0x32 /* Receive Checksum status Reg.*/ 124 #define DM9KS_BUSCR 0x38 125 #define DM9KS_MRCMDX 0xf0 126 #define DM9KS_MRCMD 0xf2 127 #define DM9KS_MDRAL 0xf4 128 #define DM9KS_MDRAH 0xf5 129 #define DM9KS_MWCMD 0xf8 130 #define DM9KS_MDWAL 0xfa 131 #define DM9KS_MDWAH 0xfb 132 #define DM9KS_TXPLL 0xfc 133 #define DM9KS_TXPLH 0xfd 134 #define DM9KS_ISR 0xfe 135 #define DM9KS_IMR 0xff 136 /*---------------------------------------------*/ 137 #define DM9KS_REG05 0x30 /* SKIP_CRC/SKIP_LONG */ 138 #define DM9KS_REGFF 0xA3 /* IMR */ 139 #define DM9KS_DISINTR 0x80 140 141 #define DM9KS_PHY 0x40 /* PHY address 0x01 */ 142 #define DM9KS_PKT_RDY 0x01 /* Packet ready to receive */ 143 144 /* Added for PXA of MAINSTONE */ 145 #ifdef CONFIG_ARCH_MAINSTONE 146 #include 147 #define DM9KS_MIN_IO (MST_ETH_PHYS + 0x300) 148 #define DM9KS_MAX_IO (MST_ETH_PHYS + 0x370) 149 #define DM9K_IRQ MAINSTONE_IRQ(3) 150 #else 151 #define DM9KS_MIN_IO 0x300 152 #define DM9KS_MAX_IO 0x370 153 #define DM9KS_IRQ 3 154 #endif 155 156 #define DM9KS_VID_L 0x28 157 #define DM9KS_VID_H 0x29 158 #define DM9KS_PID_L 0x2A 159 #define DM9KS_PID_H 0x2B 160 161 #define DM9KS_RX_INTR 0x01 162 #define DM9KS_TX_INTR 0x02 163 #define DM9KS_LINK_INTR 0x20 164 165 #define DM9KS_DWORD_MODE 1 166 #define DM9KS_BYTE_MODE 2 167 #define DM9KS_WORD_MODE 0 168 169 #define TRUE 1 170 #define FALSE 0 171 /* Number of continuous Rx packets */ 172 #define CONT_RX_PKT_CNT 0xFFFF 173 174 #define DMFE_TIMER_WUT jiffies+(HZ*5) /* timer wakeup time : 5 second */ 175 176 #ifdef DM9KS_DEBUG 177 #define DMFE_DBUG(dbug_now, msg, vaule) 178 if (dmfe_debug||dbug_now) printk(KERN_ERR 'dmfe: %s %xn', msg, vaule) 179 #else 180 #define DMFE_DBUG(dbug_now, msg, vaule) 181 if (dbug_now) printk(KERN_ERR 'dmfe: %s %xn', msg, vaule) 182 #endif 183 184 #ifndef CONFIG_ARCH_MAINSTONE 185 #pragma pack(push, 1) 186 #endif 187 188 typedef struct _RX_DESC 189 { 190 u8 rxbyte; 191 u8 status; 192 u16 length; 193 }RX_DESC; 194 195 typedef union{ 196 u8 buf[4]; 197 RX_DESC desc; 198 } rx_t; 199 #ifndef CONFIG_ARCH_MAINSTONE 200 #pragma pack(pop) 201 #endif 202 203 enum DM9KS_PHY_mode { 204 DM9KS_10MHD = 0, 205 DM9KS_100MHD = 1, 206 DM9KS_10MFD = 4, 207 DM9KS_100MFD = 5, 208 DM9KS_AUTO = 8, 209 }; 210 211 /* Structure/enum declaration ------------------------------- */ 212 typedef struct board_info { 213 u32 io_addr;/* Register I/O base address */ 214 u32 io_data;/* Data I/O address */ 215 u8 op_mode;/* PHY operation mode */ 216 u8 io_mode;/* 0:word, 2:byte */ 217 u8 Speed; /* current speed */ 218 u8 chip_revision; 219 int rx_csum;/* 0:disable, 1:enable */ 220 221 u32 reset_counter;/* counter: RESET */ 222 u32 reset_tx_timeout;/* RESET caused by TX Timeout */ 223 int tx_pkt_cnt; 224 int cont_rx_pkt_cnt;/* current number of continuos rx packets */ 225 struct net_device_stats stats; 226 227 struct timer_list timer; 228 unsigned char srom[128]; 229 spinlock_t lock; 230 struct mii_if_info mii; 231 } board_info_t; 232 /* Global variable declaration ----------------------------- */ 233 /*static int dmfe_debug = 0;*/ 234 static struct net_device * dmfe_dev = NULL; 235 static struct ethtool_ops dmfe_ethtool_ops; 236 /* For module input parameter */ 237 static int mode = DM9KS_AUTO; 238 static int media_mode = DM9KS_AUTO; 239 static int irq = DM9KS_IRQ; 240 static int iobase = DM9KS_MIN_IO; 241 242 #if 0 // use physical address; Not virtual address 243 #ifdef outb 244 #undef outb 245 #endif 246 #ifdef outw 247 #undef outw 248 #endif 249 #ifdef outl 250 #undef outl 251 #endif 252 #ifdef inb 253 #undef inb 254 #endif 255 #ifdef inw 256 #undef inw 257 #endif 258 #ifdef inl 259 #undef inl 260 #endif 261 void outb(u8 reg, u32 ioaddr) 262 { 263 (*(volatile u8 *)(ioaddr)) = reg; 264 } 265 void outw(u16 reg, u32 ioaddr) 266 {
上一篇:s3c2440的USB热插拔驱动问题
下一篇:S3C实现DMA驱动程序编写
推荐阅读最新更新时间:2024-11-13 17:20
设计资源 培训 开发板 精华推荐
- 1.09V DC转DC多输出医疗电源
- DC1067A-A,LTC2450IDC 演示板,16 位高性能,Delta Sigma 模数转换器
- AD8604ARUZ 高端运算放大器电流监视器的典型应用
- LT1021DCN8-7 精密 DAC 电压基准的典型应用
- 金朗STM32F103RCT6高教开核心板
- 基于LM317的调压模块
- Usb2.0拓展坞
- NCV887701BSTGEVB、NCV887701 汽车启停非同步升压控制器评估板
- 适用于STM32G474RE MCU的STM32 Nucleo-64开发板,支持Arduino和ST morpho连接
- LT6656BCS6-1.25、1.25V 2 端子电压基准电流源的典型应用