1.
static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_rtc,
&s3c_device_dm9000,
};
2 }, {
.virtual = (u32)S3C24XX_VA_ISA_BYTE,.pfn = __phys_to_pfn(S3C2410_CS2),
.length = 0x10000,
.type = MT_DEVICE,
}, {
.virtual = (u32)S3C24XX_VA_ISA_BYTE + 0x10000,
.pfn = __phys_to_pfn(S3C2410_CS2 + (1<<24)),
.length = SZ_4M,
.type = MT_DEVICE,
} ,{
.virtual = (u32)S3C2410_ADDR(0x02100300),
.pfn = __phys_to_pfn(0x20000300),
.length = SZ_1M,
.type = MT_DEVICE,
}
};
2.1在内核注册DM9000
#include <linux/dm9000.h>
#define DM9000_BASE 0x20000300
static struct resource s3c_dm9000_resource[] = {
[0] = {
.start = DM9000_BASE,
.end = DM9000_BASE+ 0x3,
.flags = IORESOURCE_MEM
},
[1]={
.start = DM9000_BASE + 0x4,
.end = DM9000_BASE + 0x4 + 0x7c,
.flags = IORESOURCE_MEM ,
},
[2] = {
.start = IRQ_EINT7, //依个人情况而定
.end = IRQ_EINT7, //依个人情况而定
.flags = IORESOURCE_IRQ I RQESOURCE_IRQ_HIGHLEVEL
}
};
static struct dm9000_plat_data s3c_device_dm9000_platdata = {
.flags= DM9000_PLATF_16BITONLY,
};
struct platform_device s3c_device_dm9000 = {
.name= "dm9000",
.id= -1,
.num_resources= ARRAY_SIZE(s3c_dm9000_resource),
.resource= s3c_dm9000_resource|DM9000_PLATF_NO_EEPROM,
.dev= {
.platform_data = &s3c_device_dm9000_platdata,
}
};
EXPORT_SYMBOL(s3c_device_dm9000);
//end of DM9000
2.3
arch/arm/plat-s3c/include/plat/devs.h
extern struct platform_device *s3c24xx_uart_src[];
extern struct platform_device s3c_device_timer[];
extern struct platform_device s3c_device_dm9k;
2 linux2.6.29/arch/arm/plat-s3c24xx/devs.c
3
linux2.6.29/drivers/net/dm9000.c
(1)
#include
#include
#include
#if defined(CONFIG_ARCH_S3C2410)
#include
#endif
#include "dm9000.h"
/* Board/System/Debug information/definition ---------------- */
#define DM9000_PHY 0x40 /* PHY address 0x01 */
(2)
int iosize;
int i;
u32 id_val;
# if defined(CONFIG_ARCH_S3C2410)
unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON3;
# endif
/* Init network device */
ndev = alloc_etherdev(sizeof(struct board_info));
(3)
SET_NETDEV_DEV(ndev, &pdev->dev);
dev_dbg(&pdev->dev, "dm9000_probe() ");
#if defined(CONFIG_ARCH_S3C2410)
*((volatile unsigned int *)S3C2410_BWSCON) =
(oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW3_16 | S3C2410_BWSCON_WS3 | S3C2410_BWSCON_ST3;
*((volatile unsigned int *)S3C2410_BANKCON3) = 0x1f7c;
#endif
/*
主要是设置了总线宽度16,nWAIT,ST。(具体的可以参考s3c2440数据手册的BUS WIDTH & WAIT CONTROL REGISTER (BWSCON))。然后设置BANKCON3的时间参数,值为0×1f7c(pmc:normal Tacp:6clk Tcah:4clk Tcoh:1clk Tacc:14clk Tcos:4clk 具体可以参考s3c2440数据手册的BANK CONTROL REGISTER)
*/
/* setup board info structure */
db = netdev_priv(ndev);
memset(db, 0, sizeof(*db));
(4)
db->mii.mdio_read = dm9000_phy_read;
db->mii.mdio_write = dm9000_phy_write;
#if defined(CONFIG_ARCH_S3C2410)
printk("Now use the default MAC address: 08:90:90:90:90:90 ");
mac_src = "liuyinqiang";
ndev->dev_addr[0] = 0x08;
ndev->dev_addr[1] = 0x90;
ndev->dev_addr[2] = 0x90;
ndev->dev_addr[3] = 0x90;
ndev->dev_addr[4] = 0x90;
ndev->dev_addr[5] = 0x90;
#else
/*给MAC地址赋值的,赋什么值都可以,只要不都是0就可以*/
mac_src = "eeprom";
/* try reading the node address from the attached EEPROM */
for (i = 0; i < 6; i += 2)
dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) {
mac_src = "platform da
memcpy(ndev->dev_addr, pdata->dev_addr, 6);
}
if (!is_valid_ether_addr(ndev->dev_addr)) {
/* try reading from mac */
mac_src = "chip";
for (i = 0; i < 6; i++)
ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
}
if (!is_valid_ether_addr(ndev->dev_addr))
dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
"set using ifconfig ", ndev->name);
#endif
platform_set_drvdata(pdev, ndev);
ret = register_netdev(ndev);
(5)
out:
#if defined(CONFIG_ARCH_S3C2410)
*(volatile unsigned int *)S3C2410_BWSCON = oldval_bwscon;
*(volatile unsigned int *)S3C2410_BANKCON3 = oldval_bankcon3;
#endif
dev_err(db->dev, "not found (%d). ", ret);
dm9000_release_board(pdev, db);
free_netdev(ndev);
4 linux/arch/arm/mach-s3c2440/mach-smdk2440.c
static struct platform_device *smdk2440_devices[] __initdata = {&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_dm9k,
&s3c_device_usbgadget,
};
5 增加平台设备前首先要先定义该平台设备,这主要修改arch/arm/plat-s3c24xx/common-smdk.c文件。
在common-smdk.c文件的头文件引入处添加如下代码:
#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
#include
#endif
修改完以上的内容之后,输入: # make menuconfig ,进入配置单,然后添加上对 DM9000 网卡的配置 :
Device Drivers --->
Network device support --->
Ethernet (10 or 100Mbit) --->
-*- Generic Media Independent Interface device support
<*> DM9000 support
(4) DM9000 maximum debug level
配置好后,保存配置单,然后编译出镜像,烧写到开发板中。