[PATCH v7 5/9] pwm: rzg2l-gpt: Add calculate_prescale() callback to struct rzg2l_gpt_info
Biju <[email protected]>
| Newsgroups | org.kernel.vger.linux-renesas-soc,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pwm |
|---|---|
| Message-ID | <[email protected]> |
From: Biju Das <[email protected]> The RZ/G2L GPT prescaler steps are continuous powers of 4, while RZ/G3E uses powers of 2 but with a discontinuous sequence. Add a calculate_prescale function pointer to struct rzg2l_gpt_info to allow per-SoC prescaler selection logic. Replace the direct call to rzg2l_gpt_calculate_prescale() in rzg2l_gpt_round_waveform_tohw() with an indirect call through info->calculate_prescale(). Wire the existing rzg2l_gpt_calculate_prescale() into rzg2l_data to preserve current RZ/G2L behaviour. Reviewed-by: Tommaso Merciai <[email protected]> Signed-off-by: Biju Das <[email protected]> --- v6->v7: * No change. v5->v6: * No change. v4->v5: * Updated commit description. v3->v4: * No change. v2->v3: * No change. v1->v2: * Collected tag. --- drivers/pwm/pwm-rzg2l-gpt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index fc77c27f0a97..2a1c5a22484b 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -78,6 +78,7 @@ #define RZG2L_MAX_TICKS ((u64)U32_MAX * RZG2L_MAX_SCALE_FACTOR) struct rzg2l_gpt_info { + u8 (*calculate_prescale)(u64 period); u32 gtcr_tpcs; u8 prescale_mult; }; @@ -291,7 +292,7 @@ static int rzg2l_gpt_round_waveform_tohw(struct pwm_chip *chip, period_ticks = rzg2l_gpt->period_ticks[ch]; } } else { - wfhw->prescale = rzg2l_gpt_calculate_prescale(period_ticks); + wfhw->prescale = info->calculate_prescale(period_ticks); } wfhw->gtpr = rzg2l_gpt_calculate_pv_or_dc(info, period_ticks, wfhw->prescale); @@ -498,6 +499,7 @@ static int rzg2l_gpt_probe(struct platform_device *pdev) } static const struct rzg2l_gpt_info rzg2l_data = { + .calculate_prescale = rzg2l_gpt_calculate_prescale, .gtcr_tpcs = RZG2L_GTCR_TPCS, .prescale_mult = 2, }; -- 2.43.0