30 Dec, 2020

1 commit

  • [ Upstream commit 6eefb79d6f5bc4086bd02c76f1072dd4a8d9d9f6 ]

    Commit d3817a647059 ("pwm: sun4i: Remove redundant needs_delay") changed
    the logic of an else branch so that the PWM_EN and PWM_CLK_GATING bits
    are now cleared if the PWM is to be disabled, whereas previously the
    condition was always false, and hence the branch never got executed.

    This code is reported causing backlight issues on boards based on the
    Allwinner A20 SoC. Fix this by removing the else branch, which restores
    the behaviour prior to the offending commit.

    Note that the PWM_EN and PWM_CLK_GATING bits still get cleared later in
    sun4i_pwm_apply() if the PWM is to be disabled.

    Fixes: d3817a647059 ("pwm: sun4i: Remove redundant needs_delay")
    Reported-by: Taras Galchenko
    Suggested-by: Taras Galchenko
    Tested-by: Taras Galchenko
    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Thierry Reding
    Signed-off-by: Sasha Levin

    Thierry Reding
     

24 Sep, 2020

1 commit


18 Jun, 2020

1 commit


02 Jun, 2020

1 commit


31 Mar, 2020

1 commit


20 Jan, 2020

4 commits

  • GCC can't always determine that the duty, period and prescaler values
    are initialized when returning from sun4i_pwm_calculate(), so help out a
    little by initializing them to 0.

    Signed-off-by: Thierry Reding

    Thierry Reding
     
  • The variable pval is only used in a single block in the function
    sun4i_pwm_calculate(). So declare it in a more local scope to simplify
    the function for humans and compilers.

    While at it also simplify assignment to pval.

    While the diffstat for this patch is negative for this patch I still
    thing the advantage of having a narrower scope is beneficial.

    In my compiler / .config setup (gcc 8.2.1, arm/imx_v6_v7_defconfig +
    COMPILE_TEST + PWM_SUN4I) this change doesn't result in any binary
    changes.

    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Thierry Reding

    Uwe Kleine-König
     
  • Fix inconsistent IS_ERR and PTR_ERR in sun4i_pwm_probe().

    The proper pointers to be passed as arguments are pwm->clk and pwm->bus_clk.

    This bug was detected with the help of Coccinelle.

    Fixes: b8d74644f34a ("pwm: sun4i: Prefer "mod" clock to unnamed")
    Fixes: 5b090b430d75 ("pwm: sun4i: Add an optional probe for bus clock")
    Signed-off-by: Gustavo A. R. Silva
    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Thierry Reding

    Gustavo A. R. Silva
     
  • pwm_calculate() calls clk_get_rate() while holding a spin_lock().

    This create an issue as clk_get_rate() may sleep.

    Move pwm_calculate() out of this spin_lock().

    Fixes: c32c5c50d4fe ("pwm: sun4i: Switch to atomic PWM")
    Reported-by: Alexander Finger
    Sugested-by: Vasily Khoruzhick
    Tested-by: Alexander Finger
    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Clément Péron
    Signed-off-by: Thierry Reding

    Clément Péron
     

08 Jan, 2020

6 commits

  • Now that sun4i PWM driver supports deasserting reset line and enabling
    bus clock, support for H6 PWM can be added.

    Note that while H6 PWM has two channels, only first one is wired to
    output pin. Second channel is used as a clock source to companion AC200
    chip which is bundled into same package.

    Signed-off-by: Jernej Skrabec
    Acked-by: Uwe Kleine-König
    Signed-off-by: Clément Péron
    Signed-off-by: Thierry Reding

    Jernej Skrabec
     
  • PWM core has an option to bypass whole logic and output unchanged source
    clock as PWM output. This is achieved by enabling bypass bit.

    Note that when bypass is enabled, no other setting has any meaning, not
    even enable bit.

    This mode of operation is needed to achieve high enough frequency to
    serve as clock source for AC200 chip which is integrated into same
    package as H6 SoC.

    Signed-off-by: Jernej Skrabec
    Signed-off-by: Clément Péron
    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Thierry Reding

    Jernej Skrabec
     
  • Bypass mode will require to be re-calculated when the pwm state
    is changed.

    Remove the condition so pwm_sun4i_calculate is always called.

    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Clément Péron
    Signed-off-by: Thierry Reding

    Clément Péron
     
  • H6 PWM core needs bus clock to be enabled in order to work.

    Add an optional probe for it.

    Signed-off-by: Jernej Skrabec
    Signed-off-by: Clément Péron
    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Thierry Reding

    Jernej Skrabec
     
  • New device tree bindings called the source clock of the module
    "mod" when several clocks are defined.

    Try to get a clock called "mod" if nothing is found try to get
    an unnamed clock.

    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Clément Péron
    Signed-off-by: Thierry Reding

    Clément Péron
     
  • H6 PWM core needs deasserted reset line in order to work.

    Add an optional probe for it.

    Signed-off-by: Jernej Skrabec
    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Clément Péron
    Signed-off-by: Thierry Reding

    Jernej Skrabec
     

21 Oct, 2019

2 commits

  • Since 5.4-rc1, pwm_apply_state calls ->get_state after ->apply
    if available, and this revealed an issue with integer precision
    when calculating duty_cycle and period for the currently set
    state in ->get_state callback.

    This issue manifested in broken backlight on several Allwinner
    based devices.

    Previously this worked, because ->apply updated the passed state
    directly.

    Fixes: deb9c462f4e53 ("pwm: sun4i: Don't update the state for the caller of pwm_apply_state")
    Signed-off-by: Ondrej Jirman
    Acked-by: Uwe Kleine-König
    Signed-off-by: Thierry Reding

    Ondrej Jirman
     
  • Variable pval is being assigned a value that is never read. The
    assignment is redundant and hence can be removed.

    Addresses-Coverity: ("Unused value")
    Signed-off-by: Colin Ian King
    Signed-off-by: Thierry Reding

    Colin Ian King
     

21 Sep, 2019

2 commits

  • It is surprising for a PWM consumer when the variable holding the
    requested state is modified by pwm_apply_state(). Consider for example a
    driver doing:

    #define PERIOD 5000000
    #define DUTY_LITTLE 10
    ...
    struct pwm_state state = {
    .period = PERIOD,
    .duty_cycle = DUTY_LITTLE,
    .polarity = PWM_POLARITY_NORMAL,
    .enabled = true,
    };

    pwm_apply_state(mypwm, &state);
    ...
    state.duty_cycle = PERIOD / 2;
    pwm_apply_state(mypwm, &state);

    For sure the second call to pwm_apply_state() should still have
    state.period = PERIOD and not something the hardware driver chose for a
    reason that doesn't necessarily apply to the second call.

    So declare the state argument as a pointer to a const type and adapt all
    drivers' .apply callbacks.

    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Thierry Reding

    Uwe Kleine-König
     
  • The pwm-sun4i driver is one of only three PWM drivers which updates the
    state for the caller of pwm_apply_state(). This might have surprising
    results if the caller reuses the values expecting them to still
    represent the same state.

    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Thierry Reding

    Uwe Kleine-König
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    licensed under gplv2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 99 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Alexios Zavras
    Reviewed-by: Richard Fontana
    Reviewed-by: Allison Randal
    Reviewed-by: Steve Winslow
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190528170027.163048684@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

28 Mar, 2018

3 commits

  • At the moment we assign our supported compatible strings to a respective
    instance of our sun4i_pwm_data structure, even though some of them
    are the same.
    To avoid further clutter, split out the three different combinations of
    features we have at the moment and name them accordingly.
    This should make it more obvious which compatible string to use for new
    SoCs.

    Signed-off-by: Andre Przywara
    Acked-by: Maxime Ripard
    Signed-off-by: Thierry Reding

    Andre Przywara
     
  • Commit a054c4d68408 ("pwm: sun4i: Drop legacy callbacks") dropped the
    only user of the .has_rdy member in our sun4i_pwm_data struct.
    Consequently we don't need to store this anymore for the various SoCs,
    which paves the way for further simplifications.

    Signed-off-by: Andre Przywara
    Acked-by: Maxime Ripard
    Signed-off-by: Thierry Reding

    Andre Przywara
     
  • Correctly extract the prescaler value from CTRL_REG before comparing it
    to PWM_PRESCAL_MASK.

    Also, check that both PWM_CLK_GATING and PWM_EN to ensure the PWM is
    enabled instead of relying on only one of those.

    Fixes: 93e0dfb2c52f ("pwm: sun4i: Improve hardware read out")
    Signed-off-by: Alexandre Belloni
    Signed-off-by: Thierry Reding

    Alexandre Belloni
     

15 Nov, 2017

1 commit


06 Jul, 2017

3 commits

  • Remove the legacy callbacks .enable(), .disable(), .set_polarity() and
    .config().

    Signed-off-by: Alexandre Belloni
    Acked-by: Chen-Yu Tsai
    Acked-by: Maxime Ripard
    Signed-off-by: Thierry Reding

    Alexandre Belloni
     
  • Switch the driver to atomic PWM. This makes it easier to wait a proper
    amount of time when changing the duty cycle before disabling the channel
    (main use case is switching the duty cycle to 0 before disabling).

    Signed-off-by: Alexandre Belloni
    Acked-by: Maxime Ripard
    Signed-off-by: Thierry Reding

    Alexandre Belloni
     
  • Implement .get_state instead of only reading the polarity at probe time.
    This allows to get the proper state, period and duty cycle.

    Signed-off-by: Alexandre Belloni
    Reviewed-by: Chen-Yu Tsai
    Acked-by: Maxime Ripard
    Signed-off-by: Thierry Reding

    Alexandre Belloni
     

04 Jan, 2017

1 commit


08 Sep, 2016

1 commit

  • H3 PWM controller has same register layout as sun4i driver, so it works
    by adding H3 specific data.

    Cc: Thierry Reding
    Cc: Rob Herring
    Cc: Maxime Ripard
    Cc: Alexandre Belloni
    Cc: Chen-Yu Tsai
    Cc: linux-pwm@vger.kernel.org
    Cc: devicetree@vger.kernel.org
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Milo Kim
    Acked-by: Chen-Yu Tsai
    Reviewed-by: Alexandre Belloni
    Acked-by: Rob Herring
    Signed-off-by: Thierry Reding

    Milo Kim
     

17 May, 2016

1 commit


10 Nov, 2015

2 commits


30 Jan, 2015

1 commit