From patchwork Tue Feb 23 16:01:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= X-Patchwork-Id: 12100535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F430C433E0 for ; Tue, 23 Feb 2021 16:03:02 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 16BAC64DF3 for ; Tue, 23 Feb 2021 16:03:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16BAC64DF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qx1mqBhJ+Enqb3k/wR2v8u2FZgTgwBNEEAihetfUyyM=; b=V5qza0PUKwuvropNUmJGzVooHa XgO9hj83a6t5hP02/7v01l8u3Vpxwsi+4DsXfLiGf31PqIq9RnBJUqDUK6QA7Y+ZfCPWah//Rf3HB gl2asLZdRWsrhOJxkcLXsPlupQSGJqnPS8szdqiwjI8N9d/CasreYM4LCq9/yyHI9Zysw9gYRpJUF hKHmwlSDCiORetBtNUNWOxD92BQ6DufPe5yIk+NqDEbne/4sS+DpskXYAneceu+IWLTvCVH86Q9WN fd0peNuvAHCleP8SbQshititd7vXPA9cqZiKUA0LEdzwIUGFomF+PnOs9sWR6wvUNZ/Rf7p4OIU+c +FWSOYtQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEa8B-0006Wq-Hw; Tue, 23 Feb 2021 16:01:47 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEa82-0006Uu-Hw; Tue, 23 Feb 2021 16:01:39 +0000 Received: by mail-wr1-x42c.google.com with SMTP id v1so23090733wrd.6; Tue, 23 Feb 2021 08:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QF57n3BJmbnE5g02H0hISJw4D48Vk03Ja0GucFbbgno=; b=g7yKIyLjHLJAclUi1E3w2cGHPPPeepCJF8hoqOLbcLBjV3PJCdTaErAvevJG6OwOYT ttX7Raveeakz/9V1ipN9FlrsS+TOVaGEtNrGhTKe4sqOSmFL5L/PIwwv9Adb4UW89WKZ 7XOpeH5JRAcbzvFevD4j8ytIF72fdXX2+EM0awp6NvRfK1iIUM8ILZYZQTcFSRytRD+B eshykGlz/5TPS352P/WoN9loULc2LC7mAVFG4UM1Gny3LrvfEWzJ/2Fwl76wWLiICBXu vWIcMVqy2ZVTzCH53efuq9oZIih0asMcqgXiF3sjTN7oTQt9oOeflSmLfs9iW0ovano3 JZRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QF57n3BJmbnE5g02H0hISJw4D48Vk03Ja0GucFbbgno=; b=tmcAfm6Gzn7mJfuNHYPgpTsE8EHH+E+C+d7C+USNZgP8jMZBLRZ6Li6FyIbMJ0AL/r 5RmlBoEI/A+CZnAVwMCaAV7enPIlKaBVlIbjZnaH9X9Zutk7Hok7ZLz/zthsBnOo/6Ex PIfcJgWuJJEJ/ecaGboLDXCo0u+RmO3fZxI2IA9oFJjqOI2pXwrA6XAypazj3yqIllmH BsxhaZxVqpYF5vrXDm7nRsJALLGXrCpyG3u4W4j3AVkjCCK+5qnrgyXCwNtC3vBZhpsT YT1cfGXuAsgy9reM3TsnrrAeGxAtofGnYpLj+tG0G1kts9eZtwdHnu5viDM10KS3nR7z bioA== X-Gm-Message-State: AOAM530KyJ7Ux1o/WyMcRBbx1f1YEnh5Y+MddiLRoygBvJZ2X15RRuj2 jG7NamTyk5qHnmEzRcZS8eXuE2jq5zhaOLko X-Google-Smtp-Source: ABdhPJyDyKvRwCwF1dKgt6Z1WCk/jUJlEnXDpXuYT68NLSpG8Z5uiZzpxIacTv/1WrE1omqdAlD3yA== X-Received: by 2002:adf:c3c8:: with SMTP id d8mr1050138wrg.167.1614096096954; Tue, 23 Feb 2021 08:01:36 -0800 (PST) Received: from skynet.lan (170.red-88-1-105.dynamicip.rima-tde.net. [88.1.105.170]) by smtp.gmail.com with ESMTPSA id h15sm33999381wrh.13.2021.02.23.08.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 08:01:36 -0800 (PST) From: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= To: Matt Mackall , Herbert Xu , Rob Herring , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Nicolas Saenz Julienne , Philipp Zabel , Alexandru Ardelean , Neil Armstrong , Lee Jones , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Rikard Falkeborn , Stefan Wahren , linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] dt-bindings: rng: bcm2835: document reset support Date: Tue, 23 Feb 2021 17:01:30 +0100 Message-Id: <20210223160131.29053-2-noltari@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210223160131.29053-1-noltari@gmail.com> References: <20210222194510.14004-1-noltari@gmail.com> <20210223160131.29053-1-noltari@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_110138_638976_0B138524 X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 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 Some devices may need to perform a reset before using the RNG, such as the BCM6368. Signed-off-by: Álvaro Fernández Rojas --- v2: document reset support. Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml b/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml index c147900f9041..dba70764b7d0 100644 --- a/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml +++ b/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml @@ -31,6 +31,9 @@ properties: interrupts: maxItems: 1 + resets: + maxItems: 1 + required: - compatible - reg @@ -58,4 +61,6 @@ examples: clocks = <&periph_clk 18>; clock-names = "ipsec"; + + resets = <&periph_rst 4>; }; From patchwork Tue Feb 23 16:01:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= X-Patchwork-Id: 12100537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6371CC433DB for ; Tue, 23 Feb 2021 16:03:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2268664DF3 for ; Tue, 23 Feb 2021 16:03:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2268664DF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v3N/1/1t77qgdUN4KldY6TMfDNJJCk3Hngv1IVBae7E=; b=l9VBJ0Sh8HCOk/Ao7M/lBfDncd FEbj1xu5XZDmiVlYCwm16EFxxEgRsU0txjJCJWTEwaRoW+HyoUW6FrjX/pLvy51nAlBxxIpzwl222 Or1Kvmxkz5E2hqNeyqjO8CHHPN9157l/44rxCNmdrrijiUsW2XWU52IAdtln9oKXvWDBnuuOCGzS+ /jHxR4BnAZMUccZVdt1Qkdxa3wdh3IxCTUMyQryxCa1AI8Bqtg1uTnBa7WUggSUzuVE+skjPTWAa3 Vh6SiJufvO1qwbEYaEwTWouwn8b2S60RjA4MXEf3OqV8n5/kwvdlnMTsfKl/E4Qu0kXY8DUOhsz/r fKtzpCuQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEa8D-0006XA-Im; Tue, 23 Feb 2021 16:01:49 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEa83-0006VI-T6; Tue, 23 Feb 2021 16:01:42 +0000 Received: by mail-wr1-x436.google.com with SMTP id d11so3741753wrj.7; Tue, 23 Feb 2021 08:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=s5r6aoP8yUhDgWY4u8j/36byZXYgA21Asmj6U6dj7SQ=; b=Z6dUngibA3k2Zhdndsnjl7qXctPhCY0w7C9P9gjVTv8imnAyzSJn0bI5LDTWyIJfbA 9fmGK7lYVVJmslUpoG7zLGtN62SB4i3w/4HlJMRcMaoX4BhRWnxH+WyP9M3jYWGQr//L ZL7UbFQja2YtcTPHeDh3pnrj7HOQF2NF3cCcTK7ziy4a5Ue2/hhVl/j01FNLQ6xM2knY M6cVgnFkw6TfTgN5zuBD/2JVOLUPGAnN7gOOTwtsB0YaXNZs+wm30PyZZqv5F+I2JRul BlnhwGYwhEAZ4Z59y5Z5oY/O7kY+Gvcg630FOankem2YkWX6NCLPMjbfUjb6eMh6GFTZ xa/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s5r6aoP8yUhDgWY4u8j/36byZXYgA21Asmj6U6dj7SQ=; b=CnlyIYsvXUnDpWEJGrS+MjBf/7aASmoEpebRT/xEIp6I14u7fNGbUFsuQ94d1aFre4 o4GhAmnze06WhR0/L/5ik3IYulYFcXAn9q7APERnrEkr1mjMbuxY5AbkdB0eVih0oajR 9z9yp7SiN4EvPpFWLZP7IgdpUz24EScCyjgd9T4juNIpZIpKZ2z5gqml8Phl5mFzrIcq GkmyacHvVVkemXCyvESlEMwFOLtSWmM/PkNdOlz/FYtbPIagvvxRxeHEmmt9x//z8e3q TWdF3b9clJhI1vtxE4JJQeOOdUkN2k/2RWbqtaxm9dr1OPd2yq/urIE45kTNGHTrcacI YjaQ== X-Gm-Message-State: AOAM533g/qmuteElEMPVZJT/+3LNO2l2+3Q9J7i576DeHYMAuATm+9UK TPdmv3EhtjjGToisJZAOwDM= X-Google-Smtp-Source: ABdhPJwupnnvXFwHC3i/kzK26c7qamwCkq7cEOkWgqeQU0/8URXkmDCziwuLip7VcGDHeBw3PlTXLw== X-Received: by 2002:a05:6000:1a8c:: with SMTP id f12mr26949127wry.173.1614096098283; Tue, 23 Feb 2021 08:01:38 -0800 (PST) Received: from skynet.lan (170.red-88-1-105.dynamicip.rima-tde.net. [88.1.105.170]) by smtp.gmail.com with ESMTPSA id h15sm33999381wrh.13.2021.02.23.08.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 08:01:37 -0800 (PST) From: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= To: Matt Mackall , Herbert Xu , Rob Herring , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Nicolas Saenz Julienne , Philipp Zabel , Alexandru Ardelean , Neil Armstrong , Lee Jones , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Rikard Falkeborn , Stefan Wahren , linux-crypto@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] hwrng: bcm2835: add reset support Date: Tue, 23 Feb 2021 17:01:31 +0100 Message-Id: <20210223160131.29053-3-noltari@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210223160131.29053-1-noltari@gmail.com> References: <20210222194510.14004-1-noltari@gmail.com> <20210223160131.29053-1-noltari@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210223_110140_665133_DA2BF1A2 X-CRM114-Status: GOOD ( 15.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 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 BCM6368 devices need to reset the in order to generate true random numbers. This is what BCM6368 produces without a reset: root@OpenWrt:/# cat /dev/hwrng | rngtest -c 1000 rngtest 6.10 Copyright (c) 2004 by Henrique de Moraes Holschuh This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. rngtest: starting FIPS tests... rngtest: bits received from input: 20000032 rngtest: FIPS 140-2 successes: 0 rngtest: FIPS 140-2 failures: 1000 rngtest: FIPS 140-2(2001-10-10) Monobit: 2 rngtest: FIPS 140-2(2001-10-10) Poker: 1000 rngtest: FIPS 140-2(2001-10-10) Runs: 1000 rngtest: FIPS 140-2(2001-10-10) Long run: 30 rngtest: FIPS 140-2(2001-10-10) Continuous run: 0 rngtest: input channel speed: (min=37.253; avg=320.827; max=635.783)Mibits/s rngtest: FIPS tests speed: (min=12.141; avg=15.034; max=16.428)Mibits/s rngtest: Program run time: 1336176 microseconds Signed-off-by: Álvaro Fernández Rojas --- v2: no changes. drivers/char/hw_random/bcm2835-rng.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c index 1a7c43b43c6b..1b93a896d8e8 100644 --- a/drivers/char/hw_random/bcm2835-rng.c +++ b/drivers/char/hw_random/bcm2835-rng.c @@ -13,6 +13,7 @@ #include #include #include +#include #define RNG_CTRL 0x0 #define RNG_STATUS 0x4 @@ -32,6 +33,7 @@ struct bcm2835_rng_priv { void __iomem *base; bool mask_interrupts; struct clk *clk; + struct reset_control *reset; }; static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng) @@ -94,6 +96,10 @@ static int bcm2835_rng_init(struct hwrng *rng) return ret; } + ret = reset_control_reset(priv->reset); + if (ret) + return ret; + if (priv->mask_interrupts) { /* mask the interrupt */ val = rng_readl(priv, RNG_INT_MASK); @@ -159,6 +165,10 @@ static int bcm2835_rng_probe(struct platform_device *pdev) if (PTR_ERR(priv->clk) == -EPROBE_DEFER) return -EPROBE_DEFER; + priv->reset = devm_reset_control_get_optional_exclusive(dev, NULL); + if (IS_ERR(priv->reset)) + return PTR_ERR(priv->reset); + priv->rng.name = pdev->name; priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read;