bmips: switch to upstream bcm2835-rng reset patch
authorÁlvaro Fernández Rojas <noltari@gmail.com>
Fri, 12 Mar 2021 13:29:51 +0000 (14:29 +0100)
committerÁlvaro Fernández Rojas <noltari@gmail.com>
Fri, 12 Mar 2021 13:29:51 +0000 (14:29 +0100)
This patch has been accepted upstream.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
target/linux/bmips/patches-5.10/052-dt-bindings-rng-bcm2835-add-clock-constraints.patch [new file with mode: 0644]
target/linux/bmips/patches-5.10/053-dt-bindings-rng-bcm2835-document-reset-support.patch [new file with mode: 0644]
target/linux/bmips/patches-5.10/054-hwrng-bcm2835-add-reset-support.patch [new file with mode: 0644]
target/linux/bmips/patches-5.10/207-hwrng-bcm2835-add-reset-support.patch [deleted file]

diff --git a/target/linux/bmips/patches-5.10/052-dt-bindings-rng-bcm2835-add-clock-constraints.patch b/target/linux/bmips/patches-5.10/052-dt-bindings-rng-bcm2835-add-clock-constraints.patch
new file mode 100644 (file)
index 0000000..246293e
--- /dev/null
@@ -0,0 +1,38 @@
+From 0618e07ea3e0981d7765b43d3f7db39e739842eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
+Date: Fri, 5 Mar 2021 08:01:30 +0100
+Subject: [PATCH 1/3] dt-bindings: rng: bcm2835: add clock constraints
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+brcm,bcm6368-rng controllers require enabling the IPSEC clock in order to get
+a functional RNG.
+
+Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Acked-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+---
+ .../devicetree/bindings/rng/brcm,bcm2835.yaml          | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml
++++ b/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml
+@@ -35,6 +35,16 @@ required:
+   - compatible
+   - reg
++if:
++  properties:
++    compatible:
++      enum:
++        - brcm,bcm6368-rng
++then:
++  required:
++    - clocks
++    - clock-names
++
+ additionalProperties: false
+ examples:
diff --git a/target/linux/bmips/patches-5.10/053-dt-bindings-rng-bcm2835-document-reset-support.patch b/target/linux/bmips/patches-5.10/053-dt-bindings-rng-bcm2835-document-reset-support.patch
new file mode 100644 (file)
index 0000000..ce14a10
--- /dev/null
@@ -0,0 +1,51 @@
+From 381345820db55bf8e7289de047c24c00a2e3690d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
+Date: Fri, 5 Mar 2021 08:01:31 +0100
+Subject: [PATCH 2/3] dt-bindings: rng: bcm2835: document reset support
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+brcm,bcm6368-rng controllers require resetting the IPSEC clock in order to get
+a functional RNG.
+
+Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Acked-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+---
+ .../devicetree/bindings/rng/brcm,bcm2835.yaml         | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+--- a/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml
++++ b/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml
+@@ -28,6 +28,12 @@ properties:
+   clock-names:
+     const: ipsec
++  resets:
++    maxItems: 1
++
++  reset-names:
++    const: ipsec
++
+   interrupts:
+     maxItems: 1
+@@ -44,6 +50,8 @@ then:
+   required:
+     - clocks
+     - clock-names
++    - resets
++    - reset-names
+ additionalProperties: false
+@@ -68,4 +76,7 @@ examples:
+         clocks = <&periph_clk 18>;
+         clock-names = "ipsec";
++
++        resets = <&periph_rst 4>;
++        reset-names = "ipsec";
+     };
diff --git a/target/linux/bmips/patches-5.10/054-hwrng-bcm2835-add-reset-support.patch b/target/linux/bmips/patches-5.10/054-hwrng-bcm2835-add-reset-support.patch
new file mode 100644 (file)
index 0000000..24b7481
--- /dev/null
@@ -0,0 +1,78 @@
+From e5f9f41d5e62004c913bfd4ddf06abe032f5ce1c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
+Date: Fri, 5 Mar 2021 08:01:32 +0100
+Subject: [PATCH 3/3] hwrng: bcm2835 - add reset support
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+BCM6368 devices need to reset the IPSEC controller 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 <noltari@gmail.com>
+Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
+Acked-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+---
+ drivers/char/hw_random/bcm2835-rng.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/drivers/char/hw_random/bcm2835-rng.c
++++ b/drivers/char/hw_random/bcm2835-rng.c
+@@ -13,6 +13,7 @@
+ #include <linux/platform_device.h>
+ #include <linux/printk.h>
+ #include <linux/clk.h>
++#include <linux/reset.h>
+ #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
+                       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 plat
+       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;
diff --git a/target/linux/bmips/patches-5.10/207-hwrng-bcm2835-add-reset-support.patch b/target/linux/bmips/patches-5.10/207-hwrng-bcm2835-add-reset-support.patch
deleted file mode 100644 (file)
index 1da0e95..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-From 846cd2c9eee7a99de29c743911cc047fdd56db02 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
-Date: Mon, 22 Feb 2021 20:41:04 +0100
-Subject: [PATCH] hwrng: bcm2835: add reset support
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-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 <noltari@gmail.com>
----
- drivers/char/hw_random/bcm2835-rng.c | 10 ++++++++++
- 1 file changed, 10 insertions(+)
-
---- a/drivers/char/hw_random/bcm2835-rng.c
-+++ b/drivers/char/hw_random/bcm2835-rng.c
-@@ -13,6 +13,7 @@
- #include <linux/platform_device.h>
- #include <linux/printk.h>
- #include <linux/clk.h>
-+#include <linux/reset.h>
- #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
-                       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 plat
-       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;