From patchwork Mon Dec 22 19:31:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 5528931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7CA429F1CD for ; Mon, 22 Dec 2014 19:34:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 943A120121 for ; Mon, 22 Dec 2014 19:34:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A782E200F3 for ; Mon, 22 Dec 2014 19:34:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y38ie-0003nM-3Z; Mon, 22 Dec 2014 19:32:40 +0000 Received: from mail-ie0-x22c.google.com ([2607:f8b0:4001:c03::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y38iZ-0003lR-Cd for linux-arm-kernel@lists.infradead.org; Mon, 22 Dec 2014 19:32:36 +0000 Received: by mail-ie0-f172.google.com with SMTP id tr6so4879816ieb.31 for ; Mon, 22 Dec 2014 11:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=MO6djRypHmiofnzwBidLH5c39YPn4FVQfJBrS0Lo8II=; b=EhHSY2uRNeDD3cHjwUrwUvgwo6O0hedlvR+rYZNo77pgsHK2qvdqB9Y3R/Oh4QfD9Z IcBWjeHI6J8QhtSjXjSFOK5GnjGbVwve8rHZz2NqEXLhfm1gV7LxNnLo0i6od7cWAXU8 ywX0blYtLwmf4W2J0fgBKprcCazut5qL2RGX0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MO6djRypHmiofnzwBidLH5c39YPn4FVQfJBrS0Lo8II=; b=fqO/pdzcxkTBRzDKjBRatmN0rKoQ7J7cFwbPbphhM+97fnl6aYPoX0JPZ0nXOvMcGR ntTvJsQub9dtb0rwUQqxZmgeY6AyH3CEY+Qu7Weffyaa/pohuwenjdtmlneK8lbLSn6V mtxKKxG5hg0+XD3EcrNv6XFG/UyLWakOU+bdI0cR6jwxxNXJ1rPlJOK1X/f8m6Cx773/ VimxP7AKSHBIjT7OEZO7BOnqVYADqai1B22NCfbVVBgwdlBxzIENZrXmPNXIKoy+zS/t hidaH28R6EsBlGaTFX6XyH+PxOnESYBzSxCmx6wDg1F2Faux+p+VnIyAzVD72PphhWQQ 8EgQ== X-Gm-Message-State: ALoCoQkwGpEeU9se1pDtEU/TOUVAShuNRVqbUdTiFUPbfc0xoUz5iMv4yT6Qj2LiS/dTmwSDi13h X-Received: by 10.107.169.170 with SMTP id f42mr22015876ioj.24.1419276731111; Mon, 22 Dec 2014 11:32:11 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by mx.google.com with ESMTPSA id i3sm8872577iod.19.2014.12.22.11.32.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Dec 2014 11:32:10 -0800 (PST) From: Doug Anderson To: Heiko Stuebner , Chris Zhong , Mike Turquette Subject: [PATCH] clk: rockchip: rk3288: Make s2r reliable by switching PLLs to slow mode Date: Mon, 22 Dec 2014 11:31:48 -0800 Message-Id: <1419276708-28294-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141222_113235_506259_FD8A83E1 X-CRM114-Status: GOOD ( 15.32 ) X-Spam-Score: -0.8 (/) Cc: linux-rockchip@lists.infradead.org, sboyd@codeaurora.org, Doug Anderson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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 X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We've been seeing some crashes at resume time on rk3288-based systems. On some machines they simply never wake up from suspend. Symptoms include: - System clearly got to sleep OK. Power consumption is low, the PWM for the PWM regulator has stopped, and the "global_pwroff" output shows that the system is down. - When system tries to wake up power consumption goes up. - No kernel resume code (which was left in PMU SRAM) ran. We added some basic logging to this code (write to a location in SRAM right at resume time) and didn't see the logging run. It appears that we can fix the problem by slowing down APLL before we suspend. On the system I tested things seemed reliable if I disabled 1.8GHz and 1.7GHz. The Mask ROM itself tries to slow things down (which is why PLLs are in slow mode by the time we get to the kernel), but apparently it is crashing before it even gets there. We'll be super paranoid and not just go down to 1.6GHz but we'll match what the Mask ROM seems to be doing and go into slow mode. We'll also be safe and put all PLLs (not just APLL) into slow mode (well, except DPLL which is needed for SDRAM). We'll even put NPLL into slow mode which the Mask ROM didn't do (not that it's used for much important stuff at early resume time). Note that the old Rockchip reference code did something just like this, though they jammed it into pm.c instead of putting it in the syscore ops of the clock driver. Signed-off-by: Doug Anderson --- drivers/clk/rockchip/clk-rk3288.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c index ac6be7c..8cf4210 100644 --- a/drivers/clk/rockchip/clk-rk3288.c +++ b/drivers/clk/rockchip/clk-rk3288.c @@ -805,6 +805,20 @@ static int rk3288_clk_suspend(void) rk3288_saved_cru_regs[i] = readl_relaxed(rk3288_cru_base + reg_id); } + + /* + * Switch PLLs other than DPLL (for SDRAM) to slow mode to + * avoid crashes on resume. The Mask ROM on the system will + * put APLL, CPLL, and GPLL into slow mode at resume time + * anyway (which is why we restore them), but we might not + * even make it to the Mask ROM if this isn't done at suspend + * time. + * + * NOTE: only APLL truly matters here, but we'll do them all. + */ + + writel_relaxed(0xf3030000, rk3288_cru_base + RK3288_MODE_CON); + return 0; }