From patchwork Sat Oct 17 21:28:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 7423531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1CD89BEEA4 for ; Sat, 17 Oct 2015 21:33:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3AFFB206EA for ; Sat, 17 Oct 2015 21:33:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 628AD206E7 for ; Sat, 17 Oct 2015 21:33:07 +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 1ZnZ3h-0006lO-LV; Sat, 17 Oct 2015 21:30:33 +0000 Received: from mail-lb0-f177.google.com ([209.85.217.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZnZ3d-0006iN-SF for linux-arm-kernel@lists.infradead.org; Sat, 17 Oct 2015 21:30:31 +0000 Received: by lbbpp2 with SMTP id pp2so91837937lbb.0 for ; Sat, 17 Oct 2015 14:30:06 -0700 (PDT) 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=NRWl8nemybIWTDYjjNJ6xGo0ZDci6+xPNe7bM7IevRA=; b=Ev2eq8XET7iBjcn6BraZmeaZWGHODYx+qQsTYELKYgNcsdUGOnXSTVxDUq1A/xICtA bLrrp5PkYMAC+fhc+3Ew9dezs17l0xvrNl9JUK8ojq5FadL7BlrUJDuLjohJXUd6cMWV Rh5QvPHMIS5c2bSG+cBHvaffR3s/HBuDGYT2SLkiE9w/Y59DTiHhXuYJpkVLlLX1zZcl tf5EXmY25Asu97U5Lu0al6mbBE0yW1UNckm9tykFbWH2A/eBMKubFakMQOCuw4/Q9Od1 0Iq4MZlvdtTGkSWd7jc2rRYe7qmCcV6BxSaXRukW5PTVT94H60bF7HmARsGY8s2infaY ROgA== X-Gm-Message-State: ALoCoQk96/Oa7w9i/zeOeGI1RZYIho4QP7MfXdTYEqqUr5h5SQpGTsfhrZEYJo41/Re81hMLE94k X-Received: by 10.112.32.72 with SMTP id g8mr11098059lbi.22.1445117406714; Sat, 17 Oct 2015 14:30:06 -0700 (PDT) Received: from enkidu.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id b193sm3976894lfb.46.2015.10.17.14.30.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Oct 2015 14:30:05 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH] pinctrl: mvebu: armada-38x: add suspend/resume support Date: Sat, 17 Oct 2015 23:28:48 +0200 Message-Id: <1445117328-31678-1-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151017_143030_119259_3F5463D9 X-CRM114-Status: GOOD ( 13.05 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, jason@lakedaemon.net, tawfik@marvell.com, jaz@semihalf.com, linus.walleij@linaro.org, nadavh@marvell.com, alior@marvell.com, gregory.clement@free-electrons.com, mw@semihalf.com, sebastian.hesselbarth@gmail.com 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 This commit adds suspend/resume support by saving and restoring registers' state in a dedicated array. Signed-off-by: Marcin Wojtas --- drivers/pinctrl/mvebu/pinctrl-armada-38x.c | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-38x.c b/drivers/pinctrl/mvebu/pinctrl-armada-38x.c index 6ec82c6..094cb48 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-38x.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-38x.c @@ -23,6 +23,7 @@ #include "pinctrl-mvebu.h" static void __iomem *mpp_base; +static u32 *mpp_saved_regs; static int armada_38x_mpp_ctrl_get(unsigned pid, unsigned long *config) { @@ -424,6 +425,7 @@ static int armada_38x_pinctrl_probe(struct platform_device *pdev) const struct of_device_id *match = of_match_device(armada_38x_pinctrl_of_match, &pdev->dev); struct resource *res; + int nregs; if (!match) return -ENODEV; @@ -441,11 +443,44 @@ static int armada_38x_pinctrl_probe(struct platform_device *pdev) soc->modes = armada_38x_mpp_modes; soc->nmodes = armada_38x_mpp_controls[0].npins; + nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG); + + mpp_saved_regs = devm_kcalloc(&pdev->dev, nregs, sizeof(u32), + GFP_KERNEL); + if (!mpp_saved_regs) + return -ENOMEM; + pdev->dev.platform_data = soc; return mvebu_pinctrl_probe(pdev); } +int armada_38x_pinctrl_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct mvebu_pinctrl_soc_info *soc = platform_get_drvdata(pdev); + int i, nregs; + + nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG); + + for (i = 0; i < nregs; i++) + mpp_saved_regs[i] = readl(mpp_base + i * 4); + + return 0; +} + +int armada_38x_pinctrl_resume(struct platform_device *pdev) +{ + struct mvebu_pinctrl_soc_info *soc = platform_get_drvdata(pdev); + int i, nregs; + + nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG); + + for (i = 0; i < nregs; i++) + writel(mpp_saved_regs[i], mpp_base + i * 4); + + return 0; +} + static int armada_38x_pinctrl_remove(struct platform_device *pdev) { return mvebu_pinctrl_remove(pdev); @@ -458,6 +493,8 @@ static struct platform_driver armada_38x_pinctrl_driver = { }, .probe = armada_38x_pinctrl_probe, .remove = armada_38x_pinctrl_remove, + .suspend = armada_38x_pinctrl_suspend, + .resume = armada_38x_pinctrl_resume, }; module_platform_driver(armada_38x_pinctrl_driver);