Skip to content

Commit fa829c1

Browse files
ukleinekUwe Kleine-König
authored andcommitted
pwm: stm32: Emit debug output also for corner cases of the rounding callbacks
When you're interested in the actual register settings the driver chooses or interprets you want to see them also for calls that hit corner cases. Make sure that all calls to stm32_pwm_round_waveform_tohw() and stm32_pwm_round_waveform_fromhw() emit the debug message about the register settings. Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/fe154e79319da5ff4159cdc71201a9d3b395e491.1743844730.git.u.kleine-koenig@baylibre.com [ukleinek: widen scope of rate in stm32_pwm_round_waveform_fromhw() to fix FTBFS] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 4cbeffc commit fa829c1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/pwm/pwm-stm32.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ static int stm32_pwm_round_waveform_tohw(struct pwm_chip *chip,
180180

181181
wfhw->ccr = min_t(u64, ccr, wfhw->arr + 1);
182182

183+
out:
183184
dev_dbg(&chip->dev, "pwm#%u: %lld/%lld [+%lld] @%lu -> CCER: %08x, PSC: %08x, ARR: %08x, CCR: %08x\n",
184185
pwm->hwpwm, wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns,
185186
rate, wfhw->ccer, wfhw->psc, wfhw->arr, wfhw->ccr);
186187

187-
out:
188188
clk_disable(priv->clk);
189189

190190
return ret;
@@ -213,10 +213,10 @@ static int stm32_pwm_round_waveform_fromhw(struct pwm_chip *chip,
213213
{
214214
const struct stm32_pwm_waveform *wfhw = _wfhw;
215215
struct stm32_pwm *priv = to_stm32_pwm_dev(chip);
216+
unsigned long rate = clk_get_rate(priv->clk);
216217
unsigned int ch = pwm->hwpwm;
217218

218219
if (wfhw->ccer & TIM_CCER_CCxE(ch + 1)) {
219-
unsigned long rate = clk_get_rate(priv->clk);
220220
u64 ccr_ns;
221221

222222
/* The result doesn't overflow for rate >= 15259 */
@@ -236,17 +236,16 @@ static int stm32_pwm_round_waveform_fromhw(struct pwm_chip *chip,
236236
wf->duty_length_ns = ccr_ns;
237237
wf->duty_offset_ns = 0;
238238
}
239-
240-
dev_dbg(&chip->dev, "pwm#%u: CCER: %08x, PSC: %08x, ARR: %08x, CCR: %08x @%lu -> %lld/%lld [+%lld]\n",
241-
pwm->hwpwm, wfhw->ccer, wfhw->psc, wfhw->arr, wfhw->ccr, rate,
242-
wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns);
243-
244239
} else {
245240
*wf = (struct pwm_waveform){
246241
.period_length_ns = 0,
247242
};
248243
}
249244

245+
dev_dbg(&chip->dev, "pwm#%u: CCER: %08x, PSC: %08x, ARR: %08x, CCR: %08x @%lu -> %lld/%lld [+%lld]\n",
246+
pwm->hwpwm, wfhw->ccer, wfhw->psc, wfhw->arr, wfhw->ccr, rate,
247+
wf->duty_length_ns, wf->period_length_ns, wf->duty_offset_ns);
248+
250249
return 0;
251250
}
252251

0 commit comments

Comments
 (0)