lichao-runing@163.com
/*
CS8900a.h
*/
#define CONFIG_CERF_CS8900A 1
/*
* cs8900a.c: A Crystal Semiconductor (Now Cirrus Logic) CS8900A
driver for SMDK-s3c2410 (based on cs89x0.c)
*
* Author: Yong-iL Joh <tolkien@mizi.com>
* Date : $Date: 2002/10/16 09:08:07 $
*
* $Revision: 1.1.2.5 $
Wed Aug 14 2002 Yong-iL Joh <tolkien@mizi.com>
- initial, based on cs89x0.c
Wed Aug 16 2002 Yong-iL Joh <tolkien@mizi.com>
- working!
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/spinlock.h>
#include <linux/ioport.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/hardware.h>
lichao-runing@163.com
#define IRQ_LAN IRQ_CS8900
/*
宏IRQ_LAN 定.网卡的中..
宏IRQ_CS8900 在include/asm-arm/arch-arm/smdk.h 中定.
#define IRQ_CS8900 IRQ_EINT9
宏IRQ_EINT9 定.位于include/asm-arm/arch/irqs.h 中
#define IRQ_EINT9 (5 +NORMAL_IRQ_OFFSET)
#define NORMAL_IRQ_OFFSET 32
所以网卡的中...37。
*/
#include "cs89x0.h"
/*
* Set this to zero to remove all the debug statements via
* dead code elimination
*/
#undef DEBUGGING 4
#if DEBUGGING
#define DPRINTK(n, args...) \
if (n <= DEBUGGING) { \
printk(args); \
}
#else
#define DPRINTK(n, args...)
#endif
#if DEBUGGING
static char version[] __initdata =
"cs89x0.c: v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton
<andrewm@uow.edu.au>\n";
#endif
/* First, a few definitions that the brave might change.
A zero-terminated list of I/O addresses to be probed. Some special flags..
Addr & 1 = Read back the address port, look for signature and reset
the page window before probing
Addr & 3 = Reset the page window and probe
The CLPS eval board has the Cirrus chip at 0x80090300, in ARM IO space,
but it is possible that a Cirrus board could be plugged into the ISA
slots. */
static unsigned int netcard_portlist[] __initdata =
{ vCS8900_BASE + 0x300, 0};
/*
lichao-runing@163.com
__initdata .志符和.量.明放在一起,表示gcc ..器在..的.候需
要把...量放在.data.init section 中,而..section 在.核完成初始化
之后,.被.放掉。 netcard_portlist[]..存放网卡端口的.地址,由于网
卡.接如下所示:
lichao-runing@163.com
如.中..所示,表明网卡映射到S3C2410 微.理器的BANK3 .,查.
微.理器手.可知,..的物理起始地址.0x19000000,由于在Linux 中使用
..地址,所以必..其.....地址,在ARM-LINUX 中,0x19000000 ..
的.地址.0xd0000000。所以定.如下宏,分.表示CS8900 网卡存..物理起
始地址和..起始地址。
vCS8900_BASE 定.如下:
/* CS8900a, nGCS3 */
#define pCS8900_BASE 0x19000000
#define vCS8900_BASE 0xd0000000
查.CS8900A 手.可知,其端口寄存器偏移量.0x300,所以CS8900a 端口
起始地址被定..:vCS8900_BASE + 0x300
*/
/* The number of low I/O ports used by the ethercard. */
#define NETCARD_IO_EXTENT 0xfff
/* we allow the user to override various values normally set in the EEPROM */
#define FORCE_RJ45 0x0001 /* pick one of these three */
#define FORCE_AUI 0x0002
#define FORCE_BNC 0x0004
/*
定.网卡接口.型,如果使用RJ45 水晶..接,.使用第一.宏。
*/
#define FORCE_AUTO 0x0010 /* pick one of these three */
#define FORCE_HALF 0x0020
#define FORCE_FULL 0x0030
/*
定.网卡通.使用半.工通信、.是全.工通.,.是自...。
*/
/* Information that need to be kept for each board. */
struct net_local {
struct net_device_stats stats;
int chip_type; /* one of: CS8900, CS8920, CS8920M */
char chip_revision; /* revision letter of the chip ('A'...) */
int send_cmd; /* the proper send command:
TX_NOW, TX_AFTER_381, or TX_AFTER_ALL */
lichao-runing@163.com
int auto_neg_cnf; /* auto-negotiation word from EEPROM */
int adapter_cnf; /* adapter configuration from EEPROM */
int isa_config; /* ISA configuration from EEPROM */
int irq_map; /* IRQ map from EEPROM */
int rx_mode; /* what mode are we in?
0, RX_MULTCAST_ACCEPT, or RX_ALL_ACCEPT */
int curr_rx_cfg; /* a copy of PP_RxCFG */
int linectl; /* either 0 or LOW_RX_SQUELCH,
depending on configuration. */
int send_underrun; /* keep track of how many underruns
in a row we get */
int force; /* force various values; see FORCE* above. */
spinlock_t lock;
};
/* Index to functions, as function prototypes. */
extern int cs89x0_probe(struct net_device *dev);
static int cs89x0_probe1(struct net_device *dev, int ioaddr);
static int net_open(struct net_device *dev);
static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
static void net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
static void set_multicast_list(struct net_device *dev);
static void net_timeout(struct net_device *dev);
static void net_rx(struct net_device *dev);
static int net_close(struct net_device *dev);
static struct net_device_stats *net_get_stats(struct net_device *dev);
static void reset_chip(struct net_device *dev);
static int set_mac_address(struct net_device *dev, void *addr);
static void count_rx_errors(int status, struct net_local *lp);
/* Example routines you must write ;->. */
#define tx_done(dev) 1
/* Check for a network adaptor of this type, and return '0' iff one exists.
If dev->base_addr == 0, probe all likely locations.
If dev->base_addr == 1, always return failure.
If dev->base_addr == 2, allocate space for the device and return success
(detachable devices only).
Return 0 on success.
*/
int __init cs89x0_probe(struct net_device *dev) {
int i;
lichao-runing@163.com
SET_MODULE_OWNER(dev);
DPRINTK(1, "cs89x0:cs89x0_probe(0x%x)\n", base_addr);
BWSCON = (BWSCON & ~(BWSCON_ST3 | BWSCON_WS3 | BWSCON_DW3)) |
(BWSCON_ST3 | BWSCON_WS3 | BWSCON_DW(3, BWSCON_DW_16));
BANKCON3= BANKCON_Tacs0 | BANKCON_Tcos4 | BANKCON_Tacc14 |
BANKCON_Toch1 | BANKCON_Tcah4 | BANKCON_Tacp6 | BANKCON_PMC1;
/*
.置BANK3 存.体,使其和CS8900a 网卡的.性相一致。比如BWSCON_DW_16 .
置BANK3 位..16bit,.何...置呢?因.CS8900a 网卡就是工作在16bit 模式下,即
.据.度(由其..使用到的.据..度.定).16bit。
*/
set_external_irq(IRQ_CS8900, EXT_RISING_EDGE, GPIO_PULLUP_DIS);
/*
.置IRQ_CS8900 所占用中...性,上升沿触.,PULLUP .效。
*/
for (i = 0; netcard_portlist[i]; i++) {
if (cs89x0_probe1(dev, netcard_portlist[i]) == 0)
return 0;
/*
探.网卡,如果探.到网卡后,cs89x0_probe1 返回值.0,所以就退出for 循.。由此
可.,只能探.一.网卡。
*/
}
printk(KERN_WARNING "cs89x0: no cs8900 or cs8920 detected."
"Be sure to disable PnP with SETUP\n");
return -ENODEV;
/*
如果不能探.到网卡,就.打印..消息,并返回-ENODEV ...。
*/
}
//.取寄存器.容
inline int readreg(struct net_device *dev, int portno) {
outw(portno, dev->base_addr + ADD_PORT);
return inw(dev->base_addr + DATA_PORT);
/*
dev->base_addr 是..的基地址,ADD_PORT 是偏移地址,DATA_PORT 是.据。
#define ADD_PORT 0x000A
#define DATA_PORT 0x000C
由于在此..中,CS8900A 工作在I/O 模式下,查.CS8900A 手.可知,在I/O
模式下,如果想要.取端口..portno 的寄存器(此寄存器系CS8900A .部寄存器).容,
.按照下列步.(.CS8900A 手.的P77 中的4.10.10 .):
lichao-runing@163.com
.. 首先,.端口.(即.部寄存器..).入到偏移量.ADD_PORT 的寄存器
中,即.用outw 函..完成;
.. 然后,.部寄存器的.容.被映射到偏移量.DATA_PORT 的.据寄存器中,
通.inw 函..其.出。
*/
}
//把value 值.入到端口..portno 的寄存器中
inline void writereg(struct net_device *dev, int portno, int value) {
outw(portno, dev->base_addr + ADD_PORT);
outw(value, dev->base_addr + DATA_PORT);
/*
dev->base_addr 是..的基地址,ADD_PORT 是偏移地址,DATA_PORT 是.据。
#define ADD_PORT 0x000A
#define DATA_PORT 0x000C
由于在此..中,CS8900A 工作在I/O 模式下,查.CS8900A 手.可知,在I/O
模式下,如果
CS8900A网卡驱动程序分析
需积分: 10 198 浏览量
2010-05-23
20:54:44
上传
评论
收藏 11KB RAR 举报
76587309834890
- 粉丝: 40
- 资源: 230
最新资源
- 基于Matlab人脸肤色定理的教师人数统计+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab霍夫曼变换的表盘读数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab火灾烟雾检测源码带GUI界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的恶劣天气交通标志识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的霍夫曼变换的表盘示数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的车道线识别系统 +源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的教室人数统计系统带Gui界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的教室人数统计系统带Gui界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB 的霍夫曼变换答题卡识别源码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab+bp神经网络的神经网络汉字识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈