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.