* [PATCH v2 1/2] dt-bindings: rng: atmel-trng: add new compatible
@ 2019-11-04 11:54 Codrin Ciubotariu
2019-11-04 11:54 ` [PATCH v2 2/2] hwrng: atmel: add new platform support for sam9x60 Codrin Ciubotariu
2019-11-15 6:05 ` [PATCH v2 1/2] dt-bindings: rng: atmel-trng: add new compatible Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Codrin Ciubotariu @ 2019-11-04 11:54 UTC (permalink / raw)
To: linux-crypto, devicetree, linux-arm-kernel, linux-kernel
Cc: mpm, herbert, robh+dt, mark.rutland, nicolas.ferre,
alexandre.belloni, ludovic.desroches, arnd, Tudor.Ambarus,
Claudiu.Beznea, Codrin Ciubotariu, Rob Herring
Add compatible for new IP found on sam9x60 SoC.
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Acked-by: Rob Herring <robh@kernel.org>
---
Changes in v2:
- added 'Acked-by' from Rob;
Documentation/devicetree/bindings/rng/atmel-trng.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/rng/atmel-trng.txt b/Documentation/devicetree/bindings/rng/atmel-trng.txt
index 4ac5aaa2d024..3900ee4f3532 100644
--- a/Documentation/devicetree/bindings/rng/atmel-trng.txt
+++ b/Documentation/devicetree/bindings/rng/atmel-trng.txt
@@ -1,7 +1,7 @@
Atmel TRNG (True Random Number Generator) block
Required properties:
-- compatible : Should be "atmel,at91sam9g45-trng"
+- compatible : Should be "atmel,at91sam9g45-trng" or "microchip,sam9x60-trng"
- reg : Offset and length of the register set of this block
- interrupts : the interrupt number for the TRNG block
- clocks: should contain the TRNG clk source
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] hwrng: atmel: add new platform support for sam9x60
2019-11-04 11:54 [PATCH v2 1/2] dt-bindings: rng: atmel-trng: add new compatible Codrin Ciubotariu
@ 2019-11-04 11:54 ` Codrin Ciubotariu
2019-11-15 6:05 ` [PATCH v2 1/2] dt-bindings: rng: atmel-trng: add new compatible Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Codrin Ciubotariu @ 2019-11-04 11:54 UTC (permalink / raw)
To: linux-crypto, devicetree, linux-arm-kernel, linux-kernel
Cc: mpm, herbert, robh+dt, mark.rutland, nicolas.ferre,
alexandre.belloni, ludovic.desroches, arnd, Tudor.Ambarus,
Claudiu.Beznea, Codrin Ciubotariu
Add platform support for the new IP found on sam9x60 SoC. For this
version, if the peripheral clk is above 100MHz, the HALFR bit must be
set. This bit is available only if the IP can generate a random number
every 168 cycles (instead of 84).
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
---
Changes in v2:
- replaced '*pdata' with '*data';
- added 'const' to trng_data configs;
drivers/char/hw_random/atmel-rng.c | 39 ++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/char/hw_random/atmel-rng.c b/drivers/char/hw_random/atmel-rng.c
index b3138ec26f85..ecb71c4317a5 100644
--- a/drivers/char/hw_random/atmel-rng.c
+++ b/drivers/char/hw_random/atmel-rng.c
@@ -14,14 +14,22 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/hw_random.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#define TRNG_CR 0x00
+#define TRNG_MR 0x04
#define TRNG_ISR 0x1c
#define TRNG_ODATA 0x50
#define TRNG_KEY 0x524e4700 /* RNG */
+#define TRNG_HALFR BIT(0) /* generate RN every 168 cycles */
+
+struct atmel_trng_data {
+ bool has_half_rate;
+};
+
struct atmel_trng {
struct clk *clk;
void __iomem *base;
@@ -62,6 +70,7 @@ static void atmel_trng_disable(struct atmel_trng *trng)
static int atmel_trng_probe(struct platform_device *pdev)
{
struct atmel_trng *trng;
+ const struct atmel_trng_data *data;
int ret;
trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
@@ -75,6 +84,17 @@ static int atmel_trng_probe(struct platform_device *pdev)
trng->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(trng->clk))
return PTR_ERR(trng->clk);
+ data = of_device_get_match_data(&pdev->dev);
+ if (!data)
+ return -ENODEV;
+
+ if (data->has_half_rate) {
+ unsigned long rate = clk_get_rate(trng->clk);
+
+ /* if peripheral clk is above 100MHz, set HALFR */
+ if (rate > 100000000)
+ writel(TRNG_HALFR, trng->base + TRNG_MR);
+ }
ret = clk_prepare_enable(trng->clk);
if (ret)
@@ -139,9 +159,24 @@ static const struct dev_pm_ops atmel_trng_pm_ops = {
};
#endif /* CONFIG_PM */
+static const struct atmel_trng_data at91sam9g45_config = {
+ .has_half_rate = false,
+};
+
+static const struct atmel_trng_data sam9x60_config = {
+ .has_half_rate = true,
+};
+
static const struct of_device_id atmel_trng_dt_ids[] = {
- { .compatible = "atmel,at91sam9g45-trng" },
- { /* sentinel */ }
+ {
+ .compatible = "atmel,at91sam9g45-trng",
+ .data = &at91sam9g45_config,
+ }, {
+ .compatible = "microchip,sam9x60-trng",
+ .data = &sam9x60_config,
+ }, {
+ /* sentinel */
+ }
};
MODULE_DEVICE_TABLE(of, atmel_trng_dt_ids);
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: rng: atmel-trng: add new compatible
2019-11-04 11:54 [PATCH v2 1/2] dt-bindings: rng: atmel-trng: add new compatible Codrin Ciubotariu
2019-11-04 11:54 ` [PATCH v2 2/2] hwrng: atmel: add new platform support for sam9x60 Codrin Ciubotariu
@ 2019-11-15 6:05 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2019-11-15 6:05 UTC (permalink / raw)
To: Codrin Ciubotariu
Cc: linux-crypto, devicetree, linux-arm-kernel, linux-kernel, mpm,
robh+dt, mark.rutland, nicolas.ferre, alexandre.belloni,
ludovic.desroches, arnd, Tudor.Ambarus, Claudiu.Beznea,
Rob Herring
On Mon, Nov 04, 2019 at 01:54:56PM +0200, Codrin Ciubotariu wrote:
> Add compatible for new IP found on sam9x60 SoC.
>
> Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
>
> Changes in v2:
> - added 'Acked-by' from Rob;
>
> Documentation/devicetree/bindings/rng/atmel-trng.txt | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
All applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-15 6:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 11:54 [PATCH v2 1/2] dt-bindings: rng: atmel-trng: add new compatible Codrin Ciubotariu
2019-11-04 11:54 ` [PATCH v2 2/2] hwrng: atmel: add new platform support for sam9x60 Codrin Ciubotariu
2019-11-15 6:05 ` [PATCH v2 1/2] dt-bindings: rng: atmel-trng: add new compatible Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).