mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keguang Zhang via B4 Relay <devnull+keguang.zhang.gmail.com@kernel.org>
To: "Binbin Zhou" <zhoubinbin@loongson.cn>,
	"Uwe Kleine-König" <ukleinek@kernel.org>
Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Keguang Zhang <keguang.zhang@gmail.com>,
	stable@vger.kernel.org
Subject: [PATCH v4 0/3] pwm: loongson: Fix PWM configuration handling
Date: Sun, 20 Sep 2026 20:02:05 +0800	[thread overview]
Message-ID: <20260920-pwm-loongson-fix-v4-0-41b36b3c6497@gmail.com> (raw)

This series fixes two issues in the Loongson PWM driver:

- Fix the handling of the Low Pulse Buffer Register, which was
  incorrectly treated as a duty-cycle register.

- Reset the PWM counters before enabling to ensure that
  the PWM starts from a known state.

It also includes a follow-up rework:

- Use field helpers for period validation.

The whole patchset was verified on LS1B, LS1C, and LS2K0300 boards.

Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
Changes in v4:
- Split the period validation rework into a separate patch from the
  functional fixes.
- Limit the duty cycle to the period before calculating the low pulse.
- Add a fix to reset the PWM counters before enabling, as suggested by
  Uwe Kleine-König.
- Drop v3 patch 2/3 (0de9b836a3bc), which has already been applied to
  pwm/for-next.
- Link to v3: https://lore.kernel.org/r/20260715-pwm-loongson-fix-v3-0-0aab2847eaa7@gmail.com

Changes in v3:
- Calculate the low pulse as period - duty after rounding the duty cycle.
- Handle LOW > PERIOD in pwm_loongson_get_state().
- Add a Fixes tag to the second patch.
- Link to v2: https://lore.kernel.org/r/20260626-pwm-loongson-fix-v2-0-5492db953879@gmail.com

Changes in v2:
- Drop the -ERANGE return change and restore the original behavior.
- Use mul_u64_u64_div_u64_roundup() to calculate the low pulse width.
- Update the commit message accordingly.
- Link to v1: https://lore.kernel.org/r/20260616-pwm-loongson-fix-v1-0-491dbf260a7f@gmail.com

---
Keguang Zhang (3):
      pwm: loongson: Fix low pulse buffer register handling
      pwm: loongson: Reset the counters before enabling PWM
      pwm: loongson: Use field helpers for period validation

 drivers/pwm/pwm-loongson.c | 44 ++++++++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 14 deletions(-)
---
base-commit: 17dbb6938d3ab444cd6be1c95506450595a8800d
change-id: 20260612-pwm-loongson-fix-183763451e93

Best regards,
-- 
Keguang Zhang <keguang.zhang@gmail.com>



             reply	other threads:[~2026-09-20 12:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20 12:02 Keguang Zhang via B4 Relay [this message]
2026-09-20 12:02 ` [PATCH v4 1/3] pwm: loongson: Fix low pulse buffer register handling Keguang Zhang via B4 Relay
2026-11-30 15:55   ` Uwe Kleine-König
2026-09-20 12:02 ` [PATCH v4 2/3] pwm: loongson: Reset the counters before enabling PWM Keguang Zhang via B4 Relay
2026-11-30 16:10   ` Uwe Kleine-König
2026-09-20 12:02 ` [PATCH v4 3/3] pwm: loongson: Use field helpers for period validation Keguang Zhang via B4 Relay
2026-11-30 16:03   ` Uwe Kleine-König
2026-11-30 16:04     ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260920-pwm-loongson-fix-v4-0-41b36b3c6497@gmail.com \
    --to=devnull+keguang.zhang.gmail.com@kernel.org \
    --cc=keguang.zhang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ukleinek@kernel.org \
    --cc=zhoubinbin@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®