logo

Could not compile stylesheet for simplistic. Using last compiled stylesheet.

CAN bus interface on 3.x kernel

posted in IGEPv2 EXPANSION
Sunday, June 09 2013, 04:55 PM
0
I compiled and run successfully a 3.4 kernel with preempt_rt patches.
Unfortunatelly I did not manage to make CAN interface working.
I copied igep0x00 and exp-igep0022 files from 2.6.37 kernel source, and after a little editing it compiles and run. However, the can0 interface is not created and the probe of mcp251x failes.

I tried to check kernel outputs and compare the ones form my kernel with the ones from the igep-supported 2.6.37 which has the can working.

omap_mux_init_gpio(IGEP2_GPIO_MCP251X_NRESET, OMAP_PIN_INPUT_PULLUP);
omap_mux_init_gpio(IGEP2_GPIO_MCP251X_IRQ, OMAP_PIN_INPUT_PULLUP);
omap_mux_init_signal("mcspi1_cs0", 0);

these calls return 0, and therefore succeed

both the kernels have the following line in the dmesg
[ 0.716705] IGEP: Could not obtain gpio MCP251X NRESET

The problem seems to be the status of the device after reset.
In the mcp driver code there is the function "mcp251x_hw_probe", that after the call to "mcp251_hw_reset" reads through spi two registers of the device and check their value. I refer to st1 and st2 in the code. Instead of 0x80 and 0x07, I get different numbers and not always the same.

I tried to ignore that check and return always 1. The can0 is created but, of course, is not possible to set the interface. If I try with ip link I get
[ 408.449035] mcp251x spi1.0: failed to acquire irq 317, error -22

I know it may not be enough information to understand the issue, but I was wondering if somebody had to work on this, and maybe experienced the same behavior in the attempt of making it work.

Federico

Accepted Answer

Monday, June 17 2013, 01:53 PM - #permalink
0
I solved the problem. I took another configuration file from another kernel version which I was working on, and where can bus was working, but not with preempt_rt. I tried to understand what it is that makes it work but I haven't figure it out :-/ I tried to attach the two config files in the post but I couldn't make it.
The reply is currently minimized Show
Responses (11)
  • Accepted Answer

    Monday, June 10 2013, 09:32 AM - #permalink
    0
    Could you check if mcspi pins are configured correctly ?
    The reply is currently minimized Show
  • Accepted Answer

    Monday, June 10 2013, 10:00 AM - #permalink
    0
    /sys/kernel/debug/omap_mux gives me this

    name: mcspi1_clk.mcspi1_clk (0x480021c8/0x198 = 0x0100), b ab3, t NA
    mode: OMAP_PIN_INPUT | OMAP_MUX_MODE0
    signals: mcspi1_clk | sdmmc2_dat4 | NA | NA | gpio_171 | NA | NA | safe_mode
    name: mcspi1_cs0.mcspi1_cs0 (0x480021ce/0x19e = 0x0000), b ac2, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
    signals: mcspi1_cs0 | sdmmc2_dat7 | NA | NA | gpio_174 | NA | NA | safe_mode
    name: mcspi1_cs1.mcspi1_cs1 (0x480021d0/0x1a0 = 0x0000), b ac3, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
    signals: mcspi1_cs1 | NA | NA | sdmmc3_cmd | gpio_175 | NA | NA | safe_mode
    name: mcspi1_cs2.gpio_176 (0x480021d2/0x1a2 = 0x0104), b ab1, t NA
    mode: OMAP_PIN_INPUT | OMAP_MUX_MODE4
    signals: mcspi1_cs2 | NA | NA | sdmmc3_clk | gpio_176 | NA | NA | safe_mode
    name: mcspi1_cs3.mcspi1_cs3 (0x480021d4/0x1a4 = 0x0000), b ab2, t NA
    mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
    signals: mcspi1_cs3 | NA | hsusb2_tll_data2 | hsusb2_data2 | gpio_177 | mm2_txdat | NA | safe_mode
    name: mcspi1_simo.mcspi1_simo (0x480021ca/0x19a = 0x0100), b ab4, t NA
    mode: OMAP_PIN_INPUT | OMAP_MUX_MODE0
    signals: mcspi1_simo | sdmmc2_dat5 | NA | NA | gpio_172 | NA | NA | safe_mode
    name: mcspi1_somi.mcspi1_somi (0x480021cc/0x19c = 0x0100), b aa4, t NA
    mode: OMAP_PIN_INPUT | OMAP_MUX_MODE0
    signals: mcspi1_somi | sdmmc2_dat6 | NA | NA | gpio_173 | NA | NA | safe_mode
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, June 11 2013, 09:13 AM - #permalink
    0
    And the muxing for IGEP2_GPIO_MCP251X_NRESET and IGEP2_GPIO_MCP251X_IRQ are also right ? Looks like there is a problem with these pins, maybe they are not configured correctly.
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, June 11 2013, 03:29 PM - #permalink
    0
    /sys/kernel/debug/gpio gives this gpio-157 (MCP251X IRQ ) in lo and not gpio-157 (MCP251X IRQ ) in lo irq-317 edge-rising which is present in the 2.6.37 is it a sign of misconfiguration?
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, June 12 2013, 09:15 AM - #permalink
    0
    Yes, this can be a problem. But this is due to following problem
    [ 408.449035] mcp251x spi1.0: failed to acquire irq 317, error -22
    

    For some reason getting the irq fails.

    Please try replacing the mcp251x_spi_board_info for this one
     568 static struct spi_board_info mcp251x_spi_board_info  __initdata = {
     569         .modalias       = "mcp2515",
     570         .bus_num        = -EINVAL,
     571         .chip_select    = -EINVAL,
     572         .max_speed_hz   = 1*1000*1000,
     573         .irq            = gpio_to_irq(IGEP2_GPIO_MCP251X_IRQ),
     574         .mode           = SPI_MODE_0,
     575         .platform_data  = &mcp251x_pdata,
     576 };
    


    And also remove lines from 582 to 588, and 600
     582         if ((gpio_request(irq, "MCP251X IRQ") == 0)
     583                 && (gpio_direction_input(irq) == 0))
     584                 gpio_export(irq, 0);
     585         else {
     586                 pr_err("IGEP: Could not obtain gpio MCP251X IRQ\n");
     587                 return;
     588         }
    
    (...)
    
     600         spi->irq = OMAP_GPIO_IRQ(irq);
    
    
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, June 12 2013, 09:56 AM - #permalink
    0
    Compiler doesn't like it with gpio_to_irq(IGEP2_GPIO_MCP251X_IRQ) it returns arch/arm/mach-omap2/board-igep00x0.c:430:2: error: initializer element is not constant putting directly 317 it compiles but nothing changes
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, June 13 2013, 10:40 PM - #permalink
    0
    I'm afraid I made a little of confusion.
    The problem with the irq is misleading, since it happens because I edited the driver code to return 1 even if CANSTAT has a wrong value, just to see what was gonna happen. This allows for the creation of the can0 interface and the problem with the irq raises when I "ip link" the interface. Actually, by now, I don't have a can0, my bad.

    I may have found what it is giving me problem though. I don't know how I didn't notice this in /sys/kernel/debug/gpio:

    gpio-136 ([auto] ) out lo

    this should cause the mcp251x to be continuosly reset, shouldn't it? I tried to change the value from user space and than unload and reload the mcp251x module, but it does not work and CANSTAT and CANCTRL keep having "random" values. The value of the gpio in the debugfs is hi after this operation, but is it possible that actually the physical state of the pin has not changed accordingly since it is under kernel control? If this is the case I may still have some hopes that this is the source of the problem.

    omap_mux_init_gpio is called only one time, from the exp-board0022 file in arch/arm/mach-omap2. If I comment out that call the gpio has the same configuration. Where could it be, in the kernel source, the point in which the kernel is taking control of that gpio? In the 2.6.37 kernel it does not show up in /sys/kernel/debug/gpio. I would like to have the same configuration for the kernel I'm workin on, just to be sure whether this is the problem or not.
    The reply is currently minimized Show
  • Accepted Answer

    Friday, June 14 2013, 09:05 AM - #permalink
    0
    Can you share your repository with you patches via github or something similar ? I wanna try this. Thanks.
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, June 18 2013, 08:46 AM - #permalink
    0
    Can you share with us the difference between the config file that doesn't work and the config file that works ? Thanks
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, June 18 2013, 11:26 AM - #permalink
    1
    It is actually a bit long, I'm afraid I started from different config files as base.

    http://www.pasteall.org/43271
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, June 19 2013, 08:56 AM - #permalink
    0
    Thanks!!!
    The reply is currently minimized Show
Your Reply

SUPPORT


This email address is being protected from spambots. You need JavaScript enabled to view it.
This email address is being protected from spambots. You need JavaScript enabled to view it.
IGEP Community Wiki
IGEP Community Forum
IGEP Community Online Chat