AnsweredAssumed Answered

Both Epit and GPT timers running on i.MX6S with Linux

Question asked by Luca Noga on Apr 23, 2015
Latest reply on Apr 23, 2015 by igorpadykov

Hi Community,

I'm currently working with a custom board having mounted the i.MX6 Solo. I need to toggle a pin every 30 ms and I am going to use a timer for the purpose. I've managed to have both the EPIT and the GPT timers working in the i.MX6S, modifying the kernel code.

 

If something goes wrong on the EPIT timer (some code bug), the kernel fails to boot up, so I guess the EPIT is now the system timer. The GPT is then the timer I can modify for my needings (external pin toggling). Unfortunately I can't use the Output Compare functionality because the SD1_CMD signal is used in the SOM for connection to eMMC and hence it is not available outside the SOM.

 

My idea is to manually toggle a pin from the GPT Interrupt service routine:


int gpt_output_pin_value = 1;


static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id)

{

  struct clock_event_device *evt = &clockevent_mxc;

  uint32_t tstat;

 

  if (timer_is_v2())

    tstat = __raw_readl(timer_base + V2_TSTAT);

  else

    tstat = __raw_readl(timer_base + MX1_2_TSTAT);

 

  gpio_set_value(OUTPUT_PIN_GPT, gpt_output_pin_value);

  gpt_output_pin_value = ~gpt_output_pin_value;

 

  gpt_irq_acknowledge();

  evt->event_handler(evt);

  return IRQ_HANDLED;

}


The problem is that I get an error while requesting a gpio pin and setting the output direction during the timer initialization code (mxc_timer_init), so the pin write/read functions inside the GPT ISR are not taking place.


So the question is: why can't I call gpio_request() function at the timer initialization and how can I solve the problem of require/write a gpio pin manually?


Thanks,

Luca

Outcomes