Leaked source code of windows server 2003
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.

357 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 0x07
  139. #define STIR4200_SENS_RXDSNS_HP_SIR 0x07
  140. #define STIR4200_SENS_RXDSNS_HP_FIR 0x07
  141. #define STIR4200_SENS_RXDSNS_VISHAY_6102F_FIR 0x07
  142. #define STIR4200_SENS_RXDSNS_VISHAY_6102F_SIR 0x07
  143. #define STIR4200_SENS_RXDSNS_CUSTOM_SIR_9600 0x20
  144. #define STIR4200_SENS_RXDSNS_CUSTOM_SIR 0x00
  145. #define STIR4200_SENS_RXDSNS_CUSTOM_FIR 0x20
  146. #define STIR4200_STAT_EOFRAME 0x80
  147. #define STIR4200_STAT_FFUNDER 0x40
  148. #define STIR4200_STAT_FFOVER 0x20
  149. #define STIR4200_STAT_FFDIR 0x10
  150. #define STIR4200_STAT_FFCLR 0x08
  151. #define STIR4200_STAT_FFEMPTY 0x04
  152. #define STIR4200_STAT_FFRXERR 0x02
  153. #define STIR4200_STAT_FFTXERR 0x01
  154. #define STIR4200_DPLL_DESIRED_4012 0x05
  155. #define STIR4200_DPLL_DESIRED_4012_SIR 0x06
  156. #define STIR4200_DPLL_DESIRED_4012_FIR 0x05
  157. #define STIR4200_DPLL_DESIRED_4000 0x15
  158. #define STIR4200_DPLL_DESIRED_VISHAY 0x15
  159. #define STIR4200_DPLL_DESIRED_INFI 0x06
  160. #define STIR4200_DPLL_DESIRED_HP 0x06
  161. #define STIR4200_DPLL_DESIRED_VISHAY_6102F 0x04
  162. #define STIR4200_DPLL_DEFAULT 0x52
  163. #define STIR4200_DPLL_DESIRED_CUSTOM 0x05
  164. #define STIR4200_DPLL_DESIRED_CUSTOM_SIR 0x06
  165. #define STIR4200_DPLL_DESIRED_CUSTOM_FIR 0x05
  166. #define STIR4200_TEST_EN_OSC_SUSPEND 0x10
  167. /**************************************************************************************************************************/
  168. /* Vendor Specific Device Requests */
  169. /**************************************************************************************************************************/
  170. #define STIR4200_WRITE_REGS_REQ 0
  171. #define STIR4200_READ_REGS_REQ 1
  172. #define STIR4200_READ_ROM_REQ 2
  173. #define STIR4200_WRITE_REG_REQ 3
  174. #define STIR4200_CLEAR_STALL_REQ 1
  175. /**************************************************************************************************************************/
  176. /* STIr4200 Frame Header ID Definitions */
  177. /**************************************************************************************************************************/
  178. #define STIR4200_HEADERID_BYTE1 0x55
  179. #define STIR4200_HEADERID_BYTE2 0xAA
  180. typedef struct _STIR4200_FRAME_HEADER
  181. {
  182. UCHAR id1; // header id byte 1
  183. UCHAR id2; // header id byte 2
  184. UCHAR sizlsb; // frame size LSB
  185. UCHAR sizmsb; // frame size MSB
  186. } STIR4200_FRAME_HEADER, *PSTIR4200_FRAME_HEADER;
  187. /**************************************************************************************************************************/
  188. /* STIr4200 Frame Definitions */
  189. /**************************************************************************************************************************/
  190. #define STIR4200_FIR_PREAMBLE 0x7f
  191. #define STIR4200_FIR_PREAMBLE_SIZ 16
  192. #define STIR4200_FIR_BOF 0x7E
  193. #define STIR4200_FIR_EOF 0x7E
  194. #define STIR4200_FIR_BOF_SIZ 2
  195. #define STIR4200_FIR_EOF_SIZ 2
  196. #define STIR4200_FIR_ESC_CHAR 0x7d
  197. #define STIR4200_FIR_ESC_DATA_7D 0x5d
  198. #define STIR4200_FIR_ESC_DATA_7E 0x5e
  199. #define STIR4200_FIR_ESC_DATA_7F 0x5f
  200. #define STIR4200_MIR_BOF 0x7E
  201. #define STIR4200_MIR_EOF 0x7E
  202. #define STIR4200_MIR_BOF_SIZ 2
  203. #define STIR4200_MIR_EOF_SIZ 2
  204. #define STIR4200_MIR_ESC_CHAR 0x7d
  205. #define STIR4200_MIR_ESC_DATA_7D 0x5d
  206. #define STIR4200_MIR_ESC_DATA_7E 0x5e
  207. //
  208. // A few workaroud definitions
  209. //
  210. #define STIR4200_READ_DELAY 3000
  211. #define STIR4200_MULTIPLE_READ_DELAY 2500
  212. #define STIR4200_DELTA_DELAY 250
  213. #define STIR4200_MAX_BOOST_DELAY 1000
  214. #define STIR4200_MULTIPLE_READ_THREHOLD 2048
  215. #define STIR4200_WRITE_DELAY 2000
  216. #define STIR4200_ESC_PACKET_SIZE 3072
  217. #define STIR4200_SMALL_PACKET_MAX_SIZE 32
  218. #define STIR4200_LARGE_PACKET_MIN_SIZE 1024
  219. #define STIR4200_ACK_WINDOW 20
  220. #define STIR4200_FIFO_OVERRUN_THRESHOLD 100
  221. #define STIR4200_SEND_TIMEOUT 2000
  222. /**************************************************************************************************************************/
  223. /* Prototypes of functions that access the hardware */
  224. /**************************************************************************************************************************/
  225. NTSTATUS
  226. St4200ResetFifo(
  227. IN PVOID pDevice
  228. );
  229. NTSTATUS
  230. St4200DoubleResetFifo(
  231. IN PVOID pDevice
  232. );
  233. NTSTATUS
  234. St4200SoftReset(
  235. IN PVOID pDevice
  236. );
  237. NTSTATUS
  238. St4200SetSpeed(
  239. IN OUT PVOID pDevice
  240. );
  241. NTSTATUS
  242. St4200SetIrMode(
  243. IN OUT PVOID pDevice,
  244. ULONG mode
  245. );
  246. NTSTATUS
  247. St4200GetFifoCount(
  248. IN PVOID pDevice,
  249. OUT PULONG pCountFifo
  250. );
  251. NTSTATUS
  252. St4200TuneDpllAndSensitivity(
  253. IN OUT PVOID pDevice,
  254. ULONG Speed
  255. );
  256. NTSTATUS
  257. St4200TurnOffReceiver(
  258. IN OUT PVOID pDevice
  259. );
  260. NTSTATUS
  261. St4200TurnOnReceiver(
  262. IN OUT PVOID pDevice
  263. );
  264. NTSTATUS
  265. St4200EnableOscillatorPowerDown(
  266. IN OUT PVOID pDevice
  267. );
  268. NTSTATUS
  269. St4200TurnOnSuspend(
  270. IN OUT PVOID pDevice
  271. );
  272. NTSTATUS
  273. St4200TurnOffSuspend(
  274. IN OUT PVOID pDevice
  275. );
  276. NTSTATUS
  277. St4200WriteMultipleRegisters(
  278. IN PVOID pDevice,
  279. UCHAR FirstRegister,
  280. UCHAR RegistersToWrite
  281. );
  282. NTSTATUS
  283. St4200WriteRegister(
  284. IN PVOID pDevice,
  285. UCHAR RegisterToWrite
  286. );
  287. NTSTATUS
  288. St4200ReadRegisters(
  289. IN OUT PVOID pDevice,
  290. UCHAR FirstRegister,
  291. UCHAR RegistersToRead
  292. );
  293. NTSTATUS
  294. St4200FakeSend(
  295. IN PVOID pDevice,
  296. PUCHAR pData,
  297. ULONG DataSize
  298. );
  299. NTSTATUS
  300. St4200FakeReceive(
  301. IN PVOID pDevice,
  302. PUCHAR pData,
  303. ULONG DataSize
  304. );
  305. NTSTATUS
  306. St4200CompleteReadWriteRequest(
  307. IN PDEVICE_OBJECT pUsbDevObj,
  308. IN PIRP pIrp,
  309. IN PVOID Context
  310. );
  311. /**************************************************************************************************************************/
  312. #endif // __STIR4200_H__