DM9000驱动的一处差异

快乐虾

http://blog.csdn.net/lights_joy/

[email protected]

本文适用于

ADSP-BF561

优视科技BV561EVB开发板

uclinux-2008r1.5-rc3 / 2010pre

Visual DSP++ 5.0(update 5)

欢迎转载,但请保留作者信息


日前,试了将最新的一版uclinux内核(2010pre)移植到vdsp下,习惯性地从2008r1.5-rc3里面把DM9000的资源定义复制出来:

static struct resource dm9000_bfin_resources[] = {

{

.start = 0x2C000000,

.end = 0x2C000000 + 0x7F,

.flags = IORESOURCE_MEM,

}, {

.start = IRQ_PF44,

.end = IRQ_PF44,

.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,

},

};

static struct platform_device dm9000_bfin_device = {

.name = "dm9000",

.id = -1,

.num_resources = ARRAY_SIZE(dm9000_bfin_resources),

.resource = dm9000_bfin_resources,

};

结果内核运行时提示:

insufficient resources

看一下dm9000的相关代码:

db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);

db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);

if (db->addr_res == NULL || db->data_res == NULL ||

db->irq_res == NULL) {

dev_err(db->dev, "insufficient resources\n");

ret = -ENOENT;

goto out;

}

这里需要三个资源定义,而给出的资源只有两个,难怪出错,但是在2008r1.5-rc3版本为什么却可以呢,看下老版本的资源处理:

if (pdev->num_resources < 2) {

ret = -ENODEV;

goto out;

} else if (pdev->num_resources == 2) {

base = pdev->resource[0].start;

if (!request_mem_region(base, 4, ndev->name)) {

ret = -EBUSY;

goto out;

}

ndev->base_addr = base;

ndev->irq = pdev->resource[1].start;

db->io_addr = (void __iomem *)base;

db->io_data = (void __iomem *)(base + 4);

/* ensure at least we have a default set of IO routines */

dm9000_set_io(db, 2);

} else {

db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);

db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);

………………

}

原来在08r1.5的驱动里面自动判断资源数量,并将第一个内存地址加4后做为io_data的地址!

所以在2010pre版本下的资源定义相应修改为:

static struct resource dm9000_bfin_resources[] = {

{

.start = 0x2C000000,

.end = 0x2C000000 + 0x3,

.flags = IORESOURCE_MEM,

}, {

.start = 0x2C000004,

.end = 0x2C000004 + 0x7F,

.flags = IORESOURCE_MEM,

}, {

.start = IRQ_PF44,

.end = IRQ_PF44,

.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,

},

};

搞定!

你可能感兴趣的:(.net,Blog)