From patchwork Thu Feb 28 12:21:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2197411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 65ED03FCF6 for ; Thu, 28 Feb 2013 12:25:38 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UB2VB-0004O0-8l; Thu, 28 Feb 2013 12:22:21 +0000 Received: from moutng.kundenserver.de ([212.227.126.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UB2V8-0004Ma-4J for linux-arm-kernel@lists.infradead.org; Thu, 28 Feb 2013 12:22:18 +0000 Received: from axis700.grange (dslb-178-001-229-197.pools.arcor-ip.net [178.1.229.197]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0M6ETS-1V3YnP0s02-00yALP; Thu, 28 Feb 2013 13:22:05 +0100 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id A24E140BB3; Thu, 28 Feb 2013 13:22:04 +0100 (CET) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1UB2Uu-0002FJ-CW; Thu, 28 Feb 2013 13:22:04 +0100 From: Guennadi Liakhovetski To: linux-sh@vger.kernel.org Subject: [PATCH v3 1/3] ARM: shmobile: sh73a0: wait for completion when kicking the clock Date: Thu, 28 Feb 2013 13:21:58 +0100 Message-Id: <1362054120-8600-2-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1362054120-8600-1-git-send-email-g.liakhovetski@gmx.de> References: <1362054120-8600-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:KQfk3hIgSMK7r2ppchCZ58DsWfmviNrK7d/T7GI3Am5 u2uhB5kILQ/c9T05STMVSX4ljvR804Xj6pD1CiVHbcw0zmjucV XkLAODocb8LRTdz+iyUDhcc4VZNeo016rNtsjFBWSMr6ivA0An dUi5r0baRioJi/1/Xy2qPy/ToKHE2Tus9JtSwA97HR7KzuY5W1 rcgb3lODcyt4oZ609tvHE0xP6dGF7yYyqCwqRFF2M8t1Oc39mk g/2E3vZ56qJBaSH+NNHroLP7eaibiALj0yF4BO93RZ/xDTipHB yfM7Ml5Fz/LMxk3Geso+P0xPLHKIDL8zNusijTMJyNiUbwW9FC Q6++IfDOoLNi82vR08rB8Wrps+9mMPvGWCg1dzt/f2Xg6Sl1Es +2Qa810xZe+Ow== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130228_072218_408768_91B93073 X-CRM114-Status: GOOD ( 14.81 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.171 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (g.liakhovetski[at]gmx.de) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 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: Magnus Damm , cpufreq@vger.kernel.org, "Rafael J. Wysocki" , Simon Horman , Guennadi Liakhovetski , linux-arm-kernel@lists.infradead.org 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 To reconfigure clocks, controlled by FRQCRA and FRQCRB, a kick bit has to be set and to make sure the setting has taken effect, it has to be read back repeatedly until it is cleared by the hardware. This patch adds the waiting part, that was missing until now. Signed-off-by: Guennadi Liakhovetski Acked-by: Magnus Damm --- As noted in patch 0/3, this patch affects existing systems, but AFAICS only theoretically - so far nobody is changing clock rates of any of the FRQCRA and FRQCRB clocks. Still, please, handle with care. arch/arm/mach-shmobile/clock-sh73a0.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c index 71843dd..34b5c5a 100644 --- a/arch/arm/mach-shmobile/clock-sh73a0.c +++ b/arch/arm/mach-shmobile/clock-sh73a0.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #define FRQCRA IOMEM(0xe6150000) @@ -234,14 +235,24 @@ static struct clk *main_clks[] = { &sh73a0_extalr_clk, }; -static void div4_kick(struct clk *clk) +static int frqcr_kick(void) { - unsigned long value; + int i; + + /* set KICK bit in FRQCRB to update hardware setting, check success */ + __raw_writel(__raw_readl(FRQCRB) | (1 << 31), FRQCRB); + for (i = 1000; i; i--) + if (__raw_readl(FRQCRB) & (1 << 31)) + cpu_relax(); + else + return i; + + return -ETIMEDOUT; +} - /* set KICK bit in FRQCRB to update hardware setting */ - value = __raw_readl(FRQCRB); - value |= (1 << 31); - __raw_writel(value, FRQCRB); +static void div4_kick(struct clk *clk) +{ + frqcr_kick(); } static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18,