From patchwork Thu Aug 10 19:22:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 13349870 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D4F4C001B0 for ; Thu, 10 Aug 2023 19:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=krj9N6Ve5A/BiATwuAYlg3ZjLPgV8ZH6g1txQ0FzBpk=; b=0h7 flvSG8E1lrU24OYhcOGdYBl+iRbVqiYrpTrun/Gn2/N5aHTClU57J9knyor5epSTSLqo5sZ3SJsVX qp1/5gCDv3ipXxiiayA6Xsyjta5uBeKDZNtGFp49Ls60HkDAi9T9wGg7jcTtkcWg2xNUJgyWFtAlL uQuMD/pd6xDQzUsZR4DLMqVrlpPcosMqvTspj0lsiCSdboOKwD75v7bCl2fKMJuyoTFxdLEzAT8VC r48A0YswcUoNHC+X00/Ra3lccP5Aj7TDIoiBGCVUOnlVmDnb96GMiGA+euXkDQ9njcynVGpsILv+N OLylwYIrKjS4b76Eb44Z2f8gM6FEUoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qUBEq-008XGw-0I; Thu, 10 Aug 2023 19:22:28 +0000 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qUBEm-008XFa-2C for linux-arm-kernel@lists.infradead.org; Thu, 10 Aug 2023 19:22:26 +0000 Received: by mail-qt1-x834.google.com with SMTP id d75a77b69052e-40ff796e8ddso8372251cf.2 for ; Thu, 10 Aug 2023 12:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1691695340; x=1692300140; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=d1ZdznSRTB0tO6ePy6uWU2Qov85H2/ofIwfuQKJWicY=; b=bTkav/T/EuVIw9PJszbjNuSCvD5zOUl1qXATVy4D15DJjZrBYqHrn9MlFFOc9YCJtQ lG1PN4N2ZYK/zDFwxr1paJ1/7/DTJFjL8R4HJ3t8YdV9k2Ui7ryr8IqPBSmCg3d9BHqF BK5ToFrYzlOqEQK4xGVq3lx2gwrKblAbgbiKY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691695340; x=1692300140; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=d1ZdznSRTB0tO6ePy6uWU2Qov85H2/ofIwfuQKJWicY=; b=c9iSTUNxl8/IOXx56yAkkU8prr42laN/zAn4nV6dbiM95LKf4z1kXm0NDqFKMNIvyC XxAnES9Ur6c1aipkc8T3ITor8CK+QVuwo8A7GT8fGuGGtQMWIIOjQ1fGEVlpblJBR5GM BPrU+EKEK3aNRwypTT7K7i89B0aRu5z/eVCT+/a2QM0Me2+N45tC+aeSUHZboBEjslue s8bZUpDkodHXVjg40gAxnlpS59gSMP61X4DjLbor3lTmABh7G5DtRvbOKP1PzrrnAa48 2KkvNk+vEkBo6wOIPTgCUP2Zh9YkkosUVwMAO6X9Bwhb9JCKbfbL1hWmUOsDeVf+cnp1 jmPw== X-Gm-Message-State: AOJu0Yw2Bjzlqs2gxYYjr5nmSF6JS3BCvxwklgK2OFihbb2yAWP86m1i YgzBpVYvadcmWU4Q8VtEGgvG5A== X-Google-Smtp-Source: AGHT+IGEO1XfWCPP57s8DrZcRExhCymacAoXn0010yPOwVnSGaZXOb61YS6MN+HNqMXFhiXDWw45/A== X-Received: by 2002:a05:622a:94:b0:403:6ac5:e761 with SMTP id o20-20020a05622a009400b004036ac5e761mr5084457qtw.62.1691695340258; Thu, 10 Aug 2023 12:22:20 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id jx11-20020a05622a810b00b0040f8ac751a5sm686701qtb.96.2023.08.10.12.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 12:22:19 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: Florian Fainelli , Olivia Mackall , Herbert Xu , Ray Jui , Scott Branden , Broadcom internal kernel review list , linux-crypto@vger.kernel.org (open list:HARDWARE RANDOM NUMBER GENERATOR CORE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM IPROC ARM ARCHITECTURE) Subject: [PATCH] hwrng: iproc-rng200: Implement suspend and resume calls Date: Thu, 10 Aug 2023 12:22:08 -0700 Message-Id: <20230810192209.2611558-1-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230810_122224_755126_75329E30 X-CRM114-Status: GOOD ( 17.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Chips such as BCM7278 support system wide suspend/resume which will cause the HWRNG block to lose its state and reset to its power on reset register values. We need to cleanup and re-initialize the HWRNG for it to be functional coming out of a system suspend cycle. Fixes: c3577f6100ca ("hwrng: iproc-rng200 - Add support for BCM7278") Signed-off-by: Florian Fainelli --- drivers/char/hw_random/iproc-rng200.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/char/hw_random/iproc-rng200.c b/drivers/char/hw_random/iproc-rng200.c index 06bc060534d8..c0df053cbe4b 100644 --- a/drivers/char/hw_random/iproc-rng200.c +++ b/drivers/char/hw_random/iproc-rng200.c @@ -182,6 +182,8 @@ static int iproc_rng200_probe(struct platform_device *pdev) return PTR_ERR(priv->base); } + dev_set_drvdata(dev, priv); + priv->rng.name = "iproc-rng200"; priv->rng.read = iproc_rng200_read; priv->rng.init = iproc_rng200_init; @@ -199,6 +201,28 @@ static int iproc_rng200_probe(struct platform_device *pdev) return 0; } +static int __maybe_unused iproc_rng200_suspend(struct device *dev) +{ + struct iproc_rng200_dev *priv = dev_get_drvdata(dev); + + iproc_rng200_cleanup(&priv->rng); + + return 0; +} + +static int __maybe_unused iproc_rng200_resume(struct device *dev) +{ + struct iproc_rng200_dev *priv = dev_get_drvdata(dev); + + iproc_rng200_init(&priv->rng); + + return 0; +} + +static const struct dev_pm_ops iproc_rng200_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(iproc_rng200_suspend, iproc_rng200_resume) +}; + static const struct of_device_id iproc_rng200_of_match[] = { { .compatible = "brcm,bcm2711-rng200", }, { .compatible = "brcm,bcm7211-rng200", }, @@ -212,6 +236,7 @@ static struct platform_driver iproc_rng200_driver = { .driver = { .name = "iproc-rng200", .of_match_table = iproc_rng200_of_match, + .pm = &iproc_rng200_pm_ops, }, .probe = iproc_rng200_probe, };