ese_cold_reset.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __ESE_COLD_RESET_H
  6. #define __ESE_COLD_RESET_H
  7. #include <nfcinfo.h>
  8. #define MAX_BUFF_SIZE 264
  9. /* ESE_COLD_RESET MACROS */
  10. #define COLD_RESET_CMD_LEN 3
  11. #define COLD_RESET_RSP_LEN 4
  12. #define COLD_RESET_PROT_CMD_LEN 4
  13. #define COLD_RESET_PROT_RSP_LEN 4
  14. #define PROP_NCI_CMD_GID 0x2F
  15. #define COLD_RESET_CMD_PL_LEN 0x00
  16. #define COLD_RESET_PROT_CMD_PL_LEN 0x01
  17. #define PROP_NCI_RSP_GID 0x4F
  18. #define COLD_RESET_OID 0x1E
  19. #define COLD_RESET_PROT_OID 0x1F
  20. #define ESE_COLD_RESET _IOWR(NFCC_MAGIC, 0x08, struct ese_ioctl_arg)
  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. };
  64. struct nfc_dev;
  65. int ese_cold_reset_ioctl(struct nfc_dev *nfc_dev, unsigned long arg);
  66. int read_cold_reset_rsp(struct nfc_dev *nfc_dev, char *header);
  67. #endif