icom.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * icom.h
  4. *
  5. * Copyright (C) 2001 Michael Anderson, IBM Corporation
  6. *
  7. * Serial device driver include file.
  8. */
  9. #include <linux/serial_core.h>
  10. #define BAUD_TABLE_LIMIT ((sizeof(icom_acfg_baud)/sizeof(int)) - 1)
  11. static int icom_acfg_baud[] = {
  12. 300,
  13. 600,
  14. 900,
  15. 1200,
  16. 1800,
  17. 2400,
  18. 3600,
  19. 4800,
  20. 7200,
  21. 9600,
  22. 14400,
  23. 19200,
  24. 28800,
  25. 38400,
  26. 57600,
  27. 76800,
  28. 115200,
  29. 153600,
  30. 230400,
  31. 307200,
  32. 460800,
  33. };
  34. struct icom_regs {
  35. u32 control; /* Adapter Control Register */
  36. u32 interrupt; /* Adapter Interrupt Register */
  37. u32 int_mask; /* Adapter Interrupt Mask Reg */
  38. u32 int_pri; /* Adapter Interrupt Priority r */
  39. u32 int_reg_b; /* Adapter non-masked Interrupt */
  40. u32 resvd01;
  41. u32 resvd02;
  42. u32 resvd03;
  43. u32 control_2; /* Adapter Control Register 2 */
  44. u32 interrupt_2; /* Adapter Interrupt Register 2 */
  45. u32 int_mask_2; /* Adapter Interrupt Mask 2 */
  46. u32 int_pri_2; /* Adapter Interrupt Prior 2 */
  47. u32 int_reg_2b; /* Adapter non-masked 2 */
  48. };
  49. struct func_dram {
  50. u32 reserved[108]; /* 0-1B0 reserved by personality code */
  51. u32 RcvStatusAddr; /* 1B0-1B3 Status Address for Next rcv */
  52. u8 RcvStnAddr; /* 1B4 Receive Station Addr */
  53. u8 IdleState; /* 1B5 Idle State */
  54. u8 IdleMonitor; /* 1B6 Idle Monitor */
  55. u8 FlagFillIdleTimer; /* 1B7 Flag Fill Idle Timer */
  56. u32 XmitStatusAddr; /* 1B8-1BB Transmit Status Address */
  57. u8 StartXmitCmd; /* 1BC Start Xmit Command */
  58. u8 HDLCConfigReg; /* 1BD Reserved */
  59. u8 CauseCode; /* 1BE Cause code for fatal error */
  60. u8 xchar; /* 1BF High priority send */
  61. u32 reserved3; /* 1C0-1C3 Reserved */
  62. u8 PrevCmdReg; /* 1C4 Reserved */
  63. u8 CmdReg; /* 1C5 Command Register */
  64. u8 async_config2; /* 1C6 Async Config Byte 2 */
  65. u8 async_config3; /* 1C7 Async Config Byte 3 */
  66. u8 dce_resvd[20]; /* 1C8-1DB DCE Rsvd */
  67. u8 dce_resvd21; /* 1DC DCE Rsvd (21st byte */
  68. u8 misc_flags; /* 1DD misc flags */
  69. #define V2_HARDWARE 0x40
  70. #define ICOM_HDW_ACTIVE 0x01
  71. u8 call_length; /* 1DE Phone #/CFI buff ln */
  72. u8 call_length2; /* 1DF Upper byte (unused) */
  73. u32 call_addr; /* 1E0-1E3 Phn #/CFI buff addr */
  74. u16 timer_value; /* 1E4-1E5 general timer value */
  75. u8 timer_command; /* 1E6 general timer cmd */
  76. u8 dce_command; /* 1E7 dce command reg */
  77. u8 dce_cmd_status; /* 1E8 dce command stat */
  78. u8 x21_r1_ioff; /* 1E9 dce ready counter */
  79. u8 x21_r0_ioff; /* 1EA dce not ready ctr */
  80. u8 x21_ralt_ioff; /* 1EB dce CNR counter */
  81. u8 x21_r1_ion; /* 1EC dce ready I on ctr */
  82. u8 rsvd_ier; /* 1ED Rsvd for IER (if ne */
  83. u8 ier; /* 1EE Interrupt Enable */
  84. u8 isr; /* 1EF Input Signal Reg */
  85. u8 osr; /* 1F0 Output Signal Reg */
  86. u8 reset; /* 1F1 Reset/Reload Reg */
  87. u8 disable; /* 1F2 Disable Reg */
  88. u8 sync; /* 1F3 Sync Reg */
  89. u8 error_stat; /* 1F4 Error Status */
  90. u8 cable_id; /* 1F5 Cable ID */
  91. u8 cs_length; /* 1F6 CS Load Length */
  92. u8 mac_length; /* 1F7 Mac Load Length */
  93. u32 cs_load_addr; /* 1F8-1FB Call Load PCI Addr */
  94. u32 mac_load_addr; /* 1FC-1FF Mac Load PCI Addr */
  95. };
  96. /*
  97. * adapter defines and structures
  98. */
  99. #define ICOM_CONTROL_START_A 0x00000008
  100. #define ICOM_CONTROL_STOP_A 0x00000004
  101. #define ICOM_CONTROL_START_B 0x00000002
  102. #define ICOM_CONTROL_STOP_B 0x00000001
  103. #define ICOM_CONTROL_START_C 0x00000008
  104. #define ICOM_CONTROL_STOP_C 0x00000004
  105. #define ICOM_CONTROL_START_D 0x00000002
  106. #define ICOM_CONTROL_STOP_D 0x00000001
  107. #define ICOM_IRAM_OFFSET 0x1000
  108. #define ICOM_IRAM_SIZE 0x0C00
  109. #define ICOM_DCE_IRAM_OFFSET 0x0A00
  110. #define ICOM_CABLE_ID_VALID 0x01
  111. #define ICOM_CABLE_ID_MASK 0xF0
  112. #define ICOM_DISABLE 0x80
  113. #define CMD_XMIT_RCV_ENABLE 0xC0
  114. #define CMD_XMIT_ENABLE 0x40
  115. #define CMD_RCV_DISABLE 0x00
  116. #define CMD_RCV_ENABLE 0x80
  117. #define CMD_RESTART 0x01
  118. #define CMD_HOLD_XMIT 0x02
  119. #define CMD_SND_BREAK 0x04
  120. #define RS232_CABLE 0x06
  121. #define V24_CABLE 0x0E
  122. #define V35_CABLE 0x0C
  123. #define V36_CABLE 0x02
  124. #define NO_CABLE 0x00
  125. #define START_DOWNLOAD 0x80
  126. #define ICOM_INT_MASK_PRC_A 0x00003FFF
  127. #define ICOM_INT_MASK_PRC_B 0x3FFF0000
  128. #define ICOM_INT_MASK_PRC_C 0x00003FFF
  129. #define ICOM_INT_MASK_PRC_D 0x3FFF0000
  130. #define INT_RCV_COMPLETED 0x1000
  131. #define INT_XMIT_COMPLETED 0x2000
  132. #define INT_IDLE_DETECT 0x0800
  133. #define INT_RCV_DISABLED 0x0400
  134. #define INT_XMIT_DISABLED 0x0200
  135. #define INT_RCV_XMIT_SHUTDOWN 0x0100
  136. #define INT_FATAL_ERROR 0x0080
  137. #define INT_CABLE_PULL 0x0020
  138. #define INT_SIGNAL_CHANGE 0x0010
  139. #define HDLC_PPP_PURE_ASYNC 0x02
  140. #define HDLC_FF_FILL 0x00
  141. #define HDLC_HDW_FLOW 0x01
  142. #define START_XMIT 0x80
  143. #define ICOM_ACFG_DRIVE1 0x20
  144. #define ICOM_ACFG_NO_PARITY 0x00
  145. #define ICOM_ACFG_PARITY_ENAB 0x02
  146. #define ICOM_ACFG_PARITY_ODD 0x01
  147. #define ICOM_ACFG_8BPC 0x00
  148. #define ICOM_ACFG_7BPC 0x04
  149. #define ICOM_ACFG_6BPC 0x08
  150. #define ICOM_ACFG_5BPC 0x0C
  151. #define ICOM_ACFG_1STOP_BIT 0x00
  152. #define ICOM_ACFG_2STOP_BIT 0x10
  153. #define ICOM_DTR 0x80
  154. #define ICOM_RTS 0x40
  155. #define ICOM_RI 0x08
  156. #define ICOM_DSR 0x80
  157. #define ICOM_DCD 0x20
  158. #define ICOM_CTS 0x40
  159. #define NUM_XBUFFS 1
  160. #define NUM_RBUFFS 2
  161. #define RCV_BUFF_SZ 0x0200
  162. #define XMIT_BUFF_SZ 0x1000
  163. struct statusArea {
  164. /**********************************************/
  165. /* Transmit Status Area */
  166. /**********************************************/
  167. struct xmit_status_area{
  168. u32 leNext; /* Next entry in Little Endian on Adapter */
  169. u32 leNextASD;
  170. u32 leBuffer; /* Buffer for entry in LE for Adapter */
  171. u16 leLengthASD;
  172. u16 leOffsetASD;
  173. u16 leLength; /* Length of data in segment */
  174. u16 flags;
  175. #define SA_FLAGS_DONE 0x0080 /* Done with Segment */
  176. #define SA_FLAGS_CONTINUED 0x8000 /* More Segments */
  177. #define SA_FLAGS_IDLE 0x4000 /* Mark IDLE after frm */
  178. #define SA_FLAGS_READY_TO_XMIT 0x0800
  179. #define SA_FLAGS_STAT_MASK 0x007F
  180. } xmit[NUM_XBUFFS];
  181. /**********************************************/
  182. /* Receive Status Area */
  183. /**********************************************/
  184. struct {
  185. u32 leNext; /* Next entry in Little Endian on Adapter */
  186. u32 leNextASD;
  187. u32 leBuffer; /* Buffer for entry in LE for Adapter */
  188. u16 WorkingLength; /* size of segment */
  189. u16 reserv01;
  190. u16 leLength; /* Length of data in segment */
  191. u16 flags;
  192. #define SA_FL_RCV_DONE 0x0010 /* Data ready */
  193. #define SA_FLAGS_OVERRUN 0x0040
  194. #define SA_FLAGS_PARITY_ERROR 0x0080
  195. #define SA_FLAGS_FRAME_ERROR 0x0001
  196. #define SA_FLAGS_FRAME_TRUNC 0x0002
  197. #define SA_FLAGS_BREAK_DET 0x0004 /* set conditionally by device driver, not hardware */
  198. #define SA_FLAGS_RCV_MASK 0xFFE6
  199. } rcv[NUM_RBUFFS];
  200. };
  201. struct icom_adapter;
  202. #define ICOM_MAJOR 243
  203. #define ICOM_MINOR_START 0
  204. struct icom_port {
  205. struct uart_port uart_port;
  206. u8 imbed_modem;
  207. #define ICOM_UNKNOWN 1
  208. #define ICOM_RVX 2
  209. #define ICOM_IMBED_MODEM 3
  210. unsigned char cable_id;
  211. unsigned char read_status_mask;
  212. unsigned char ignore_status_mask;
  213. void __iomem * int_reg;
  214. struct icom_regs __iomem *global_reg;
  215. struct func_dram __iomem *dram;
  216. int port;
  217. struct statusArea *statStg;
  218. dma_addr_t statStg_pci;
  219. u32 *xmitRestart;
  220. dma_addr_t xmitRestart_pci;
  221. unsigned char *xmit_buf;
  222. dma_addr_t xmit_buf_pci;
  223. unsigned char *recv_buf;
  224. dma_addr_t recv_buf_pci;
  225. int next_rcv;
  226. int put_length;
  227. int status;
  228. #define ICOM_PORT_ACTIVE 1 /* Port exists. */
  229. #define ICOM_PORT_OFF 0 /* Port does not exist. */
  230. int load_in_progress;
  231. struct icom_adapter *adapter;
  232. };
  233. struct icom_adapter {
  234. void __iomem * base_addr;
  235. unsigned long base_addr_pci;
  236. struct pci_dev *pci_dev;
  237. struct icom_port port_info[4];
  238. int index;
  239. int version;
  240. #define ADAPTER_V1 0x0001
  241. #define ADAPTER_V2 0x0002
  242. u32 subsystem_id;
  243. #define FOUR_PORT_MODEL 0x0252
  244. #define V2_TWO_PORTS_RVX 0x021A
  245. #define V2_ONE_PORT_RVX_ONE_PORT_IMBED_MDM 0x0251
  246. int numb_ports;
  247. struct list_head icom_adapter_entry;
  248. struct kref kref;
  249. };
  250. /* prototype */
  251. extern void iCom_sercons_init(void);
  252. struct lookup_proc_table {
  253. u32 __iomem *global_control_reg;
  254. unsigned long processor_id;
  255. };
  256. struct lookup_int_table {
  257. u32 __iomem *global_int_mask;
  258. unsigned long processor_id;
  259. };