ccid.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Copyright (C) 2020 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _USB_CCID_H_
  13. #define _USB_CCID_H_
  14. #include <stdint.h>
  15. #define CCID_DESCRIPTOR_LENGTH 0x36
  16. typedef struct
  17. {
  18. uint8_t bLength;
  19. uint8_t bDescriptorType;
  20. uint16_t bcdCCID; // 0110h
  21. uint8_t bMaxSlotIndex;
  22. uint8_t bVoltageSupport;
  23. uint32_t dwProtocols;
  24. uint32_t dwDefaultClock;
  25. uint32_t dwMaximumClock;
  26. uint8_t bNumClockSupported;
  27. uint32_t dwDataRate;
  28. uint32_t dwMaxDataRate;
  29. uint8_t bNumDataRatesSupported;
  30. uint32_t dwMaxIFSD;
  31. uint32_t dwSynchProtocols;
  32. uint32_t dwMechanical;
  33. uint32_t dwFeatures;
  34. uint32_t dwMaxCCIDMessageLength;
  35. uint8_t bClassGetResponse;
  36. uint8_t bClassEnvelope;
  37. uint16_t wLcdLayout;
  38. uint8_t bPINSupport;
  39. uint8_t bMaxCCIDBusySlots;
  40. } __attribute__((packed)) ccidClassDesc_t;
  41. #define CCID_0110 0x0110
  42. #define CCID_DESCRIPTOR_TYPE 0x21
  43. #define SMART_CARD_DEVICE_CLASS 0x0b
  44. // Table 5.3-1 Summary of CCID Class Specific Request
  45. #define CCIDGENERICREQ_ABORT 0x01
  46. #define CCIDGENERICREQ_GET_CLOCK_FREQUENCIES 0x02
  47. #define CCIDGENERICREQ_GET_DATA_RATES 0x03
  48. // voltage
  49. #define CCID_VOLTAGE_5V (1 << 0)
  50. #define CCID_VOLTAGE_3V (1 << 1)
  51. #define CCID_VOLTAGE_1V8 (1 << 2)
  52. // mechanical
  53. #define CCID_MECHANICAL_NO_SPECIAL (0)
  54. #define CCID_MECHANICAL_CARD_ACCEPT (1 << 0)
  55. #define CCID_MECHANICAL_CARD_EJECTION (1 << 1)
  56. #define CCID_MECHANICAL_CARD_CAPTURE (1 << 2)
  57. #define CCID_MECHANICAL_CARD_LOCK_UNLOCK (1 << 3)
  58. // feature
  59. #define CCID_FEATURE_NO_SPECIAL (0)
  60. // Automatic parameter configuration based on ATR data
  61. #define CCID_FEATURE_AUTO_PCONF (1 << 1)
  62. // Automatic activation of ICC on inserting
  63. #define CCID_FEATURE_AUTO_ACTIV (1 << 2)
  64. // Automatic ICC voltage selection
  65. #define CCID_FEATURE_AUTO_VOLT (1 << 3)
  66. // Automatic ICC clock frequency change
  67. #define CCID_FEATURE_AUTO_CLOCK (1 << 4)
  68. // Automatic baud rate change
  69. #define CCID_FEATURE_AUTO_BAUD (1 << 5)
  70. // Automatic parameters negotiation made by the CCID
  71. #define CCID_FEATURE_AUTO_PNEGO (1 << 6)
  72. // Automatic PPS made by the CCID according to the active paramters
  73. #define CCID_FEATURE_AUTO_PPS (1 << 7)
  74. // CCID can set ICC in clock stop mode
  75. #define CCID_FEATURE_ICCSTOP (1 << 8)
  76. // NAD value other the 00 accepted (T=1 protocol in use)
  77. #define CCID_FEATURE_NAD (1 << 9)
  78. // Automatic IFSD exchange as first exchange (T=1 protocol in use)
  79. #define CCID_FEATURE_AUTO_IFSD (1 << 10)
  80. // TPDU level exchanges with CCID
  81. #define CCID_FEATURE_EXC_TPDU (1 << 16)
  82. // Short APDU level exchange with CCID
  83. #define CCID_FEATURE_EXC_SAPDU (1 << 17)
  84. // Short and Extended APDI level exchange with CCID
  85. #define CCID_FEATURE_EXC_APDU (1 << 18)
  86. // USB Wake up signaling supported on card insertion and removal
  87. #define CCID_FEATURE_WAKEUP (1 << 20)
  88. // protocol
  89. #define CCID_PROTOCOL_NO_SEL 0x00
  90. #define CCID_PROTOCOL_T0 0x01
  91. #define CCID_PROTOCOL_T1 0x02
  92. // pin support
  93. #define CCID_PINSUPPORT_NONE 0x00
  94. #define CCID_PINSUPPORT_VERIFICATION (1 << 1)
  95. #define CCID_PINSUPPORT_MODIFICATION (1 << 2)
  96. #endif