对DM9000的支持
1. 在下面文件添加 board/samsung/my2410/my2410.c
添加:
#include <net.h>
#include <netdev.h>
#ifdef CONFIG_DRIVER_DM9000
int board_eth_init(bd_t *bis)
{
return dm9000_initialize(bis);
}
#endif
2. 修改配置文件, include/configs/my2410.h
在 Command line configuration 部分,添加
#define CONFIG_CMD_PING
去掉CS8900的部分
添加:
#define CONFIG_NET_MULTI 1
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x10000300
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE+4)
#define CONFIG_DM9000_NO_SROM 1
#undef CONFIG_DM9000_DEBUG
//#define CONFIG_DM9000_DEBUG
//#define CONFIG_DM9000_USE_32BIT
注意:
u-boot-2009.08 可以自动检测DM9000网卡的位数,我的检测为32位
并且网卡位于BANK2
在 board/my/my2410/lowlevel_init.S
设置 #define B2_BWSCON (DW32) 即可
不需要此处的 define CONFIG_DM9000_USE_32BIT
时序采用默认时序即可
修改IP等网络配置
#define CONFIG_BOOTDELAY 3
/*#define CONFIG_BOOTARGS "root=ramfs devfs=mount console=ttySA0,9600" */
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 211.87.227.35
#define CONFIG_SERVERIP 211.87.227.75
注意:CONFIG_SERVERIP 是你的主机的IP,此时你的主机作为服务器
CONFIG_IPADDR是开发板的IP
3. 修改drivers/net/dm9000x.c
修改函数:
phy_read
将 udelay(100); 替换为下面:
int i;
…… ……
//udelay(100); /* Wait read complete */
i=0;
while(DM9000_ior(DM9000_EPCR) & 0x01) /* Wait read complete */
{
udelay(100);
i++;
if (i == 1000) {
printf("DM9000 access error/n");
return 0;
}
}
修改函数
phy_write
将 udelay(500); 替换为下面:
int i;
…… ……
//udelay(500);
i=0;
while(DM9000_ior(DM9000_EPCR) & 0x01) /* Wait read complete */
{
udelay(100);
i++;
if (i == 1000) {
printf("DM9000 access error/n");
return 0;
}
}
修改开头部分调试信息
将语句 printf(func ": length: %d/n", length); /
替换为:
/*printf(func ": length: %d/n", length); *//
printf("%s : length: %d/n",func, length); /
注释掉下面函数的调试信息部分,有助于看清调试的信息
static u16
phy_read(int reg)
//DM9000_DBG("phy_read(0x%x): 0x%x/n", reg, val);
修改函数 dm9000_init
将语句
if (i == 10000) {
printf("could not establish link/n");
return 0;
}
替换为
/*if (i == 10000) {
printf("could not establish link/n");
return 0;
}*/
if (i == 1650) {
break;
}
注释掉dm9000_halt 的函数体
static void dm9000_halt(struct eth_device *netdev)
{
/*DM9000_DBG("%s/n", __func__);
//* RESET devie *//
phy_write(0, 0x8000); //* PHY RESET *//
DM9000_iow(DM9000_GPR, 0x01); //* Power-Down PHY *//
DM9000_iow(DM9000_IMR, 0x80); //* Disable all interrupt *//
DM9000_iow(DM9000_RCR, 0x00); //* Disable RX */
}
4. 修改文件/net/net.c
104行左右
# define ARP_TIMEOUT 5000UL /* Milliseconds before trying ARP again */
替换成
# define ARP_TIMEOUT (CONFIG_SYS_HZ/1000*5000UL)
575行左右
NetSetTimeout (10000UL, startAgainTimeout);
替换成
NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, startAgainTimeout);
586行左右
NetSetTimeout (10000UL, startAgainTimeout);
替换成
NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, startAgainTimeout);
757行左右
NetSetTimeout (10000UL, PingTimeout);
替换成
NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, PingTimeout);
781行左右
#define CDP_TIMEOUT 250UL /* one packet every 250ms */
替换成
#define CDP_TIMEOUT (250UL*CONFIG_SYS_HZ/1000)
5. 很多人建议对UPLL MPLL的设置变换顺序
在 board/samsung/my2410/my2410.c 的 board_init 函数
此时,DM9000已能正常运行,
只是需要先激活一下,也就是当第一次ping时,网络不通,以后就没有问题了……
如果谁能帮忙解决,不胜感激
觉得可以在系统初始化的时候初始化网络
/**************************************/
由于板子自身的原因,100M 不能很好的工作,强制换成 10 m 全双工 模式,
修改如下:
修改函数:
static int dm9000_init(struct eth_device *dev, bd_t *bd)
在如下语句后加入后面四句设置工作模式
/* Program operating register, only internal phy supported */
DM9000_iow(DM9000_NCR, 0x0);
/* 设置工作模式 */
// 10MHD 有些延迟
//u16 phy_reg4 = 0x21;
//u16 phy_reg0 = 0x0000;
// 10MFD 很快
u16 phy_reg4 = 0x41;
u16 phy_reg0 = 0x1100;
phy_write(4, phy_reg4); /* Set PHY media mode */
phy_write(0, phy_reg0); /* Tmp */