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: 2601081 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A44C24020A for ; Wed, 22 May 2013 09:12:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755182Ab3EVJMl (ORCPT ); Wed, 22 May 2013 05:12:41 -0400 Received: from moutng.kundenserver.de ([212.227.126.187]:59638 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754071Ab3EVJMk (ORCPT ); Wed, 22 May 2013 05:12:40 -0400 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 cc: linux-pm@vger.kernel.org, Magnus Damm , "Rafael J. Wysocki" , linux-arm-kernel@lists.infradead.org, Simon Horman 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== Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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};