fl2440的U-boot-2010.09移植(三)DM9000网卡及开发板相关配置

时间:2022-10-30 17:11:40

一、在board/fl2440/fl2440.c 中对GPIO和PLL的配置进行修改
(1)修改GPIO和PLL的配置(36行附近)为:

#if FCLK_SPEED==0/* Fout = 203MHz, Fin = 12MHz for Audio */
#define M_MDIV0xC3
#define M_PDIV0x4
#define M_SDIV0x1
#elif FCLK_SPEED==1

#if defined(CONFIG_S3C2410) /* Fout = 202.8MHz */
#define M_MDIV0xA1
#define M_PDIV0x3
#define M_SDIV0x1
#endif

#if defined(CONFIG_S3C2440) /* Fout = 405MHZ */
#define M_MDIV 0x7f
#define M_PDIV 0x2
#define M_SDIV 0x1
#endif
#endif

#define USB_CLOCK 1

#if USB_CLOCK==0
#define U_M_MDIV0xA1
#define U_M_PDIV0x3
#define U_M_SDIV0x1
#elif USB_CLOCK==1

#if defined(CONFIG_S3C2410)
#define U_M_MDIV0x48
#define U_M_PDIV0x3
#define U_M_SDIV0x2
#endif

#if defined(CONFIG_S3C2440)/*见S3C2440数据手册P227*/
#define U_M_MDIV0x38
#define U_M_PDIV0x2
#define U_M_SDIV0x2
#endif
#endif

(2)修改board_init函数中的LED和蜂鸣器的GPIO寄存器配置:

#if defined(CONFIG_S3C2440)
gpio->GPBCON = 0x001dd7fc;//初始化相应的GPB 口为输出口,为显示LED作准备,之前忘了改导致灯不亮
#else
gpio->GPBCON = 0x00044555;
#endif

……
gpio->GPCCON =  0xAAAA56A9;
  gpio->GPCUP = 0xFFFFFFFF;
…… 





        gpio->GPDUP = 0xFFFFFFFF;

 (3)为引导linux 内核,修改开发板的类型代码

#if defined(CONFIG_S3C2410)
 /* arch number of SMDK2410-Board */
 gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
#endif
#if defined(CONFIG_S3C2440)
 /* arch number of fl2440-Board */
 gd->bd->bi_arch_number = MACH_TYPE_S3C2440;
#endif

(4)为使int board_init (void)设置完成后,为了测试Uboot第二阶段工作完成,我加入了LED灯亮起显示,在int board_init (void)的最后添加:

        icache_enable();
dcache_enable();
#if defined(CONFIG_FL2440)
gpio->GPBDAT = ((1<<5) | (1<<6) | (1<<8) | (1<<10));//使LED全部熄灭
        gpio->GPBDAT &= 0xffe; /*添加关闭蜂鸣器语句*/
        gpio->GPBDAT = ~(3<<5);
#endif
return 0;

二、添加DM9000网卡的支持

(5)在board/fl2440/fl2440.c 中board_eth_init函数添加对dm9000的支持

#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_CS8900
rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
#endif

#ifdef CONFIG_DRIVER_DM9000
rc = dm9000_initialize(bis);
#endif
return rc;
}
#endif


(6)然后修改include/configs/fl2440.h文件中关于网卡的宏定义,将原来的:

#define CONFIG_NET_MULTI
#define CONFIG_CS8900/* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE0x19000300
#define CONFIG_CS8900_BUS16/* the Linux driver does accesses as shorts */

修改为:

#define CONFIG_NET_MULTI                 1
#define CONFIG_DRIVER_DM9000             1
#define CONFIG_DM9000_USE_16BIT          1
#define CONFIG_DM9000_BASE               0x20000300
#define DM9000_IO                        CONFIG_DM9000_BASE
#define DM9000_DATA                      (CONFIG_DM9000_BASE + 4)
#define CONFIG_DM9000_NO_SROM            1 //防止dm9000去从srom中读取物理地址信息

并在98行附近添加

#define CONFIG_CMD_DHCP
#define CONFIG_CMD_PING /*****add by yanghao*****/
#define CONFIG_CMD_NET /*add by yanghao*/

并将104行附近

/*#define CONFIG_ETHADDR08:00:3e:26:0a:5b */
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR10.0.0.110
#define CONFIG_SERVERIP10.0.0.1

修改为:

#define CONFIG_ETHADDR08:00:3e:26:0a:5b 
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR192.168.1.4
#define CONFIG_SERVERIP192.168.1.1

这里是修改开发板的IP地址和主机地址,需要将主机地址修改成“192.168.1.1”

 (7)打开driver/net/dm9000x.c文件,修改函数dm9000_halt,防止uboot在ping通主机后又马上断开连接的问题

static void dm9000_halt(struct eth_device *netdev)
{
DM9000_DBG("%s\n", __func__);
#if 0 //为了防止dm9000建立连接后又马上断开的情况
/* 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 */
#endif
}