capture for gpt

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

capture for gpt

5,615 次查看
rainho
Contributor II

Hi!

IMX6ULL in LINUX how to set GPT2 to input capture mode to capture the external PWM signal frequency? I have tried to write a driver for Capture myself, but I cannot trigger a capture interrupt. Please tell me how to configure it correctly.
Please answer any questions. Thank you!

标记 (1)
0 项奖励
回复
17 回复数

5,587 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @rainho 

I hope you are doing well.
 
Time could be used by timer-imx-gpt.c driver. One can refer to the below-mentioned link to implement gpt input capture.
 
One can also refer to below example in SDK to implement input capture in Linux.
/SDK_2.2_MCIM6ULL/boards/evkmcimx6ull/driver_examples/gpt/capture in SDK2.2_iMX6ULL_LINUX
 
Thanks & Regards,
Sanket Parekh
0 项奖励
回复

5,580 次查看
rainho
Contributor II

Thanks for your answer, my friend!
I used Method two, which is already in the attachment file of my post, using JTAG_TMS pin multiplexing CAPTURE1, but could not capture external signals, in other words, capture interrupts did not occur, however, what is the problem, because GPT1 is a Linux system timer, So I'm not going to add capture code for Method one.
Please answer my questions, have a good day!

0 项奖励
回复

5,537 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @rainho,

Please refer to /arch/arm/boot/dts/imx6ul.dtsi and make sure gpt2 node is correctly defined (clocks,interrupts,pinctrl properties) and enabled.
 
One can refer to clocksource/drivers/imx: add input capture support to add capture mode support in /drivers/clocksource/timer-imx-gpt.c driver.
 
Please make a note that JTAG_TMS pad is used for SAI2_MCLK in SAI2 in imx6ull evk dts.
 
Thanks & Regards,
Sanket Parekh
0 项奖励
回复

5,535 次查看
rainho
Contributor II

Thank you for your answer!

I have solved it. I just put the pin of the device tree in the hog pinctrl, but I don't know why I have to put it in this pinctrl-hog. Can you answer my question?

Thank you! Wishing you a happy life

0 项奖励
回复

5,436 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @rainho 

This case is solved. Can I mark this case to close state?

Thanks & Regards

Sanket Parekh

0 项奖励
回复

5,431 次查看
rainho
Contributor II

There is another big question, can you answer my question, it can be captured under the hog node, but the result of custom multiplexing node is not acceptable! It's like I just replied to someone else's file which described what I failed, but I don't understand how the reuse position affects
Thanks

0 项奖励
回复

5,418 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @rainho 

Have you defined the pinctrl property for the gpt2 device node?
-> This issue could be due to the GPT2 capture function's pad could be used by another device. and putting gpio in gpio-hog pinctrl would restrict it for another device (e.g. SAI2 ) to use it.
 
Thanks & Regards,
Sanket Parekh

0 项奖励
回复

5,415 次查看
rainho
Contributor II

Hello, I defined the gpt pinctrl node separately, but I have shielded the sai2 node. Furthermore, I checked my device tree and only the multiplexing node I defined uses capture2, which should not cause any impact.

0 项奖励
回复

5,350 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @rainho 

I hope you are doing well.

Please provide me with boot logs with the highest log level and the whole device file for further debugging.
 
There seems to be typing mistake in the device tree file dev-tree.dts shared by you 
 

pinctrl_gpt2cap: capgrp{
            fsl,pin=<
                          MX6UL_PAD_JTAG_TMS__GPT2_CAPTURE1 0x1b0b1
            >;
};

The node name should be fsl,pins instead of fsl,pin.

Please refer to imx_pinctrl_parse_groups function: line 604 in pinctrl-imx.c , where fsl,pins information is extracted from device tree.
 
Thanks & Regards,
Sanket Parekh
0 项奖励
回复

5,325 次查看
rainho
Contributor II

Then, here's the new driver

0 项奖励
回复

5,212 次查看
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @rainho 

I hope you are doing well.

There seems to be another typing mistake in gpt2 node in the device tree file dev-tree.dts shared by you

&gpt2 {
        compatible = "ainuode,gpt2";
        pinctrl-name = "default";
        pinctrl-0 = <&pinctrl_gpt2cap>;
        clocks = <&clks IMX6UL_CLK_GPT2_BUS>,
                      <&clks IMX6UL_CLK_GPT_3M>;
       clock-names = "ipg", "per";
       // capture-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
      status = "okay";
};
The property name should be pinctrl-names instead of pinctrl-name.
 
Please refer to /drivers/pinctrl/devicetree.c [line: 283] 

Please refer to Drivers needing both pin control and GPIOs at https://www.kernel.org/doc/Documentation/pinctrl.txt

Thanks & Regards,
Sanket Parekh
0 项奖励
回复

5,202 次查看
rainho
Contributor II

Oh, thank you for your answer. It turned out to be caused by my carelessness. I looked for a long time but couldn’t see it. Hey, it’s so difficult!
Thank you again and wish you a happy life!

0 项奖励
回复

5,328 次查看
rainho
Contributor II

Hi,Sanket Parekh!

ok, I overlooked this before, but I still can't capture the interrupt after I changed it, the attachment is my device tree file.

The following is the capture driver startup log I personally wrote:

gpt 20e8000.gpt: res start is 0x20e8000
gpt 20e8000.gpt: gpt->base is a0a68000
gpt 20e8000.gpt: gpt ipgclk is 24000000HZ
gpt 20e8000.gpt: gpt perclk is 3000000HZ

And the register value after starting the work:

gpt 20e8000.gpt: MXC_TCTL is 0x1006b
gpt 20e8000.gpt: V2_IR is 0x28

After checking the manual, there is no wrong configuration register, I hope you can answer my doubts, thank you!

0 项奖励
回复

5,473 次查看
FrankLiu2019
Contributor II

Since the pinctrl_hog_1 node is referenced under the iomuxc node, the iomuxc driver in the Linux kernel automatically initializes all pins under the pinctrl_hog_1 node  . So in the previous program, you might not have initialized the capture pin. I'm also using IMX6ULL GPT2 to capture the PWM ,Could you please show me your gpt_capture.h and the device tree file.I can't find any information about the V2_IR_IM1EN register,did you name it yourself?

0 项奖励
回复

5,446 次查看
rainho
Contributor II

Hello, FrankLiu
The following is the file you want, V2_TCTL_IM1_RISING is what you said to enable input capture, and I have blocked the multiplexing of the hog node in the device tree. The multiplexed IO can not be captured if it is placed in the pinctrl_gpt2cap node defined by itself, and it is replaced by hog It can be captured in the node!
So if it is placed in the node defined by itself, do I need to initialize IO in the gpt_capture.c driver? Do you still need to add IO initialization yourself? If so, how to initialize it?
Thank you for your answer, I hope it can be answered!

0 项奖励
回复

5,411 次查看
FrankLiu2019
Contributor II

Hi rainho 

   GPT2 CAPTURE1 needs to be initialized by gpio subsystem.

,You may need to create a child node under the root node and then use linux API to initialize the IO.I'm debugging this feature and it's not quite done yet.I see your code has comments in Chinese, if you are a Chinese developer, you can add  mywechat,1239543898,We can work on this problem together.

0 项奖励
回复

5,406 次查看
rainho
Contributor II

hi, frankliu!

OK, I added it. Also, this multiplexing function does not require the GPIO subsystem API to intervene. I mentioned it to you before, and it is solved by putting it under the HOG node.

0 项奖励
回复