From patchwork Tue Apr 23 15:46:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2478451 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 51F0ADF2E5 for ; Tue, 23 Apr 2013 15:49:52 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUfSM-0006td-BF; Tue, 23 Apr 2013 15:48:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUfRs-0004Hf-G3; Tue, 23 Apr 2013 15:48:04 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUfRU-0004G7-3c for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2013 15:47:54 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MLP00IXJT7FXI30@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2013 00:47:39 +0900 (KST) X-AuditID: cbfee61a-b7f156d000002a55-6b-5176ad1a847e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 56.A2.10837.A1DA6715; Wed, 24 Apr 2013 00:47:39 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MLP0032TT5SFQ80@mmp1.samsung.com>; Wed, 24 Apr 2013 00:47:38 +0900 (KST) From: Tomasz Figa To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 03/13] clocksource: samsung_pwm_timer: Make PWM spinlock global Date: Tue, 23 Apr 2013 17:46:24 +0200 Message-id: <1366731994-7478-4-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1366731994-7478-1-git-send-email-t.figa@samsung.com> References: <1366731994-7478-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t9jAV3ptWWBBqcmsFj8nXSM3WLSugNM FgdmP2S1OPNb16J3wVU2i7NNb9gtNj2+xmox4/w+Jou1R+6yW5y6/pnNYv2M1ywWmzdNZbY4 NmMJo8WqXX8YHfg8fv+axOjxd9ULZo+ds+6ye9y5tofN4925c+wem5fUe5yfsZDR48qJJlaP vi2rGD0+b5IL4IrisklJzcksSy3St0vgyli4bB9TQYtyxZf5H9kaGDfIdjFyckgImEg87T7O BmGLSVy4tx7I5uIQEljEKPF970EmCKeLSWLdhW9gVWwCahKfGx6B2SICGhJTuh6zgxQxC1xi kpi/axMrSEJYIESid+9xZhCbRUBVYuvslWBxXgFHid5t1xkh1slLPL3fBzaIU8BJYufRh2C2 EFDN0b/tTBMYeRcwMqxiFE0tSC4oTkrPNdQrTswtLs1L10vOz93ECA7mZ1I7GFc2WBxiFOBg VOLhfTGrLFCINbGsuDL3EKMEB7OSCK/1bKAQb0piZVVqUX58UWlOavEhRmkOFiVx3gOt1oFC AumJJanZqakFqUUwWSYOTqkGRl6xL0/d37NZhj+3WGwW+2e6SGuSpZaxzG7dlWF87/n3G062 8J3wjmPjow1HmUxe83+0X9tzYFW89Xxd9gMnpKpqtwScvGNnee/UugeXIp4bBbFPk25v3b76 5C7uBdbXo02Y9Lh/iglpirGalmjuZNRdqGeU2n/ngW0C1273DVX/eHXcKjfoKrEUZyQaajEX FScCAI6RYH5iAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130423_114740_674600_6728BB50 X-CRM114-Status: GOOD ( 10.86 ) X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.33 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, arnd@arndb.de, devicetree-discuss@lists.ozlabs.org, tomasz.figa@gmail.com, kyungmin.park@samsung.com, linux-samsung-soc@vger.kernel.org, john.stultz@linaro.org, ben-linux@fluff.org, olof@lixom.net, thomas.abraham@linaro.org, tglx@linutronix.de, Tomasz Figa , m.szyprowski@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 Signed-off-by: Kyungmin Park --- 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;