I am using the FlexTime Module (FTM) as defined in Chapter 21 of the LS1021A Reference Manual Rev. 0. I need to configure the part to use FTM6 as a 32-bit Up counter driven by an external clock source with no prescalar. FTM6 will be chained to FTM2 to get the full 32 bit counter. The FTM will be used as a counter for an external precision clock source and is not driving any PWM signals.
Currently, I am using the kernel driver fsl_ftm_timer. However, I do not see how this driver can be configured to meet my requirements.
In order to drive FTM6 from an external clock source, bits 27-28 of FTMx_SC must be set high. This can be achieved in the driver by masking the value and writing directly into the register. However, the driver currently defines and uses two clocks, 'ftm-evt' and 'ftm-src'.
1.) Can I define an external clock source in the device tree that can be set as one of these clock fields in the driver? Or should I instead do a bitmask and set the FTMx_SC register manually? If I use a bitmask, are the other clocks still necessary?
Next, I need to chain FTM6 and FTM2 together by setting SCFG_FTM_CHAIN_CONFIG bit 17. Again, this can be done with a bitmask in the driver.
2.) Does the fsl-ftm-timer driver have a built-in mechanism for setting the SCFG_FTM_CHAIN_CONFIG register or does this need to be added in?
3.) What is the correct register value for FTMx_QDCTRL to configure PHA and PHB as FTM6 and FTM2? Is there another register that must also be set for chaining?
The following code snippet outlines my current device tree entires for FTM2 and FTM6. I added support to set the FTM Channel and prescale value through the device tree into the driver. I am unsure if this is on the right path or not, but it outlines the general concept.
ftm2: ftm2@29e0000 {
compatible = "fsl,ftm-timer";
reg = <0x0 0x29e0000 0x0 0x10000>;
clock-names = "????";
clocks = <????>;
ftm-chn = "FTM_CHN2"; /* Chain FTM2 & FTM6 */
prescale = <0>; /* Divide by 1 */
ftm6: ftm6@2a20000 {
compatible = "fsl,ftm-timer";
reg = <0x0 0x2a20000 0x0 0x10000>;
clock-names = "ftm-ext", "ftm-ext-counter-en"; /* Use external clock source */
clocks = <&ext_clk>;
ftm-chn = "FTM_CHN2"; /* Chain FTM2 & FTM6 */
prescale = <0>; /* Divide by 1 */
};
Thank you,
Josh Kurland
We have very similar support case, as far as I can understand this case is opened by your FAE. This case is supported by factory application engineering team. I see this case is answered already.