How to read GPT1 CAPTURE1?

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

How to read GPT1 CAPTURE1?

Jump to solution
2,190 Views
magicarrow98
Contributor II

Hi,

I am working on I.MX8M mini(A53) using linux kernel 4.14.78(debian).

I want to find out the motor speed with the GPT CAPTURE function by connecting a motor encoder to SAI3_RXFS.

This is my device tree.

- fsl-imx8mm.dtsi

gpt1: gpt@302d0000 {
compatible = "fsl,imx8mm-gpt", "fsl,imx7d-gpt";
reg = <0x0 0x302d0000 0x0 0x10000>;
interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk IMX8MM_CLK_GPT1_ROOT>,
<&clk IMX8MM_CLK_GPT1_ROOT>,
<&clk IMX8MM_CLK_GPT_3M>;
clock-names = "ipg", "per", "osc_per";
status = "okay";
};

system_counter: timer@306a0000 {
compatible = "nxp,sysctr-timer";
reg = <0x0 0x306a0000 0x0 0x10000>, /* system-counter-rd base */
<0x0 0x306b0000 0x0 0x10000>, /* system-counter-cmp base */
<0x0 0x306c0000 0x0 0x10000>; /* system-counter-ctrl base */
clock-frequency = <8000000>;
interrupts = <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
};

...

sai3: sai@30030000 {
compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai", "fsl,imx6sx-sai";
reg = <0x0 0x30030000 0x0 0x10000>;
interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk IMX8MM_CLK_SAI3_IPG>,
<&clk IMX8MM_CLK_DUMMY>,
<&clk IMX8MM_CLK_SAI3_ROOT>,
<&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>;
clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
dmas = <&sdma2 4 2 0>, <&sdma2 5 2 0>;
dma-names = "rx", "tx";
status = "disabled";
};

However, in the "I.MX_Reference_Manual.pdf", I.MX8M use the System Counter Timer instead of GPT.

IMX8MMRM.pdf is written for the GPT CAPTURE register, is this not available?

How to enable timer Interrupt in iMX8MQ EVK 

In this question, I use IMX8MQ, can I apply this to my board?

Tags (1)
0 Kudos
1 Solution
2,089 Views
igorpadykov
NXP Employee
NXP Employee

for gpt example one can look at SDK_EVK-MIMX8MM

(folder ../driver_examples/gpt) available on Welcome | MCUXpresso SDK Builder 

Best regards
igor

View solution in original post

4 Replies
2,089 Views
igorpadykov
NXP Employee
NXP Employee

Hi jun

>However, in the "I.MX_Reference_Manual.pdf", I.MX8M use the System Counter Timer instead of GPT.

seems one can use GPT in i.MX8M and i.MX8M Mini, as Mini uses the same driver.

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

0 Kudos
2,089 Views
magicarrow98
Contributor II

Hi igor.

Thank you for your response.

I added the following to the device tree to use the GPT driver.

gpt1: gpt@302d0000 {
compatible = "fsl,imx8mm-gpt", "fsl,imx7d-gpt";
reg = <0x0 0x302d0000 0x0 0x10000>;
interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk IMX8MM_CLK_GPT1_ROOT>,
<&clk IMX8MM_CLK_GPT1_ROOT>,
<&clk IMX8MM_CLK_GPT_3M>;
clock-names = "ipg", "per", "osc_per";
status = "okay";
};

However, I haven't used the GPT driver yet.

Searching gpt in the kernel does not find the device node.

pastedImage_1.png


How can I read the value of GPT1_CAPTURE1 from GPT driver?

0 Kudos
2,090 Views
igorpadykov
NXP Employee
NXP Employee

for gpt example one can look at SDK_EVK-MIMX8MM

(folder ../driver_examples/gpt) available on Welcome | MCUXpresso SDK Builder 

Best regards
igor

2,090 Views
magicarrow98
Contributor II

Thanks, igor.

Your answer was very helpful.

But still I don't know how to do GPT CAPTURE.

In my opinion, I need to add gpt1 to device tree and register MX8MM_IOMUXC_SAI3_RXFS_GPT1_CAPTURE1 in pinctrl so I can use SAI3_RXFS Pin as GPT CAPTURE.

I have only added gpt1 yet and do not know how to register pinctrl.
Can you tell me how to do this?