AnsweredAssumed Answered

Programming GPIO as IRQ input

Question asked by Mauro de Pascale on Jan 19, 2015
Latest reply on Feb 20, 2015 by Karina Valencia Aguilar

Hi,

 

I'm currently working on a Vybrid based board using the Ember SOM and now I'm trying to connect a I2C accellerometer  (ADXL34x from AD) to the board using some exposed GPIO ports.

The hardware team connected the ADXL this way:

 

SDA (SOM's I2C_1 data ) on PTE28

SCK (SOM's I2C_1 clk ) on PTE27

INT1 on PTE13

INT2 on PTE6

 

Looking at the existing BSP code, reading the Reference Manual and posts on the forum I've been able to correctly configure

the GPIOs PTE28 and PTE27 as in the following: 

 

/*I2C1*/

#define MVF600_PAD132_PTE27__I2C1_SCL                \

        IOMUX_PAD(0x0210, 0x0210, 5, 0x0344, 3, \

                MVF600_I2C_PAD_CTRL | PAD_CTL_ODE | PAD_CTL_OBE_IBE_ENABLE )

 

#define MVF600_PAD133_PTE28__I2C1_SDA                \

        IOMUX_PAD(0x0214, 0x0214, 5, 0x0348, 3, \

                MVF600_I2C_PAD_CTRL | PAD_CTL_ODE | PAD_CTL_OBE_IBE_ENABLE )

 

Adding the correct pad declaration into the pads structure:

 

static iomux_v3_cfg_t mvf600_pads[] = {

/* other pads here */

#if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE)

    MVF600_PAD132_PTE27__I2C1_SCL,

    MVF600_PAD133_PTE28__I2C1_SDA,

#endif

/* other pads here */

}

 

and adding the ADXL driver initialization into the BSP:

 

static struct i2c_board_info mxc_i2c1_board_info[] __initdata = {

 

#if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE)

    {

        I2C_BOARD_INFO("adxl34x", 0x53),

        .irq =  gpio_to_irq(118),

    },

#endif

...

 

This way the probe works correctly and I see on the instrument the I2C bus working when the driver loads at kernel boot.

However I've issues trying to configure the irq to see events coming from the ADXL.

 

How to achieve that ?

 

I made various attempts:

 

added GPIO declaration to pads this way:

 

#define MVF600_PAD63_PTE13__I2C1_INT1         \
            IOMUX_PAD(0x01D8, 0x01D8, 0, 0x0000, 0, \
   MVF600_GPIO_GENERAL_CTRL | PAD_CTL_IBE_ENABLE)

 

#define MVF600_PAD56_PTE6__I2C1_INT2         \
            IOMUX_PAD(0x01BC, 0x01BC, 0, 0x0000, 0, \
   MVF600_GPIO_GENERAL_CTRL | PAD_CTL_IBE_ENABLE)

 

 

This hangs the kernel.

 

Trying to export GPIO setting the RISING EDGE programmatically:

 

    void __iomem *reg = MVF_IO_ADDRESS(MVF_GPIO4_INT_BASE_ADDR) ;

    int edge = /* GPIO_INT_RISE_EDGE */ 0x09;

    gpio_export(118, true);

    status = gpio_request_one(118, GPIOF_DIR_IN, "ADXL int");

    if (status == -EBUSY) /* already requested */

        gpio_export(118, false);

 

 

    /* Enabling int on rising edge */

    __raw_writel(edge << 16, reg + (22 & 0x1f) * 4);

    __raw_writel(1 << ( 22 & 0x1f ), MVF_IO_ADDRESS(MVF_GPIO4_INT_BASE_ADDR) + /*GPIO_ISR */ 0xA0);

 

This way nothing happens.

 

I think there's something I'm definitely missing but I'm clueless, may you help me with this matter ?

 

Thx a lot in advance.

 

Mdp

Outcomes