summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>2025-11-21 13:49:48 +0300
committerUwe Kleine-König <ukleinek@kernel.org>2026-01-20 20:38:05 +0300
commitaa12c7e70319c9746e55e5b00a215119ba838dad (patch)
tree1f2ebaa26b8c97005a488c625b4c8dabeddd87f7
parent85a5ffbd56b236e96a7a22a631f9febf36d7ead5 (diff)
downloadlinux-aa12c7e70319c9746e55e5b00a215119ba838dad.tar.xz
pwm: Emit native configuration in /sys/kernel/debug/pwm
Currently there are two abstractions for PWM drivers. Use the waveform representation for the drivers that support it as this is more expressive and so tells more about the actual hardware state. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://patch.msgid.link/20251121104947.2652013-2-u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
-rw-r--r--drivers/pwm/core.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index ec8731515333..41fd3a9b2883 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -2638,10 +2638,10 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
for (i = 0; i < chip->npwm; i++) {
struct pwm_device *pwm = &chip->pwms[i];
- struct pwm_state state, hwstate;
+ struct pwm_state state;
+ int err;
pwm_get_state(pwm, &state);
- pwm_get_state_hw(pwm, &hwstate);
seq_printf(s, " pwm-%-3d (%-20.20s):", i, pwm->label);
@@ -2657,9 +2657,26 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
seq_puts(s, ", usage_power");
seq_puts(s, "\n");
- seq_printf(s, " actual configuration: %3sabled, %llu/%llu ns, %s polarity",
- hwstate.enabled ? "en" : "dis", hwstate.duty_cycle, hwstate.period,
- hwstate.polarity ? "inverse" : "normal");
+ if (pwmchip_supports_waveform(chip)) {
+ struct pwm_waveform wf;
+
+ err = pwm_get_waveform_might_sleep(pwm, &wf);
+ if (!err)
+ seq_printf(s, " actual configuration: %lld/%lld [+%lld]",
+ wf.duty_length_ns, wf.period_length_ns, wf.duty_offset_ns);
+ else
+ seq_printf(s, " actual configuration: read out error: %pe\n", ERR_PTR(err));
+ } else {
+ struct pwm_state hwstate;
+
+ err = pwm_get_state_hw(pwm, &hwstate);
+ if (!err)
+ seq_printf(s, " actual configuration: %3sabled, %llu/%llu ns, %s polarity",
+ hwstate.enabled ? "en" : "dis", hwstate.duty_cycle, hwstate.period,
+ hwstate.polarity ? "inverse" : "normal");
+ else
+ seq_printf(s, " actual configuration: read out error: %pe", ERR_PTR(err));
+ }
seq_puts(s, "\n");
}