Skip to content

drivers: pwm: introduce ti_am3352_ecap #88860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

natto1784
Copy link
Contributor

@natto1784 natto1784 commented Apr 21, 2025

This patch adds driver support for TI ECAP module which can capture an external input or work as a standalone APWM generator.

Tested on AM243x EVM using loopback from EPWM (#88757)

@natto1784 natto1784 force-pushed the ecap branch 3 times, most recently from d7eee0f to 90ca724 Compare April 23, 2025 12:25
@natto1784 natto1784 marked this pull request as ready for review April 23, 2025 12:41
@github-actions github-actions bot added area: PWM Pulse Width Modulation platform: TI SimpleLink Texas Instruments SimpleLink MCU labels Apr 23, 2025
This patch adds driver support for TI ECAP module which can capture an
external input or work as a standalone APWM generator.

Signed-off-by: Amneesh Singh <[email protected]>
@natto1784
Copy link
Contributor Author

CC: @gramsay0 @Ayush1325 @glneo - Please feel free to review if and when you get some time.

uint32_t pulse_cycles, pwm_flags_t flags)
{
ARG_UNUSED(channel);
struct ti_ecap_regs *regs = DEV_REGS(dev);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be volatile?
I know it is not used in many other drivers, but I feel like registers should use the volatile keyword.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Individual registers all have volatile keyword in front of them in struct ti_ecap_regs

@kartben kartben requested a review from Copilot May 28, 2025 19:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a new PWM driver for TI ECAP modules to support both capture and APWM operations on TI SoCs.

  • Added a DTS binding file for ti,am3352-ecap.
  • Implemented the driver in drivers/pwm/pwm_ti_am3352_ecap.c with capture and PWM functionalities.
  • Updated Kconfig and CMakeLists.txt to integrate the new driver.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
dts/bindings/pwm/ti,am3352-ecap.yaml Added DTS binding with required properties for the new driver.
drivers/pwm/pwm_ti_am3352_ecap.c New driver implementation handling both PWM and capture modes.
drivers/pwm/Kconfig.ti_am3352_ecap Config file for enabling the TI ECAP based PWM controller.
drivers/pwm/Kconfig Extended to include new Kconfig file for TI ECAP driver.
drivers/pwm/CMakeLists.txt Updated build file to incorporate the new driver source file.
Comments suppressed due to low confidence (2)

drivers/pwm/pwm_ti_am3352_ecap.c:119

  • Casting the pointer 'cycles' from uint64_t* to uint32_t* can potentially truncate the clock rate if it exceeds 32 bits. Consider using a temporary uint32_t variable to retrieve the clock rate, then assign it to *cycles for improved clarity and type safety.
return clock_control_get_rate(cfg->clock_dev, cfg->clock_subsys, (uint32_t *)cycles);

drivers/pwm/pwm_ti_am3352_ecap.c:253

  • [nitpick] The error message would be more helpful if it included the error code or additional details from the pinctrl configuration failure to assist in debugging.
LOG_ERR("Fail to configure pinctrl\n");

@kartben kartben assigned vaishnavachath and unassigned anangl Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: PWM Pulse Width Modulation platform: TI SimpleLink Texas Instruments SimpleLink MCU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants