mfd: rz-mtu3: Fix MTU5 timer start register offset
PATCH 1/1 mfd: rz-mtu3: Fix MTU5 timer start register offset
rz_mtu3_get_tstr_offset() returns RZ_MTU3_TSTR for MTU5, which is the index of TSTR in rz_mtu3_8bit_ch_reg_offs[], not a register offset. rz_mtu3_start_stop_ch() and rz_mtu3_is_enabled() pass the result to the shared register helpers, which add it to the MMIO base directly. For MTU5 they therefore access offset 0x002, which is TMDR1 of MTU3, instead of TSTR at offset 0xab4.
Reproduced on RZ/G2L SMARC with MTU3 in PWM mode 1 on MTIOC3A and a temporary debugfs hook calling rz_mtu3_enable()/rz_mtu3_disable() on MTU5:
TMDR1 (MTU3) TSTR (MTU5) initial 0x02 0x00 MTU5 start, before fix 0x06 0x00 MTU5 start, after fix 0x02 0x04
Before the fix, starting MTU5 switches MTU3 out of PWM mode 1 while MTU5 itself never starts, and rz_mtu3_is_enabled() still reports MTU5 as running.
Look up the real offset in rz_mtu3_8bit_ch_reg_offs[].
No in-tree user starts or stops MTU5 today.
--- drivers/mfd/rz-mtu3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/rz-mtu3.c +1 -1
@@ -196,7 +196,7 @@ static u16 rz_mtu3_get_tstr_offset(struct rz_mtu3_channel *ch) offset =RZ_MTU3_TSTRA ;break ;case RZ_MTU3_CHAN_5 : - offset =RZ_MTU3_TSTR ; + offset = rz_mtu3_8bit_ch_reg_offs[RZ_MTU3_CHAN_5 ][RZ_MTU3_TSTR ];break ;case RZ_MTU3_CHAN_6 :case RZ_MTU3_CHAN_7 :
base-commit: ebb7a8dc1e74c705daffe11c2faf38ec2628f838
Signature · 1 line
2.25.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 20 lines
rz_mtu3_get_tstr_offset()returnsRZ_MTU3_TSTRfor MTU5, which is the index of TSTR in rz_mtu3_8bit_ch_reg_offs[], not a register offset.rz_mtu3_start_stop_ch()andrz_mtu3_is_enabled()pass the result to the shared register helpers, which add it to the MMIO base directly. For MTU5 they therefore access offset0x002, which is TMDR1 of MTU3, instead of TSTR at offset0xab4.Reproduced on RZ/G2L SMARC with MTU3 in PWM mode 1 on MTIOC3A and a temporary debugfs hook calling rz_mtu3_enable()/rz_mtu3_disable() on MTU5:
TMDR1 (MTU3) TSTR (MTU5) initial 0x02 0x00 MTU5 start, before fix 0x06 0x00 MTU5 start, after fix 0x02 0x04Before the fix, starting MTU5 switches MTU3 out of PWM mode 1 while MTU5 itself never starts, and
rz_mtu3_is_enabled()still reports MTU5 as running.
Quoted 6 lines
Look up the real offset in rz_mtu3_8bit_ch_reg_offs[].
No in-tree user starts or stops MTU5 today.
Fixes 654c293e1687 ("mfd: Add Renesas RZ/G2L MTU3a core driver")Signed-off-by Nhat Tran <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1