devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomasz Figa <t.figa@samsung.com>
To: linux-arm-kernel@lists.infradead.org
Cc: devicetree-discuss@lists.ozlabs.org,
	linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com,
	kyungmin.park@samsung.com, tomasz.figa@gmail.com,
	m.szyprowski@samsung.com, arnd@arndb.de, john.stultz@linaro.org,
	tglx@linutronix.de, olof@lixom.net, ben-linux@fluff.org,
	thomas.abraham@linaro.org, Tomasz Figa <t.figa@samsung.com>
Subject: [PATCH v3 03/13] clocksource: samsung_pwm_timer: Make PWM spinlock global
Date: Tue, 23 Apr 2013 17:46:24 +0200	[thread overview]
Message-ID: <1366731994-7478-4-git-send-email-t.figa@samsung.com> (raw)
In-Reply-To: <1366731994-7478-1-git-send-email-t.figa@samsung.com>

This patch makes the PWM spinlock global and exports it to allow using
it in Samsung PWM driver (will be reworked to use proper synchronization
in further patches).

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/clocksource/samsung_pwm_timer.c | 24 +++++++++++++-----------
 include/clocksource/samsung_pwm.h       |  2 ++
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c
index 1752457..d9048b8 100644
--- a/drivers/clocksource/samsung_pwm_timer.c
+++ b/drivers/clocksource/samsung_pwm_timer.c
@@ -49,6 +49,9 @@
 #define TCON_INVERT(chan)		(1 << (4 * (chan) + 2))
 #define TCON_AUTORELOAD(chan)		(1 << (4 * (chan) + 3))
 
+DEFINE_SPINLOCK(samsung_pwm_lock);
+EXPORT_SYMBOL(samsung_pwm_lock);
+
 struct samsung_timer_source {
 	unsigned int event_id;
 	unsigned int source_id;
@@ -72,14 +75,14 @@ static void samsung_timer_set_prescale(struct samsung_pwm *pwm,
 	if (channel >= 2)
 		shift = TCFG0_PRESCALER1_SHIFT;
 
-	spin_lock_irqsave(&pwm->slock, flags);
+	spin_lock_irqsave(&samsung_pwm_lock, flags);
 
 	reg = readl(pwm->base + REG_TCFG0);
 	reg &= ~(TCFG0_PRESCALER_MASK << shift);
 	reg |= (prescale - 1) << shift;
 	writel(reg, pwm->base + REG_TCFG0);
 
-	spin_unlock_irqrestore(&pwm->slock, flags);
+	spin_unlock_irqrestore(&samsung_pwm_lock, flags);
 }
 
 static void samsung_timer_set_divisor(struct samsung_pwm *pwm,
@@ -92,14 +95,14 @@ static void samsung_timer_set_divisor(struct samsung_pwm *pwm,
 
 	bits = (fls(divisor) - 1) - pwm->variant.div_base;
 
-	spin_lock_irqsave(&pwm->slock, flags);
+	spin_lock_irqsave(&samsung_pwm_lock, flags);
 
 	reg = readl(pwm->base + REG_TCFG1);
 	reg &= ~(TCFG1_MUX_MASK << shift);
 	reg |= bits << shift;
 	writel(reg, pwm->base + REG_TCFG1);
 
-	spin_unlock_irqrestore(&pwm->slock, flags);
+	spin_unlock_irqrestore(&samsung_pwm_lock, flags);
 }
 
 static void samsung_time_stop(unsigned int channel)
@@ -110,13 +113,13 @@ static void samsung_time_stop(unsigned int channel)
 	if (channel > 0)
 		++channel;
 
-	spin_lock_irqsave(&pwm->slock, flags);
+	spin_lock_irqsave(&samsung_pwm_lock, flags);
 
 	tcon = __raw_readl(pwm->base + REG_TCON);
 	tcon &= ~TCON_START(channel);
 	__raw_writel(tcon, pwm->base + REG_TCON);
 
-	spin_unlock_irqrestore(&pwm->slock, flags);
+	spin_unlock_irqrestore(&samsung_pwm_lock, flags);
 }
 
 static void samsung_time_setup(unsigned int channel, unsigned long tcnt)
@@ -128,7 +131,7 @@ static void samsung_time_setup(unsigned int channel, unsigned long tcnt)
 	if (tcon_chan > 0)
 		++tcon_chan;
 
-	spin_lock_irqsave(&pwm->slock, flags);
+	spin_lock_irqsave(&samsung_pwm_lock, flags);
 
 	tcon = __raw_readl(pwm->base + REG_TCON);
 
@@ -141,7 +144,7 @@ static void samsung_time_setup(unsigned int channel, unsigned long tcnt)
 	__raw_writel(tcnt, pwm->base + REG_TCMPB(channel));
 	__raw_writel(tcon, pwm->base + REG_TCON);
 
-	spin_unlock_irqrestore(&pwm->slock, flags);
+	spin_unlock_irqrestore(&samsung_pwm_lock, flags);
 }
 
 static void samsung_time_start(unsigned int channel, bool periodic)
@@ -152,7 +155,7 @@ static void samsung_time_start(unsigned int channel, bool periodic)
 	if (channel > 0)
 		++channel;
 
-	spin_lock_irqsave(&pwm->slock, flags);
+	spin_lock_irqsave(&samsung_pwm_lock, flags);
 
 	tcon = __raw_readl(pwm->base + REG_TCON);
 
@@ -166,7 +169,7 @@ static void samsung_time_start(unsigned int channel, bool periodic)
 
 	__raw_writel(tcon, pwm->base + REG_TCON);
 
-	spin_unlock_irqrestore(&pwm->slock, flags);
+	spin_unlock_irqrestore(&samsung_pwm_lock, flags);
 }
 
 static int samsung_set_next_event(unsigned long cycles,
@@ -394,7 +397,6 @@ static void __init samsung_pwm_alloc(struct device_node *np,
 		return;
 	}
 	memcpy(&pwm->variant, variant, sizeof(pwm->variant));
-	spin_lock_init(&pwm->slock);
 	for (i = 0; i < SAMSUNG_PWM_NUM; ++i)
 		pwm->irq[i] = irq_of_parse_and_map(np, i);
 
diff --git a/include/clocksource/samsung_pwm.h b/include/clocksource/samsung_pwm.h
index eff8668..399d241 100644
--- a/include/clocksource/samsung_pwm.h
+++ b/include/clocksource/samsung_pwm.h
@@ -23,6 +23,8 @@
 struct platform_device;
 struct device_node;
 
+extern spinlock_t samsung_pwm_lock;
+
 struct samsung_pwm_variant {
 	u8 bits;
 	u8 div_base;
-- 
1.8.2.1

  parent reply	other threads:[~2013-04-23 15:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23 15:46 [PATCH v3 00/13] ARM: EXYNOS: Fix Universal C210 support Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 01/13] Documentation: Add device tree bindings for Samsung PWM timers Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 02/13] clocksource: samsung_pwm_timer: Let platforms select the driver Tomasz Figa
2013-04-23 15:46 ` Tomasz Figa [this message]
2013-04-23 15:46 ` [PATCH v3 04/13] clocksource: samsung_pwm_timer: Keep all driver data in a structure Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 05/13] clocksource: samsung_pwm_timer: Drop unused samsung_pwm struct Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 06/13] clocksource: samsung_pwm_timer: Add support for non-DT platforms Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 07/13] clocksource: samsung_pwm_timer: Use proper clockevents max_delta Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 08/13] clocksource: samsung_pwm_timer: Correct programming of clock events Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 09/13] clocksource: samsung_pwm_timer: Work around rounding errors in clockevents core Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 10/13] ARM: SAMSUNG: Do not register legacy timer interrupts on Exynos Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 11/13] ARM: EXYNOS: Fix support of Exynos4210 rev0 SoC Tomasz Figa
2013-04-28 19:22   ` Olof Johansson
2013-04-28 22:17     ` Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 12/13] ARM: dts: exynos4: Add node for PWM device Tomasz Figa
2013-04-23 15:46 ` [PATCH v3 13/13] ARM: dts: exynos4210: Add basic dts file for universal_c210 board Tomasz Figa
2013-04-24 15:56 ` [PATCH v3 00/13] ARM: EXYNOS: Fix Universal C210 support Tomasz Figa
2013-04-25 14:46 ` Arnd Bergmann
2013-04-25 15:48   ` Kukjin Kim
2013-04-27  0:34   ` Olof Johansson
2013-04-28  6:52     ` Kukjin Kim
2013-04-28 19:17       ` Olof Johansson

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=1366731994-7478-4-git-send-email-t.figa@samsung.com \
    --to=t.figa@samsung.com \
    --cc=arnd@arndb.de \
    --cc=ben-linux@fluff.org \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=john.stultz@linaro.org \
    --cc=kgene.kim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=olof@lixom.net \
    --cc=tglx@linutronix.de \
    --cc=thomas.abraham@linaro.org \
    --cc=tomasz.figa@gmail.com \
    /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).