2019-04-30 16:31:18

by Ard Biesheuvel

[permalink] [raw]
Subject: [PATCH 0/5] synquacer - wire up Atmel SHA204A as RNG in DT and ACPI mode

The Socionext SynQuacer based 96boards DeveloperBox platform does not
incorporate a random number generator, but it does have a 96boards low
speed connector which supports extension boards such as the Secure96,
which has a TPM and some crypto accelerators, one of which incorporates
a random number generator.

This series implements support for the RNG part, which is one of several
functions of the Atmel SHA204A I2C crypto accelerator, and wires it up so
both DT and ACPI based boot methods can use the device.

Cc: Herbert Xu <[email protected]>
Cc: Tudor Ambarus <[email protected]>

Ard Biesheuvel (5):
i2c: acpi: permit bus speed to be discovered after enumeration
crypto: atmel-ecc: add support for ACPI probing on non-AT91 platforms
crypto: atmel-ecc: factor out code that can be shared
crypto: atmel-i2c: add support for SHA204A random number generator
dt-bindings: add Atmel SHA204A I2C crypto processor

Documentation/devicetree/bindings/crypto/atmel-crypto.txt | 13 +
drivers/crypto/Kconfig | 19 +-
drivers/crypto/Makefile | 2 +
drivers/crypto/atmel-ecc.c | 403 ++------------------
drivers/crypto/atmel-ecc.h | 116 ------
drivers/crypto/atmel-i2c.c | 364 ++++++++++++++++++
drivers/crypto/atmel-i2c.h | 196 ++++++++++
drivers/crypto/atmel-sha204a.c | 171 +++++++++
drivers/i2c/i2c-core-acpi.c | 6 +-
9 files changed, 790 insertions(+), 500 deletions(-)
delete mode 100644 drivers/crypto/atmel-ecc.h
create mode 100644 drivers/crypto/atmel-i2c.c
create mode 100644 drivers/crypto/atmel-i2c.h
create mode 100644 drivers/crypto/atmel-sha204a.c

--
2.20.1


2019-04-30 16:31:26

by Ard Biesheuvel

[permalink] [raw]
Subject: [PATCH 2/5] crypto: atmel-ecc: add support for ACPI probing on non-AT91 platforms

The Atmel/Microchip EC508A is a I2C device that could be wired into
any platform, and is being used on the Linaro/96boards Secure96
mezzanine adapter. This means it could be found on any platform, even
on ones that use ACPI enumeration (via PRP0001 devices). So update the
code to enable this use case.

This involves tweaking the bus rate discovery code to take ACPI probing
into account, which records the maximum bus rate as a property of the
slave device. For the atmel-ecc code, this means that the effective bus
rate should never exceed the maximum rate, unless we are dealing with
buggy firmware. Nonetheless, let's just use the existing plumbing to
discover the bus rate and keep the existing logic intact.

Signed-off-by: Ard Biesheuvel <[email protected]>
---
drivers/crypto/Kconfig | 1 -
drivers/crypto/atmel-ecc.c | 13 ++++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 0be55fcc19ba..4c95567e188f 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -530,7 +530,6 @@ config CRYPTO_DEV_ATMEL_SHA

config CRYPTO_DEV_ATMEL_ECC
tristate "Support for Microchip / Atmel ECC hw accelerator"
- depends on ARCH_AT91 || COMPILE_TEST
depends on I2C
select CRYPTO_ECDH
select CRC16
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index ba00e4563ca0..5705348f540f 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -657,11 +657,14 @@ static int atmel_ecc_probe(struct i2c_client *client,
return -ENODEV;
}

- ret = of_property_read_u32(client->adapter->dev.of_node,
- "clock-frequency", &bus_clk_rate);
- if (ret) {
- dev_err(dev, "of: failed to read clock-frequency property\n");
- return ret;
+ clk_rate = i2c_acpi_find_bus_speed(&client->adapter->dev);
+ if (!clk_rate) {
+ ret = device_property_read_u32(&client->adapter->dev,
+ "clock-frequency", &bus_clk_rate);
+ if (ret) {
+ dev_err(dev, "failed to read clock-frequency property\n");
+ return ret;
+ }
}

if (bus_clk_rate > 1000000L) {
--
2.20.1

2019-04-30 16:31:27

by Ard Biesheuvel

[permalink] [raw]
Subject: [PATCH 5/5] dt-bindings: add Atmel SHA204A I2C crypto processor

Add a compatible string for the Atmel SHA204A I2C crypto processor.

Cc: Rob Herring <[email protected]>
Cc: Mark Rutland <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
---
Documentation/devicetree/bindings/crypto/atmel-crypto.txt | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
index 6b458bb2440d..a93d4b024d0e 100644
--- a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
+++ b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
@@ -79,3 +79,16 @@ atecc508a@c0 {
compatible = "atmel,atecc508a";
reg = <0xC0>;
};
+
+* Symmetric Cryptography (I2C)
+
+Required properties:
+- compatible : must be "atmel,atsha204a".
+- reg: I2C bus address of the device.
+- clock-frequency: must be present in the i2c controller node.
+
+Example:
+atsha204a@c0 {
+ compatible = "atmel,atsha204a";
+ reg = <0xC0>;
+};
--
2.20.1

2019-05-09 20:45:33

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 5/5] dt-bindings: add Atmel SHA204A I2C crypto processor

On Tue, Apr 30, 2019 at 6:29 PM Ard Biesheuvel
<[email protected]> wrote:

> Add a compatible string for the Atmel SHA204A I2C crypto processor.
>
> Cc: Rob Herring <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Signed-off-by: Ard Biesheuvel <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2019-05-16 16:07:33

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH 5/5] dt-bindings: add Atmel SHA204A I2C crypto processor

(+ devicetree list)

On Tue, 30 Apr 2019 at 18:29, Ard Biesheuvel <[email protected]> wrote:
>
> Add a compatible string for the Atmel SHA204A I2C crypto processor.
>
> Cc: Rob Herring <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Signed-off-by: Ard Biesheuvel <[email protected]>
> ---
> Documentation/devicetree/bindings/crypto/atmel-crypto.txt | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> index 6b458bb2440d..a93d4b024d0e 100644
> --- a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> +++ b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> @@ -79,3 +79,16 @@ atecc508a@c0 {
> compatible = "atmel,atecc508a";
> reg = <0xC0>;
> };
> +
> +* Symmetric Cryptography (I2C)
> +
> +Required properties:
> +- compatible : must be "atmel,atsha204a".
> +- reg: I2C bus address of the device.
> +- clock-frequency: must be present in the i2c controller node.
> +
> +Example:
> +atsha204a@c0 {
> + compatible = "atmel,atsha204a";
> + reg = <0xC0>;
> +};
> --
> 2.20.1
>

If there are no objections to this patch, may I please have an ack?

2019-05-24 13:13:01

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH 5/5] dt-bindings: add Atmel SHA204A I2C crypto processor

On Tue, Apr 30, 2019 at 11:29 AM Ard Biesheuvel
<[email protected]> wrote:
>
> Add a compatible string for the Atmel SHA204A I2C crypto processor.
>
> Cc: Rob Herring <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Signed-off-by: Ard Biesheuvel <[email protected]>
> ---
> Documentation/devicetree/bindings/crypto/atmel-crypto.txt | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> index 6b458bb2440d..a93d4b024d0e 100644
> --- a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> +++ b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> @@ -79,3 +79,16 @@ atecc508a@c0 {
> compatible = "atmel,atecc508a";
> reg = <0xC0>;
> };
> +
> +* Symmetric Cryptography (I2C)

This doesn't really seem to be related to the rest of the file which
are all sub-blocks on SoCs. You could just add this one to
trivial-devices.yaml.

> +
> +Required properties:
> +- compatible : must be "atmel,atsha204a".
> +- reg: I2C bus address of the device.
> +- clock-frequency: must be present in the i2c controller node.

That's a property of the controller and doesn't belong here.

> +
> +Example:
> +atsha204a@c0 {

crypto@c0

> + compatible = "atmel,atsha204a";
> + reg = <0xC0>;
> +};
> --
> 2.20.1
>

2019-05-24 13:17:24

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH 5/5] dt-bindings: add Atmel SHA204A I2C crypto processor

On Fri, 24 May 2019 at 15:12, Rob Herring <[email protected]> wrote:
>
> On Tue, Apr 30, 2019 at 11:29 AM Ard Biesheuvel
> <[email protected]> wrote:
> >
> > Add a compatible string for the Atmel SHA204A I2C crypto processor.
> >
> > Cc: Rob Herring <[email protected]>
> > Cc: Mark Rutland <[email protected]>
> > Signed-off-by: Ard Biesheuvel <[email protected]>
> > ---
> > Documentation/devicetree/bindings/crypto/atmel-crypto.txt | 13 +++++++++++++
> > 1 file changed, 13 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> > index 6b458bb2440d..a93d4b024d0e 100644
> > --- a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> > +++ b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> > @@ -79,3 +79,16 @@ atecc508a@c0 {
> > compatible = "atmel,atecc508a";
> > reg = <0xC0>;
> > };
> > +
> > +* Symmetric Cryptography (I2C)
>
> This doesn't really seem to be related to the rest of the file which
> are all sub-blocks on SoCs. You could just add this one to
> trivial-devices.yaml.
>
> > +
> > +Required properties:
> > +- compatible : must be "atmel,atsha204a".
> > +- reg: I2C bus address of the device.
> > +- clock-frequency: must be present in the i2c controller node.
>
> That's a property of the controller and doesn't belong here.
>

Both comments apply equally to the ECC508 above it, which I
duplicated. Would you like me to move that one into
trivial-devices.yaml as well? (and drop the clock-freq property)

> > +
> > +Example:
> > +atsha204a@c0 {
>
> crypto@c0
>

OK.

> > + compatible = "atmel,atsha204a";
> > + reg = <0xC0>;
> > +};
> > --
> > 2.20.1
> >

2019-05-24 13:37:29

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH 5/5] dt-bindings: add Atmel SHA204A I2C crypto processor

On Fri, May 24, 2019 at 8:16 AM Ard Biesheuvel
<[email protected]> wrote:
>
> On Fri, 24 May 2019 at 15:12, Rob Herring <[email protected]> wrote:
> >
> > On Tue, Apr 30, 2019 at 11:29 AM Ard Biesheuvel
> > <[email protected]> wrote:
> > >
> > > Add a compatible string for the Atmel SHA204A I2C crypto processor.
> > >
> > > Cc: Rob Herring <[email protected]>
> > > Cc: Mark Rutland <[email protected]>
> > > Signed-off-by: Ard Biesheuvel <[email protected]>
> > > ---
> > > Documentation/devicetree/bindings/crypto/atmel-crypto.txt | 13 +++++++++++++
> > > 1 file changed, 13 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> > > index 6b458bb2440d..a93d4b024d0e 100644
> > > --- a/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> > > +++ b/Documentation/devicetree/bindings/crypto/atmel-crypto.txt
> > > @@ -79,3 +79,16 @@ atecc508a@c0 {
> > > compatible = "atmel,atecc508a";
> > > reg = <0xC0>;
> > > };
> > > +
> > > +* Symmetric Cryptography (I2C)
> >
> > This doesn't really seem to be related to the rest of the file which
> > are all sub-blocks on SoCs. You could just add this one to
> > trivial-devices.yaml.
> >
> > > +
> > > +Required properties:
> > > +- compatible : must be "atmel,atsha204a".
> > > +- reg: I2C bus address of the device.
> > > +- clock-frequency: must be present in the i2c controller node.
> >
> > That's a property of the controller and doesn't belong here.
> >
>
> Both comments apply equally to the ECC508 above it, which I
> duplicated.

Okay, I only quickly scanned it. The problem for this file will be
when converting to schema, it's generally 1 binding per file.

> Would you like me to move that one into
> trivial-devices.yaml as well? (and drop the clock-freq property)

If you want, but that can be a separate patch.

Rob