icom.h 9.5 KB

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