From patchwork Tue Feb 23 17:00:05 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: 12100623 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 D4AC3C433E0 for ; Tue, 23 Feb 2021 17:01:37 +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 831EE64E7C for ; Tue, 23 Feb 2021 17:01:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 831EE64E7C 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=PLfogy1jh4cm1ABZytENfVurghqnWvmR+ZsFqvh+bYg=; b=fXp1UMZ2uN8bThjCoVsXpW9VJe yA1eIK4F57RzEaEmeiT+AP1O+rh+oo2xlf+9ORkaIbyPDkRdptFcmvQ6oVDVYRQJbW0WM6urNvP1m OL1G9NkRbr/xjEqfholdE3KsW3eAciXv1kkgkWfu9i42Dcg5z0/Tf6dnSLuaBebbwaFG48iWAYbzb LOxsce0wceSQXpgduVNyYblF6dWgFaZibX2y8ZJezUkoGdPZ/e+0SsTcDFShIwja7r9FTi27Ypx7I hcHL+MW6fpR//9b368fnEMQS6oRxixALy97tf/1e/EAldjY2uXVGS6ci3bVegK1yDX+ciLaHmrgVF lIFMUolQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEb2y-0005ei-1W; Tue, 23 Feb 2021 17:00:28 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEb2j-0005Yx-Aq; Tue, 23 Feb 2021 17:00:14 +0000 Received: by mail-wr1-x430.google.com with SMTP id w11so629790wrr.10; Tue, 23 Feb 2021 09:00:12 -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=OEwefO5s7q5tH8TqEcawfPCkw0BmTmIeA1fwlofl6+E=; b=Bvq5kq6G7MCxav6SCKRj9tVkSW2MxAaxSfktzpSeV0/O3T/obTjyqum3K1iDlWWgct 9mQZdnU3aioarFsdGaE3X+JrK+oMGiw08deIiIyeAeXVkQZOWLbi6SkORHSRJb1p3dDr jgPxkYRdGb6B5OvJHA7HV7TPM5DiciIPKAUoG0dr1hx3LfRAs7ZyslpT0buRQQRkUn5e OLctdS0KvBHXbhNVv3NG74BEZ+HftDSqtPkB+JhWG/56xeOTiKlJqW50sOstCqqOqMos cZKfq02U6vyRINuBwxANrC621kkx6V6jXumyLuZskLPen2rbsOCziVdyVSRs591haCby 4t0g== 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=OEwefO5s7q5tH8TqEcawfPCkw0BmTmIeA1fwlofl6+E=; b=sMKo5GtDtXVkKVd/qKURJ0K0jyeHje6g3TqfcM3zQJBRJTIU63e2BhvtkDKzqdFpHz gB2vsV/481kFEvMiwrTrzm01jdFEJR/vx9/lcbV1zKusCAOeJ8PSjNjs6WaCQYG4SFGG CO9/HB9iIlfRq8NOMWBh2+9sqznrcHyDsjlOjUWowsuDLh4IzMq3XXtrvwSITfJQBx6M 3jVMdd+4mZAoYPCmed57OmjcltanINl4kgoTorrPJjucun4nScOgJy0yb8jC6W6p5cLl JMuJrYbwrwWECmWq6SLQAkdpf/eQupNhkcswGMHmsI4onVWDzBprrdbtSNv/LzAX9RwN aBRg== X-Gm-Message-State: AOAM530FTQdE3wM7DyOtj3XBmAIt04YJNJ0eVzHfCESm7YYNfc0UCesF 7p1ucoOgcYLIrdC5hZHGmBs= X-Google-Smtp-Source: ABdhPJxzcvsA9J78p039E9gaxjTRycu1+O26r/KZPd+kCOMtGAsEnxNg6N9CcEyvyOY3R0lUAHANeg== X-Received: by 2002:a5d:58fb:: with SMTP id f27mr26949829wrd.119.1614099611881; Tue, 23 Feb 2021 09:00:11 -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 u12sm3057190wmq.38.2021.02.23.09.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 09:00:11 -0800 (PST) From: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= To: Matt Mackall , Herbert Xu , Rob Herring , Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Philipp Zabel , Mark Brown , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Guenter Roeck , Bjorn Andersson , =?utf-8?b?TsOtY29sYXMgRi4g?= =?utf-8?b?Ui4gQS4gUHJhZG8=?= , 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 v3 1/2] dt-bindings: rng: bcm2835: document reset support Date: Tue, 23 Feb 2021 18:00:05 +0100 Message-Id: <20210223170006.29558-2-noltari@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210223170006.29558-1-noltari@gmail.com> References: <20210222194510.14004-1-noltari@gmail.com> <20210223170006.29558-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_120013_459292_4953A070 X-CRM114-Status: GOOD ( 10.68 ) 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 --- v3: make resets required if brcm,bcm6368-rng. v2: document reset support. .../devicetree/bindings/rng/brcm,bcm2835.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml b/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml index c147900f9041..11c23e1f6988 100644 --- a/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml +++ b/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml @@ -37,6 +37,21 @@ required: additionalProperties: false +if: + properties: + compatible: + enum: + - brcm,bcm6368-rng +then: + properties: + resets: + maxItems: 1 + required: + - resets +else: + properties: + resets: false + examples: - | rng@7e104000 { @@ -58,4 +73,6 @@ examples: clocks = <&periph_clk 18>; clock-names = "ipsec"; + + resets = <&periph_rst 4>; }; From patchwork Tue Feb 23 17:00:06 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: 12100631 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 2E905C433E0 for ; Tue, 23 Feb 2021 17:01:52 +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 E61E364E77 for ; Tue, 23 Feb 2021 17:01:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E61E364E77 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=SzBTBeh9+j2DJgcWotUU4IghPgWwLQOI0BjPO9m5iIg=; b=AP75Skr6jxCCigJ0t/N+Nl17h/ z8HBYBTWYiwXkWpRIp0gW3hr+4A+6JaZgOQvkXwFgbR+L3GZMBbP6Z9nhC4pwMhp0ECesVEJUfIwK S9ylKw63W5qLD1EgwBYGmt2A3IpaNTcSbEizO3WyNGzq2pLg6CuV0g445fY2Toecro/ocLUW8nvva Acu/ZaGRBh5gMetZommlsI7sEUanYZr1kHkPMnZQ9G+6jpxGSOQhcDrPUmppIMOxNC7do5zczoS0X jlmgzCX6Brj6LFp1suUdaHUP14yvlERcVi5XbgpZlz1qpQVNZkJzScCiBfn3Z5bmt2FVm6Hy21/JC NrCQwXLQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEb37-0005gz-Jq; Tue, 23 Feb 2021 17:00:37 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lEb2k-0005Zq-Qj; Tue, 23 Feb 2021 17:00:16 +0000 Received: by mail-wr1-x434.google.com with SMTP id c7so6554276wru.8; Tue, 23 Feb 2021 09:00:14 -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=LiTCa6DBif/PzMmCMLr4DjB3Hi0VKw857tDOttZsLNE=; b=kvsOcWcgEK3QmhXthFAy5GwObgwYPEF1evtOsjmM1OlqsrMz9ykUBiMTT84HNzvxNe w6bPFW61/yt7h3aq8HEoKS6xhsJ0r5oUEuyyi07LMZEpZorhCGwhwN3dvt7Ilf9Jt8Cf +tcJsKnGVUaHMfVrEayhOSmnIalYFkGjB8IGyRAqPjcMKxpvk2su23+TuacMIdCMU3oa QpM8PLvtt40xHrkGze0uVqXBiye72Zudcb0UUBMgTS5iMr3fsM+T8RHueEaWQhYmSBoB Y9x2zJdpFoH0ZHQaSn796fspvcM8rtSPCMba4baFkllc8vJueFM0IrJkg/OnGkZXIJVL k0uQ== 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=LiTCa6DBif/PzMmCMLr4DjB3Hi0VKw857tDOttZsLNE=; b=R17K3RTvtMQp7OJ58EjU9gfdtEAlBW9aoQp1OigH7onJKkLFPlWzAdp9ABuyyouado Qe3V95ajNj3Cke3bh9LKEhXnlIZ4MSeHiSat8ILlHgnKapkfgRgjfrqMswHCdYuxCYEO t5SOG/HqIWBFxD5ZzXipQE5foDTiCx1/gvSqzfrpfXSHVluzYsZzpS3BhRbKTFiA+OP6 fgwnTkEwAlp97gZ705iecQNvP8JyAaeJ4KJjD8YCVaoRSjSGNrfodYwK7ehK1iSgxn0Z Ru4EXtbPXWDEP1jkbmsFlvFxsHgVtmWzDaxwrDjzH/VGj7ztnK8zZl33lddkrYvHRHIL 1Pzw== X-Gm-Message-State: AOAM531LbTttERg2zYFG4CVtlycJYEGT6r18Y1TBrRovnXVgQGb2nRyM jFqlouqRmgr+rX1QTzpqv/M= X-Google-Smtp-Source: ABdhPJykd3acZCrN6qeMOXqXvbtu9EKp9Em3ZBixIDwhCWnn+rgjhXGqBROKFqyF3KHZe7UtaEEBIQ== X-Received: by 2002:a5d:404d:: with SMTP id w13mr396623wrp.230.1614099613369; Tue, 23 Feb 2021 09:00:13 -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 u12sm3057190wmq.38.2021.02.23.09.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 09:00:12 -0800 (PST) From: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= To: Matt Mackall , Herbert Xu , Rob Herring , Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Philipp Zabel , Mark Brown , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Guenter Roeck , Bjorn Andersson , =?utf-8?b?TsOtY29sYXMgRi4g?= =?utf-8?b?Ui4gQS4gUHJhZG8=?= , 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 v3 2/2] hwrng: bcm2835: add reset support Date: Tue, 23 Feb 2021 18:00:06 +0100 Message-Id: <20210223170006.29558-3-noltari@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210223170006.29558-1-noltari@gmail.com> References: <20210222194510.14004-1-noltari@gmail.com> <20210223170006.29558-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_120014_926017_604F33C5 X-CRM114-Status: GOOD ( 16.67 ) 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 cat: write error: Broken pipe Signed-off-by: Álvaro Fernández Rojas --- v3: no changes. 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;