scsi: qla2xxx: remove double assignment in qla2x00_update_fcport
[linux-2.6-microblaze.git] / drivers / crypto / atmel-ecc.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2017, Microchip Technology Inc.
4  * Author: Tudor Ambarus <tudor.ambarus@microchip.com>
5  */
6
7 #ifndef __ATMEL_ECC_H__
8 #define __ATMEL_ECC_H__
9
10 #define ATMEL_ECC_PRIORITY              300
11
12 #define COMMAND                         0x03 /* packet function */
13 #define SLEEP_TOKEN                     0x01
14 #define WAKE_TOKEN_MAX_SIZE             8
15
16 /* Definitions of Data and Command sizes */
17 #define WORD_ADDR_SIZE                  1
18 #define COUNT_SIZE                      1
19 #define CRC_SIZE                        2
20 #define CMD_OVERHEAD_SIZE               (COUNT_SIZE + CRC_SIZE)
21
22 /* size in bytes of the n prime */
23 #define ATMEL_ECC_NIST_P256_N_SIZE      32
24 #define ATMEL_ECC_PUBKEY_SIZE           (2 * ATMEL_ECC_NIST_P256_N_SIZE)
25
26 #define STATUS_RSP_SIZE                 4
27 #define ECDH_RSP_SIZE                   (32 + CMD_OVERHEAD_SIZE)
28 #define GENKEY_RSP_SIZE                 (ATMEL_ECC_PUBKEY_SIZE + \
29                                          CMD_OVERHEAD_SIZE)
30 #define READ_RSP_SIZE                   (4 + CMD_OVERHEAD_SIZE)
31 #define MAX_RSP_SIZE                    GENKEY_RSP_SIZE
32
33 /**
34  * atmel_ecc_cmd - structure used for communicating with the device.
35  * @word_addr: indicates the function of the packet sent to the device. This
36  *             byte should have a value of COMMAND for normal operation.
37  * @count    : number of bytes to be transferred to (or from) the device.
38  * @opcode   : the command code.
39  * @param1   : the first parameter; always present.
40  * @param2   : the second parameter; always present.
41  * @data     : optional remaining input data. Includes a 2-byte CRC.
42  * @rxsize   : size of the data received from i2c client.
43  * @msecs    : command execution time in milliseconds
44  */
45 struct atmel_ecc_cmd {
46         u8 word_addr;
47         u8 count;
48         u8 opcode;
49         u8 param1;
50         u16 param2;
51         u8 data[MAX_RSP_SIZE];
52         u8 msecs;
53         u16 rxsize;
54 } __packed;
55
56 /* Status/Error codes */
57 #define STATUS_SIZE                     0x04
58 #define STATUS_NOERR                    0x00
59 #define STATUS_WAKE_SUCCESSFUL          0x11
60
61 static const struct {
62         u8 value;
63         const char *error_text;
64 } error_list[] = {
65         { 0x01, "CheckMac or Verify miscompare" },
66         { 0x03, "Parse Error" },
67         { 0x05, "ECC Fault" },
68         { 0x0F, "Execution Error" },
69         { 0xEE, "Watchdog about to expire" },
70         { 0xFF, "CRC or other communication error" },
71 };
72
73 /* Definitions for eeprom organization */
74 #define CONFIG_ZONE                     0
75
76 /* Definitions for Indexes common to all commands */
77 #define RSP_DATA_IDX                    1 /* buffer index of data in response */
78 #define DATA_SLOT_2                     2 /* used for ECDH private key */
79
80 /* Definitions for the device lock state */
81 #define DEVICE_LOCK_ADDR                0x15
82 #define LOCK_VALUE_IDX                  (RSP_DATA_IDX + 2)
83 #define LOCK_CONFIG_IDX                 (RSP_DATA_IDX + 3)
84
85 /*
86  * Wake High delay to data communication (microseconds). SDA should be stable
87  * high for this entire duration.
88  */
89 #define TWHI_MIN                        1500
90 #define TWHI_MAX                        1550
91
92 /* Wake Low duration */
93 #define TWLO_USEC                       60
94
95 /* Command execution time (milliseconds) */
96 #define MAX_EXEC_TIME_ECDH              58
97 #define MAX_EXEC_TIME_GENKEY            115
98 #define MAX_EXEC_TIME_READ              1
99
100 /* Command opcode */
101 #define OPCODE_ECDH                     0x43
102 #define OPCODE_GENKEY                   0x40
103 #define OPCODE_READ                     0x02
104
105 /* Definitions for the READ Command */
106 #define READ_COUNT                      7
107
108 /* Definitions for the GenKey Command */
109 #define GENKEY_COUNT                    7
110 #define GENKEY_MODE_PRIVATE             0x04
111
112 /* Definitions for the ECDH Command */
113 #define ECDH_COUNT                      71
114 #define ECDH_PREFIX_MODE                0x00
115
116 #endif /* __ATMEL_ECC_H__ */