blob: c35f5992e2f37dcbc74bd2ed951998d94975863b [file] [log] [blame]
Marek Behúnaa5eb9a2017-06-09 19:28:44 +02001/*
2 * I2C Driver for Atmel ATSHA204 over I2C
3 *
4 * Copyright (C) 2014 Josh Datko, Cryptotronix, jbd@cryptotronix.com
Wolfgang Denk0cf207e2021-09-27 17:42:39 +02005 * 2016 Tomas Hlavacek, CZ.NIC, tmshlvck@gmail.com
Marek Behún61143f72022-06-01 17:17:06 +02006 * 2017 Marek Behún, CZ.NIC, kabel@kernel.org
Marek Behúnaa5eb9a2017-06-09 19:28:44 +02007 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#ifndef _ATSHA204_I2C_H_
13#define _ATSHA204_I2C_H_
14
15enum atsha204a_zone
16{
17 ATSHA204A_ZONE_CONFIG = 0,
18 ATSHA204A_ZONE_OTP = 1,
19 ATSHA204A_ZONE_DATA = 2,
20};
21
22enum atsha204a_status
23{
24 ATSHA204A_STATUS_SUCCESS = 0x00,
25 ATSHA204A_STATUS_MISCOMPARE = 0x01,
26 ATSHA204A_STATUS_PARSE_ERROR = 0x03,
27 ATSHA204A_STATUS_EXEC_ERROR = 0x0F,
28 ATSHA204A_STATUS_AFTER_WAKE = 0x11,
29 ATSHA204A_STATUS_CRC_ERROR = 0xFF,
30};
31
32enum atsha204a_func
33{
34 ATSHA204A_FUNC_RESET = 0x00,
35 ATSHA204A_FUNC_SLEEP = 0x01,
36 ATSHA204A_FUNC_IDLE = 0x02,
37 ATSHA204A_FUNC_COMMAND = 0x03,
38};
39
40enum atsha204a_cmd
41{
42 ATSHA204A_CMD_READ = 0x02,
43 ATSHA204A_CMD_RANDOM = 0x1B,
44};
45
46struct atsha204a_resp
47{
48 u8 length;
49 u8 code;
50 u8 data[82];
51} __attribute__ ((packed));
52
53struct atsha204a_req
54{
55 u8 function;
56 u8 length;
57 u8 command;
58 u8 param1;
59 u16 param2;
60 u8 data[78];
61} __attribute__ ((packed));
62
63int atsha204a_wakeup(struct udevice *);
64int atsha204a_idle(struct udevice *);
65int atsha204a_sleep(struct udevice *);
66int atsha204a_read(struct udevice *, enum atsha204a_zone, bool, u16, u8 *);
67int atsha204a_get_random(struct udevice *, u8 *, size_t);
68
69#endif /* _ATSHA204_I2C_H_ */