Capture with DMTimer, get the Edge of the Trigger

Hello!

I try to create a Kernel driver which uses the DMTimer capture mode to catch triggers on the GPIO of the timer. Therefore I use timer4 PIN (P8.7). For this driver I basicly use the Code of Dan Drowns pps-gmtimer [1].

In the initialization of the timer I changed the catch mode from OMAP_TIMER_CTRL_TCM_LOWTOHIGH to OMAP_TIMER_CTRL_TCM_BOTHEDGES:

ctrl = __omap_dm_timer_read(timer, OMAP_TIMER_CTRL_REG, timer->posted);
ctrl &= ~(OMAP_TIMER_CTRL_PRE | (0x07 << 2));
ctrl |= OMAP_TIMER_CTRL_AR;
__omap_dm_timer_write(timer, OMAP_TIMER_LOAD_REG, 0, timer->posted);

ctrl |= OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_TCM_BOTHEDGES | OMAP_TIMER_CTRL_GPOCFG;

__omap_dm_timer_load_start(timer, ctrl, 0, timer->posted);

In the interrupt routine I also want to save the edge of the trigger. My first question: Does the DMTimer somehow save the trigger reason? In the documentation of the Sitara AM335x I can’t find any register of the DMTimer where this might be stored.

For now I put the signal also to another GPIO and read out the value of that GPIO at the timer the interrupt happens. But I think I might miss a edge.

Another way of distiguishing the edges I thought of was to set the trigger to “OMAP_TIMER_CTRL_TCM_LOWTOHIGH” first and then to reconfigure it to “OMAP_TIMER_CTRL_TCM_HIGHTOLOW” (or vice versa) in the interrupt routine. My second and third question: Is this possible? And: Can I keep the timer value if I do that?

Thanks for the help,
Christoph

[1] https://github.com/ddrown/pps-gmtimer