Dear folks:
                  Hi,i met a bus off in S3C64XX SockCan,from lower-level spi 
read/write,seems mcp2515 read/write is OK,but when i use cansend to send data 
,mcp2515 enter bus off mode,what should i go on debuging or verfy hardware is 
no problem? please give me suggestions,i will read mcp2515 datasheet and 
socketcan carefully in deep.

Kernel booting log:

Driver 'sd' needs updating - please use bus_type methods
drivers/spi/spi_s3c.c:s3c_spi_init:1149
drivers/spi/spi_s3c.c:s3c_spi_probe:842 ID=0

mcp251x_read_reg

mcp251x_spi_trans

mcp251x_read_reg

mcp251x_spi_trans

mcp251x_read_reg

mcp251x_spi_trans
mcp251x spi0.0: CANSTAT 0x80 CANCTRL 0x07

mcp251x_write_reg

mcp251x_spi_trans
mcp251x spi0.0: probed

Samsung SoC SPI Driver loaded for Bus SPI-0 with 1 Slaves attached
    Max,Min-Speed [33250000, 129882]Hz
    Irq=80    IOmem=[0x7f00bfff-0x7f00b000]    DMA=[Rx-33, Tx-34]
usbmon: debugfs is not available


here is debug step:


2)ifconfig can0 up

3)./cansend can0 111#1122334455667788


debug log:
[root@Tommy canbustest]# ./ip link set can0 type can bitrate 125000 triple-sampl
ing on
[root@Tommy canbustest]# ifconfig can0 up

mcp251x_read_reg

mcp251x_spi_trans

mcp251x_write_reg

mcp251x_spi_trans

mcp251x_write_reg

mcp251x_spi_trans

mcp251x_write_bits

mcp251x_spi_trans

mcp251x_read_reg

mcp251x_spi_trans

mcp251x_read_reg

mcp251x_spi_trans

mcp251x_read_reg

mcp251x_spi_trans
mcp251x spi0.0: CNF: 0x03 0xf5 0x01

mcp251x_write_reg

mcp251x_spi_trans

mcp251x_write_reg

mcp251x_spi_trans

mcp251x_write_reg

mcp251x_spi_trans

mcp251x_write_reg

mcp251x_spi_trans

mcp251x_read_reg

mcp251x_spi_trans


[root@Tommy canbustest]# ./cansend can0 111#1122334455667788

mcp251x_hw_tx

mcp251x_hw_tx_frame

mcp251x_spi_trans

mcp251x_write_reg

mcp251x_spi_trans

mcp251x_read_reg

mcp251x_spi_trans

mcp251x_write_bits

mcp251x_spi_trans

mcp251x_read_reg

mcp251x_spi_trans

mcp251x_write_reg

mcp251x_spi_trans
can state bus off
can_bus_off
mcp251x spi0.0: bus-off

mcp251x_write_reg

mcp251x_spi_trans


---------------------------------------------------


following  is my platform code:

#ifdef CONFIG_CAN_MCP251X
/* SPI / CAN MCP251x support */
static void s3c6410_set_cs(unsigned line, int cs)
{
    unsigned int pin;
    int change = 1;

    switch (line) {
    case 0:
        pin = S3C64XX_GPC(3);    //MCP2515 Use SPI0
        break;
    default:
        printk(KERN_ERR "s3c6410_set_cs, unknown line %d\n", line);
        change = 0;
        break;
    }
    if (change) {
        gpio_set_value(pin, cs);
    }
};

static void __init s3c6410_mcp251x_init(void)
{
    printk(KERN_DEBUG "s3c6410_mcp251x_init: Entry\n");
        printk(KERN_INFO "mcp251x: setup gpio pins CS and External Int\n");
        s3c_gpio_cfgpin(S3C64XX_GPN(2), S3C64XX_GPN2_EINT2);
        s3c_gpio_setpull(S3C64XX_GPN(2), S3C_GPIO_PULL_UP);

        s3c_gpio_setpull(S3C64XX_GPC(3), S3C_GPIO_PULL_NONE);   // Manual chip 
select pin as used in s3c6410_set_cs
        s3c_gpio_cfgpin(S3C64XX_GPC(3), S3C_GPIO_OUTPUT);       // Manual chip 
select pin as used in s3c6410_set_cs
}

static int mcp251x_ioSetup(struct spi_device *spi)
{
    return 0;
}

/**
 * struct s3c64xx_spi_csinfo - ChipSelect description
 * @fb_delay: Slave specific feedback delay.
 *            Refer to FB_CLK_SEL register definition in SPI chapter.
 * @line: Custom 'identity' of the CS line.
 * @set_level: CS line control.
 *
 * This is per SPI-Slave Chipselect information.
 * Allocate and initialize one in machine init code and make the
 * spi_board_info.controller_data point to it.
 */
struct s3c64xx_spi_csinfo {
    u8 fb_delay;
    unsigned line;
    void (*set_level) (unsigned line_id, int lvl);
};

static struct s3c64xx_spi_csinfo mcp251x_cs_info[] = {
    {
     .fb_delay = 0x3,    // 9ns feedback delay for cs line
     .line = 0,
     .set_level = s3c6410_set_cs,
     },
};

static struct mcp251x_platform_data mcp251x_info = {
    .oscillator_frequency = 16000000,
    .board_specific_setup = mcp251x_ioSetup,
    .model = CAN_MCP251X_MCP2515,
    .power_enable = NULL,
    .transceiver_enable = NULL,
};

static struct spi_board_info s3c6410_mcp251x_board_info[] __initdata = {
    {
     .modalias = "mcp251x",
     .platform_data = &mcp251x_info,
     .controller_data = &mcp251x_cs_info,
     .max_speed_hz = 2 * 1000 * 1000,
     .irq = S3C_EINT(2),    /* GPN2 */
     .chip_select = 0,
     .bus_num = 0,
     .mode = SPI_MODE_0,
     },
};
#endif


thanks if you give me good advice to test my mcp2515.

B.R
Tommy
_______________________________________________
Socketcan-core mailing list
Socketcan-core@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to