From patchwork Wed Dec 12 01:41:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10725465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCC7418A7 for ; Wed, 12 Dec 2018 01:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C01852A7C9 for ; Wed, 12 Dec 2018 01:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B44062A877; Wed, 12 Dec 2018 01:41:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6246C2A7E2 for ; Wed, 12 Dec 2018 01:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbeLLBlf (ORCPT ); Tue, 11 Dec 2018 20:41:35 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39804 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbeLLBlf (ORCPT ); Tue, 11 Dec 2018 20:41:35 -0500 Received: by mail-wm1-f66.google.com with SMTP id f81so4190937wmd.4; Tue, 11 Dec 2018 17:41:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=b0gmXsO5OP57gsVOEg45HXYJC2cIpKkznTobeXNbJS8=; b=aEHWop8kdfvYD14gSreb9344r9sp99fsE4jkjrVTbBsU5hvWsgvB+98jQQ5+QJqv+6 BVv1kk4p4OD3FUjtylxP6zYhRTavkNKTpZnNLXkaP3Ut+c7dirBDiW5EPQNJj2dtMU6O K1A1IR39Rg0zm0RSKuOoFH6p5xtQsDlrSpRxWZg1tmTXbt8pC682AEUUVKtTAcvcr5Ob bCIwmNRsSvzpArAjlj9Tn8nz0uQQvOQyVm1NVk0hS4L5MYu5EIaIYOJJIdMelVoMUczQ oc+eq36+NncGFTogceFinVnbYBh5G/1PNnnRn22LTW+zCHtraMFJjgSMsmB0ZzHwW1+a sUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=b0gmXsO5OP57gsVOEg45HXYJC2cIpKkznTobeXNbJS8=; b=JD05TyUGgQ3HXg/Sc6QYqfEU4oWBcu5mZp97z+CaZYvG3RUd8e/eylqXDXpHtF1NHz CB9KfpcDbLPvxo4f5qQZzv3wLG9+g11XiZ+/xLVdsP5DYRUndlOJVGTWZZi4EMiJcCSl K+Ew5syqUyvGW6E6uqFcWbz++cnajnRQ0QZt4VOmjzxIiaLtEZupg49b2enLXHIBavzX WPIQKVkEsFfPL+xD5S6rwCgXvY6xAZF8gNHiHlJeFxu1jkCHAUopURkxwFxZHJw2d1ZW Fw++cG7FtEdwVPXRinqVLab/5c7DwTEMaFGJaud2NpZRrPllcaPyVeHFhaVjOLCRzDA0 s2FQ== X-Gm-Message-State: AA+aEWbF+uJQXL2kZCuzoRvNPAg4y9qy/LKRSrgsb72iNs6I5Xy7PtPO AhuJmfKP/wLo5wfLKHVDpQmoyagM X-Google-Smtp-Source: AFSGD/VWRxicaeCGs0ThmDYdKpI9xyiLWR2GGpQTdgz3yI6d3y0qOxnOfpRHKZwecXW8MfM1apYJeA== X-Received: by 2002:a1c:a84f:: with SMTP id r76mr4486509wme.16.1544578893678; Tue, 11 Dec 2018 17:41:33 -0800 (PST) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id v1sm20864870wrw.90.2018.12.11.17.41.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 17:41:32 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-clk@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Marek Vasut , Alexey Firago , Laurent Pinchart , Michael Turquette , Stephen Boyd Subject: [PATCH V2] clk: vc5: Add suspend/resume support Date: Wed, 12 Dec 2018 02:41:30 +0100 Message-Id: <20181212014130.18634-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.18.0 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add simple suspend/resume handlers to the driver to restore the chip configuration after resume. It is possible that the chip was configured with non-default values before suspend-resume cycle and that the chip is powered down during this cycle, so the configuration could get lost. Signed-off-by: Marek Vasut Cc: Alexey Firago Cc: Laurent Pinchart Cc: Michael Turquette Cc: Stephen Boyd Cc: linux-renesas-soc@vger.kernel.org --- V2: Replace ifdef with __maybe_unused Simplify return value handling in resume --- drivers/clk/clk-versaclock5.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c index decffb3826ec..b66586a3abb7 100644 --- a/drivers/clk/clk-versaclock5.c +++ b/drivers/clk/clk-versaclock5.c @@ -906,6 +906,34 @@ static int vc5_remove(struct i2c_client *client) return 0; } +static int __maybe_unused vc5_suspend(struct device *dev) +{ + struct vc5_driver_data *vc5 = dev_get_drvdata(dev); + int ret; + + ret = regcache_sync(vc5->regmap); + if (ret != 0) { + dev_err(dev, "Failed to save register map: %d\n", ret); + return ret; + } + regcache_cache_only(vc5->regmap, true); + regcache_mark_dirty(vc5->regmap); + + return 0; +} + +static int __maybe_unused vc5_resume(struct device *dev) +{ + struct vc5_driver_data *vc5 = dev_get_drvdata(dev); + int ret; + + regcache_cache_only(vc5->regmap, false); + ret = regcache_sync(vc5->regmap); + if (ret) + dev_err(dev, "Failed to restore register map: %d\n", ret); + return ret; +} + static const struct vc5_chip_info idt_5p49v5923_info = { .model = IDT_VC5_5P49V5923, .clk_fod_cnt = 2, @@ -961,9 +989,12 @@ static const struct of_device_id clk_vc5_of_match[] = { }; MODULE_DEVICE_TABLE(of, clk_vc5_of_match); +static SIMPLE_DEV_PM_OPS(vc5_pm_ops, vc5_suspend, vc5_resume); + static struct i2c_driver vc5_driver = { .driver = { .name = "vc5", + .pm = &vc5_pm_ops, .of_match_table = clk_vc5_of_match, }, .probe = vc5_probe,