This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux (GPIO) Interrupt speed problems

Other Parts Discussed in Thread: DM3730

Hello,

I am using a DM3730 and have setup the use of a GPIO pin 170 as a source for a linux kernel interrupt specifically to interface to the INT signal from an MCP2515 can controller.  The kernel config is like this:

static struct spi_board_info omap3tao3530_spi_can_board_info[] = {
 {
 .modalias = "mcp251x",
 .platform_data = &spi3_mcp2515_pdata,
 .irq = OMAP_GPIO_IRQ(OVERO_GPIO_CAN_INT),
 .max_speed_hz = 8*1000*1000,
 .bus_num = 3,
 .mode = SPI_MODE_0,
 .chip_select = 0,
 },

};

and the pin setup

static void __init spi3_mcp251x_init(void)
{
 printk(KERN_DEBUG "spi3_mcp251x_init: Entry\n");
 if ((gpio_request(OVERO_GPIO_CAN_INT, "MCP251x CAN INT") == 0) &&
 (gpio_direction_input(OVERO_GPIO_CAN_INT) == 0)) {
 gpio_export(OVERO_GPIO_CAN_INT, 0);
 set_irq_type(OMAP_GPIO_IRQ(OVERO_GPIO_CAN_INT), IRQ_TYPE_EDGE_FALLING);
 } else {
 printk(KERN_ERR "could not obtain gpio for MCP251x CAN bus interrupt\n");
 return;
 }
 gpio_direction_input(OVERO_GPIO_CAN_INT);

}  OMAP3_MUX(HDQ_SIO, OMAP_MUX_MODE4 | OMAP_PIN_INPUT), //GPIO interrupt

 

All seems to be working I can use the application that I have to send and receive data using the spi3 bus and the interrupt is seen.  The problem I am having however is that I cant seem to get a reliable interrupt seen by the kernel at anything faster than 10ms.  Is there any way that I can speed this reaction/scan time up ?

I have measured the time that it takes to see the interrupt, react and read all the data at ~380us so there is plenty of time for the exit of the irc function and to see the change in pin state.

I have had a look at the HZ definition and changed it from 100 to 1000 in an attempt to push the jiffies down to 1ms but this seems to have made things worse.  I just need reliable operation at relatively high interrupt rates and I would have thought that a ucontroller working at 800MHz should be capable of seeing and servicing a 1ms interrupt.

Is there anyone out there that understands my problem or maybe something I can change in the kernel config or code ?

Help greatfully appreciated and it means that my system is almost ready for V1 spin if I can prove that this interface works.

Thanks in advance

Marc

 

  • Marc,

    There is a small mistake in the code that you've pasted. 

        .irq = OMAP_GPIO_IRQ(OVERO_GPIO_CAN_INT),  is wrong. It has to be  = 0. 

    Basically the interrupt that you are getting from mcp2515 is not for SPI transfers, but for signalling about the CAN communication. Once you receive the interrupt, you can go ahead and do SPI read/write from your driver. So what I mean here is the GPIO 170 interrupt has to be handled in mcp2515 driver that you are having and need not be provided to the SPI driver. Also you've to write a separate interrupt handler routine for the handling GPIO_170 interrupt.

    Hope this helps.

    -Renjith

    www.pathpartnertech.com