Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

338 lines
12 KiB

  1. /**************************************************************************************************************************
  2. * STIR4200.H - SigmaTel STIr4200 hardware (register) specific definitions
  3. **************************************************************************************************************************
  4. * (C) Unpublished Copyright of Sigmatel, Inc. All Rights Reserved.
  5. *
  6. *
  7. * Created: 04/06/2000
  8. * Version 0.9
  9. * Edited: 04/27/2000
  10. * Version 0.92
  11. * Edited: 05/03/2000
  12. * Version 0.93
  13. * Edited: 05/12/2000
  14. * Version 0.94
  15. * Edited: 05/19/2000
  16. * Version 0.95
  17. * Edited: 06/29/2000
  18. * Version 0.97
  19. * Edited: 08/22/2000
  20. * Version 1.02
  21. * Edited: 09/16/2000
  22. * Version 1.03
  23. * Edited: 09/25/2000
  24. * Version 1.10
  25. * Edited: 11/10/2000
  26. * Version 1.12
  27. * Edited: 12/29/2000
  28. * Version 1.13
  29. * Edited: 01/16/2001
  30. * Version 1.14
  31. *
  32. *
  33. **************************************************************************************************************************/
  34. #ifndef __STIR4200_H__
  35. #define __STIR4200_H__
  36. #define STIR4200_FIFO_SIZE 4096
  37. //
  38. // Some useful macros
  39. //
  40. #define MAKEUSHORT(lo, hi) ((unsigned short)(((unsigned char)(lo)) | ((unsigned short)((unsigned char)(hi))) << 8))
  41. #define MAKEULONG(lo, hi) ((unsigned long)(((unsigned short)(lo)) | ((unsigned long)((unsigned short)(hi))) << 16))
  42. #ifndef LOWORD
  43. #define LOWORD(l) ((unsigned short)(l))
  44. #endif
  45. #ifndef HIWORD
  46. #define HIWORD(l) ((unsigned short)(((unsigned long)(l) >> 16) & 0xFFFF))
  47. #endif
  48. #ifndef LOBYTE
  49. #define LOBYTE(w) ((unsigned char)(w))
  50. #endif
  51. #ifndef HIBYTE
  52. #define HIBYTE(w) ((unsigned char)(((unsigned short)(w) >> 8) & 0xFF))
  53. #endif
  54. /**************************************************************************************************************************/
  55. /* STIr4200 Tranceiver Hardware Model Definitions */
  56. /**************************************************************************************************************************/
  57. typedef struct _STIR4200_TRANCEIVER
  58. {
  59. UCHAR FifoDataReg;
  60. UCHAR ModeReg;
  61. UCHAR BaudrateReg;
  62. UCHAR ControlReg;
  63. UCHAR SensitivityReg;
  64. UCHAR StatusReg;
  65. UCHAR FifoCntLsbReg;
  66. UCHAR FifoCntMsbReg;
  67. UCHAR DpllTuneReg;
  68. UCHAR IrdigSetupReg;
  69. UCHAR Reserved1Reg;
  70. UCHAR Reserved2Reg;
  71. UCHAR Reserved3Reg;
  72. UCHAR Reserved4Reg;
  73. UCHAR Reserved5Reg;
  74. UCHAR TestReg;
  75. } STIR4200_TRANCEIVER, *PSTIR4200_TRANCEIVER;
  76. /**************************************************************************************************************************/
  77. /* STIr4200 Receiver State */
  78. /**************************************************************************************************************************/
  79. typedef enum
  80. {
  81. STATE_INIT = 0,
  82. STATE_GOT_FIR_BOF,
  83. STATE_GOT_BOF,
  84. STATE_ACCEPTING,
  85. STATE_ESC_SEQUENCE,
  86. STATE_SAW_FIR_BOF,
  87. STATE_SAW_EOF,
  88. STATE_CLEANUP
  89. } PORT_RCV_STATE;
  90. #define STATE_GOT_MIR_BOF STATE_GOT_FIR_BOF
  91. #define STATE_SAW_MIR_BOF STATE_SAW_FIR_BOF
  92. /**************************************************************************************************************************/
  93. /* Register Offsets */
  94. /**************************************************************************************************************************/
  95. #define STIR4200_FIFO_DATA_REG 0
  96. #define STIR4200_MODE_REG 1
  97. #define STIR4200_BAUDRATE_REG 2
  98. #define STIR4200_CONTROL_REG 3
  99. #define STIR4200_SENSITIVITY_REG 4
  100. #define STIR4200_STATUS_REG 5
  101. #define STIR4200_FIFOCNT_LSB_REG 6
  102. #define STIR4200_FIFOCNT_MSB_REG 7
  103. #define STIR4200_DPLLTUNE_REG 8
  104. #define STIR4200_IRDIG_SETUP_REG 9
  105. #define STIR4200_RESERVE1_REG 10
  106. #define STIR4200_RESERVE2_REG 11
  107. #define STIR4200_RESERVE3_REG 12
  108. #define STIR4200_RESERVE4_REG 13
  109. #define STIR4200_RESERVE5_REG 14
  110. #define STIR4200_TEST_REG 15
  111. #define STIR4200_MAX_REG STIR4200_TEST_REG
  112. /**************************************************************************************************************************/
  113. /* Register Bit Definitions */
  114. /**************************************************************************************************************************/
  115. #define STIR4200_MODE_PDLCK8 0x01
  116. #define STIR4200_MODE_RESET_OFF 0x02
  117. #define STIR4200_MODE_AUTO_RESET 0x04
  118. #define STIR4200_MODE_BULKIN_FIX 0x08
  119. #define STIR4200_MODE_FIR 0x80
  120. #define STIR4200_MODE_MIR 0x40
  121. #define STIR4200_MODE_SIR 0x20
  122. #define STIR4200_MODE_ASK 0x10
  123. #define STIR4200_MODE_MASK (STIR4200_MODE_FIR | STIR4200_MODE_MIR | STIR4200_MODE_SIR | STIR4200_MODE_ASK)
  124. #define STIR4200_CTRL_SDMODE 0x80
  125. #define STIR4200_CTRL_RXSLOW 0x40
  126. #define STIR4200_CTRL_DLOOP1 0x20
  127. #define STIR4200_CTRL_TXPWD 0x10
  128. #define STIR4200_CTRL_RXPWD 0x08
  129. #define STIR4200_CTRL_SRESET 0x01
  130. #define STIR4200_SENS_IDMASK 0x07
  131. #define STIR4200_SENS_SPWIDTH 0x08
  132. #define STIR4200_SENS_BSTUFF 0x10
  133. #define STIR4200_SENS_RXDSNS_DEFAULT 0x20
  134. #define STIR4200_SENS_RXDSNS_4012_SIR_9600 0x20
  135. #define STIR4200_SENS_RXDSNS_4012_SIR 0x00
  136. #define STIR4200_SENS_RXDSNS_4012_FIR 0x20
  137. #define STIR4200_SENS_RXDSNS_INFI_SIR 0x07
  138. #define STIR4200_SENS_RXDSNS_INFI_FIR 0x27
  139. #define STIR4200_STAT_EOFRAME 0x80
  140. #define STIR4200_STAT_FFUNDER 0x40
  141. #define STIR4200_STAT_FFOVER 0x20
  142. #define STIR4200_STAT_FFDIR 0x10
  143. #define STIR4200_STAT_FFCLR 0x08
  144. #define STIR4200_STAT_FFEMPTY 0x04
  145. #define STIR4200_STAT_FFRXERR 0x02
  146. #define STIR4200_STAT_FFTXERR 0x01
  147. #define STIR4200_DPLL_DESIRED_4012 0x05
  148. #define STIR4200_DPLL_DESIRED_4012_SIR 0x06
  149. #define STIR4200_DPLL_DESIRED_4012_FIR 0x05
  150. #define STIR4200_DPLL_DESIRED_4000 0x15
  151. #define STIR4200_DPLL_DESIRED_VISHAY 0x15
  152. #define STIR4200_DPLL_DESIRED_INFI 0x15
  153. #define STIR4200_DPLL_DEFAULT 0x52
  154. #define STIR4200_TEST_EN_OSC_SUSPEND 0x10
  155. /**************************************************************************************************************************/
  156. /* Vendor Specific Device Requests */
  157. /**************************************************************************************************************************/
  158. #define STIR4200_WRITE_REGS_REQ 0
  159. #define STIR4200_READ_REGS_REQ 1
  160. #define STIR4200_READ_ROM_REQ 2
  161. #define STIR4200_WRITE_REG_REQ 3
  162. #define STIR4200_CLEAR_STALL_REQ 1
  163. /**************************************************************************************************************************/
  164. /* STIr4200 Frame Header ID Definitions */
  165. /**************************************************************************************************************************/
  166. #define STIR4200_HEADERID_BYTE1 0x55
  167. #define STIR4200_HEADERID_BYTE2 0xAA
  168. typedef struct _STIR4200_FRAME_HEADER
  169. {
  170. UCHAR id1; // header id byte 1
  171. UCHAR id2; // header id byte 2
  172. UCHAR sizlsb; // frame size LSB
  173. UCHAR sizmsb; // frame size MSB
  174. } STIR4200_FRAME_HEADER, *PSTIR4200_FRAME_HEADER;
  175. /**************************************************************************************************************************/
  176. /* STIr4200 Frame Definitions */
  177. /**************************************************************************************************************************/
  178. #define STIR4200_FIR_PREAMBLE 0x7f
  179. #define STIR4200_FIR_PREAMBLE_SIZ 16
  180. #define STIR4200_FIR_BOF 0x7E
  181. #define STIR4200_FIR_EOF 0x7E
  182. #define STIR4200_FIR_BOF_SIZ 2
  183. #define STIR4200_FIR_EOF_SIZ 2
  184. #define STIR4200_FIR_ESC_CHAR 0x7d
  185. #define STIR4200_FIR_ESC_DATA_7D 0x5d
  186. #define STIR4200_FIR_ESC_DATA_7E 0x5e
  187. #define STIR4200_FIR_ESC_DATA_7F 0x5f
  188. #define STIR4200_MIR_BOF 0x7E
  189. #define STIR4200_MIR_EOF 0x7E
  190. #define STIR4200_MIR_BOF_SIZ 2
  191. #define STIR4200_MIR_EOF_SIZ 2
  192. #define STIR4200_MIR_ESC_CHAR 0x7d
  193. #define STIR4200_MIR_ESC_DATA_7D 0x5d
  194. #define STIR4200_MIR_ESC_DATA_7E 0x5e
  195. //
  196. // A few workaroud definitions
  197. //
  198. #define STIR4200_READ_DELAY 3000
  199. #define STIR4200_MULTIPLE_READ_DELAY 2500
  200. #define STIR4200_DELTA_DELAY 250
  201. #define STIR4200_MAX_BOOST_DELAY 1000
  202. #define STIR4200_MULTIPLE_READ_THREHOLD 2048
  203. #define STIR4200_WRITE_DELAY 2000
  204. #define STIR4200_ESC_PACKET_SIZE 3072
  205. #define STIR4200_SMALL_PACKET_MAX_SIZE 32
  206. #define STIR4200_LARGE_PACKET_MIN_SIZE 1024
  207. #define STIR4200_ACK_WINDOW 20
  208. #define STIR4200_FIFO_OVERRUN_THRESHOLD 100
  209. #define STIR4200_SEND_TIMEOUT 2000
  210. /**************************************************************************************************************************/
  211. /* Prototypes of functions that access the hardware */
  212. /**************************************************************************************************************************/
  213. NTSTATUS
  214. St4200ResetFifo(
  215. IN PVOID pDevice
  216. );
  217. NTSTATUS
  218. St4200DoubleResetFifo(
  219. IN PVOID pDevice
  220. );
  221. NTSTATUS
  222. St4200SoftReset(
  223. IN PVOID pDevice
  224. );
  225. NTSTATUS
  226. St4200SetSpeed(
  227. IN OUT PVOID pDevice
  228. );
  229. NTSTATUS
  230. St4200SetIrMode(
  231. IN OUT PVOID pDevice,
  232. ULONG mode
  233. );
  234. NTSTATUS
  235. St4200GetFifoCount(
  236. IN PVOID pDevice,
  237. OUT PULONG pCountFifo
  238. );
  239. NTSTATUS
  240. St4200TuneDpllAndSensitivity(
  241. IN OUT PVOID pDevice,
  242. ULONG Speed
  243. );
  244. NTSTATUS
  245. St4200TurnOffReceiver(
  246. IN OUT PVOID pDevice
  247. );
  248. NTSTATUS
  249. St4200TurnOnReceiver(
  250. IN OUT PVOID pDevice
  251. );
  252. NTSTATUS
  253. St4200EnableOscillatorPowerDown(
  254. IN OUT PVOID pDevice
  255. );
  256. NTSTATUS
  257. St4200TurnOnSuspend(
  258. IN OUT PVOID pDevice
  259. );
  260. NTSTATUS
  261. St4200TurnOffSuspend(
  262. IN OUT PVOID pDevice
  263. );
  264. NTSTATUS
  265. St4200WriteMultipleRegisters(
  266. IN PVOID pDevice,
  267. UCHAR FirstRegister,
  268. UCHAR RegistersToWrite
  269. );
  270. NTSTATUS
  271. St4200WriteRegister(
  272. IN PVOID pDevice,
  273. UCHAR RegisterToWrite
  274. );
  275. NTSTATUS
  276. St4200ReadRegisters(
  277. IN OUT PVOID pDevice,
  278. UCHAR FirstRegister,
  279. UCHAR RegistersToRead
  280. );
  281. NTSTATUS
  282. St4200FakeSend(
  283. IN PVOID pDevice,
  284. PUCHAR pData,
  285. ULONG DataSize
  286. );
  287. NTSTATUS
  288. St4200CompleteReadWriteRequest(
  289. IN PDEVICE_OBJECT pUsbDevObj,
  290. IN PIRP pIrp,
  291. IN PVOID Context
  292. );
  293. /**************************************************************************************************************************/
  294. #endif // __STIR4200_H__