TI中文支持网
TI专业的中文技术问题搜集分享网站

关于AM335x扩展DM9000的问题

各位好,我因工作需要,在AM335xx板上用nCS1扩展2路DM9000网卡,原理图如下,

但是驱动运行起来以后,提示dm9000 dm9000: not found (-19).,用gpmc_cs_request(GPMC_CS, SZ_16M, &mem_base)请求的地址为gpmc cs1 base : 0x01000000, size : 0x01000000, 7个寄存器的数值读出如下, 

[ 5.720581] dm9000 Ethernet Driver, V1.31
[ 5.724914] gpmc_cssp_init for ST16C554 device succeeded
[ 5.730499] gpmc cs1 base : 0x01000000, size : 0x01000000
[ 5.736145] gpmc cs1[1] reg: 0x28001000
[ 5.740173] gpmc cs1[2] reg: 0x00060901
[ 5.744171] gpmc cs1[3] reg: 0x22000010
[ 5.748199] gpmc cs1[4] reg: 0x06026813
[ 5.752197] gpmc cs1[5] reg: 0x0007090c
[ 5.756225] gpmc cs1[6] reg: 0x84000000
[ 5.760223] gpmc cs1[7] reg: 0x00000f41
[ 5.764282] dm9000 dm9000: db->io_addr: 0xe085a000
[ 5.769714] dm9000 dm9000: read wrong id 0x00000000
[ 5.774841] dm9000 dm9000: read wrong id 0x00000000
[ 5.779937] dm9000 dm9000: read wrong id 0x00000000
[ 5.785064] dm9000 dm9000: read wrong id 0x00000000
[ 5.790161] dm9000 dm9000: read wrong id 0x00000000
[ 5.795257] dm9000 dm9000: read wrong id 0x00000000
[ 5.800354] dm9000 dm9000: read wrong id 0x00000000
[ 5.805480] dm9000 dm9000: read wrong id 0x00000000
[ 5.810577] dm9000 dm9000: wrong id: 0x00000000
[ 5.815307] dm9000 dm9000: not found (-19).

nand flash使用nCS0,分配地址如下:

[ 0.211578] gpmc cs0 base : 0x08000000, size : 0x10000000
[ 0.211578] gpmc cs0[1] reg: 0x00000800
[ 0.211578] gpmc cs0[2] reg: 0x001e1e00
[ 0.211578] gpmc cs0[3] reg: 0x001e1e00
[ 0.211608] gpmc cs0[4] reg: 0x16051807
[ 0.211608] gpmc cs0[5] reg: 0x00151e1e
[ 0.211608] gpmc cs0[6] reg: 0x16000f80
[ 0.211608] gpmc cs0[7] reg: 0x00000048
[ 0.211639] Registering NAND on CS0

我的修改过程如下:

在Board-am335xevm.c文件中添加

#define DM9000C_BASE 0x01000000 //csn1

/* pinmux for gpio based key */
static struct pinmux_config dm9000c_pin_mux[] = {
{"gpmc_ad0.gpmc_ad0", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad1.gpmc_ad1", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad2.gpmc_ad2", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad3.gpmc_ad3", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad4.gpmc_ad4", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad5.gpmc_ad5", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad6.gpmc_ad6", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad7.gpmc_ad7", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad0.gpmc_ad8", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad1.gpmc_ad9", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad2.gpmc_ad10", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad3.gpmc_ad11", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad4.gpmc_ad12", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad5.gpmc_ad13", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad6.gpmc_ad14", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"gpmc_ad7.gpmc_ad15", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"mcasp0_aclkx.gpio3_14", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
{"gpmc_oen_ren.gpmc_oen_ren", OMAP_MUX_MODE0 | AM33XX_PULL_DISA},
{"gpmc_wen.gpmc_wen", OMAP_MUX_MODE0 | AM33XX_PULL_DISA},
{"gpmc_csn1.gpmc_csn1", OMAP_MUX_MODE0 | AM33XX_PULL_DISA},
{NULL, 0},
};

static struct resource dm9000c_resource[] = {
[0] = {
.start = DM9000C_BASE,
.end = DM9000C_BASE+ 0x3,
.flags = IORESOURCE_MEM
},
[1] = {
.start = DM9000C_BASE + (1<<21),
.end = DM9000C_BASE + (1<<21) + 0x03,
.flags = IORESOURCE_MEM
},
[2] = {
.start = GPIO_TO_PIN(3, 14), //中断号
.end = GPIO_TO_PIN(3, 14),
.flags = (IORESOURCE_IRQ | IRQF_TRIGGER_FALLING)
}
};

static struct dm9000_plat_data dm9000c_platdata = {
.flags = DM9000_PLATF_16BITONLY,
};

struct platform_device dm9000c_device = {
.name= "dm9000",
.id= -1,
.num_resources= ARRAY_SIZE(dm9000c_resource),
.resource= dm9000c_resource,
.dev= {
.platform_data = &dm9000c_platdata,
}
};

static void __init am335x_add_device_dm9000c(int evm_id, int profile)
{
setup_pin_mux(dm9000c_pin_mux);
platform_device_register(&dm9000c_device);
}

在dm9000.c文里添加函数

static struct gpmc_timings ext_uart_timings = {
/* Minimum clock period for synchronous mode (in picoseconds) */
.sync_clk = 0,
/* CS signal timings corresponding to GPMC_CONFIG2 */
.cs_on = 10, /* T6s */
.cs_rd_off = 85, /* oe_off + T7h */
.cs_wr_off = 60, /* Tcs for write: we_off + T13h */
/* ADV signal timings corresponding to GPMC_CONFIG3 */
// .adv_on = 0, /* Address setup Tas*/
// .adv_rd_off = 110, /* Read deassertion time Trd + Tdd*/
// .adv_wr_off = 90, /* Write deassertion time Twr + Tdh*/
/* WE signals timings corresponding to GPMC_CONFIG4 */
.we_on = 20, /* WE assertion time: cs_on + T13d */
.we_off = 60, /* WE deassertion time: we_on + T13w */
/* OE signals timings corresponding to GPMC_CONFIG4 */
.oe_on = 25, /* OE assertion time: cs_on + T7d */
.oe_off = 75, /* OE deassertion time: oe_on + T7w */
/* Access time and cycle time timings corresponding to GPMC_CONFIG5 */
// .page_burst_access = 2 * 10, /* Multiple access word delay */
.access = 65, /* Start-cycle to first data valid delay: at leaset oe_on + T12d */
.rd_cycle = 115, /* Total read cycle time: cs_rd_off + (T9d – T7h) – oe_on */
.wr_cycle = 90, /* Total write cycle time: cs_wr_off + (T15d – T13h) – we_on */
/* The following are only on OMAP3430 */
.wr_access = 40, /* WRACCESSTIME: max we_off – T16s */
.wr_data_mux_bus = 0, /* WRDATAONADMUXBUS */
};

static unsigned long dm9000_gpmc_init(int GPMC_CS)
{
int val;
unsigned int base, size;
unsigned long mem_base;
int i = 0;

// val = gpmc_read_reg(GPMC_REVISION);
// val = gpmc_read_reg(0x00);
// gpmc cs disable memory
val = gpmc_cs_read_reg(GPMC_CS, GPMC_CS_CONFIG7);
val &= ~GPMC_CONFIG7_CSVALID;
gpmc_cs_write_reg(GPMC_CS, GPMC_CS_CONFIG7, val);

// disable cs3 irq
//gpmc_cs_configure(cs, GPMC_SET_IRQ_STATUS, 0);
//gpmc_cs_configure(cs, GPMC_ENABLE_IRQ, 0);

val = GPMC_CONFIG1_READTYPE_SYNC | GPMC_CONFIG1_WRITETYPE_SYNC | GPMC_CONFIG1_DEVICESIZE_16 | GPMC_CONFIG1_DEVICETYPE_NOR;
gpmc_cs_write_reg(GPMC_CS, GPMC_CS_CONFIG1, val);
if (gpmc_cs_set_timings(GPMC_CS, &ext_uart_timings) < 0) {
printk(KERN_ERR "Failed gpmc_cs_set_timings for ST16C554 device\n");
return -1;
}

if (gpmc_cs_request(GPMC_CS, SZ_16M, &mem_base) < 0) {
printk(KERN_ERR "[ext_uart platform init]: gpmc_cs_request failed\n");
return -1;
}

printk(KERN_INFO "gpmc_cssp_init for dm9000 device succeeded\n");

printk("gpmc cs%d base : 0x%08x, size : 0x%08x\n", GPMC_CS, mem_base, SZ_16M);
for (i=0;i<7;i++)
{
printk("gpmc cs%d[%d] reg: 0x%08x\n", GPMC_CS, i+1, gpmc_cs_read_reg(GPMC_CS, GPMC_CS_CONFIG1+(i*4)));
}
return 0;
}

各位看看是否有过这方面经验的人,帮小弟解决一下?万分感谢

Jian Zhou:

DM9000是数据/地址复用方式么?

lei wang49:

楼主解决这个问题没有 小弟我也碰到了 求解

赞(0)
未经允许不得转载:TI中文支持网 » 关于AM335x扩展DM9000的问题
分享到: 更多 (0)