2024-04-27 00:14:55

by Lothar Rubusch

[permalink] [raw]
Subject: [PATCH 0/5] crypto: atmel-sha204a - read out otp zone

Read out otp memory zone of this secure eeprom and rng chip. The chip
has an otp zone and data zone, both still not accessed. The otp zone
can be used to store persistently serial numbers or similar, if externally
pre-configured. In any way the Atmel SHA204a needs to be preconfgured and
fuse locked in order to be useful also for the already implemented RNG
functionality. Placing data into the otp zone is optional. If empty, the
chip returns 0xff on all field. The implementation passes the content to
a new sysfs handle to userspace. If the chip is locked or not accessible
no sysfs handle is set.

Signed-off-by: Lothar Rubusch <[email protected]>
---

Lothar Rubusch (5):
crypto: atmel-i2 - add missing arg description
crypto: atmel-sha204a - remove unused includes
crypto: atmel-i2c - rename read function
crypto: atmel-sha204a - add reading from otp zone
crypto: atmel-sha204a - provide the otp content

drivers/crypto/atmel-i2c.c | 30 +++++++++++--
drivers/crypto/atmel-i2c.h | 8 +++-
drivers/crypto/atmel-sha204a.c | 77 ++++++++++++++++++++++++++++++----
3 files changed, 102 insertions(+), 13 deletions(-)

--
2.39.2



2024-04-27 00:15:55

by Lothar Rubusch

[permalink] [raw]
Subject: [PATCH 3/5] crypto: atmel-i2c - rename read function

Make the memory read function name more specific to the read memory zone.
The Atmel SHA204 chips provide config, otp and data zone. The implemented
read function in fact only reads some fields in zone config. The function
renaming allows for a uniform naming scheme when reading from other memory
zones.

Signed-off-by: Lothar Rubusch <[email protected]>
---
drivers/crypto/atmel-i2c.c | 6 +++---
drivers/crypto/atmel-i2c.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/atmel-i2c.c b/drivers/crypto/atmel-i2c.c
index 83a9093ef..a0d0d4f2a 100644
--- a/drivers/crypto/atmel-i2c.c
+++ b/drivers/crypto/atmel-i2c.c
@@ -51,7 +51,7 @@ static void atmel_i2c_checksum(struct atmel_i2c_cmd *cmd)
*__crc16 = cpu_to_le16(bitrev16(crc16(0, data, len)));
}

-void atmel_i2c_init_read_cmd(struct atmel_i2c_cmd *cmd)
+void atmel_i2c_init_read_config_cmd(struct atmel_i2c_cmd *cmd)
{
cmd->word_addr = COMMAND;
cmd->opcode = OPCODE_READ;
@@ -68,7 +68,7 @@ void atmel_i2c_init_read_cmd(struct atmel_i2c_cmd *cmd)
cmd->msecs = MAX_EXEC_TIME_READ;
cmd->rxsize = READ_RSP_SIZE;
}
-EXPORT_SYMBOL(atmel_i2c_init_read_cmd);
+EXPORT_SYMBOL(atmel_i2c_init_read_config_cmd);

void atmel_i2c_init_random_cmd(struct atmel_i2c_cmd *cmd)
{
@@ -301,7 +301,7 @@ static int device_sanity_check(struct i2c_client *client)
if (!cmd)
return -ENOMEM;

- atmel_i2c_init_read_cmd(cmd);
+ atmel_i2c_init_read_config_cmd(cmd);

ret = atmel_i2c_send_receive(client, cmd);
if (ret)
diff --git a/drivers/crypto/atmel-i2c.h b/drivers/crypto/atmel-i2c.h
index a442b47a4..275297a82 100644
--- a/drivers/crypto/atmel-i2c.h
+++ b/drivers/crypto/atmel-i2c.h
@@ -178,7 +178,7 @@ void atmel_i2c_flush_queue(void);

int atmel_i2c_send_receive(struct i2c_client *client, struct atmel_i2c_cmd *cmd);

-void atmel_i2c_init_read_cmd(struct atmel_i2c_cmd *cmd);
+void atmel_i2c_init_read_config_cmd(struct atmel_i2c_cmd *cmd);
void atmel_i2c_init_random_cmd(struct atmel_i2c_cmd *cmd);
void atmel_i2c_init_genkey_cmd(struct atmel_i2c_cmd *cmd, u16 keyid);
int atmel_i2c_init_ecdh_cmd(struct atmel_i2c_cmd *cmd,
--
2.39.2


2024-04-27 00:22:06

by Lothar Rubusch

[permalink] [raw]
Subject: [PATCH 2/5] crypto: atmel-sha204a - remove unused includes

Remove unnecessarily included headers.

Signed-off-by: Lothar Rubusch <[email protected]>
---
drivers/crypto/atmel-sha204a.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
index c77f482d2..5c3fef6e9 100644
--- a/drivers/crypto/atmel-sha204a.c
+++ b/drivers/crypto/atmel-sha204a.c
@@ -5,17 +5,8 @@
* Copyright (c) 2019 Linaro, Ltd. <[email protected]>
*/

-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/errno.h>
#include <linux/i2c.h>
-#include <linux/init.h>
#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/scatterlist.h>
-#include <linux/slab.h>
-#include <linux/workqueue.h>
#include "atmel-i2c.h"

static void atmel_sha204a_rng_done(struct atmel_i2c_work_data *work_data,
--
2.39.2