ese_cold_reset.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __ESE_COLD_RESET_H
  7. #define __ESE_COLD_RESET_H
  8. #include <nfcinfo.h>
  9. #define MAX_BUFF_SIZE 264
  10. /* ESE_COLD_RESET MACROS */
  11. #define COLD_RESET_CMD_LEN 3
  12. #define COLD_RESET_RSP_LEN 4
  13. #define COLD_RESET_PROT_CMD_LEN 4
  14. #define COLD_RESET_PROT_RSP_LEN 4
  15. #define PROP_NCI_CMD_GID 0x2F
  16. #define COLD_RESET_CMD_PL_LEN 0x00
  17. #define COLD_RESET_PROT_CMD_PL_LEN 0x01
  18. #define PROP_NCI_RSP_GID 0x4F
  19. #define COLD_RESET_OID 0x1E
  20. #define COLD_RESET_PROT_OID 0x1F
  21. enum ese_ioctl_arg_type {
  22. ESE_ARG_TYPE_COLD_RESET = 0,
  23. };
  24. /* ESE_COLD_RESET ioctl origin, max 4 are supported */
  25. enum ese_cold_reset_origin {
  26. ESE_COLD_RESET_ORIGIN_ESE = 0,
  27. ESE_COLD_RESET_ORIGIN_NFC,
  28. ESE_COLD_RESET_ORIGIN_OTHER = 0x20,
  29. ESE_COLD_RESET_ORIGIN_NONE = 0xFF,
  30. };
  31. /* ESE_COLD_RESET ioctl sub commands, max 8 are supported */
  32. enum ese_cold_reset_sub_cmd {
  33. ESE_COLD_RESET_DO = 0,
  34. ESE_COLD_RESET_PROTECT_EN,
  35. ESE_COLD_RESET_PROTECT_DIS,
  36. };
  37. /* Data passed in buf of ese cold reset ioctl */
  38. struct ese_cold_reset_arg {
  39. __u8 src;
  40. __u8 sub_cmd;
  41. __u16 rfu;
  42. };
  43. /* Argument buffer passed to ese ioctl */
  44. struct ese_ioctl_arg {
  45. __u64 buf;
  46. __u32 buf_size;
  47. __u8 type;
  48. };
  49. /* Features specific Parameters */
  50. struct cold_reset {
  51. wait_queue_head_t read_wq;
  52. char *cmd_buf;
  53. uint16_t cmd_len;
  54. uint16_t rsp_len;
  55. /* Source of last ese protection command */
  56. uint8_t last_src_ese_prot;
  57. uint8_t status;
  58. /* Is cold reset protection enabled */
  59. bool is_crp_en;
  60. bool rsp_pending;
  61. /* Is NFC enabled from UI */
  62. bool is_nfc_enabled;
  63. bool is_nfc_read_pending;
  64. };
  65. struct nfc_dev;
  66. int ese_cold_reset_ioctl(struct nfc_dev *nfc_dev, unsigned long arg);
  67. int read_cold_reset_rsp(struct nfc_dev *nfc_dev, char *header);
  68. #endif