[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251128003634.247529-1-rafael.v.volkmer@gmail.com>
Date: Thu, 27 Nov 2025 21:36:25 -0300
From: "Rafael V. Volkmer" <rafael.v.volkmer@...il.com>
To: ukleinek@...nel.org
Cc: linux-kernel@...r.kernel.org,
linux-pwm@...r.kernel.org,
rafael.v.volkmer@...il.com
Subject: [PATCH v7 0/9] pwm: tiehrpwm: prepare for waveform callbacks
Hello,
in a previous discussion about pwm-tiehrpwm I agreed to rework the
driver towards the new waveform callbacks and eventually drop the
legacy .apply()/.get_state() ones. Before doing that larger conversion,
this v7 series focuses on two narrower goals:
- clean up and regularise the register and bitfield handling so that
the driver is easier to reason about and better suited for the
upcoming waveform callbacks; and
- fix a bug where the driver assumes both channels are
disabled at probe time and does not correctly account for channels
that are already running when Linux attaches to the eHRPWM block.
The series is based on v6.18-rc7.
The series is structured as follows:
-------
- Patches 1-3 prefix the register and field definitions with
TIEHRPWM_ and convert the TBCTL, AQCTL, AQSFRC and AQCSFRC fields
to GENMASK()/FIELD_PREP()-based helpers.
- Patch 4 derives the PERIOD_MAX limit from the TBPRD field using the
new TIEHRPWM_TBPRD_TBPRD definition, instead of an open-coded
constant.
- Patch 5 refactors the TBCTL prescaler handling to use FIELD_PREP()
for the CLKDIV and HSPCLKDIV fields and updates both in a single
ehrpwm_modify() call.
- Patches 6 and 7 factor out the Action-Qualifier force codes and
polarity presets into named constants and then unify the AQCTL setup
for channels A and B, including the compare-down configuration.
- Patch 8 is a small style-only cleanup in the period conflict check.
- Patch 9 fixes the probe-time handling of channels that were already
enabled when the driver attaches and balances both tbclk and runtime
PM references for them.
Patches 1-8 are intended to be no functional change and only improve the
structure and readability of pwm-tiehrpwm, providing a cleaner base for
the upcoming waveform callback conversion. Patch 9 is a functional fix
for the probe-time handling of already running channels.
Testing
-------
These patches have been tested on a TI AM623 EVM board.
For the probe-time behaviour, the scenario where a channel is configured
and enabled by firmware before the driver is probed was exercised using
U-Boot as the bootloader to pre-program and enable the eHRPWM channel
prior to handing control to Linux.
Follow-up
---------
As a follow-up to this series, I plan to send a separate set of patches
that converts pwm-tiehrpwm to the new PWM waveform callbacks and drops
the legacy .apply()/.get_state() callbacks, building directly on top of
the refactored code in this v7. Keeping the refactoring and the API
conversion separate should make both series easier to review.
-------------
Feedback on the structure of this series, or on further splitting /
squashing before the waveform callback work, is very welcome.
Thanks for your time and review.
Best regards,
Rafael V. Volkmer
Rafael V. Volkmer (9):
pwm: tiehrpwm: prefix register and field definitions
pwm: tiehrpwm: drop _MASK suffix from TBCTL PRDLD field
pwm: tiehrpwm: use GENMASK() and FIELD_PREP() for register fields
pwm: tiehrpwm: derive PERIOD_MAX from TBPRD field
pwm: tiehrpwm: use FIELD_PREP() for prescaler fields
pwm: tiehrpwm: factor out AQ force codes and polarity presets
pwm: tiehrpwm: unify AQ setup and cover compare-down events
pwm: tiehrpwm: tidy period conflict check
pwm: tiehrpwm: handle already-running channels at probe
drivers/pwm/pwm-tiehrpwm.c | 428 ++++++++++++++++++++++++-------------
1 file changed, 278 insertions(+), 150 deletions(-)
--
2.43.0
Powered by blists - more mailing lists