高级会员
- 积分
- 563
- 金钱
- 563
- 注册时间
- 2016-9-28
- 在线时间
- 158 小时
|
本帖最后由 mftang2016 于 2016-10-30 09:42 编辑
硬件: mini2440
编译环境: ubuntu-12.04
linux 内核: linux-2.6.32.2
编译器版本: gcc version 4.3.2
Step 1: 在mach-mini2440.c中添加 DM9000的头文件
#include <linux/dm9000.h>
Step 2: 在mach-mini2440.c中添加如下代码
/*
DM9000AEP 10/100 ethernet controller
*/
#define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)
static struct resource mini2440_dm9k_resource[] = {
[0] = {
.start = MACH_MINI2440_DM9K_BASE,
.end = MACH_MINI2440_DM9K_BASE + 3,
.flags = IORESOURCE_MEM
},
[1] = {
.start = MACH_MINI2440_DM9K_BASE + 4,
.end = MACH_MINI2440_DM9K_BASE + 7,
.flags = IORESOURCE_MEM
},
[2] = {
.start = IRQ_EINT7,
.end = IRQ_EINT7,
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
}
};
/*
* * The DM9000 has no eeprom, and it's MAC address is set by
* * the bootloader before starting the kernel.
* */
static struct dm9000_plat_data mini2440_dm9k_pdata = {
.flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};
static struct platform_device mini2440_device_eth = {
.name = "dm9000",
.id = -1,
.num_resources = ARRAY_SIZE(mini2440_dm9k_resource),
.resource = mini2440_dm9k_resource,
.dev = {
.platform_data = &mini2440_dm9k_pdata,
},
};
Step 3: 修改 dm9000.C 文件中相关配置,使其支持mini2440的硬件。
1. 添加如下代码:
#if defined(CONFIG_ARCH_S3C2410)
#include <mach/regs-mem.h>
#endif
2. 加入DM9000初始化代码
#if defined(CONFIG_ARCH_S3C2410)
unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4;
*((volatile unsigned int *)S3C2410_BWSCON) =
(oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 | S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;
*((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c;
#endif
Step 4: 执行如下命令,添加DM9000驱动到内核
mftang2016@ubuntu:~/mini2440/linux-2.6.32.2$ make menuconfig
Step 5: 编译内核,将生成的zImage 文件下载到开发板中,出现如下信息,表示移植成功:
|
|