Device Tree for FTM0 on i.MX8X

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

Device Tree for FTM0 on i.MX8X

ソリューションへジャンプ
726件の閲覧回数
eduardo3
Contributor III

I am trying to configure FTM0 on a i.MX8X, but I am finding tricky to find examples for the Linux device tree. This is what we have at the moment:

/* Rotary Encoder FTM */
pinctrl_ftm: ftmgrp {
  fsl,pins = <
    IMX8QXP_UART2_RX_ADMA_FTM_CH0 0xC8000040
    IMX8QXP_UART2_TX_ADMA_FTM_CH1 0xC8000040
  >;
};

/ {
        /* ... */
        /* Rotary Encoder */
        counter0: ftm0@5a8a0000 {
		#address-cells = <2>;
		#size-cells = <2>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_ftm>;
                compatible = "fsl,ftm-quaddec";
                reg = <0x0 0x5a8a0000 0x0 0x10000>;
                big-endian;
                status = "okay";
        };
};

 

We can see the driver loading but when turning our rotary button, count remains the same (that under /sys/...)

I also attempted to define a clock for that (not sure if I have to). This is the definitions with a clock:

/* based UART2 */
&dma_subsys {
	ftm0_lpcg: clock-controller@5aca0000 {
		compatible = "fsl,imx8qxp-lpcg";
		reg = <0x5aca0000 0x10000>;
		#clock-cells = <1>;
		clocks = <&clk IMX_SC_R_FTM_0 IMX_SC_PM_CLK_PER>, <&dma_ipg_clk>;
		bit-offset = <0 16>;
		clock-output-names = "ftm0_lpcg_clk", "ftm0_lpcg_ipg_clk";
		power-domains = <&pd IMX_SC_R_FTM_0>;
	};
};

/ {
        /*...*/
        /* Rotary Encoder */
        counter0: ftm0@5a8a0000 {
		#address-cells = <2>;
		#size-cells = <2>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_ftm>;
		clocks = <&ftm0_lpcg 1>, <&ftm0_lpcg 0>;
		clock-names = "ipg", "ftm0";
		assigned-clocks = <&clk IMX_SC_R_FTM_0 IMX_SC_PM_CLK_PER>;
		assigned-clock-rates = <160000000>;
                compatible = "fsl,ftm-quaddec";
                reg = <0x0 0x5a8a0000 0x0 0x10000>;
                big-endian;
                status = "okay";
        };
};

 

The result is the same (count is always 0). This is what I have on Linux:

oot@imx8qxp-d7:/sys/bus/platform/devices/5a8a0000.ftm0# find
.
./uevent
./supplier:platform:scu:pinctrl
./of_node
./power
./power/runtime_active_time
./power/runtime_status
./power/autosuspend_delay_ms
./power/runtime_suspended_time
./power/control
./driver
./supplier:platform:5aca0000.clock-controller
./counter0
./counter0/uevent
./counter0/signal1
./counter0/signal1/signal
./counter0/signal1/name
./counter0/of_node
./counter0/power
./counter0/power/runtime_active_time
./counter0/power/runtime_status
./counter0/power/autosuspend_delay_ms
./counter0/power/runtime_suspended_time
./counter0/power/control
./counter0/num_signals
./counter0/num_counts
./counter0/subsystem
./counter0/signal0
./counter0/signal0/signal
./counter0/signal0/name
./counter0/count0
./counter0/count0/function
./counter0/count0/count
./counter0/count0/signal1_action_available
./counter0/count0/prescaler
./counter0/count0/signal0_action_available
./counter0/count0/function_available
./counter0/count0/prescaler_available
./counter0/count0/signal0_action
./counter0/count0/name
./counter0/count0/signal1_action
./counter0/name
./driver_override
./subsystem
./modalias

 

So what I am looking for is some guidance how to make FTM0 to work or, at least, have a list of what I have to do in order to make it work on Linux.

Regards.

0 件の賞賛
1 解決策
546件の閲覧回数
eduardo3
Contributor III

Since could not use the quadrature decoder phase A and B with imx8qxp, we reconfigured channels 0 and 1 to be GPIOs and we are using the generic rotary-encoder driver.

元の投稿で解決策を見る

0 件の賞賛
4 返答(返信)
547件の閲覧回数
eduardo3
Contributor III

Since could not use the quadrature decoder phase A and B with imx8qxp, we reconfigured channels 0 and 1 to be GPIOs and we are using the generic rotary-encoder driver.

0 件の賞賛
690件の閲覧回数
Sanket_Parekh
NXP TechSupport
NXP TechSupport
Hi @eduardo3 ,
 
Please refer to the below-mentioned documents and drivers for FTM module in kernel source.
-  Documentation/devicetree/bindings/counter/ftm-quaddec.txt
-  Documentation/devicetree/bindings/timer/fsl,ftm-timer.txt
-  drivers/clocksource/timer-fsl-ftm.c
-  drivers/counter/ftm-quaddec.c
 
Clock names are hardcoded in ftm_clk_init(); in drivers/clocksource/timer-fsl-ftm.c
 
Test or example application of FTM for i.MX in Linux BSP is not available yet.
 
Please refer to Table 16-81. FTM signal descriptions in i.MX8DualX/8DualXPlus/8QuadXPlus Applications Processor Reference Manual.
 
One can look at SDK_2_9_0_MEK-MIMX8QX/boards/mekmimx8qx/driver_examples/ftm in MCUExpresso SDK to understand the working of FTM module.
 
Thanks & Regards,
Sanket Parekh
0 件の賞賛
565件の閲覧回数
petero5
Contributor III

PS. @Sanket_Parekh

Looking at i.MX 8DualX/8DualXPlus/8QuadXPlus Applications Processor Reference Manual, Rev. 0, 05/2020

p7599
"Table 16-81 shows the user-accessible signals for the FTM."
I see descriptions of FTM channels CHn (7-0) plus PHA and PHB for the Quadrature Decoder.

However, the following table only has CH0-2, not PHA and PHB?
p654 Table 9-1. Pin Assignments
ADMA_FTM_CH0 UART2_RX ALT1
ADMA_FTM_CH1 UART2_TX ALT1
ADMA_FTM_CH2 FLEXCAN1_RX ALT2

And:
p7198 16.1.2.14 FTM
"Quadrature decoder cannot be used since phase A and B inputs are not available"

Does this mean that after all, for the imx8qxp, the Quadrature decoder (and ftm-quaddec.c) cannot actually be used, because phase A and B inputs cannot actually be pinmuxed to anything? And there is no connection at all between CH0/CH1 and PHA/PHB?

Is there a summary table anywhere showing which i.MX 8 SOCs do/do not support Quadrature decoder please?

Thank you
-- Peter

0 件の賞賛
594件の閲覧回数
petero5
Contributor III

Hi @Sanket_Parekh 

Thank you for the references:
https://github.com/nxp-imx/linux-imx/blob/lf-5.15.y/Documentation/devicetree/bindings/counter/ftm-qu...
https://github.com/nxp-imx/linux-imx/blob/lf-5.15.y/Documentation/devicetree/bindings/timer/fsl,ftm-...
https://github.com/nxp-imx/linux-imx/blob/lf-5.15.y/drivers/clocksource/timer-fsl-ftm.c
https://github.com/nxp-imx/linux-imx/blob/lf-5.15.y/drivers/counter/ftm-quaddec.c

Our board has a rotary encoder on the pins:
IMX8QXP_UART2_RX_ADMA_FTM_CH0
IMX8QXP_UART2_TX_ADMA_FTM_CH1

I've searched google for "IMX8QXP_UART2_RX_ADMA_FTM_CH0" (and separately also "fsl,ftm-quaddec") and this thread seems to be the only example on the internet of anyone trying to use the ftm-quaddec from linux?

To use a rotary encoder with an imx8qxp from linux, is the best way to add a "fsl,ftm-quaddec" node to the device tree?

You also mentioned "fsl,ftm-timer"?
How does that relate to the quaddec please?
Do we need to add both the quaddec and the timer to the device tree, or just the quaddec?
The two devicetree binding files don't seem to mention a connection?

If we do need to add the timer too, that depends on clocks.
But those clocks don't seem to be defined in any of the existing examples in arch/arm64/boot/dts/freescale either?
If needed, where can we learn how to define those clocks please?

Thank you
-- Peter

0 件の賞賛