Skip to content

Conversation

FelixWang47831
Copy link
Contributor

@FelixWang47831 FelixWang47831 commented Sep 1, 2025

For previous code, if timer_mode_sel is set to 0(Time Counter Mode), bypass_prescaler_glitch will be 1-0 = 1, which means the prescaler does not work on time counter mode. But prescaler is very useful, especially for long timing count.

In this PR:

  1. Update prescale_glitch_filter in dts bindings, add 0 in enum and the default value for this property has been changed to 0, to indicate prescaler and glitch filter are disabled.
    Have checked all of device tree settings, the prescaler property are all 1, which means the clock are not prescaled. And in previous driver code, bypass_prescaler_glitch are always 1, the prescaler never works. Therefore this change will not bring running issue for existing boards.

  2. If user sets prescale-glitch-filter properity other than 0, set bypass_prescaler_glitch to false to make prescaler work.

  3. Calculate clock frequency with prescaler setting

@FelixWang47831 FelixWang47831 force-pushed the LPTMR-counter-prescaler-fix branch 2 times, most recently from fb35cd1 to 87c17cb Compare September 1, 2025 09:37
@FelixWang47831 FelixWang47831 changed the title Lptmr counter prescaler fix LPTMR counter prescaler fix Sep 1, 2025
@FelixWang47831 FelixWang47831 marked this pull request as ready for review September 1, 2025 10:19
@zephyrbot zephyrbot added area: Counter platform: NXP Drivers NXP Semiconductors, drivers labels Sep 1, 2025
@FelixWang47831 FelixWang47831 marked this pull request as draft September 2, 2025 09:16
@FelixWang47831 FelixWang47831 force-pushed the LPTMR-counter-prescaler-fix branch 2 times, most recently from a9e7a06 to ae525b2 Compare September 3, 2025 07:09
@FelixWang47831 FelixWang47831 marked this pull request as ready for review September 3, 2025 07:55
@FelixWang47831 FelixWang47831 force-pushed the LPTMR-counter-prescaler-fix branch 3 times, most recently from 16db088 to e2d7251 Compare September 16, 2025 09:48
@FelixWang47831 FelixWang47831 marked this pull request as draft September 16, 2025 10:04
@FelixWang47831 FelixWang47831 force-pushed the LPTMR-counter-prescaler-fix branch 4 times, most recently from 068f3c9 to af34f81 Compare September 16, 2025 14:55
@FelixWang47831 FelixWang47831 marked this pull request as ready for review September 17, 2025 01:29
@mmahadevan108
Copy link
Contributor

mmahadevan108 commented Oct 2, 2025

cc @henrikbrixandersen

@dleach02
Copy link
Member

dleach02 commented Oct 8, 2025

@FelixWang47831 need to address merge conflicts

The lptmr0 has been enabled with default settings defined in
dts/arm/nxp/nxp_rt118x.dtsi. Enable lptmr3 to test with
designated prescaler.

Signed-off-by: Felix Wang <[email protected]>
In current code, if timer-mode-sel is 0(Timer Counter Mode),
bypass_prescaler_glitch will be 1, that makes prescaler setting
be bypassed. But this setting is very useful, especially for
long timing count.

In this patch, we update prescale-glitch-filter default value to 0,
to indicate prescaler and glitch filter are disabled, which comply
the existing devices DTS setting (prescaler = 1).
And if user sets prescale-glitch-filter properity other than 0,
we should set bypass_prescaler_glitch to false to make prescaler work,
and the clock frequence should be calculated with prescaler setting.

Update prescaler field in dt-bindings to tell developer should use
prescale-glitch-filter instead.

Signed-off-by: Felix Wang <[email protected]>
For lptmr counter driver, since "prescaler" has been
deprecated and replaced by prescale-glitch-filter.
Update related setting in device tree files.

Signed-off-by: Felix Wang <[email protected]>
@FelixWang47831 FelixWang47831 force-pushed the LPTMR-counter-prescaler-fix branch from 4e10b32 to ed9c807 Compare October 9, 2025 01:53
@zephyrbot zephyrbot added area: Tests Issues related to a particular existing or missing test area: Devicetree Bindings platform: NXP MCU area: Boards/SoCs labels Oct 9, 2025
@zephyrbot zephyrbot requested a review from nashif October 9, 2025 01:54
Copy link

sonarqubecloud bot commented Oct 9, 2025

@FelixWang47831
Copy link
Contributor Author

@FelixWang47831 need to address merge conflicts

Hi @dleach02 Has fixed conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants