linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, "Lokesh Vutla" <lokeshvutla@ti.com>,
	"Tony Lindgren" <tony@atomide.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Enrico Weigelt" <info@metux.net>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-pwm@vger.kernel.org (open list:PWM SUBSYSTEM)
Subject: [PATCH 18/21] clocksource/drivers/timer-ti-dm: Enable autoreload in set_pwm
Date: Wed, 18 Mar 2020 18:41:28 +0100	[thread overview]
Message-ID: <20200318174131.20582-18-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20200318174131.20582-1-daniel.lezcano@linaro.org>

From: Lokesh Vutla <lokeshvutla@ti.com>

dm timer ops set_load() api allows to configure the load value and to
set the auto reload feature. But auto reload feature is independent of
load value and should be part of configuring pwm. This way pwm can be
disabled by disabling auto reload feature using set_pwm() so that the
current pwm cycle will be completed. Else pwm disabling causes the
cycle to be stopped abruptly.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200305082715.15861-7-lokeshvutla@ti.com
---
 drivers/clocksource/timer-ti-dm.c          | 16 +++++-----------
 drivers/pwm/pwm-omap-dmtimer.c             |  8 +++++---
 include/linux/platform_data/dmtimer-omap.h |  5 ++---
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c
index 73ac73efdef8..f5c73ebfe4ca 100644
--- a/drivers/clocksource/timer-ti-dm.c
+++ b/drivers/clocksource/timer-ti-dm.c
@@ -562,21 +562,13 @@ static int omap_dm_timer_stop(struct omap_dm_timer *timer)
 	return 0;
 }
 
-static int omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload,
+static int omap_dm_timer_set_load(struct omap_dm_timer *timer,
 				  unsigned int load)
 {
-	u32 l;
-
 	if (unlikely(!timer))
 		return -EINVAL;
 
 	omap_dm_timer_enable(timer);
-	l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
-	if (autoreload)
-		l |= OMAP_TIMER_CTRL_AR;
-	else
-		l &= ~OMAP_TIMER_CTRL_AR;
-	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_LOAD_REG, load);
 
 	omap_dm_timer_disable(timer);
@@ -605,7 +597,7 @@ static int omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable,
 }
 
 static int omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on,
-				 int toggle, int trigger)
+				 int toggle, int trigger, int autoreload)
 {
 	u32 l;
 
@@ -615,12 +607,14 @@ static int omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on,
 	omap_dm_timer_enable(timer);
 	l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
 	l &= ~(OMAP_TIMER_CTRL_GPOCFG | OMAP_TIMER_CTRL_SCPWM |
-	       OMAP_TIMER_CTRL_PT | (0x03 << 10));
+	       OMAP_TIMER_CTRL_PT | (0x03 << 10) | OMAP_TIMER_CTRL_AR);
 	if (def_on)
 		l |= OMAP_TIMER_CTRL_SCPWM;
 	if (toggle)
 		l |= OMAP_TIMER_CTRL_PT;
 	l |= trigger << 10;
+	if (autoreload)
+		l |= OMAP_TIMER_CTRL_AR;
 	omap_dm_timer_write_reg(timer, OMAP_TIMER_CTRL_REG, l);
 
 	omap_dm_timer_disable(timer);
diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c
index 88a3c5690fea..9e4378dc6897 100644
--- a/drivers/pwm/pwm-omap-dmtimer.c
+++ b/drivers/pwm/pwm-omap-dmtimer.c
@@ -183,7 +183,7 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
 	if (timer_active)
 		omap->pdata->stop(omap->dm_timer);
 
-	omap->pdata->set_load(omap->dm_timer, true, load_value);
+	omap->pdata->set_load(omap->dm_timer, load_value);
 	omap->pdata->set_match(omap->dm_timer, true, match_value);
 
 	dev_dbg(chip->dev, "load value: %#08x (%d), match value: %#08x (%d)\n",
@@ -192,7 +192,8 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
 	omap->pdata->set_pwm(omap->dm_timer,
 			      pwm_get_polarity(pwm) == PWM_POLARITY_INVERSED,
 			      true,
-			      PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE);
+			      PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE,
+			      true);
 
 	/* If config was called while timer was running it must be reenabled. */
 	if (timer_active)
@@ -222,7 +223,8 @@ static int pwm_omap_dmtimer_set_polarity(struct pwm_chip *chip,
 	omap->pdata->set_pwm(omap->dm_timer,
 			      polarity == PWM_POLARITY_INVERSED,
 			      true,
-			      PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE);
+			      PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE,
+			      true);
 	mutex_unlock(&omap->mutex);
 
 	return 0;
diff --git a/include/linux/platform_data/dmtimer-omap.h b/include/linux/platform_data/dmtimer-omap.h
index 3173b7b6ff6f..95d852aef130 100644
--- a/include/linux/platform_data/dmtimer-omap.h
+++ b/include/linux/platform_data/dmtimer-omap.h
@@ -30,12 +30,11 @@ struct omap_dm_timer_ops {
 	int	(*stop)(struct omap_dm_timer *timer);
 	int	(*set_source)(struct omap_dm_timer *timer, int source);
 
-	int	(*set_load)(struct omap_dm_timer *timer, int autoreload,
-			    unsigned int value);
+	int	(*set_load)(struct omap_dm_timer *timer, unsigned int value);
 	int	(*set_match)(struct omap_dm_timer *timer, int enable,
 			     unsigned int match);
 	int	(*set_pwm)(struct omap_dm_timer *timer, int def_on,
-			   int toggle, int trigger);
+			   int toggle, int trigger, int autoreload);
 	int	(*get_pwm_status)(struct omap_dm_timer *timer);
 	int	(*set_prescaler)(struct omap_dm_timer *timer, int prescaler);
 
-- 
2.17.1


  parent reply	other threads:[~2020-03-18 17:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 17:38 [GIT PULL] timer drivers for v5.7 Daniel Lezcano
2020-03-18 17:41 ` [PATCH 01/21] clocksource/drivers/fttmr010: Parametrise shutdown Daniel Lezcano
2020-03-18 17:41   ` [PATCH 02/21] clocksource/drivers/fttmr010: Set interrupt and shutdown Daniel Lezcano
2020-03-18 17:41   ` [PATCH 03/21] dt-bindings: fttmr010: Add ast2600 compatible Daniel Lezcano
2020-03-18 17:41   ` [PATCH 04/21] clocksource: Add driver for the Ingenic JZ47xx OST Daniel Lezcano
2020-03-18 17:41   ` [PATCH 05/21] clocksource/drivers/owl: Improve owl_timer_init fail messages Daniel Lezcano
2020-03-18 17:41   ` [PATCH 06/21] clocksource/drivers/timer-ti-dm: Do not update counter on updating the period Daniel Lezcano
2020-03-18 17:41   ` [PATCH 07/21] clocksource/drivers/timer-ti-dm: Drop bogus omap_dm_timer_of_set_source() Daniel Lezcano
2020-03-18 17:41   ` [PATCH 08/21] dt-bindings: timer: Add X1000 bindings Daniel Lezcano
2020-03-18 17:41   ` [PATCH 09/21] clocksource/drivers/ingenic: Add support for TCU of X1000 Daniel Lezcano
2020-03-18 17:41   ` [PATCH 10/21] clocksource: Replace setup_irq() by request_irq() Daniel Lezcano
2020-03-27 10:24     ` Linus Walleij
2020-03-18 17:41   ` [PATCH 11/21] clocksource/drivers/timer-cs5535: Request irq with non-NULL dev_id Daniel Lezcano
2020-03-18 17:41   ` [PATCH 12/21] clocksource/drivers/timer-microchip-pit64b: Fix rate for gck Daniel Lezcano
2020-03-18 17:41   ` [PATCH 13/21] clocksource/drivers/timer-ti-dm: Convert to SPDX identifier Daniel Lezcano
2020-03-18 17:41   ` [PATCH 14/21] clocksource/drivers/timer-ti-dm: Prepare for using cpuidle Daniel Lezcano
2020-03-18 17:41   ` [PATCH 15/21] clocksource/drivers/timer-ti-dm: Implement cpu_pm notifier for context save and restore Daniel Lezcano
2020-03-18 17:41   ` [PATCH 16/21] clocksource/drivers/timer-ti-dm: Do not update counter on updating the period Daniel Lezcano
2020-03-18 17:41   ` [PATCH 17/21] clocksource/drivers/timer-ti-dm: Add support to get pwm current status Daniel Lezcano
2020-03-18 17:41   ` Daniel Lezcano [this message]
2020-03-18 17:41   ` [PATCH 19/21] clocksource/drivers/imx-tpm: Remove unused includes Daniel Lezcano
2020-03-18 17:41   ` [PATCH 20/21] clocksource/drivers/imx-sysctr: " Daniel Lezcano
2020-03-18 17:41   ` [PATCH 21/21] clocksource/drivers/timer-probe: Avoid creating dead devices Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200318174131.20582-18-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=info@metux.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    --cc=tony@atomide.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).