Lines Matching +full:- +full:eproto
1 // SPDX-License-Identifier: GPL-2.0-or-later
31 reinit_completion(&fw_info->completion); in s3fwrn5_fw_send_msg()
38 &fw_info->completion, msecs_to_jiffies(1000)); in s3fwrn5_fw_send_msg()
42 return -ENXIO; in s3fwrn5_fw_send_msg()
44 if (!fw_info->rsp) in s3fwrn5_fw_send_msg()
45 return -EINVAL; in s3fwrn5_fw_send_msg()
47 *rsp = fw_info->rsp; in s3fwrn5_fw_send_msg()
48 fw_info->rsp = NULL; in s3fwrn5_fw_send_msg()
59 hdr.type = type | fw_info->parity; in s3fwrn5_fw_prep_msg()
60 fw_info->parity ^= 0x80; in s3fwrn5_fw_prep_msg()
66 return -ENOMEM; in s3fwrn5_fw_prep_msg()
96 hdr = (struct s3fwrn5_fw_header *) rsp->data; in s3fwrn5_fw_get_bootinfo()
97 if (hdr->code != S3FWRN5_FW_RET_SUCCESS) { in s3fwrn5_fw_get_bootinfo()
98 ret = -EINVAL; in s3fwrn5_fw_get_bootinfo()
102 memcpy(bootinfo, rsp->data + S3FWRN5_FW_HDR_SIZE, 10); in s3fwrn5_fw_get_bootinfo()
133 hdr = (struct s3fwrn5_fw_header *) rsp->data; in s3fwrn5_fw_enter_update_mode()
134 if (hdr->code != S3FWRN5_FW_RET_SUCCESS) { in s3fwrn5_fw_enter_update_mode()
135 ret = -EPROTO; in s3fwrn5_fw_enter_update_mode()
153 hdr = (struct s3fwrn5_fw_header *) rsp->data; in s3fwrn5_fw_enter_update_mode()
154 if (hdr->code != S3FWRN5_FW_RET_SUCCESS) { in s3fwrn5_fw_enter_update_mode()
155 ret = -EPROTO; in s3fwrn5_fw_enter_update_mode()
173 hdr = (struct s3fwrn5_fw_header *) rsp->data; in s3fwrn5_fw_enter_update_mode()
174 if (hdr->code != S3FWRN5_FW_RET_SUCCESS) in s3fwrn5_fw_enter_update_mode()
175 ret = -EPROTO; in s3fwrn5_fw_enter_update_mode()
204 hdr = (struct s3fwrn5_fw_header *) rsp->data; in s3fwrn5_fw_update_sector()
205 if (hdr->code != S3FWRN5_FW_RET_SUCCESS) { in s3fwrn5_fw_update_sector()
206 ret = -EPROTO; in s3fwrn5_fw_update_sector()
212 /* Send data split into 256-byte packets */ in s3fwrn5_fw_update_sector()
225 hdr = (struct s3fwrn5_fw_header *) rsp->data; in s3fwrn5_fw_update_sector()
226 if (hdr->code != S3FWRN5_FW_RET_SUCCESS) { in s3fwrn5_fw_update_sector()
227 ret = -EPROTO; in s3fwrn5_fw_update_sector()
259 hdr = (struct s3fwrn5_fw_header *) rsp->data; in s3fwrn5_fw_complete_update_mode()
260 if (hdr->code != S3FWRN5_FW_RET_SUCCESS) in s3fwrn5_fw_complete_update_mode()
261 ret = -EPROTO; in s3fwrn5_fw_complete_update_mode()
271 * 0x00 - 0x0B : Date and time string (w/o NUL termination)
272 * 0x10 - 0x13 : Firmware version
273 * 0x14 - 0x17 : Signature address
274 * 0x18 - 0x1B : Signature size
275 * 0x1C - 0x1F : Firmware image address
276 * 0x20 - 0x23 : Firmware sectors count
277 * 0x24 - 0x27 : Custom signature address
278 * 0x28 - 0x2B : Custom signature size
285 struct s3fwrn5_fw_image *fw = &fw_info->fw; in s3fwrn5_fw_request_firmware()
291 ret = request_firmware(&fw->fw, fw_info->fw_name, in s3fwrn5_fw_request_firmware()
292 &fw_info->ndev->nfc_dev->dev); in s3fwrn5_fw_request_firmware()
296 if (fw->fw->size < S3FWRN5_FW_IMAGE_HEADER_SIZE) { in s3fwrn5_fw_request_firmware()
297 release_firmware(fw->fw); in s3fwrn5_fw_request_firmware()
298 return -EINVAL; in s3fwrn5_fw_request_firmware()
301 memcpy(fw->date, fw->fw->data + 0x00, 12); in s3fwrn5_fw_request_firmware()
302 fw->date[12] = '\0'; in s3fwrn5_fw_request_firmware()
304 memcpy(&fw->version, fw->fw->data + 0x10, 4); in s3fwrn5_fw_request_firmware()
306 memcpy(&sig_off, fw->fw->data + 0x14, 4); in s3fwrn5_fw_request_firmware()
307 fw->sig = fw->fw->data + sig_off; in s3fwrn5_fw_request_firmware()
308 memcpy(&fw->sig_size, fw->fw->data + 0x18, 4); in s3fwrn5_fw_request_firmware()
310 memcpy(&image_off, fw->fw->data + 0x1C, 4); in s3fwrn5_fw_request_firmware()
311 fw->image = fw->fw->data + image_off; in s3fwrn5_fw_request_firmware()
312 memcpy(&fw->image_sectors, fw->fw->data + 0x20, 4); in s3fwrn5_fw_request_firmware()
314 memcpy(&custom_sig_off, fw->fw->data + 0x24, 4); in s3fwrn5_fw_request_firmware()
315 fw->custom_sig = fw->fw->data + custom_sig_off; in s3fwrn5_fw_request_firmware()
316 memcpy(&fw->custom_sig_size, fw->fw->data + 0x28, 4); in s3fwrn5_fw_request_firmware()
323 release_firmware(fw_info->fw.fw); in s3fwrn5_fw_release_firmware()
342 if (bootinfo->hw_version[0] == match[i].version[0] && in s3fwrn5_fw_get_base_addr()
343 bootinfo->hw_version[1] == match[i].version[1] && in s3fwrn5_fw_get_base_addr()
344 bootinfo->hw_version[3] == match[i].version[3]) { in s3fwrn5_fw_get_base_addr()
349 return -EINVAL; in s3fwrn5_fw_get_base_addr()
355 return !!bootinfo->hw_version[2]; in s3fwrn5_fw_is_custom()
360 struct device *dev = &fw_info->ndev->nfc_dev->dev; in s3fwrn5_fw_setup()
374 ret = s3fwrn5_fw_get_base_addr(&bootinfo, &fw_info->base_addr); in s3fwrn5_fw_setup()
380 fw_info->sector_size = bootinfo.sector_size; in s3fwrn5_fw_setup()
382 fw_info->sig_size = s3fwrn5_fw_is_custom(&bootinfo) ? in s3fwrn5_fw_setup()
383 fw_info->fw.custom_sig_size : fw_info->fw.sig_size; in s3fwrn5_fw_setup()
384 fw_info->sig = s3fwrn5_fw_is_custom(&bootinfo) ? in s3fwrn5_fw_setup()
385 fw_info->fw.custom_sig : fw_info->fw.sig; in s3fwrn5_fw_setup()
396 struct s3fwrn5_fw_version *new = (void *) &fw_info->fw.version; in s3fwrn5_fw_check_version()
399 if (new->major > old->major) in s3fwrn5_fw_check_version()
401 if (new->build1 > old->build1) in s3fwrn5_fw_check_version()
403 if (new->build2 > old->build2) in s3fwrn5_fw_check_version()
411 struct device *dev = &fw_info->ndev->nfc_dev->dev; in s3fwrn5_fw_download()
412 struct s3fwrn5_fw_image *fw = &fw_info->fw; in s3fwrn5_fw_download()
418 image_size = fw_info->sector_size * fw->image_sectors; in s3fwrn5_fw_download()
428 ret = crypto_shash_tfm_digest(tfm, fw->image, image_size, hash_data); in s3fwrn5_fw_download()
438 dev_info(dev, "Firmware update: %s\n", fw_info->fw_name); in s3fwrn5_fw_download()
441 SHA1_DIGEST_SIZE, fw_info->sig, fw_info->sig_size); in s3fwrn5_fw_download()
447 for (off = 0; off < image_size; off += fw_info->sector_size) { in s3fwrn5_fw_download()
449 fw_info->base_addr + off, fw->image + off); in s3fwrn5_fw_download()
469 fw_info->parity = 0x00; in s3fwrn5_fw_init()
470 fw_info->rsp = NULL; in s3fwrn5_fw_init()
471 fw_info->fw.fw = NULL; in s3fwrn5_fw_init()
472 strcpy(fw_info->fw_name, fw_name); in s3fwrn5_fw_init()
473 init_completion(&fw_info->completion); in s3fwrn5_fw_init()
484 struct s3fwrn5_fw_info *fw_info = &info->fw_info; in s3fwrn5_fw_recv_frame()
486 if (WARN_ON(fw_info->rsp)) { in s3fwrn5_fw_recv_frame()
488 return -EINVAL; in s3fwrn5_fw_recv_frame()
491 fw_info->rsp = skb; in s3fwrn5_fw_recv_frame()
493 complete(&fw_info->completion); in s3fwrn5_fw_recv_frame()