Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3101045iog; Mon, 27 Jun 2022 09:08:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u16LW38AaOAqkpsg0l1VIO9/AMX1oAakJcfY1MoJLizl6kF1dlvjEJelblq/AZtHYjtHK/ X-Received: by 2002:a17:906:1018:b0:718:dd3f:f28c with SMTP id 24-20020a170906101800b00718dd3ff28cmr13856763ejm.55.1656346099186; Mon, 27 Jun 2022 09:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656346099; cv=none; d=google.com; s=arc-20160816; b=Ne4yLuZi1Yu0eDw+ZMMxCjT2Jq0SfJiVsMVQXqg1GwrcDLgblbahodTbbUwGE6uj4I v4qslCP1lETW7OHrq9y0mSlv5xZgMb9028WdcfZJNF1wyWseJfZCwkhFDtUoyFTDq4Xi TD1D5w0iB1+0NugEblJtf2Cax+gJca0K3vJ0K9/uxcZlcFpgU65bvwkryjx+Nxl4kzwj geuWjkYr41XoUzOEMslNyLUgqFIz+XNNNplsWkX0O/7Br7wa4EVIA7Mf2iPpCXbE0xRT 4Ph951yRut+7K+/Z7+1guPKLT0Bl88qyLHCtGJgnQmLO8quM4fr2TlX/fAB8Di1OeGJ1 aclw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0qlBRy1DTfSl+t/1HK5ZdOY+lMSvlxVr/aGDmF/nNOM=; b=WfS93L1RGYBAtuVhf3oSEZuY2TJ9MROZTq87LFPBgy4+eUdI0onlc/Yq+WqI1GBg2E xCreeoNsAuA0IlaBhb/wOsBUO/4POBcCGra7j6H2nmH34STXLaWLW3FzncwD4MklKRGm l39Qwysd/ObX+h5mYPI2dHqzRXFaAtrdPOL6d6iL7FXqInyWiuR0tau9Y7Zfp6++UYxV IVamuioXl5PwhGgzlYtmP6R/BvRyLxqdSXh1mKm/u+yzZLsca5tW7LgEz8vCK8IwjqEQ iepVd0RWs/9FmtUsmYKEQUX9+RMKGO1NG+wSrLj7yM+OVqVWB0oW4c9dKlQVqvgIF/p7 K6/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l18-20020aa7c312000000b004358044f044si12177635edq.432.2022.06.27.09.07.54; Mon, 27 Jun 2022 09:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238284AbiF0Pbt (ORCPT + 99 others); Mon, 27 Jun 2022 11:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238193AbiF0Pb2 (ORCPT ); Mon, 27 Jun 2022 11:31:28 -0400 Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62F0D19C3D for ; Mon, 27 Jun 2022 08:31:25 -0700 (PDT) Received: from ramsan.of.borg ([84.195.186.194]) by xavier.telenet-ops.be with bizsmtp id oFXH2700S4C55Sk01FXHaj; Mon, 27 Jun 2022 17:31:23 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1o5qhp-0014ye-0o; Mon, 27 Jun 2022 17:31:17 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o5qho-004jF0-J1; Mon, 27 Jun 2022 17:31:16 +0200 From: Geert Uytterhoeven To: Vignesh Raghavendra , Sergey Shtylyov , Krzysztof Kozlowski , Wolfram Sang , Lad Prabhakar , Miquel Raynal , Richard Weinberger Cc: Mark Brown , linux-mtd@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 7/7] memory: renesas-rpc-if: Reinitialize registers during system resume Date: Mon, 27 Jun 2022 17:31:14 +0200 Message-Id: <923c057c77b146710a82d486f89ce3a8ebda7ccd.1656341824.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During PSCI system suspend, R-Car Gen3 SoCs may be powered down, and thus the RPC-IF register state may be lost. Consequently, when using the RPC-IF after system resume, data corruption may happen. Fix this by reinitializing the hardware state during system resume. As this requires resuming the RPC-IF core device, this can only be done when the device is under active control of the HyperBus or SPI child driver. Signed-off-by: Geert Uytterhoeven --- drivers/memory/renesas-rpc-if.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c index ec76e603ad24d214..2a49d4511c8296c5 100644 --- a/drivers/memory/renesas-rpc-if.c +++ b/drivers/memory/renesas-rpc-if.c @@ -757,6 +757,20 @@ static int rpcif_remove(struct platform_device *pdev) return 0; } +static int rpcif_resume(struct device *dev) +{ + struct rpcif_priv *rpc = dev_get_drvdata(dev); + + if (!pm_runtime_enabled(dev)) { + /* Not yet activated or deactivated by child device */ + return 0; + } + + return rpcif_hw_init(dev, rpc->bus_size == 2); +} + +static DEFINE_SIMPLE_DEV_PM_OPS(rpcif_pm_ops, NULL, rpcif_resume); + static const struct of_device_id rpcif_of_match[] = { { .compatible = "renesas,rcar-gen3-rpc-if", .data = (void *)RPCIF_RCAR_GEN3 }, { .compatible = "renesas,rzg2l-rpc-if", .data = (void *)RPCIF_RZ_G2L }, @@ -770,6 +784,7 @@ static struct platform_driver rpcif_driver = { .driver = { .name = "rpc-if", .of_match_table = rpcif_of_match, + .pm = pm_sleep_ptr(&rpcif_pm_ops), }, }; module_platform_driver(rpcif_driver); -- 2.25.1