On Wed, Apr 7, 2010 at 5:19 AM, Lei Luo <[email protected]> wrote:
> Hi Christian,
>
Hi, please always remember to CC the socketcan mailing list so people
googling can find this. And we can say RTFM to them if they ask this
question again. ;-)
> I am a newbie of socketcan, I got the source code from the svn server.
> There are two mcp2510 can controllers in my arm at91rm9200 board. I
> compiled and installed socketcan with mcp251x modules successfully. But
> there is no can device after OS loaded in my board. So, how should I do to
> add the mcp251x_info to the platform definition file as what you have said
> in the beginning of mcp251x.c? I added it into at91rm9200_device.c, and
> include <socketcan/can/platform/mcp251x.h>, some err informations such as
> "mcp251x_setup" presented.
I just recently configured a mcp251x for a at91sam9260 machine which
is not too different from the at91rm9200. If you use the SVN version
(so I guess old kernel) you have to copy mcp251x.h somewhere in the
kernel include path. Then add to your board device:
....
#include <linux/can/mcp251x.h>
.....
static struct mcp251x_platform_data mcp251x_info = {
.oscillator_frequency = 4000000,
// <- set the crystal you used
.model = CAN_MCP251X_MCP2510,
.transceiver_enable = NULL,
// <- if you want to power up/down the transceiver for PM
};
static struct spi_board_info ek_spi_devices[] = {
......
{
.modalias = "mcp251x",
.platform_data = &mcp251x_info,
.irq = AT91_PIN_PB18,
// <- set the IRQ
.max_speed_hz = 5*1000*100,
.chip_select = 0,
.controller_data = (void *) AT91_PIN_PB3,
// <- set the CS line
.bus_num = 0,
// <- if you are on SPI port 0, otherwise 1
},
......
};
static void __init ek_board_init(void)
{
.....
/* SPI */
at91_set_gpio_output(AT91_PIN_PB17, 0); /* power on */
// <- if you control power of the MCP
at91_set_gpio_output(AT91_PIN_PB16, 1); /* can reset */
// <- if you control reset of the MCP remember to deassert it
at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
.....
For 2 CAN devices just do it twice :-). Remember to enable debug
*before* loading modules (echo a big number to
/proc/sys/kernel/printk). When you load modules you will see something
like "MCP probed" or "MCP no probed". If you don't see this anything
you didn't do what's above or haven't loaded all the necessary modules
(SPI master driver for example). If you see "not probed" please send
the complete debug output. Chances are that you SPI link is not
working or you got the wrong CS/IRQ pin.
Hope this helps, Bye!
--
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core