How to enable interrupts of EXP_GPIOs from PCA6416 in IMX8M Mini EVK

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

How to enable interrupts of EXP_GPIOs from PCA6416 in IMX8M Mini EVK

Jump to solution
5,020 Views
qian_hao
Contributor I

Hi,

 

I'm working with IMX8M Mini EVK.

I'm trying to handle interrupts from EXP_GPIO, but got -6 when calling gpiod_to_irq().
The node setting of pca6416 in dts is like below:
========================
    pca6416: gpio@20 {
        compatible = "ti,tca6416";
        reg = <0x20>;
        gpio-controller;
        #gpio-cells = <2>;
    };
========================
I added below to use some EXP_GPIOs in my fpga driver:
========================
&ecspi2 {
    status = "okay";

    fpga1: fpga_fw@0 {
        reg = <0>;
        compatible = "lattice,fpga_fw";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_expio>;
        spi-max-frequency = <10000000>;
        fpga_resetb-gpio = <&pca6416 10 GPIO_ACTIVE_HIGH>;
        fpga_nconfig-gpio = <&pca6416 11 GPIO_ACTIVE_HIGH>;
        fpga_conf_done-gpio = <&pca6416 12 GPIO_ACTIVE_HIGH>;
        fpga_intb-gpio = <&pca6416 13 GPIO_ACTIVE_HIGH>;
        fpga_nstatus-gpio = <&pca6416 14 GPIO_ACTIVE_HIGH>;
        fpga_init_done-gpio = <&pca6416 15 GPIO_ACTIVE_HIGH>;
    };
};
========================
and use below api in the driver:
========================
devm_gpiod_get()
gpiod_to_irq()    ← it returns -6 error
========================

 

Do I need to add properties of "interrupt-" to use interrupt feature for EXP_GPIOs?
If so, could you please offer an example code?
 

Thank you,

Qian

0 Kudos
1 Solution
4,778 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi,

 PCA6416's driver is gpio-pca953x.c

static const struct of_device_id pca953x_dt_ids[] = {

......

{ .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), },

......

}

On i.MX8M mini EVK board, those GPIO's from PCA6416 are all output, so INT pin is not configured.

The following steps are for you reference:

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

1. IOMUX in device tree
        pinctrl_i2c2_dev: mydev_iogrp {
            fsl,pins = <
                MX8MM_IOMUXC_GPIO1_IO012_GPIO1_IO12        0x19    /*  expend gpio int */
            >;
        };

2. add these lines to pca6146 node in dts:

        pinctrl-0 = <&pinctrl_i2c2_dev:>;
        interrupt-parent = <&gpio1>;
        interrupts = <12 IRQ_TYPE_LEVEL_LOW>;

3. In driver's probe function

......

int irq = client->irq;

int ret = devm_request_irq(&client->dev, irq, (irq_handler_t) my_device_handler, IRQF_TRIGGER_LOW, "my i2c device", NULL);
if(ret)
  enable_irq(irq);

......

[Comment]

In the driver, It seems that there is function called "pca953x_irq_setup()" ,  probably you can directly use it. I didn't test it.

Hope a bove information is helpful for you.

Have  a nice day!

B.R,

Weidong

View solution in original post

7 Replies
4,779 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi,

 PCA6416's driver is gpio-pca953x.c

static const struct of_device_id pca953x_dt_ids[] = {

......

{ .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), },

......

}

On i.MX8M mini EVK board, those GPIO's from PCA6416 are all output, so INT pin is not configured.

The following steps are for you reference:

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

1. IOMUX in device tree
        pinctrl_i2c2_dev: mydev_iogrp {
            fsl,pins = <
                MX8MM_IOMUXC_GPIO1_IO012_GPIO1_IO12        0x19    /*  expend gpio int */
            >;
        };

2. add these lines to pca6146 node in dts:

        pinctrl-0 = <&pinctrl_i2c2_dev:>;
        interrupt-parent = <&gpio1>;
        interrupts = <12 IRQ_TYPE_LEVEL_LOW>;

3. In driver's probe function

......

int irq = client->irq;

int ret = devm_request_irq(&client->dev, irq, (irq_handler_t) my_device_handler, IRQF_TRIGGER_LOW, "my i2c device", NULL);
if(ret)
  enable_irq(irq);

......

[Comment]

In the driver, It seems that there is function called "pca953x_irq_setup()" ,  probably you can directly use it. I didn't test it.

Hope a bove information is helpful for you.

Have  a nice day!

B.R,

Weidong

4,778 Views
qian_hao
Contributor I

Hi Werdong,

Thank you for your thorough answer.

Actually, I've made a conclusion similar to your suggestion.

So, I think I should request interrupt to the INT pin of PCA6146 (which is connected to GPIO1_IO12 on imx8mm) rather than to the EXP_GPIO on PCA6146 directly, as expander's driver only monitors it's INT pin for interrupts.

With your answer, I can be sure to my conclusion before.

After all, thank you very much.

Appreciate your a lot.

Qian

0 Kudos
4,778 Views
khang_letruong1
Contributor I

Dear b45499‌ and @Hao Qian,

Could you confirm MX8MM_IOMUXC_GPIO1_IO012_GPIO1_IO12 or MX8MM_IOMUXC_GPIO1_IO012_GPIO1_IO12, please ?

0 Kudos
4,778 Views
qian_hao
Contributor I

Hi,

It is MX8MM_IOMUXC_GPIO1_IO012_GPIO1_IO12.

MX8MM_IOMUXC_GPIO1_IO012_GPIO1_IO12 was only a small spell mistake I think.

0 Kudos
4,779 Views
khang_letruong1
Contributor I

Dear @Hao Qian,

Thanks for your confirmation. I will be appreciated if you can tell how to configure the DTS so that interrupt signal could be propagated from one of the GPIOs of PCA6416 to INT that is connected to the GPIO1_IO12 of iMX8M SoC, please ?

Thank you very much in advance,

Khang

0 Kudos
4,779 Views
khang_letruong1
Contributor I

Dear All,

I'd like to bother you again. I understood that PCA6416 would monitor any change of one of its EXP_GPIOs to propagate the change and to trigger the INT signal.  My question is that should I modify the pca953x driver to configure one of these EXP_GPIOs as input as well since they are all outputs by default?

Best regards,

Khang

0 Kudos
2,427 Views
antho
Contributor III

Hi Khang,

I understood that PCA6416 would monitor any change of one of its EXP_GPIOs to propagate the change and to trigger the INT signal


Have you managed to do this by any chance ? I'm trying to.

I have configured inotify on /sys/class/gpio/gpio<N>/value to monitor changes on the pca9505 gpio expander inputs. But it is not updated without polling.

Regards,

0 Kudos