How use Ethernet pin as gpio interrupt pin

cancel
Showing results for 
Search instead for 
Did you mean: 

How use Ethernet pin as gpio interrupt pin

963 Views
Matteo
Contributor II

Hi!!!

I have a problem with my i.mx28 based custom board. My custom board works with Linux ed it is connected by NFS to my host computer.

I have connectet pin ENET0_TXD2 to an external device and I have configured this pin as a input gpio. In my driver I have set this pin as input,


gpio_direction_input(ENET0_TXD2);

and I have called the interrupt request function;

pin = gpio_to_irq(ENET0_TXD2);

request_irq ( pin, &interruptFunction, IRQF_TRIGGER_RISING, ..., NULL );

irqreturn_t interruptFunction (int irq, void *dev_id)

{

     irq handler....

}

The problem is that when there is a rising edge on the ENET0_TXD2 pin nothing happens, i.e. the interrupt function associated to a rising edge on the pin ENET0_TXD2 is never called.

I have repleced pin ENET0_TXD2 with another pin (LCD_HSYNC) and everything works perfectly.


Why with pin ENET_TXD2 the interrupt function is never called?

I have to change some particular setting in the kernel (ethernet driver ecc ecc)?


Do you have any suggestions?


Thanks,

Matteo.

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

340 Views
AnsonHuang
NXP Employee
NXP Employee

Hi, Matteo

     I think you may need to dump the register of this pin's GPIO setting(PINCTRL, including IOMUX and GPIO setting) and interrupt controller's setting(ICOLL). And make sure this pin's irq request is successful, then it should be working, can you dump below register for me(this pin is in bank 4, right?), then I can help you look into it.

HW_PINCTRL_MUXSEL8

HW_PINCTRL_DOE4

HW_PINCTRL_PIN2IRQ4

HW_PINCTRL_IRQEN4

HW_PINCTRL_IRQLEVEL4

HW_PINCTRL_IRQSTAT4

HW_ICOLL_INTERRUPT123

0 Kudos

340 Views
Matteo
Contributor II

Hi Yongcai,

thenks for your reply.

The value of the registers for pin ENET_TXD2 are:

before the command eneble_irq() -->

                                                       HW_PINCTRL_MUXSEL8 = fffc0c00

                                                       HW_PINCTRL_DOE4 = e000

                                                       HW_PINCTRL_PIN2IRQ4 = 1fffff

                                                       HW_PINCTRL_IRQLEVEL4 = 0

                                                       HHW_PINCTRL_IRQPOL4 = 0

                                                       HW_PINCTRL_IRQEN4 = 0

                                                       HW_ICOLL_INTERRUPT123 = 0

                                                       HW_PINCTRL_IRQSTAT4 = 121ff

after the command enable_irq() -->

                                                       HW_PINCTRL_MUXSEL8 = fffc0c00

                                                       HW_PINCTRL_DOE4 = e000

                                                       HW_PINCTRL_PIN2IRQ4 = 1fffff

                                                       HW_PINCTRL_IRQLEVEL4 = 0

                                                       HHW_PINCTRL_IRQPOL4 = 0

                                                       HW_PINCTRL_IRQEN4 = 0

                                                       HW_ICOLL_INTERRUPT123 = 0

                                                       HW_PINCTRL_IRQSTAT4 = 121ff

Bit 11 on the  HW_PINCTRL_IRQEN4 is not set to 1 even if I have enabled the interrupt.


I have tryed to do the same things with the pin LCD_HSYNC (GPIO1_29) and all work properly. It is the register HW_PINCTRL_IRQEN1 before and after the command enable_irq(). You can see that the eneble interrupt bit is set to 1. fo the GPIO1_29.

before     -->     HW_PINCTRL_IRQEN1 = 0

after       -->     HW_PINCTRL_IRQEN1 = 20000000

Do you have any suggestion?

Thanks.

0 Kudos

340 Views
AnsonHuang
NXP Employee
NXP Employee

Hi, Matteo

     The register value matches what I guessed before, the IRQ of pin ENET_TXD2 is not enabled even you have request_irq done. This should be the root cause, but we need to know why it is not enabled after you done all those irq enable/request.

     I am confused that all the GPIO are sharing same driver, so I can NOT understand why this pin is not OK but LCD_HSYNC is OK. So you may need to add some debug info to see what happened.

     Below function you called, I think the gpio_to_irq will called arch/arm/plat-mxs/gpio.c's mxs_gpio_to_irq eventually, and can you check the return value of your code, "pin", and the return value of request_irq function.

pin = gpio_to_irq(ENET0_TXD2);

request_irq ( pin, &interruptFunction, IRQF_TRIGGER_RISING, ..., NULL );

irqreturn_t interruptFunction (int irq, void *dev_id)

{

     irq handler....

}

0 Kudos