capture for gpt

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

capture for gpt

4,398件の閲覧回数
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 返答(返信)

4,370件の閲覧回数
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 件の賞賛
返信

4,363件の閲覧回数
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 件の賞賛
返信

4,320件の閲覧回数
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 件の賞賛
返信

4,318件の閲覧回数
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 件の賞賛
返信

4,219件の閲覧回数
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 件の賞賛
返信

4,214件の閲覧回数
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 件の賞賛
返信

4,201件の閲覧回数
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 件の賞賛
返信

4,198件の閲覧回数
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 件の賞賛
返信

4,133件の閲覧回数
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 件の賞賛
返信

4,108件の閲覧回数
rainho
Contributor II

Then, here's the new driver

0 件の賞賛
返信

3,995件の閲覧回数
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 件の賞賛
返信

3,985件の閲覧回数
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 件の賞賛
返信

4,111件の閲覧回数
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 件の賞賛
返信

4,256件の閲覧回数
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 件の賞賛
返信

4,229件の閲覧回数
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 件の賞賛
返信

4,194件の閲覧回数
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 件の賞賛
返信

4,189件の閲覧回数
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 件の賞賛
返信