From patchwork Wed Oct 29 11:52:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 5186991 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 74283C11AC for ; Wed, 29 Oct 2014 11:54:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3446201CD for ; Wed, 29 Oct 2014 11:54:43 +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 C77BE20179 for ; Wed, 29 Oct 2014 11:54:42 +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 1XjRpp-0003yR-MD; Wed, 29 Oct 2014 11:54:41 +0000 Received: from mail-pd0-f196.google.com ([209.85.192.196]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XjRoR-0002jU-L3; Wed, 29 Oct 2014 11:53:16 +0000 Received: by mail-pd0-f196.google.com with SMTP id r10so1640975pdi.3 for ; Wed, 29 Oct 2014 04:52:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pZu+9HoGkZtAzyhdfJafxmiYPyRjSW8Jhc46T9x3na4=; b=FVeuNl/7G+oGslUp2sLhTO/YnxKKrzPrANAyaeGAT6DUkSWE7AgHp5qlgEYLGtjtIt wpB6RM26jPdJMjAPPWMklwMhkoELrVLPC7T+T52NFgxsCNPG+6WNiw3g3irfgFp2Nx/M yymYAJaBn8B9WPTwPJYatvd748DeKEczhbdWIGtk1yxp6+EeRHsQ3NMLYLSDag5QMHM2 FuhiE6vHS4unV6gnrDkkISzHRK3hukfcbNErUUq7yd8+oDsTS4S+UdFjc3Z/KYocA6KV W0E/iVtQuC2dIqxGnRwh5RyJ8wXFQz7tw8jJXnYlzDoznFWPheBtLyPCcxr3cKcB9mv0 4V7g== X-Received: by 10.66.191.8 with SMTP id gu8mr9942507pac.126.1414583573272; Wed, 29 Oct 2014 04:52:53 -0700 (PDT) Received: from localhost.localdomain ([104.166.103.139]) by mx.google.com with ESMTPSA id tc8sm3441987pab.19.2014.10.29.04.52.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 04:52:52 -0700 (PDT) From: Chris Zhong To: heiko@sntech.de, dianders@chromium.org Subject: [PATCH v6 2/7] pinctrl: rockchip: save and restore gpio6_c6 pinmux in suspend/resume Date: Wed, 29 Oct 2014 19:52:00 +0800 Message-Id: <1414583525-17395-3-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414583525-17395-1-git-send-email-zyw@rock-chips.com> References: <1414583525-17395-1-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141029_045315_720906_69284D49 X-CRM114-Status: GOOD ( 15.59 ) X-Spam-Score: -0.5 (/) Cc: Mark Rutland , Russell King , Pawel Moll , Ian Campbell , Linus Walleij , khilman@kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Rob Herring , linux-gpio@vger.kernel.org, Chris Zhong , mturquette@linaro.org, linux-arm-kernel@lists.infradead.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=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 Save and restore the gpio6_c6 pinmux setting, since Maskrom of RK3288 would modify it to sdmmc0_det, so it need to be restored to the correct setting after resume from Maskrom. Signed-off-by: Chris Zhong Tested-by: Doug Anderson Reviewed-by: Doug Anderson Tested-by: Heiko Stuebner Reviewed-by: Heiko Stuebner --- Changes in v6: None Changes in v5: - add pinctrl_force_default() in the error case Changes in v4: None Changes in v3: None Changes in v2: None drivers/pinctrl/pinctrl-rockchip.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 172ad1d..49ca40c 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -1770,16 +1770,44 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( return ctrl; } +#define RK3288_GRF_GPIO6C_IOMUX 0x64 +#define GPIO6C6_SEL_WRITE_ENABLE BIT(28) + +static u32 rk3288_grf_gpio6c_iomux; + static int __maybe_unused rockchip_pinctrl_suspend(struct device *dev) { struct rockchip_pinctrl *info = dev_get_drvdata(dev); + int ret = pinctrl_force_sleep(info->pctl_dev); + + if (ret) + return ret; + + /* + * RK3288 GPIO6_C6 mux would be modified by Maskrom when resume, so save + * the setting here, and restore it at resume. + */ + if (info->ctrl->type == RK3288) { + ret = regmap_read(info->regmap_base, RK3288_GRF_GPIO6C_IOMUX, + &rk3288_grf_gpio6c_iomux); + if (ret) { + pinctrl_force_default(info->pctl_dev); + return ret; + } + } - return pinctrl_force_sleep(info->pctl_dev); + return 0; } static int __maybe_unused rockchip_pinctrl_resume(struct device *dev) { struct rockchip_pinctrl *info = dev_get_drvdata(dev); + int ret = regmap_write(info->regmap_base, RK3288_GRF_GPIO6C_IOMUX, + rk3288_grf_gpio6c_iomux | + GPIO6C6_SEL_WRITE_ENABLE); + + if (ret) + return ret; return pinctrl_force_default(info->pctl_dev); }