From patchwork Wed May 22 09:12:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2601121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 514B240077 for ; Wed, 22 May 2013 09:13:56 +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 1Uf56s-0007B3-GC; Wed, 22 May 2013 09:13:26 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uf56k-00039l-Un; Wed, 22 May 2013 09:13:18 +0000 Received: from moutng.kundenserver.de ([212.227.126.187]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uf56Y-00038F-6E for linux-arm-kernel@lists.infradead.org; Wed, 22 May 2013 09:13:07 +0000 Received: from axis700.grange (dslb-094-221-111-159.pools.arcor-ip.net [94.221.111.159]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0MTaYl-1V5J5x0FwV-00S1L5; Wed, 22 May 2013 11:12:34 +0200 Received: by axis700.grange (Postfix, from userid 1000) id 8651A40BB4; Wed, 22 May 2013 11:12:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 836B940BB3; Wed, 22 May 2013 11:12:33 +0200 (CEST) Date: Wed, 22 May 2013 11:12:33 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-sh@vger.kernel.org Subject: [PATCH 1/2] ARM: shmobile: r8a73a4: wait for completion when kicking the clock Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:8GO0XgCGTs4jrvxulmY775FAk6IazDnSN6LHOkbo0Ta ET+NVwCaZ2s0VgwLoMYmgTHtEe6hE3dBqTQ7lNCOio9CY1Whyi 9PjBaQWPjbY/rMYWmqTRgsWp0SDgkS2Q1783s6KUpZ3rO5UjRw XkJkLGWNGnscR2faclIWys/I8dXG2DR9KsevxAIvk8SLENLQ6L bzAAGCObVHyMW4Gq4B80cwNGFlI0RStj74pSYmmIdycxZBLK3G hFz0ZQ4jrPGDLMJPUsZajj7LcvRzuQ31dGMOpgJhezLHttDii7 NXdrl+STcm182uolYCerG1Xq1aJx/cI+8JzoeHRyalvUQZAcSG 524mjvPysM9aSaoUjXV2jovYC+O+beDTosE/6HQQ/XOOkqpToX Yf/eAAF4XK+dQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130522_051306_469707_0AA45183 X-CRM114-Status: GOOD ( 13.50 ) X-Spam-Score: -3.0 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.187 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 -1.1 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: "Rafael J. Wysocki" , Simon Horman , Magnus Damm , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.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: , 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 --- arch/arm/mach-shmobile/clock-r8a73a4.c | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-shmobile/clock-r8a73a4.c b/arch/arm/mach-shmobile/clock-r8a73a4.c index 5f7fe62..d5176d0 100644 --- a/arch/arm/mach-shmobile/clock-r8a73a4.c +++ b/arch/arm/mach-shmobile/clock-r8a73a4.c @@ -184,6 +184,21 @@ PLL_CLOCK(pll2h_clk, &main_div2_clk, pll_parent_main_extal, 3, 5, PLL2HCR, 5); SH_FIXED_RATIO_CLK(pll1_div2_clk, pll1_clk, div2); +static int frqcr_kick_do(struct clk *clk) +{ + int i; + + /* set KICK bit in FRQCRB to update hardware setting, check success */ + iowrite32(ioread32(CPG_MAP(FRQCRB)) | BIT(31), CPG_MAP(FRQCRB)); + for (i = 1000; i; i--) + if (ioread32(CPG_MAP(FRQCRB)) & BIT(31)) + cpu_relax(); + else + return 0; + + return -ETIMEDOUT; +} + static struct clk *main_clks[] = { &extalr_clk, &extal1_clk, @@ -205,12 +220,7 @@ static struct clk *main_clks[] = { /* DIV4 */ static void div4_kick(struct clk *clk) { - unsigned long value; - - /* set KICK bit in FRQCRB to update hardware setting */ - value = ioread32(CPG_MAP(FRQCRB)); - value |= (1 << 31); - iowrite32(value, CPG_MAP(FRQCRB)); + frqcr_kick_do(clk); } static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18, 24, 0, 36, 48, 10};