summaryrefslogtreecommitdiff
path: root/drivers/mfd/mcp-sa11x0.c
diff options
context:
space:
mode:
authorClark Wang <xiaoning.wang@nxp.com>2024-10-08 15:41:23 -0400
committerUwe Kleine-König <ukleinek@kernel.org>2024-10-25 11:42:36 +0200
commita25351e4c7740eb22561a3ee4ef17611c6f410b0 (patch)
tree68cb04db1f2d6f4c8356c4134c6091f35356678c /drivers/mfd/mcp-sa11x0.c
parent15effedc481e69a23b374ba516d73a2bc665abe6 (diff)
downloadlwn-a25351e4c7740eb22561a3ee4ef17611c6f410b0.tar.gz
lwn-a25351e4c7740eb22561a3ee4ef17611c6f410b0.zip
pwm: imx27: Workaround of the pwm output bug when decrease the duty cycle
Implement workaround for ERR051198 (https://www.nxp.com/docs/en/errata/IMX8MN_0N14Y.pdf) PWM output may not function correctly if the FIFO is empty when a new SAR value is programmed. Description: When the PWM FIFO is empty, a new value programmed to the PWM Sample register (PWM_PWMSAR) will be directly applied even if the current timer period has not expired. If the new SAMPLE value programmed in the PWM_PWMSAR register is less than the previous value, and the PWM counter register (PWM_PWMCNR) that contains the current COUNT value is greater than the new programmed SAMPLE value, the current period will not flip the level. This may result in an output pulse with a duty cycle of 100%. Workaround: Program the current SAMPLE value in the PWM_PWMSAR register before updating the new duty cycle to the SAMPLE value in the PWM_PWMSAR register. This will ensure that the new SAMPLE value is modified during a non-empty FIFO, and can be successfully updated after the period expires. Write the old SAR value before updating the new duty cycle to SAR. This avoids writing the new value into an empty FIFO. This only resolves the issue when the PWM period is longer than 2us (or <500kHz) because write register is not quick enough when PWM period is very short. Reproduce steps: cd /sys/class/pwm/pwmchip1/pwm0 echo 2000000000 > period # It is easy to observe by using long period echo 1000000000 > duty_cycle echo 1 > enable echo 8000 > duty_cycle # One full high pulse will be seen by scope Fixes: 166091b1894d ("[ARM] MXC: add pwm driver for i.MX SoCs") Reviewed-by: Jun Li <jun.li@nxp.com> Signed-off-by: Clark Wang <xiaoning.wang@nxp.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> Link: https://lore.kernel.org/r/20241008194123.1943141-1-Frank.Li@nxp.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Diffstat (limited to 'drivers/mfd/mcp-sa11x0.c')
0 files changed, 0 insertions, 0 deletions