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: 5528921 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5AC65BEEA8 for ; Mon, 22 Dec 2014 19:32:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48BE2201BC for ; Mon, 22 Dec 2014 19:32:39 +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 638BB201BB for ; Mon, 22 Dec 2014 19:32:38 +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 1Y38ib-0003nD-T8; Mon, 22 Dec 2014 19:32:37 +0000 Received: from mail-ie0-x22e.google.com ([2607:f8b0:4001:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y38iZ-0003lX-0g for linux-rockchip@lists.infradead.org; Mon, 22 Dec 2014 19:32:35 +0000 Received: by mail-ie0-f174.google.com with SMTP id at20so4728315iec.5 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=GgE1OzH4+FcKoB2vZuJR5HZj8dsx/Yuz1Ex39R5RvVNPHw66JhNXaNqi3v6hHt179D IBBY86RrhB9/CQ4iCSFrB32SaD5/MYDVrfJXoEpeR3m1Z2rExx787y87n3Zpi0gkIm69 KmjJkJOGklRR4QPJxfowRrbdtUEDjDO15c6p3u1B8C98Ml4PBmQ655obCscNoVStv3Ft nkfqdEIi2eO333RYgf6WNhsTNJ5dFUZMzTe5iPJyOECjr+uhJ4eJmWfreVfjllFIkLf5 Iqo9pkmvq6KdS1+MVlHgxnFyJPkmKxbPySARFOON4Gvu2mkChC90CcrdObs7lslIwlUc 23Yw== X-Gm-Message-State: ALoCoQmYaUDEfTio9Tmo3Pm0sybH71v7jC/ydZUnbENXEUYDUvtT0rqMxNFyGxNbULCa2BT52e+l 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_103995_6E2C394C X-CRM114-Status: GOOD ( 13.61 ) 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-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=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; }