whiteheat.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /*
  2. * USB ConnectTech WhiteHEAT driver
  3. *
  4. * Copyright (C) 2002
  5. * Connect Tech Inc.
  6. *
  7. * Copyright (C) 1999, 2000
  8. * Greg Kroah-Hartman (greg@kroah.com)
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * See Documentation/usb/usb-serial.txt for more information on using this
  16. * driver
  17. *
  18. */
  19. #ifndef __LINUX_USB_SERIAL_WHITEHEAT_H
  20. #define __LINUX_USB_SERIAL_WHITEHEAT_H
  21. /* WhiteHEAT commands */
  22. #define WHITEHEAT_OPEN 1 /* open the port */
  23. #define WHITEHEAT_CLOSE 2 /* close the port */
  24. #define WHITEHEAT_SETUP_PORT 3 /* change port settings */
  25. #define WHITEHEAT_SET_RTS 4 /* turn RTS on or off */
  26. #define WHITEHEAT_SET_DTR 5 /* turn DTR on or off */
  27. #define WHITEHEAT_SET_BREAK 6 /* turn BREAK on or off */
  28. #define WHITEHEAT_DUMP 7 /* dump memory */
  29. #define WHITEHEAT_STATUS 8 /* get status */
  30. #define WHITEHEAT_PURGE 9 /* clear the UART fifos */
  31. #define WHITEHEAT_GET_DTR_RTS 10 /* get the state of DTR and RTS
  32. for a port */
  33. #define WHITEHEAT_GET_HW_INFO 11 /* get EEPROM info and
  34. hardware ID */
  35. #define WHITEHEAT_REPORT_TX_DONE 12 /* get the next TX done */
  36. #define WHITEHEAT_EVENT 13 /* unsolicited status events */
  37. #define WHITEHEAT_ECHO 14 /* send data to the indicated
  38. IN endpoint */
  39. #define WHITEHEAT_DO_TEST 15 /* perform specified test */
  40. #define WHITEHEAT_CMD_COMPLETE 16 /* reply for some commands */
  41. #define WHITEHEAT_CMD_FAILURE 17 /* reply for failed commands */
  42. /*
  43. * Commands to the firmware
  44. */
  45. /*
  46. * WHITEHEAT_OPEN
  47. * WHITEHEAT_CLOSE
  48. * WHITEHEAT_STATUS
  49. * WHITEHEAT_GET_DTR_RTS
  50. * WHITEHEAT_REPORT_TX_DONE
  51. */
  52. struct whiteheat_simple {
  53. __u8 port; /* port number (1 to N) */
  54. };
  55. /*
  56. * WHITEHEAT_SETUP_PORT
  57. */
  58. #define WHITEHEAT_PAR_NONE 'n' /* no parity */
  59. #define WHITEHEAT_PAR_EVEN 'e' /* even parity */
  60. #define WHITEHEAT_PAR_ODD 'o' /* odd parity */
  61. #define WHITEHEAT_PAR_SPACE '0' /* space (force 0) parity */
  62. #define WHITEHEAT_PAR_MARK '1' /* mark (force 1) parity */
  63. #define WHITEHEAT_SFLOW_NONE 'n' /* no software flow control */
  64. #define WHITEHEAT_SFLOW_RX 'r' /* XOFF/ON is sent when RX
  65. fills/empties */
  66. #define WHITEHEAT_SFLOW_TX 't' /* when received XOFF/ON will
  67. stop/start TX */
  68. #define WHITEHEAT_SFLOW_RXTX 'b' /* both SFLOW_RX and SFLOW_TX */
  69. #define WHITEHEAT_HFLOW_NONE 0x00 /* no hardware flow control */
  70. #define WHITEHEAT_HFLOW_RTS_TOGGLE 0x01 /* RTS is on during transmit,
  71. off otherwise */
  72. #define WHITEHEAT_HFLOW_DTR 0x02 /* DTR is off/on when RX
  73. fills/empties */
  74. #define WHITEHEAT_HFLOW_CTS 0x08 /* when received CTS off/on
  75. will stop/start TX */
  76. #define WHITEHEAT_HFLOW_DSR 0x10 /* when received DSR off/on
  77. will stop/start TX */
  78. #define WHITEHEAT_HFLOW_RTS 0x80 /* RTS is off/on when RX
  79. fills/empties */
  80. struct whiteheat_port_settings {
  81. __u8 port; /* port number (1 to N) */
  82. __u32 baud; /* any value 7 - 460800, firmware calculates
  83. best fit; arrives little endian */
  84. __u8 bits; /* 5, 6, 7, or 8 */
  85. __u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */
  86. __u8 parity; /* see WHITEHEAT_PAR_* above */
  87. __u8 sflow; /* see WHITEHEAT_SFLOW_* above */
  88. __u8 xoff; /* XOFF byte value */
  89. __u8 xon; /* XON byte value */
  90. __u8 hflow; /* see WHITEHEAT_HFLOW_* above */
  91. __u8 lloop; /* 0/1 turns local loopback mode off/on */
  92. } __attribute__ ((packed));
  93. /*
  94. * WHITEHEAT_SET_RTS
  95. * WHITEHEAT_SET_DTR
  96. * WHITEHEAT_SET_BREAK
  97. */
  98. #define WHITEHEAT_RTS_OFF 0x00
  99. #define WHITEHEAT_RTS_ON 0x01
  100. #define WHITEHEAT_DTR_OFF 0x00
  101. #define WHITEHEAT_DTR_ON 0x01
  102. #define WHITEHEAT_BREAK_OFF 0x00
  103. #define WHITEHEAT_BREAK_ON 0x01
  104. struct whiteheat_set_rdb {
  105. __u8 port; /* port number (1 to N) */
  106. __u8 state; /* 0/1 turns signal off/on */
  107. };
  108. /*
  109. * WHITEHEAT_DUMP
  110. */
  111. #define WHITEHEAT_DUMP_MEM_DATA 'd' /* data */
  112. #define WHITEHEAT_DUMP_MEM_IDATA 'i' /* idata */
  113. #define WHITEHEAT_DUMP_MEM_BDATA 'b' /* bdata */
  114. #define WHITEHEAT_DUMP_MEM_XDATA 'x' /* xdata */
  115. /*
  116. * Allowable address ranges (firmware checks address):
  117. * Type DATA: 0x00 - 0xff
  118. * Type IDATA: 0x80 - 0xff
  119. * Type BDATA: 0x20 - 0x2f
  120. * Type XDATA: 0x0000 - 0xffff
  121. *
  122. * B/I/DATA all read the local memory space
  123. * XDATA reads the external memory space
  124. * BDATA returns bits as bytes
  125. *
  126. * NOTE: 0x80 - 0xff (local space) are the Special Function Registers
  127. * of the 8051, and some have on-read side-effects.
  128. */
  129. struct whiteheat_dump {
  130. __u8 mem_type; /* see WHITEHEAT_DUMP_* above */
  131. __u16 addr; /* address, see restrictions above */
  132. __u16 length; /* number of bytes to dump, max 63 bytes */
  133. };
  134. /*
  135. * WHITEHEAT_PURGE
  136. */
  137. #define WHITEHEAT_PURGE_RX 0x01 /* purge rx fifos */
  138. #define WHITEHEAT_PURGE_TX 0x02 /* purge tx fifos */
  139. struct whiteheat_purge {
  140. __u8 port; /* port number (1 to N) */
  141. __u8 what; /* bit pattern of what to purge */
  142. };
  143. /*
  144. * WHITEHEAT_ECHO
  145. */
  146. struct whiteheat_echo {
  147. __u8 port; /* port number (1 to N) */
  148. __u8 length; /* length of message to echo, max 61 bytes */
  149. __u8 echo_data[61]; /* data to echo */
  150. };
  151. /*
  152. * WHITEHEAT_DO_TEST
  153. */
  154. #define WHITEHEAT_TEST_UART_RW 0x01 /* read/write uart registers */
  155. #define WHITEHEAT_TEST_UART_INTR 0x02 /* uart interrupt */
  156. #define WHITEHEAT_TEST_SETUP_CONT 0x03 /* setup for
  157. PORT_CONT/PORT_DISCONT */
  158. #define WHITEHEAT_TEST_PORT_CONT 0x04 /* port connect */
  159. #define WHITEHEAT_TEST_PORT_DISCONT 0x05 /* port disconnect */
  160. #define WHITEHEAT_TEST_UART_CLK_START 0x06 /* uart clock test start */
  161. #define WHITEHEAT_TEST_UART_CLK_STOP 0x07 /* uart clock test stop */
  162. #define WHITEHEAT_TEST_MODEM_FT 0x08 /* modem signals, requires a
  163. loopback cable/connector */
  164. #define WHITEHEAT_TEST_ERASE_EEPROM 0x09 /* erase eeprom */
  165. #define WHITEHEAT_TEST_READ_EEPROM 0x0a /* read eeprom */
  166. #define WHITEHEAT_TEST_PROGRAM_EEPROM 0x0b /* program eeprom */
  167. struct whiteheat_test {
  168. __u8 port; /* port number (1 to n) */
  169. __u8 test; /* see WHITEHEAT_TEST_* above*/
  170. __u8 info[32]; /* additional info */
  171. };
  172. /*
  173. * Replies from the firmware
  174. */
  175. /*
  176. * WHITEHEAT_STATUS
  177. */
  178. #define WHITEHEAT_EVENT_MODEM 0x01 /* modem field is valid */
  179. #define WHITEHEAT_EVENT_ERROR 0x02 /* error field is valid */
  180. #define WHITEHEAT_EVENT_FLOW 0x04 /* flow field is valid */
  181. #define WHITEHEAT_EVENT_CONNECT 0x08 /* connect field is valid */
  182. #define WHITEHEAT_FLOW_NONE 0x00 /* no flow control active */
  183. #define WHITEHEAT_FLOW_HARD_OUT 0x01 /* TX is stopped by CTS
  184. (waiting for CTS to go on) */
  185. #define WHITEHEAT_FLOW_HARD_IN 0x02 /* remote TX is stopped
  186. by RTS */
  187. #define WHITEHEAT_FLOW_SOFT_OUT 0x04 /* TX is stopped by XOFF
  188. received (waiting for XON) */
  189. #define WHITEHEAT_FLOW_SOFT_IN 0x08 /* remote TX is stopped by XOFF
  190. transmitted */
  191. #define WHITEHEAT_FLOW_TX_DONE 0x80 /* TX has completed */
  192. struct whiteheat_status_info {
  193. __u8 port; /* port number (1 to N) */
  194. __u8 event; /* indicates what the current event is,
  195. see WHITEHEAT_EVENT_* above */
  196. __u8 modem; /* modem signal status (copy of uart's
  197. MSR register) */
  198. __u8 error; /* line status (copy of uart's LSR register) */
  199. __u8 flow; /* flow control state, see WHITEHEAT_FLOW_*
  200. above */
  201. __u8 connect; /* 0 means not connected, non-zero means
  202. connected */
  203. };
  204. /*
  205. * WHITEHEAT_GET_DTR_RTS
  206. */
  207. struct whiteheat_dr_info {
  208. __u8 mcr; /* copy of uart's MCR register */
  209. };
  210. /*
  211. * WHITEHEAT_GET_HW_INFO
  212. */
  213. struct whiteheat_hw_info {
  214. __u8 hw_id; /* hardware id number, WhiteHEAT = 0 */
  215. __u8 sw_major_rev; /* major version number */
  216. __u8 sw_minor_rev; /* minor version number */
  217. struct whiteheat_hw_eeprom_info {
  218. __u8 b0; /* B0 */
  219. __u8 vendor_id_low; /* vendor id (low byte) */
  220. __u8 vendor_id_high; /* vendor id (high byte) */
  221. __u8 product_id_low; /* product id (low byte) */
  222. __u8 product_id_high; /* product id (high byte) */
  223. __u8 device_id_low; /* device id (low byte) */
  224. __u8 device_id_high; /* device id (high byte) */
  225. __u8 not_used_1;
  226. __u8 serial_number_0; /* serial number (low byte) */
  227. __u8 serial_number_1; /* serial number */
  228. __u8 serial_number_2; /* serial number */
  229. __u8 serial_number_3; /* serial number (high byte) */
  230. __u8 not_used_2;
  231. __u8 not_used_3;
  232. __u8 checksum_low; /* checksum (low byte) */
  233. __u8 checksum_high; /* checksum (high byte */
  234. } hw_eeprom_info; /* EEPROM contents */
  235. };
  236. /*
  237. * WHITEHEAT_EVENT
  238. */
  239. struct whiteheat_event_info {
  240. __u8 port; /* port number (1 to N) */
  241. __u8 event; /* see whiteheat_status_info.event */
  242. __u8 info; /* see whiteheat_status_info.modem, .error,
  243. .flow, .connect */
  244. };
  245. /*
  246. * WHITEHEAT_DO_TEST
  247. */
  248. #define WHITEHEAT_TEST_FAIL 0x00 /* test failed */
  249. #define WHITEHEAT_TEST_UNKNOWN 0x01 /* unknown test requested */
  250. #define WHITEHEAT_TEST_PASS 0xff /* test passed */
  251. struct whiteheat_test_info {
  252. __u8 port; /* port number (1 to N) */
  253. __u8 test; /* indicates which test this is a response for,
  254. see WHITEHEAT_DO_TEST above */
  255. __u8 status; /* see WHITEHEAT_TEST_* above */
  256. __u8 results[32]; /* test-dependent results */
  257. };
  258. #endif