Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: DM9000B on SMC/EBI not working [solved]
PostPosted: Sun May 17, 2009 1:33 pm 
Offline
User avatar

Joined: Sat May 16, 2009 11:23 pm
Posts: 2
Hello,

I added a DM9000B device to my AT91SAM9260-ek board to the SMC/EBI controller on CS2 (almost identical to the to the AT91SAM9261-ek ethernet setup except the interrupt line is PB19 instead of PC11) but I'm having issues getting it to work. While loading the Linux kernel, I get these messages:

dm9000 Ethernet Driver, V1.31
dm9000 dm9000.0: read wrong id 0x2b012900
dm9000 dm9000.0: read wrong id 0x2b012900
...
dm9000 dm9000.0: wrong id: 0x2b2a2928
dm9000 dm9000.0: not found (-19).

Which signifies that the driver couldn't find the device. Upon further inspection, it seems as though the reads & writes are occurring, but they are not reaching the CS2 (address 0x30000000). So, I'm wondering if anyone had any previous experiences with the DM9000 on the AT91SAM926x or possibly might have some insight on the SMC/EBI interface. Is there any possibility that initializing it wrong would make this occur? :oops: :D

Thanks,
Jesse L. Zamora

Code from the board-at91sam9260-ek.c file for the DM9000:

...

#if defined(CONFIG_DM9000)
static struct resource dm9000_resource[] = {
[0] = {
.start = AT91_CHIPSELECT_2,
.end = AT91_CHIPSELECT_2 + 3,
.flags = IORESOURCE_MEM
},
[1] = {
.start = AT91_CHIPSELECT_2 + 0x44,
.end = AT91_CHIPSELECT_2 + 0xFF,
.flags = IORESOURCE_MEM
},
[2] = {
.start = AT91_PIN_PB19,
.end = AT91_PIN_PB19,
.flags = IORESOURCE_IRQ
}
};

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

static struct platform_device dm9000_device = {
.name = "dm9000",
.id = 0,
.num_resources = ARRAY_SIZE(dm9000_resource),
.resource = dm9000_resource,
.dev = {
.platform_data = &dm9000_platdata,
}
};

/*
* SMC timings for the DM9000.
* Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
*/
static struct sam9_smc_config __initdata dm9000_smc_config = {
.ncs_read_setup = 0,
.nrd_setup = 2,
.ncs_write_setup = 0,
.nwe_setup = 2,

.ncs_read_pulse = 16,
.nrd_pulse = 8,
.ncs_write_pulse = 16,
.nwe_pulse = 8,

.read_cycle = 16,
.write_cycle = 16,

.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16,
.tdf_cycles = 1,
};

static void __init ek_add_device_dm9000(void)
{
/* Intialize dm9000 on chip select 2 */
sam9_smc_configure(2, &dm9000_smc_config);

/* Is this necessary? Currently the reset pin doesn't seem to do anything.... */
//at91_set_gpio_output(AT91_PIN_PC10, 0);

/* Initialize the PB19 interrupt */
at91_set_gpio_input(AT91_PIN_PB19, 0);

platform_device_register(&dm9000_device);
}

#else
static void __init ek_add_device_dm9000(void) {}
#endif

...

static void __init ek_board_init(void)
{
...

/* DM9000 ethernet */
ek_add_device_dm9000();

...
}


Last edited by xtremek on Tue May 19, 2009 9:19 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: DM9000B on SMC/EBI not working [solved]
PostPosted: Tue May 19, 2009 9:16 pm 
Offline
User avatar

Joined: Sat May 16, 2009 11:23 pm
Posts: 2
Ah, I just figured this out. The reason why it wasn't working is that the pin for CS2 (which is PC11) is a dual-purpose pin that can be either the NCS2 (Peripheral A) for the SMC or NPCS1 (Peripheral B) for the SPI0 interface. So, I found that the code for the SPI0 interface was using PC11, so I just removed the code for the SPI (since we're not using it at all anyway) and initialized it to be a Peripheral A. For anyone who might be looking for some help with this type of thing, here's the code I used for initializing the DM9000B (specifically tailored for the AT91SAM9260-ek):

Code:
static struct resource dm9000_resource[] = {
    [0] = {
        .start  = AT91_CHIPSELECT_2,
        .end    = AT91_CHIPSELECT_2 + 3,
        .flags  = IORESOURCE_MEM
    },
    [1] = {
        .start  = AT91_CHIPSELECT_2 + 0x44,
        .end    = AT91_CHIPSELECT_2 + 0xFF,
        .flags  = IORESOURCE_MEM
    },
    [2] = {
        .start  = AT91_PIN_PB19,
        .end    = AT91_PIN_PB19,
        .flags  = IORESOURCE_IRQ
    }
};

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

static struct platform_device dm9000_device = {
    .name       = "dm9000",
    .id     = 0,
    .num_resources  = ARRAY_SIZE(dm9000_resource),
    .resource   = dm9000_resource,
    .dev        = {
        .platform_data  = &dm9000_platdata,
    }
};

/*
* SMC timings for the DM9000.
* Note: These timings were calculated for MASTER_CLOCK = 100000000 according to the DM9000 timings.
*/
static struct sam9_smc_config __initdata dm9000_smc_config = {
    .ncs_read_setup     = 0,
    .nrd_setup      = 2,
    .ncs_write_setup    = 0,
    .nwe_setup      = 2,

    .ncs_read_pulse     = 8,
    .nrd_pulse      = 4,
    .ncs_write_pulse    = 8,
    .nwe_pulse      = 4,

    .read_cycle     = 16,
    .write_cycle        = 16,

    .mode           = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16,
    .tdf_cycles     = 1,
};

static void __init ek_add_device_dm9000(void)
{
    /* Configure PC11 as a NCS2 pin instead of SPI0_NPCS1... */
    at91_set_A_periph(AT91_PIN_PC11, 0);
   
    /* Configure chip-select 2 (DM9000) */
    sam9_smc_configure(2, &dm9000_smc_config);

    /* Configure Interrupt pin as input, no pull-up */
    at91_set_gpio_input(AT91_PIN_PB19, 0);

    platform_device_register(&dm9000_device);
}


I simply removed the code for the reset pin because we don't use it with the DM9000B device.

If you are using the CS6 or CS7 even, you would just replace the AT91_PIN_PC11 with the pin that for that particular interrupt. Also make sure something else is not using that pin, otherwise you won't get the chip select when reading & writing!

Xtreme Kommander AKA Jesse L. Zamora

P.S. If you need some help or something with a DM9000 device on the SMC, email me (during the year 2009; if you're in 2010 or later, I won't reply since I update my email every year) at xtremek2009@gmail.com.


Top
 Profile  
 
 Post subject: Re: DM9000B on SMC/EBI not working [solved]
PostPosted: Tue Jun 14, 2011 4:13 am 
Offline

Joined: Tue May 24, 2011 11:29 am
Posts: 1
hello xtremek,
I meet the same questions and thanks for your share.
I have changed some codes depend on yours,and there is my code:
static struct resource at91sam9260_dm9000_resource[] = {
[0] = {
.start = AT91_CHIPSELECT_2 ,
.end = AT91_CHIPSELECT_2 + 0x03,
.flags = IORESOURCE_MEM
},
[1] = {
.start = AT91_CHIPSELECT_2 + 0x44,
.end = AT91_CHIPSELECT_2 + 0xff,
.flags = IORESOURCE_MEM
},
[2] = {
.start = AT91_PIN_PC12,
.end = AT91_PIN_PC12,
.flags = IORESOURCE_IRQ
}
};

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

static struct platform_device at91sam9260_dm9000_device = {
.name = "dm9000",
.id = 0,
.num_resources = ARRAY_SIZE(at91sam9260_dm9000_resource),
.resource = at91sam9260_dm9000_resource,
.dev = {
.platform_data = &dm9000_platdata,
}
};

static void __init ek_add_device_dm9000(void)
{

/* Configure PC11 as a NCS2 pin instead of SPI0_NPCS1... */
at91_set_A_periph(AT91_PIN_PC11, 0);

/*
* Configure Chip-Select 2 on SMC for the DM9000.
* Note: These timings were calculated for MASTER_CLOCK = 100000000
* according to the DM9000 timings.
*/
at91_sys_write(AT91_SMC_SETUP(2), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0) | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
at91_sys_write(AT91_SMC_PULSE(2), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(8) | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(8));
at91_sys_write(AT91_SMC_CYCLE(2), AT91_SMC_NWECYCLE_(16) | AT91_SMC_NRDCYCLE_(16));
at91_sys_write(AT91_SMC_MODE(2), AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16 | AT91_SMC_TDF_(1));

/* Configure Reset signal as output */
at91_set_gpio_output(AT91_PIN_PC10, 0);

/* Configure Interrupt pin as input, no pull-up */
at91_set_gpio_input(AT91_PIN_PC12, 0);

platform_device_register(&at91sam9260_dm9000_device);
}

The leds connect to DM9000EP have been lighted, and the DM9000EP ID has been found.

But a new problem is when I ping another IP it doesn't work.

Do you have some suggestions,thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: