summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/atmel-sha204a.c
diff options
context:
space:
mode:
authorLothar Rubusch <l.rubusch@gmail.com>2024-05-03 23:10:53 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2024-05-10 11:15:25 +0200
commite05ce444e9e59f924b53da8209bfb7208653817c (patch)
tree5503d5206154a6b54fdcc70947f59ba1b3f502ab /drivers/crypto/atmel-sha204a.c
parentcrypto: atmel-i2c - rename read function (diff)
downloadlinux-e05ce444e9e59f924b53da8209bfb7208653817c.tar.xz
linux-e05ce444e9e59f924b53da8209bfb7208653817c.zip
crypto: atmel-sha204a - add reading from otp zone
Provide a read function reading the otp zone. The otp zone can be used for storing serial numbers. The otp zone, as also data zone, are only accessible if the chip was locked before. Locking the chip is a post production customization and has to be done manually i.e. not by this driver. Without this step the chip is pretty much not usable, where putting or not putting data into the otp zone is optional. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--drivers/crypto/atmel-sha204a.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
index c77f482d2a97..563a0493b492 100644
--- a/drivers/crypto/atmel-sha204a.c
+++ b/drivers/crypto/atmel-sha204a.c
@@ -91,6 +91,29 @@ static int atmel_sha204a_rng_read(struct hwrng *rng, void *data, size_t max,
return max;
}
+static int atmel_sha204a_otp_read(struct i2c_client *client, u16 addr, u8 *otp)
+{
+ struct atmel_i2c_cmd cmd;
+ int ret = -1;
+
+ if (atmel_i2c_init_read_otp_cmd(&cmd, addr) < 0) {
+ dev_err(&client->dev, "failed, invalid otp address %04X\n",
+ addr);
+ return ret;
+ }
+
+ ret = atmel_i2c_send_receive(client, &cmd);
+
+ if (cmd.data[0] == 0xff) {
+ dev_err(&client->dev, "failed, device not ready\n");
+ return -ret;
+ }
+
+ memcpy(otp, cmd.data+1, 4);
+
+ return ret;
+}
+
static int atmel_sha204a_probe(struct i2c_client *client)
{
struct atmel_i2c_client_priv *i2c_priv;