Configuration of general purpose timers (GPT) in the device tree

Hi all,

I would like to use two timers on my custom carrier board for the Colibri IMX7D 1GB and I therefore have to modify the device tree. This is what I plan to configure:

  • Timer GPT1 (mainly to divide an input frequency and put it on an output):

    SODIMM pin 93 as GPT1.COMPARE1
    SODIMM pin 60 as GPT1.CLK

  • Timer GPT4 (used to get a precise time pulse from a GPS module)


Modifying the device tree and creating a new image (based on torizon-core-docker-colibri-imx7-emmc-Tezi_5.6.0+build.13) is not a problem, I already successfully made a number of changes for my board.
But I don’t have any clue on how to define the timers in the device tree or how to use them from C/C++.

=> Could you give me any hints on how to declare them in the device tree?

=> Are there any examples on how to use them from C/C+?

Any help is welcome !

Best regards,

Greetings @ompie,

The GPT sub-system isn’t something we have a whole lot of experience with ourselves, but I did some research on this and here’s what I was able to find.

In the Linux kernel source itself we have the following:

As for user-space examples of using GPT, information was more scarce. Nevertheless here’s what I was able to find:

  • NXP forum post with attached code and firmware guide regarding GPT. However this was for the i.MX6 not the i.MX7. While similar there’s for sure some differences here and there. Strangely enough I could not find a public firmware guide for the i.MX7. Perhaps this is something that can be asked/requested from NXP: Solved: iMX6 General Purpose Timer - NXP Community
  • Other than this there’s also the i.MX7 reference manual and the i.MX Linux Reference manual. Both these documents can be downloaded from NXP and contain some information on GPT. Though the information is a bit higher level and doesn’t include many actual code examples.

This is the information I was able to find publicly. Perhaps inquiring NXP about i.MX7 GPT on their forums may yield more information. They may have code samples and such lying around as they did for the i.MX6 as seen in the other forum post.

Best Regards,

Thanks Jeremias,

I’ll have a look at the proposed links and will do some research et NXP.
At least there is a base definition for the GPTs in Toradex’s device trees so with a bit of luck, there is no need to fiddle them.

Best regards,

If you do happen to find or get any additional information on this topic from NXP please do share. It would be appreciated since information on this topic isn’t very well documented publicly.

Best Regards,

I promise I’ll share my experience when I get the timer running!