20 Jan, 2020

1 commit


21 Oct, 2019

5 commits

  • Instead of passing the individual values of the breakpoint, pass a
    pointer to the breakpoint.

    Signed-off-by: Thierry Reding

    Thierry Reding
     
  • Remove usage of the ternary operator to assign values for register
    fields. Instead, parameterize the register and field offset macros
    and pass the index to them.

    This removes clutter and improves readability.

    Signed-off-by: Thierry Reding

    Thierry Reding
     
  • Both index and level can only be either 0 or 1 and the filter value is
    limited to values between (and including) 0 and 15. Validate that the
    device tree node contains values that are within these ranges.

    Signed-off-by: Thierry Reding

    Thierry Reding
     
  • Add suspend/resume PM sleep ops. When going to low power, enforce the PWM
    channel isn't active. Let the PWM consumers disable it during their own
    suspend sequence, see [1]. So, perform a check here, and handle the
    pinctrl states. Also restore the break inputs upon resume, as registers
    content may be lost when going to low power mode.

    [1] https://lkml.org/lkml/2019/2/5/770

    Signed-off-by: Fabrice Gasnier
    Signed-off-by: Thierry Reding

    Fabrice Gasnier
     
  • Split breakinput routine that configures STM32 timers 'break' safety
    feature upon probe, into two routines:
    - stm32_pwm_apply_breakinputs() sets all the break inputs into registers.
    - stm32_pwm_probe_breakinputs() probes the device tree break input settings
    before calling stm32_pwm_apply_breakinputs()

    This is a precursor patch to ease PM support. Registers content may get
    lost during low power. So, break input settings applied upon probe need
    to be restored upon resume (e.g. by calling stm32_pwm_apply_breakinputs()).

    Signed-off-by: Fabrice Gasnier
    Signed-off-by: Thierry Reding

    Fabrice Gasnier
     

21 Sep, 2019

1 commit

  • 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
     

25 Jun, 2019

1 commit


14 Jun, 2018

1 commit

  • …ierry.reding/linux-pwm

    Pull pwm updates from Thierry Reding:
    "This contains a couple of fixes and cleanups for the Meson and
    ACPI/LPSS drivers as well as capture support for STM32.

    Note that given the cross- subsystem changes, the STM32 patches were
    merged through the MFD and PWM trees, both sharing an immutable
    branch"

    * tag 'pwm/for-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm:
    pwm: stm32: Fix build warning with CONFIG_DMA_ENGINE disabled
    pwm: stm32: Enforce dependency on CONFIG_MFD_STM32_TIMERS
    ACPI / LPSS: Add missing prv_offset setting for byt/cht PWM devices
    pwm: lpss: platform: Save/restore the ctrl register over a suspend/resume
    dt-bindings: mfd: stm32-timers: Add support for dmas
    pwm: simplify getting .drvdata
    pwm: meson: Fix allocation of PWM channel array

    Linus Torvalds
     

06 Jun, 2018

1 commit

  • Without dmaengine support, we get a harmless warning about an unused
    function:

    drivers/pwm/pwm-stm32.c:166:12: error: 'stm32_pwm_capture' defined but not used [-Werror=unused-function]

    Changing the #ifdef to an IS_ENABLED() check shuts up that warning and
    is slightly nicer to read.

    Fixes: 53e38fe73f94 ("pwm: stm32: Add capture support")
    Signed-off-by: Arnd Bergmann
    Acked-by: Fabrice Gasnier
    Signed-off-by: Thierry Reding

    Arnd Bergmann
     

04 Jun, 2018

1 commit

  • This removes build warning when COMPILE_TEST=y and MFD_STM32_TIMERS=n
    in drivers/pwm/pwm-stm32.c. In function 'stm32_pwm_capture' 'raw_prd' and
    'raw_dty' may be used uninitialized in this function
    [-Wmaybe-uninitialized]

    Signed-off-by: Fabrice Gasnier
    Acked-by: Thierry Reding
    Tested-by: Randy Dunlap
    Signed-off-by: Lee Jones

    Fabrice Gasnier
     

16 May, 2018

3 commits

  • Using input prescaler, capture unit will trigger DMA once every
    configurable /2, /4 or /8 events (rising edge). This helps improve
    period (only) capture accuracy at high rates.

    Signed-off-by: Fabrice Gasnier
    Reviewed-by: Benjamin Gaignard
    Acked-by: Thierry Reding
    Signed-off-by: Lee Jones

    Fabrice Gasnier
     
  • Currently, capture is based on timeout window to configure prescaler.
    PWM capture framework provides 1s window at the time of writing.

    There's place for improvement, after input signal has been captured once:
    - Finer tune counter clock prescaler, by using 1st capture result (with
    arbitrary margin).
    - Do a 2nd capture, with scaled capture window.
    This increases accuracy, especially at high rates.

    Signed-off-by: Fabrice Gasnier
    Reviewed-by: Benjamin Gaignard
    Acked-by: Thierry Reding
    Signed-off-by: Lee Jones

    Fabrice Gasnier
     
  • Add support for PMW input mode on pwm-stm32. STM32 timers support
    period and duty cycle capture as long as they have at least two PWM
    channels. One capture channel is used for period (rising-edge), one
    for duty-cycle (falling-edge).
    When there's only one channel available, only period can be captured.
    Duty-cycle is simply zero'ed in such a case.

    Capture requires exclusive access (e.g. no pwm output running at the
    same time, to protect common prescaler).
    Timer DMA burst mode (from MFD core) is being used, to take two
    snapshots of capture registers (upon each period rising edge).

    Signed-off-by: Fabrice Gasnier
    Reviewed-by: Benjamin Gaignard
    Acked-by: Thierry Reding
    Signed-off-by: Lee Jones

    Fabrice Gasnier
     

28 Mar, 2018

3 commits


26 Jan, 2017

1 commit

  • This driver adds support for PWM driver on STM32 platform.
    The SoC have multiple instances of the hardware IP and each
    of them could have small differences: number of channels,
    complementary output, auto reload register size...

    version 9:
    - fix commit message header
    - remove one space MODULE_ALIAS

    version 8:
    - fix comments done by Thierry on version 7

    version 6:
    - change st,breakinput parameter to make it usuable for stm32f7 too.

    version 4:
    - detect at probe time hardware capabilities
    - fix comments done on v2 and v3
    - use PWM atomic ops

    version 2:
    - only keep one comptatible
    - use DT parameters to discover hardware block configuration

    Signed-off-by: Benjamin Gaignard
    Acked-by: Thierry Reding
    Signed-off-by: Lee Jones

    Benjamin Gaignard