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

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

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

Jump to solution
1,407 Views
nluca
Contributor III

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

Labels (2)
0 Kudos
Reply
1 Solution
866 Views
igorpadykov
NXP Employee
NXP Employee

Hi Luca

reason may be that gpio objects do not exist ar time of timer initialization,

in particular one can look at AN3984 sect.2.2.2 Board Initialization Content

for linux board init process.

Best regards

igor

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

Note: If this post answers your question, please click the Correct Answer button. Thank you!

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

View solution in original post

0 Kudos
Reply
1 Reply
867 Views
igorpadykov
NXP Employee
NXP Employee

Hi Luca

reason may be that gpio objects do not exist ar time of timer initialization,

in particular one can look at AN3984 sect.2.2.2 Board Initialization Content

for linux board init process.

Best regards

igor

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

Note: If this post answers your question, please click the Correct Answer button. Thank you!

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

0 Kudos
Reply