s5pv210 uboot-2012-10移植(五) 之支持LAN9220网卡

时间:2023-02-03 16:34:29

我的s5pv210开发板是100M的LAN9220网卡芯片,通过CS5的总线连接的,对应的地址空间是0xA8000000,16位的。

1.跟踪代码发现在smc9115_pre_init里配置总线,board/samsung/smdkv210/smdkc100.c +36

/*
* Miscellaneous platform dependent initialisations
*/
static void smc9115_pre_init(void)
{
#define SROM_BW (*(volatile unsigned int *)0xE8000000)
#define SROM_BC5 (*(volatile unsigned int *)0xE8000018)
#define MP0_1CON (*(volatile unsigned int *)0xE02002E0)

#if 0
u32 smc_bw_conf, smc_bc_conf;

struct s5pc100_gpio *const gpio =
(struct s5pc100_gpio *)samsung_get_base_gpio();

/* gpio configuration GPK0CON */
s5p_gpio_cfg_pin(&gpio->k0, CONFIG_ENV_SROM_BANK, GPIO_FUNC(2));

/* Ethernet needs bus width of 16 bits */
smc_bw_conf = SMC_DATA16_WIDTH(CONFIG_ENV_SROM_BANK);
smc_bc_conf = SMC_BC_TACS(0x0) | SMC_BC_TCOS(0x4) | SMC_BC_TACC(0xe)
| SMC_BC_TCOH(0x1) | SMC_BC_TAH(0x4)
| SMC_BC_TACP(0x6) | SMC_BC_PMC(0x0);

/* Select and configure the SROMC bank */
s5p_config_sromc(CONFIG_ENV_SROM_BANK, smc_bw_conf, smc_bc_conf);
#endif

unsigned int tmp;

SROM_BW &= ~((0xf<<20));
SROM_BW |= ((3<<20));

tmp = MP0_1CON;
tmp &= ~((0xf<<20)|(0xf<<12));
tmp |= ((0x2<<20)|(0x2<<12));
MP0_1CON = tmp;
}
2.跟踪代码,在board_eth_init函数里,初始化LAN9220网卡,需要传入CONFIG_SMC911X_BASE基地址

int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC911X
rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
//printf ("rc: %d\n", rc);
#endif
return rc;
}
修改include/configs/smdkv210.h +241

/*
* Ethernet Contoller driver
*/
#ifdef CONFIG_CMD_NET
#define CONFIG_SMC911X 1 /* we have a SMC9115 on-board */
#define CONFIG_SMC911X_16_BIT 1 /* SMC911X_16_BIT Mode */
#define CONFIG_SMC911X_BASE 0xA8000000 /* SMC911X Drive Base */
#define CONFIG_ENV_SROM_BANK 3 /* Select SROM Bank-3 for Ethernet*/
#endif /* CONFIG_CMD_NET */

3.make,把BL1和UBOOT烧写到SD卡里,启动,可以识别网卡芯片,使用ping 192.168.0.1会发现不支持ping命令

s5pv210 uboot-2012-10移植(五) 之支持LAN9220网卡

4.搜索代码,发现需要配置CONFIG_CMD_PING,include/configs/smdkv210.h +246

#ifdef CONFIG_CMD_NET
#define CONFIG_SMC911X 1 /* we have a SMC9115 on-board */
#define CONFIG_SMC911X_16_BIT 1 /* SMC911X_16_BIT Mode */
#define CONFIG_SMC911X_BASE 0xA8000000 /* SMC911X Drive Base */
#define CONFIG_ENV_SROM_BANK 3 /* Select SROM Bank-3 for Ethernet*/
#define CONFIG_CMD_PING
#endif /* CONFIG_CMD_NET */

5.make,把BL1和UBOOT烧写到SD卡里,启动,可以识别网卡芯片,使用ping 192.168.0.1会发先错误,没有设置网卡物理地址和板子的ip地址

s5pv210 uboot-2012-10移植(五) 之支持LAN9220网卡

6.设置环境变量,ping

s5pv210 uboot-2012-10移植(五) 之支持LAN9220网卡

7.每次重启后都需要重新配置,很麻烦的, include/configs/smdkv210.h +248

#define CONFIG_NETMASK		255.255.255.0
#define CONFIG_IPADDR 192.168.0.89
#define CONFIG_SERVERIP 192.168.0.88
#define CONFIG_ETHADDR 00:40:5c:26:0a:5b
#define CONFIG_GATEWAYIP 192.168.0.1

8.make,烧写到SD卡中,上电,ping可以从控制台里看到,在通过tftp命令从服务器端下载uImage,或者可以printenv看看有没有在环境变量里设定。

s5pv210 uboot-2012-10移植(五) 之支持LAN9220网卡