[PATCH v8 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]> --- v7->v8: * No change. 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 47be358cd749..a5f85a510dee 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; }; @@ -293,7 +294,7 @@ static int rzg2l_gpt_round_waveform_tohw(struct pwm_chip *chip, wfhw->prescale = rzg2l_gpt->prescale[ch]; } } else { - wfhw->prescale = rzg2l_gpt_calculate_prescale(period_ticks); + wfhw->prescale = info->calculate_prescale(period_ticks); rzg2l_gpt->prescale[ch] = wfhw->prescale; } @@ -507,6 +508,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