Application: We want to use GPIOs with rising & falling edge interrupt on M7.
Problem:
It works when we halt uboot and run M7 binary. But when we boot with linux, Linux kernel panics.
So, we have disable unused and conflicting GPIOs from Device Tree. But the problem still occures. (Note: We cannot block whole “&gpio” node in device tree, as other hardware peripherals are using some gpio pins. some with interrupt and some without interrupt.)
Then we have used RDC with RDC_SEMA42 to temporary lock GPIO Port access on Linux.
Now, what happens is that, when interrupt gets from specific pins, M7 and A53 both calls IRQ. As a result, Linux kernel panics beacause we have blocked GPIO Port access from RDC. Linux Terminal Output is as follows:
Can we use GPIO pins as interrupt on M7?(It is possible, but I want to know it is advisable or not because A53 is also using IRQ and it will conflict if both will try to access IRQ Register at a same time.)
Do I have to make any changes to Linux Kernel Source Code to make it work?
Since I am using RDC as semaphone, do I have to configure Linux Source to make RDC (as semaphone) work properly on A53 ?
Machine Details: Toradex Verdin iMX8M Plus WB 1.1A on Verdin Development Board
Linux Kernel Details: Linux version 5.4.193-5.7.2-devel+git.b60d3160fd04 (oe-user@oe-host) (gcc version 9.5.0 (GCC)) #1 SMP PREEMPT Fri Dec 23 15:47:24 UTC 2022
indeed you have to disable whole &gpio, especially when using interrupts. Linux GPIO driver will choke when it will see unexpected interrupt, which Linux didn’t enable. Either find a way if any to make this interrupt not reaching Linux or disable whole &gpio. You could as well make Linux ignoring that unexpected interrupt, but then what’s the point to moving it to CM, Linux performance still may suffer handling this unexpected interrupt.
It would be the best to to figure which &gpio bank can be dedicated to CM only and use pins from that bank on CM.
There’s as well partially finished gpio-rpmsg driver (primarily done for imx7ulp, for which NXP finally noticed the need for better sharing GPIO module between Cortex-M and CA. ). Using that driver you could disable real &gpio on Linux and define another one &gpio, which would send RPMSG messages instead of direct I/O to GPIO, Cortex-M will do physical writes/reads to GPIO and send RPMSG messages to CA when interrupt happens. All GPIO pins references from disabled &gpio could be easily remapped to virtual GPIO. libgpiod with Linux gpio-imx-rpmsg.c driver
There are many challanges we have to face when we modify kernel and every time we want to upgrade OS, we have to repeatedly modify and test the kernel.
So, It can be our last option if we couldn’t find easy solution.
It is the best option.
But would be challenging. I need more than 40 GPIOs. So, I have to disable atleast 2 GPIO nodes.
To make it possible, I have to change hardware routing of other peripherels.
Yes, not fully finished and not populated to other SDK’s. I guess only imx7ulp SDK supports it. And RPMSG GPIO stuff in that SDK is hard to separate from other code… But that’s the way to go if you really need to share CM-CA un-shareable GPIO.
If on Linux you don’t need any GPIO interrupts for particular GPIO bank, then you could just remove interrupt assignments in device tree for that bank.
On iMX7 (I hope on iMX8M as well, i don’t know), each &gpio has two interrupts, one for 0-15 pins and another one for 16-31. Current Linux GPIO driver will work if you just remove 2nd interrupt. Driver will think that just 16 pins are available in the bank. So that you could use those 16-31 pins on CM. Unfortunately interrupt order can’t be swapped without driver mods.
Clearly NXP should redesign GPIO to let dedicate every single GPIO to CM or CA. Write access should be restricted to one side, read access should be allowed to both sides.
Thanks @EdwardThis solves our problem!
There are many ways to solve this issue but my team found this easy.
We have to changes routing of our Custom Carrier Board and disable whole banks - &gpio3 and &gpio4 in Device Tree to make GPIO Interrupt work on Cortex-M7.