2010/4/7 christian pellegrin <[email protected]>
> 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. ;-)
>
Sorry for my mistake.
>
>
> 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.
>
I added can definitions into board-dk.c. When I "modprobe mcp251x", it shows
"CAN device driver interface" in console, mcp251x modules is loaded as can
be seen from "lsmod". But I can't find can device files such as "can0, can1,
..." and there is no can infomation in "ip link show".
Is something I did wrong? Or the device files of can should not created
automaticly as they are connected with spi?
The code I added is as follows:
static struct mcp251x_platform_data mcp251x_info = {
.oscillator_frequency = 12000000,
.model = CAN_MCP251X_MCP2510,
};
static struct spi_board_info dk_spi_devices[] = {
{
.modalias = "mcp251x",
.platform_data = &mcp251x_info,
.irq = AT91_PIN_PC14,// <- set the IRQ
.max_speed_hz = 5*1000*1000,
.chip_select = 2,
.controller_data = (void *) AT91_PIN_PA4,// <- set the CS line
},
{
.modalias = "mcp251x",
.platform_data = &mcp251x_info,
.irq = AT91_PIN_PC15,// <- set the IRQ
.max_speed_hz = 5*1000*1000,
.chip_select = 3,
.controller_data = (void *) AT91_PIN_PA6,// <- set the CS line
}
};
Thanks for helps!
Regards,
Luo
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users