• Paul Cercueil's avatar
    pwm: jz4740: Make PWM start with the active part · a020f22a
    Paul Cercueil authored
    The PWM in Ingenic SoCs starts in inactive state until the internal
    timer reaches the duty value, then becomes active until the timer
    reaches the period value. In theory, we should then use (period - duty)
    as the real duty value, as a high duty value would otherwise result in
    the PWM pin being inactive most of the time.
    
    This is the reason why the duty value was inverted in the driver until
    now, but it still had the problem that it would not start with the
    active part.
    
    To address this remaining issue, the common trick is to invert the
    duty, and invert the polarity when the PWM is enabled.
    
    Since the duty was already inverted, and we invert it again, we now
    program the hardware for the requested duty, and simply invert the
    polarity when the PWM is enabled.
    Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
    Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
    a020f22a
pwm-jz4740.c 7.2 KB