Lines Matching refs:cmd

45 static void atmel_i2c_checksum(struct atmel_i2c_cmd *cmd)  in atmel_i2c_checksum()  argument
47 u8 *data = &cmd->count; in atmel_i2c_checksum()
48 size_t len = cmd->count - CRC_SIZE; in atmel_i2c_checksum()
54 void atmel_i2c_init_read_config_cmd(struct atmel_i2c_cmd *cmd) in atmel_i2c_init_read_config_cmd() argument
56 cmd->word_addr = COMMAND; in atmel_i2c_init_read_config_cmd()
57 cmd->opcode = OPCODE_READ; in atmel_i2c_init_read_config_cmd()
62 cmd->param1 = CONFIGURATION_ZONE; in atmel_i2c_init_read_config_cmd()
63 cmd->param2 = cpu_to_le16(DEVICE_LOCK_ADDR); in atmel_i2c_init_read_config_cmd()
64 cmd->count = READ_COUNT; in atmel_i2c_init_read_config_cmd()
66 atmel_i2c_checksum(cmd); in atmel_i2c_init_read_config_cmd()
68 cmd->msecs = MAX_EXEC_TIME_READ; in atmel_i2c_init_read_config_cmd()
69 cmd->rxsize = READ_RSP_SIZE; in atmel_i2c_init_read_config_cmd()
73 int atmel_i2c_init_read_otp_cmd(struct atmel_i2c_cmd *cmd, u16 addr) in atmel_i2c_init_read_otp_cmd() argument
78 cmd->word_addr = COMMAND; in atmel_i2c_init_read_otp_cmd()
79 cmd->opcode = OPCODE_READ; in atmel_i2c_init_read_otp_cmd()
84 cmd->param1 = OTP_ZONE; in atmel_i2c_init_read_otp_cmd()
85 cmd->param2 = cpu_to_le16(addr); in atmel_i2c_init_read_otp_cmd()
86 cmd->count = READ_COUNT; in atmel_i2c_init_read_otp_cmd()
88 atmel_i2c_checksum(cmd); in atmel_i2c_init_read_otp_cmd()
90 cmd->msecs = MAX_EXEC_TIME_READ; in atmel_i2c_init_read_otp_cmd()
91 cmd->rxsize = READ_RSP_SIZE; in atmel_i2c_init_read_otp_cmd()
97 void atmel_i2c_init_random_cmd(struct atmel_i2c_cmd *cmd) in atmel_i2c_init_random_cmd() argument
99 cmd->word_addr = COMMAND; in atmel_i2c_init_random_cmd()
100 cmd->opcode = OPCODE_RANDOM; in atmel_i2c_init_random_cmd()
101 cmd->param1 = 0; in atmel_i2c_init_random_cmd()
102 cmd->param2 = 0; in atmel_i2c_init_random_cmd()
103 cmd->count = RANDOM_COUNT; in atmel_i2c_init_random_cmd()
105 atmel_i2c_checksum(cmd); in atmel_i2c_init_random_cmd()
107 cmd->msecs = MAX_EXEC_TIME_RANDOM; in atmel_i2c_init_random_cmd()
108 cmd->rxsize = RANDOM_RSP_SIZE; in atmel_i2c_init_random_cmd()
112 void atmel_i2c_init_genkey_cmd(struct atmel_i2c_cmd *cmd, u16 keyid) in atmel_i2c_init_genkey_cmd() argument
114 cmd->word_addr = COMMAND; in atmel_i2c_init_genkey_cmd()
115 cmd->count = GENKEY_COUNT; in atmel_i2c_init_genkey_cmd()
116 cmd->opcode = OPCODE_GENKEY; in atmel_i2c_init_genkey_cmd()
117 cmd->param1 = GENKEY_MODE_PRIVATE; in atmel_i2c_init_genkey_cmd()
119 cmd->param2 = cpu_to_le16(keyid); in atmel_i2c_init_genkey_cmd()
121 atmel_i2c_checksum(cmd); in atmel_i2c_init_genkey_cmd()
123 cmd->msecs = MAX_EXEC_TIME_GENKEY; in atmel_i2c_init_genkey_cmd()
124 cmd->rxsize = GENKEY_RSP_SIZE; in atmel_i2c_init_genkey_cmd()
128 int atmel_i2c_init_ecdh_cmd(struct atmel_i2c_cmd *cmd, in atmel_i2c_init_ecdh_cmd() argument
133 cmd->word_addr = COMMAND; in atmel_i2c_init_ecdh_cmd()
134 cmd->count = ECDH_COUNT; in atmel_i2c_init_ecdh_cmd()
135 cmd->opcode = OPCODE_ECDH; in atmel_i2c_init_ecdh_cmd()
136 cmd->param1 = ECDH_PREFIX_MODE; in atmel_i2c_init_ecdh_cmd()
138 cmd->param2 = cpu_to_le16(DATA_SLOT_2); in atmel_i2c_init_ecdh_cmd()
148 cmd->data, ATMEL_ECC_PUBKEY_SIZE); in atmel_i2c_init_ecdh_cmd()
152 atmel_i2c_checksum(cmd); in atmel_i2c_init_ecdh_cmd()
154 cmd->msecs = MAX_EXEC_TIME_ECDH; in atmel_i2c_init_ecdh_cmd()
155 cmd->rxsize = ECDH_RSP_SIZE; in atmel_i2c_init_ecdh_cmd()
241 int atmel_i2c_send_receive(struct i2c_client *client, struct atmel_i2c_cmd *cmd) in atmel_i2c_send_receive() argument
253 ret = i2c_master_send(client, (u8 *)cmd, cmd->count + WORD_ADDR_SIZE); in atmel_i2c_send_receive()
258 msleep(cmd->msecs); in atmel_i2c_send_receive()
261 ret = i2c_master_recv(client, cmd->data, cmd->rxsize); in atmel_i2c_send_receive()
271 return atmel_i2c_status(&client->dev, cmd->data); in atmel_i2c_send_receive()
282 struct atmel_i2c_cmd *cmd = &work_data->cmd; in atmel_i2c_work_handler() local
286 status = atmel_i2c_send_receive(client, cmd); in atmel_i2c_work_handler()
321 struct atmel_i2c_cmd *cmd; in device_sanity_check() local
324 cmd = kmalloc(sizeof(*cmd), GFP_KERNEL); in device_sanity_check()
325 if (!cmd) in device_sanity_check()
328 atmel_i2c_init_read_config_cmd(cmd); in device_sanity_check()
330 ret = atmel_i2c_send_receive(client, cmd); in device_sanity_check()
340 if (cmd->data[LOCK_CONFIG_IDX] || cmd->data[LOCK_VALUE_IDX]) { in device_sanity_check()
347 kfree(cmd); in device_sanity_check()