Commit 030c28a0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'pwm/for-5.16-rc1' of...

Merge tag 'pwm/for-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm

Pull pwm updates from Thierry Reding:
 "This set is mostly small fixes and cleanups, so more of a janitorial
  update for this cycle"

* tag 'pwm/for-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm:
  pwm: vt8500: Rename pwm_busy_wait() to make it obviously driver-specific
  dt-bindings: pwm: tpu: Add R-Car M3-W+ device tree bindings
  dt-bindings: pwm: tpu: Add R-Car V3U device tree bindings
  pwm: pwm-samsung: Trigger manual update when disabling PWM
  pwm: visconti: Simplify using devm_pwmchip_add()
  pwm: samsung: Describe driver in Kconfig
  pwm: Make it explicit that pwm_apply_state() might sleep
  pwm: Add might_sleep() annotations for !CONFIG_PWM API functions
  pwm: atmel: Drop unused header
parents 0d5d7463 e9d866d5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -35,9 +35,11 @@ properties:
          - renesas,tpu-r8a7794   # R-Car E2
          - renesas,tpu-r8a7795   # R-Car H3
          - renesas,tpu-r8a7796   # R-Car M3-W
          - renesas,tpu-r8a77961  # R-Car M3-W+
          - renesas,tpu-r8a77965  # R-Car M3-N
          - renesas,tpu-r8a77970  # R-Car V3M
          - renesas,tpu-r8a77980  # R-Car V3H
          - renesas,tpu-r8a779a0  # R-Car V3U
      - const: renesas,tpu

  reg:
+3 −1
Original line number Diff line number Diff line
@@ -476,7 +476,9 @@ config PWM_SAMSUNG
	depends on PLAT_SAMSUNG || ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
	depends on HAS_IOMEM
	help
	  Generic PWM framework driver for Samsung.
	  Generic PWM framework driver for Samsung S3C24xx, S3C64xx, S5Pv210
	  and Exynos SoCs.
	  Choose Y here only if you build for such Samsung SoC.

	  To compile this driver as a module, choose M here: the module
	  will be called pwm-samsung.
+9 −0
Original line number Diff line number Diff line
@@ -532,6 +532,15 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
	struct pwm_chip *chip;
	int err;

	/*
	 * Some lowlevel driver's implementations of .apply() make use of
	 * mutexes, also with some drivers only returning when the new
	 * configuration is active calling pwm_apply_state() from atomic context
	 * is a bad idea. So make it explicit that calling this function might
	 * sleep.
	 */
	might_sleep();

	if (!pwm || !state || !state->period ||
	    state->duty_cycle > state->period)
		return -EINVAL;
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
#include <linux/err.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
+22 −8
Original line number Diff line number Diff line
@@ -117,6 +117,20 @@ static inline unsigned int to_tcon_channel(unsigned int channel)
	return (channel == 0) ? 0 : (channel + 1);
}

static void __pwm_samsung_manual_update(struct samsung_pwm_chip *chip,
				      struct pwm_device *pwm)
{
	unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm);
	u32 tcon;

	tcon = readl(chip->base + REG_TCON);
	tcon |= TCON_MANUALUPDATE(tcon_chan);
	writel(tcon, chip->base + REG_TCON);

	tcon &= ~TCON_MANUALUPDATE(tcon_chan);
	writel(tcon, chip->base + REG_TCON);
}

static void pwm_samsung_set_divisor(struct samsung_pwm_chip *pwm,
				    unsigned int channel, u8 divisor)
{
@@ -276,6 +290,13 @@ static void pwm_samsung_disable(struct pwm_chip *chip, struct pwm_device *pwm)
	tcon &= ~TCON_AUTORELOAD(tcon_chan);
	writel(tcon, our_chip->base + REG_TCON);

	/*
	 * In case the PWM is at 100% duty cycle, force a manual
	 * update to prevent the signal from staying high.
	 */
	if (readl(our_chip->base + REG_TCMPB(pwm->hwpwm)) == (u32)-1U)
		__pwm_samsung_manual_update(our_chip, pwm);

	our_chip->disabled_mask |= BIT(pwm->hwpwm);

	spin_unlock_irqrestore(&samsung_pwm_lock, flags);
@@ -284,18 +305,11 @@ static void pwm_samsung_disable(struct pwm_chip *chip, struct pwm_device *pwm)
static void pwm_samsung_manual_update(struct samsung_pwm_chip *chip,
				      struct pwm_device *pwm)
{
	unsigned int tcon_chan = to_tcon_channel(pwm->hwpwm);
	u32 tcon;
	unsigned long flags;

	spin_lock_irqsave(&samsung_pwm_lock, flags);

	tcon = readl(chip->base + REG_TCON);
	tcon |= TCON_MANUALUPDATE(tcon_chan);
	writel(tcon, chip->base + REG_TCON);

	tcon &= ~TCON_MANUALUPDATE(tcon_chan);
	writel(tcon, chip->base + REG_TCON);
	__pwm_samsung_manual_update(chip, pwm);

	spin_unlock_irqrestore(&samsung_pwm_lock, flags);
}
Loading