linux2.6.30.4中dm9000网卡成功移植到TQ2440

修改步骤如下:(红色为添加得内容)

 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 data";

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
5 、配置并编译内核
修改完以上的内容之后,输入: # 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
配置好后,保存配置单,然后编译出镜像,烧写到开发板中。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值