Programming GPIO as IRQ input

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Programming GPIO as IRQ input

1,257 Views
maurodepascale
Contributor I

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

Labels (2)
Tags (3)
0 Kudos
6 Replies

641 Views
timesyssupport
Senior Contributor II

Hello Mauro,

You mention in your message, the "Ember SOM", do you mean Emcraft?

We are not in possession of Emcraft hardware, nor the associated BSP/reference manual, so are not suited to answering what may be causing issues with regards to this particular hardware and sources.

Can you clarify which hardware you are working with, please?

Thank you,

Timesys Support

0 Kudos

641 Views
maurodepascale
Contributor I

Hi,

yes, we are using the Emcraft SOM (sorry, can't say from where Ember came out and how I it get unnoticed while composing the mail ... ).

Vybrid VF6 SOM

As told I was able to figure out how to program a couple of GPIOs to interface an I2C enabled device to them, but I'm completely clueless about how to configure a GPIO as an IRQ input to be able to process events.

I was hoping in getting some directions on the matter 'cause at the moment I'm stuck and I really don't know where to look further.

Thx in advance for any advice you could provide and anyhow thx a lot indeed.

Regard,

Mdp

0 Kudos

641 Views
karina_valencia
NXP Apps Support
NXP Apps Support

Hi Mauro,

please contact Emcraft directly to  get support on this case.

0 Kudos

641 Views
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport are yo available to attend this case?

0 Kudos

641 Views
karina_valencia
NXP Apps Support
NXP Apps Support

Timesys Support do you have an update on this case?

0 Kudos

641 Views
karina_valencia
NXP Apps Support
NXP Apps Support

Timesys Support any comment?

0 Kudos