hifn7751reg.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /* $FreeBSD: src/sys/dev/hifn/hifn7751reg.h,v 1.7 2007/03/21 03:42:49 sam Exp $ */
  2. /* $OpenBSD: hifn7751reg.h,v 1.35 2002/04/08 17:49:42 jason Exp $ */
  3. /*-
  4. * Invertex AEON / Hifn 7751 driver
  5. * Copyright (c) 1999 Invertex Inc. All rights reserved.
  6. * Copyright (c) 1999 Theo de Raadt
  7. * Copyright (c) 2000-2001 Network Security Technologies, Inc.
  8. * http://www.netsec.net
  9. *
  10. * Please send any comments, feedback, bug-fixes, or feature requests to
  11. * software@invertex.com.
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions
  15. * are met:
  16. *
  17. * 1. Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the distribution.
  22. * 3. The name of the author may not be used to endorse or promote products
  23. * derived from this software without specific prior written permission.
  24. *
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  27. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  28. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  29. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  30. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  31. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  35. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. * Effort sponsored in part by the Defense Advanced Research Projects
  38. * Agency (DARPA) and Air Force Research Laboratory, Air Force
  39. * Materiel Command, USAF, under agreement number F30602-01-2-0537.
  40. *
  41. */
  42. #ifndef __HIFN_H__
  43. #define __HIFN_H__
  44. /*
  45. * Some PCI configuration space offset defines. The names were made
  46. * identical to the names used by the Linux kernel.
  47. */
  48. #define HIFN_BAR0 PCIR_BAR(0) /* PUC register map */
  49. #define HIFN_BAR1 PCIR_BAR(1) /* DMA register map */
  50. #define HIFN_TRDY_TIMEOUT 0x40
  51. #define HIFN_RETRY_TIMEOUT 0x41
  52. /*
  53. * PCI vendor and device identifiers
  54. * (the names are preserved from their OpenBSD source).
  55. */
  56. #define PCI_VENDOR_HIFN 0x13a3 /* Hifn */
  57. #define PCI_PRODUCT_HIFN_7751 0x0005 /* 7751 */
  58. #define PCI_PRODUCT_HIFN_6500 0x0006 /* 6500 */
  59. #define PCI_PRODUCT_HIFN_7811 0x0007 /* 7811 */
  60. #define PCI_PRODUCT_HIFN_7855 0x001f /* 7855 */
  61. #define PCI_PRODUCT_HIFN_7951 0x0012 /* 7951 */
  62. #define PCI_PRODUCT_HIFN_7955 0x0020 /* 7954/7955 */
  63. #define PCI_PRODUCT_HIFN_7956 0x001d /* 7956 */
  64. #define PCI_VENDOR_INVERTEX 0x14e1 /* Invertex */
  65. #define PCI_PRODUCT_INVERTEX_AEON 0x0005 /* AEON */
  66. #define PCI_VENDOR_NETSEC 0x1660 /* NetSec */
  67. #define PCI_PRODUCT_NETSEC_7751 0x7751 /* 7751 */
  68. /*
  69. * The values below should multiple of 4 -- and be large enough to handle
  70. * any command the driver implements.
  71. *
  72. * MAX_COMMAND = base command + mac command + encrypt command +
  73. * mac-key + rc4-key
  74. * MAX_RESULT = base result + mac result + mac + encrypt result
  75. *
  76. *
  77. */
  78. #define HIFN_MAX_COMMAND (8 + 8 + 8 + 64 + 260)
  79. #define HIFN_MAX_RESULT (8 + 4 + 20 + 4)
  80. /*
  81. * hifn_desc_t
  82. *
  83. * Holds an individual descriptor for any of the rings.
  84. */
  85. typedef struct hifn_desc {
  86. volatile u_int32_t l; /* length and status bits */
  87. volatile u_int32_t p;
  88. } hifn_desc_t;
  89. /*
  90. * Masks for the "length" field of struct hifn_desc.
  91. */
  92. #define HIFN_D_LENGTH 0x0000ffff /* length bit mask */
  93. #define HIFN_D_MASKDONEIRQ 0x02000000 /* mask the done interrupt */
  94. #define HIFN_D_DESTOVER 0x04000000 /* destination overflow */
  95. #define HIFN_D_OVER 0x08000000 /* overflow */
  96. #define HIFN_D_LAST 0x20000000 /* last descriptor in chain */
  97. #define HIFN_D_JUMP 0x40000000 /* jump descriptor */
  98. #define HIFN_D_VALID 0x80000000 /* valid bit */
  99. /*
  100. * Processing Unit Registers (offset from BASEREG0)
  101. */
  102. #define HIFN_0_PUDATA 0x00 /* Processing Unit Data */
  103. #define HIFN_0_PUCTRL 0x04 /* Processing Unit Control */
  104. #define HIFN_0_PUISR 0x08 /* Processing Unit Interrupt Status */
  105. #define HIFN_0_PUCNFG 0x0c /* Processing Unit Configuration */
  106. #define HIFN_0_PUIER 0x10 /* Processing Unit Interrupt Enable */
  107. #define HIFN_0_PUSTAT 0x14 /* Processing Unit Status/Chip ID */
  108. #define HIFN_0_FIFOSTAT 0x18 /* FIFO Status */
  109. #define HIFN_0_FIFOCNFG 0x1c /* FIFO Configuration */
  110. #define HIFN_0_PUCTRL2 0x28 /* Processing Unit Control (2nd map) */
  111. #define HIFN_0_MUTE1 0x80
  112. #define HIFN_0_MUTE2 0x90
  113. #define HIFN_0_SPACESIZE 0x100 /* Register space size */
  114. /* Processing Unit Control Register (HIFN_0_PUCTRL) */
  115. #define HIFN_PUCTRL_CLRSRCFIFO 0x0010 /* clear source fifo */
  116. #define HIFN_PUCTRL_STOP 0x0008 /* stop pu */
  117. #define HIFN_PUCTRL_LOCKRAM 0x0004 /* lock ram */
  118. #define HIFN_PUCTRL_DMAENA 0x0002 /* enable dma */
  119. #define HIFN_PUCTRL_RESET 0x0001 /* Reset processing unit */
  120. /* Processing Unit Interrupt Status Register (HIFN_0_PUISR) */
  121. #define HIFN_PUISR_CMDINVAL 0x8000 /* Invalid command interrupt */
  122. #define HIFN_PUISR_DATAERR 0x4000 /* Data error interrupt */
  123. #define HIFN_PUISR_SRCFIFO 0x2000 /* Source FIFO ready interrupt */
  124. #define HIFN_PUISR_DSTFIFO 0x1000 /* Destination FIFO ready interrupt */
  125. #define HIFN_PUISR_DSTOVER 0x0200 /* Destination overrun interrupt */
  126. #define HIFN_PUISR_SRCCMD 0x0080 /* Source command interrupt */
  127. #define HIFN_PUISR_SRCCTX 0x0040 /* Source context interrupt */
  128. #define HIFN_PUISR_SRCDATA 0x0020 /* Source data interrupt */
  129. #define HIFN_PUISR_DSTDATA 0x0010 /* Destination data interrupt */
  130. #define HIFN_PUISR_DSTRESULT 0x0004 /* Destination result interrupt */
  131. /* Processing Unit Configuration Register (HIFN_0_PUCNFG) */
  132. #define HIFN_PUCNFG_DRAMMASK 0xe000 /* DRAM size mask */
  133. #define HIFN_PUCNFG_DSZ_256K 0x0000 /* 256k dram */
  134. #define HIFN_PUCNFG_DSZ_512K 0x2000 /* 512k dram */
  135. #define HIFN_PUCNFG_DSZ_1M 0x4000 /* 1m dram */
  136. #define HIFN_PUCNFG_DSZ_2M 0x6000 /* 2m dram */
  137. #define HIFN_PUCNFG_DSZ_4M 0x8000 /* 4m dram */
  138. #define HIFN_PUCNFG_DSZ_8M 0xa000 /* 8m dram */
  139. #define HIFN_PUNCFG_DSZ_16M 0xc000 /* 16m dram */
  140. #define HIFN_PUCNFG_DSZ_32M 0xe000 /* 32m dram */
  141. #define HIFN_PUCNFG_DRAMREFRESH 0x1800 /* DRAM refresh rate mask */
  142. #define HIFN_PUCNFG_DRFR_512 0x0000 /* 512 divisor of ECLK */
  143. #define HIFN_PUCNFG_DRFR_256 0x0800 /* 256 divisor of ECLK */
  144. #define HIFN_PUCNFG_DRFR_128 0x1000 /* 128 divisor of ECLK */
  145. #define HIFN_PUCNFG_TCALLPHASES 0x0200 /* your guess is as good as mine... */
  146. #define HIFN_PUCNFG_TCDRVTOTEM 0x0100 /* your guess is as good as mine... */
  147. #define HIFN_PUCNFG_BIGENDIAN 0x0080 /* DMA big endian mode */
  148. #define HIFN_PUCNFG_BUS32 0x0040 /* Bus width 32bits */
  149. #define HIFN_PUCNFG_BUS16 0x0000 /* Bus width 16 bits */
  150. #define HIFN_PUCNFG_CHIPID 0x0020 /* Allow chipid from PUSTAT */
  151. #define HIFN_PUCNFG_DRAM 0x0010 /* Context RAM is DRAM */
  152. #define HIFN_PUCNFG_SRAM 0x0000 /* Context RAM is SRAM */
  153. #define HIFN_PUCNFG_COMPSING 0x0004 /* Enable single compression context */
  154. #define HIFN_PUCNFG_ENCCNFG 0x0002 /* Encryption configuration */
  155. /* Processing Unit Interrupt Enable Register (HIFN_0_PUIER) */
  156. #define HIFN_PUIER_CMDINVAL 0x8000 /* Invalid command interrupt */
  157. #define HIFN_PUIER_DATAERR 0x4000 /* Data error interrupt */
  158. #define HIFN_PUIER_SRCFIFO 0x2000 /* Source FIFO ready interrupt */
  159. #define HIFN_PUIER_DSTFIFO 0x1000 /* Destination FIFO ready interrupt */
  160. #define HIFN_PUIER_DSTOVER 0x0200 /* Destination overrun interrupt */
  161. #define HIFN_PUIER_SRCCMD 0x0080 /* Source command interrupt */
  162. #define HIFN_PUIER_SRCCTX 0x0040 /* Source context interrupt */
  163. #define HIFN_PUIER_SRCDATA 0x0020 /* Source data interrupt */
  164. #define HIFN_PUIER_DSTDATA 0x0010 /* Destination data interrupt */
  165. #define HIFN_PUIER_DSTRESULT 0x0004 /* Destination result interrupt */
  166. /* Processing Unit Status Register/Chip ID (HIFN_0_PUSTAT) */
  167. #define HIFN_PUSTAT_CMDINVAL 0x8000 /* Invalid command interrupt */
  168. #define HIFN_PUSTAT_DATAERR 0x4000 /* Data error interrupt */
  169. #define HIFN_PUSTAT_SRCFIFO 0x2000 /* Source FIFO ready interrupt */
  170. #define HIFN_PUSTAT_DSTFIFO 0x1000 /* Destination FIFO ready interrupt */
  171. #define HIFN_PUSTAT_DSTOVER 0x0200 /* Destination overrun interrupt */
  172. #define HIFN_PUSTAT_SRCCMD 0x0080 /* Source command interrupt */
  173. #define HIFN_PUSTAT_SRCCTX 0x0040 /* Source context interrupt */
  174. #define HIFN_PUSTAT_SRCDATA 0x0020 /* Source data interrupt */
  175. #define HIFN_PUSTAT_DSTDATA 0x0010 /* Destination data interrupt */
  176. #define HIFN_PUSTAT_DSTRESULT 0x0004 /* Destination result interrupt */
  177. #define HIFN_PUSTAT_CHIPREV 0x00ff /* Chip revision mask */
  178. #define HIFN_PUSTAT_CHIPENA 0xff00 /* Chip enabled mask */
  179. #define HIFN_PUSTAT_ENA_2 0x1100 /* Level 2 enabled */
  180. #define HIFN_PUSTAT_ENA_1 0x1000 /* Level 1 enabled */
  181. #define HIFN_PUSTAT_ENA_0 0x3000 /* Level 0 enabled */
  182. #define HIFN_PUSTAT_REV_2 0x0020 /* 7751 PT6/2 */
  183. #define HIFN_PUSTAT_REV_3 0x0030 /* 7751 PT6/3 */
  184. /* FIFO Status Register (HIFN_0_FIFOSTAT) */
  185. #define HIFN_FIFOSTAT_SRC 0x7f00 /* Source FIFO available */
  186. #define HIFN_FIFOSTAT_DST 0x007f /* Destination FIFO available */
  187. /* FIFO Configuration Register (HIFN_0_FIFOCNFG) */
  188. #define HIFN_FIFOCNFG_THRESHOLD 0x0400 /* must be written as this value */
  189. /*
  190. * DMA Interface Registers (offset from BASEREG1)
  191. */
  192. #define HIFN_1_DMA_CRAR 0x0c /* DMA Command Ring Address */
  193. #define HIFN_1_DMA_SRAR 0x1c /* DMA Source Ring Address */
  194. #define HIFN_1_DMA_RRAR 0x2c /* DMA Result Ring Address */
  195. #define HIFN_1_DMA_DRAR 0x3c /* DMA Destination Ring Address */
  196. #define HIFN_1_DMA_CSR 0x40 /* DMA Status and Control */
  197. #define HIFN_1_DMA_IER 0x44 /* DMA Interrupt Enable */
  198. #define HIFN_1_DMA_CNFG 0x48 /* DMA Configuration */
  199. #define HIFN_1_PLL 0x4c /* 7955/7956: PLL config */
  200. #define HIFN_1_7811_RNGENA 0x60 /* 7811: rng enable */
  201. #define HIFN_1_7811_RNGCFG 0x64 /* 7811: rng config */
  202. #define HIFN_1_7811_RNGDAT 0x68 /* 7811: rng data */
  203. #define HIFN_1_7811_RNGSTS 0x6c /* 7811: rng status */
  204. #define HIFN_1_DMA_CNFG2 0x6c /* 7955/7956: dma config #2 */
  205. #define HIFN_1_7811_MIPSRST 0x94 /* 7811: MIPS reset */
  206. #define HIFN_1_REVID 0x98 /* Revision ID */
  207. #define HIFN_1_PUB_RESET 0x204 /* Public/RNG Reset */
  208. #define HIFN_1_PUB_BASE 0x300 /* Public Base Address */
  209. #define HIFN_1_PUB_OPLEN 0x304 /* 7951-compat Public Operand Length */
  210. #define HIFN_1_PUB_OP 0x308 /* 7951-compat Public Operand */
  211. #define HIFN_1_PUB_STATUS 0x30c /* 7951-compat Public Status */
  212. #define HIFN_1_PUB_IEN 0x310 /* Public Interrupt enable */
  213. #define HIFN_1_RNG_CONFIG 0x314 /* RNG config */
  214. #define HIFN_1_RNG_DATA 0x318 /* RNG data */
  215. #define HIFN_1_PUB_MODE 0x320 /* PK mode */
  216. #define HIFN_1_PUB_FIFO_OPLEN 0x380 /* first element of oplen fifo */
  217. #define HIFN_1_PUB_FIFO_OP 0x384 /* first element of op fifo */
  218. #define HIFN_1_PUB_MEM 0x400 /* start of Public key memory */
  219. #define HIFN_1_PUB_MEMEND 0xbff /* end of Public key memory */
  220. /* DMA Status and Control Register (HIFN_1_DMA_CSR) */
  221. #define HIFN_DMACSR_D_CTRLMASK 0xc0000000 /* Destinition Ring Control */
  222. #define HIFN_DMACSR_D_CTRL_NOP 0x00000000 /* Dest. Control: no-op */
  223. #define HIFN_DMACSR_D_CTRL_DIS 0x40000000 /* Dest. Control: disable */
  224. #define HIFN_DMACSR_D_CTRL_ENA 0x80000000 /* Dest. Control: enable */
  225. #define HIFN_DMACSR_D_ABORT 0x20000000 /* Destinition Ring PCIAbort */
  226. #define HIFN_DMACSR_D_DONE 0x10000000 /* Destinition Ring Done */
  227. #define HIFN_DMACSR_D_LAST 0x08000000 /* Destinition Ring Last */
  228. #define HIFN_DMACSR_D_WAIT 0x04000000 /* Destinition Ring Waiting */
  229. #define HIFN_DMACSR_D_OVER 0x02000000 /* Destinition Ring Overflow */
  230. #define HIFN_DMACSR_R_CTRL 0x00c00000 /* Result Ring Control */
  231. #define HIFN_DMACSR_R_CTRL_NOP 0x00000000 /* Result Control: no-op */
  232. #define HIFN_DMACSR_R_CTRL_DIS 0x00400000 /* Result Control: disable */
  233. #define HIFN_DMACSR_R_CTRL_ENA 0x00800000 /* Result Control: enable */
  234. #define HIFN_DMACSR_R_ABORT 0x00200000 /* Result Ring PCI Abort */
  235. #define HIFN_DMACSR_R_DONE 0x00100000 /* Result Ring Done */
  236. #define HIFN_DMACSR_R_LAST 0x00080000 /* Result Ring Last */
  237. #define HIFN_DMACSR_R_WAIT 0x00040000 /* Result Ring Waiting */
  238. #define HIFN_DMACSR_R_OVER 0x00020000 /* Result Ring Overflow */
  239. #define HIFN_DMACSR_S_CTRL 0x0000c000 /* Source Ring Control */
  240. #define HIFN_DMACSR_S_CTRL_NOP 0x00000000 /* Source Control: no-op */
  241. #define HIFN_DMACSR_S_CTRL_DIS 0x00004000 /* Source Control: disable */
  242. #define HIFN_DMACSR_S_CTRL_ENA 0x00008000 /* Source Control: enable */
  243. #define HIFN_DMACSR_S_ABORT 0x00002000 /* Source Ring PCI Abort */
  244. #define HIFN_DMACSR_S_DONE 0x00001000 /* Source Ring Done */
  245. #define HIFN_DMACSR_S_LAST 0x00000800 /* Source Ring Last */
  246. #define HIFN_DMACSR_S_WAIT 0x00000400 /* Source Ring Waiting */
  247. #define HIFN_DMACSR_ILLW 0x00000200 /* Illegal write (7811 only) */
  248. #define HIFN_DMACSR_ILLR 0x00000100 /* Illegal read (7811 only) */
  249. #define HIFN_DMACSR_C_CTRL 0x000000c0 /* Command Ring Control */
  250. #define HIFN_DMACSR_C_CTRL_NOP 0x00000000 /* Command Control: no-op */
  251. #define HIFN_DMACSR_C_CTRL_DIS 0x00000040 /* Command Control: disable */
  252. #define HIFN_DMACSR_C_CTRL_ENA 0x00000080 /* Command Control: enable */
  253. #define HIFN_DMACSR_C_ABORT 0x00000020 /* Command Ring PCI Abort */
  254. #define HIFN_DMACSR_C_DONE 0x00000010 /* Command Ring Done */
  255. #define HIFN_DMACSR_C_LAST 0x00000008 /* Command Ring Last */
  256. #define HIFN_DMACSR_C_WAIT 0x00000004 /* Command Ring Waiting */
  257. #define HIFN_DMACSR_PUBDONE 0x00000002 /* Public op done (7951 only) */
  258. #define HIFN_DMACSR_ENGINE 0x00000001 /* Command Ring Engine IRQ */
  259. /* DMA Interrupt Enable Register (HIFN_1_DMA_IER) */
  260. #define HIFN_DMAIER_D_ABORT 0x20000000 /* Destination Ring PCIAbort */
  261. #define HIFN_DMAIER_D_DONE 0x10000000 /* Destination Ring Done */
  262. #define HIFN_DMAIER_D_LAST 0x08000000 /* Destination Ring Last */
  263. #define HIFN_DMAIER_D_WAIT 0x04000000 /* Destination Ring Waiting */
  264. #define HIFN_DMAIER_D_OVER 0x02000000 /* Destination Ring Overflow */
  265. #define HIFN_DMAIER_R_ABORT 0x00200000 /* Result Ring PCI Abort */
  266. #define HIFN_DMAIER_R_DONE 0x00100000 /* Result Ring Done */
  267. #define HIFN_DMAIER_R_LAST 0x00080000 /* Result Ring Last */
  268. #define HIFN_DMAIER_R_WAIT 0x00040000 /* Result Ring Waiting */
  269. #define HIFN_DMAIER_R_OVER 0x00020000 /* Result Ring Overflow */
  270. #define HIFN_DMAIER_S_ABORT 0x00002000 /* Source Ring PCI Abort */
  271. #define HIFN_DMAIER_S_DONE 0x00001000 /* Source Ring Done */
  272. #define HIFN_DMAIER_S_LAST 0x00000800 /* Source Ring Last */
  273. #define HIFN_DMAIER_S_WAIT 0x00000400 /* Source Ring Waiting */
  274. #define HIFN_DMAIER_ILLW 0x00000200 /* Illegal write (7811 only) */
  275. #define HIFN_DMAIER_ILLR 0x00000100 /* Illegal read (7811 only) */
  276. #define HIFN_DMAIER_C_ABORT 0x00000020 /* Command Ring PCI Abort */
  277. #define HIFN_DMAIER_C_DONE 0x00000010 /* Command Ring Done */
  278. #define HIFN_DMAIER_C_LAST 0x00000008 /* Command Ring Last */
  279. #define HIFN_DMAIER_C_WAIT 0x00000004 /* Command Ring Waiting */
  280. #define HIFN_DMAIER_PUBDONE 0x00000002 /* public op done (7951 only) */
  281. #define HIFN_DMAIER_ENGINE 0x00000001 /* Engine IRQ */
  282. /* DMA Configuration Register (HIFN_1_DMA_CNFG) */
  283. #define HIFN_DMACNFG_BIGENDIAN 0x10000000 /* big endian mode */
  284. #define HIFN_DMACNFG_POLLFREQ 0x00ff0000 /* Poll frequency mask */
  285. #define HIFN_DMACNFG_UNLOCK 0x00000800
  286. #define HIFN_DMACNFG_POLLINVAL 0x00000700 /* Invalid Poll Scalar */
  287. #define HIFN_DMACNFG_LAST 0x00000010 /* Host control LAST bit */
  288. #define HIFN_DMACNFG_MODE 0x00000004 /* DMA mode */
  289. #define HIFN_DMACNFG_DMARESET 0x00000002 /* DMA Reset # */
  290. #define HIFN_DMACNFG_MSTRESET 0x00000001 /* Master Reset # */
  291. /* DMA Configuration Register (HIFN_1_DMA_CNFG2) */
  292. #define HIFN_DMACNFG2_PKSWAP32 (1 << 19) /* swap the OPLEN/OP reg */
  293. #define HIFN_DMACNFG2_PKSWAP8 (1 << 18) /* swap the bits of OPLEN/OP */
  294. #define HIFN_DMACNFG2_BAR0_SWAP32 (1<<17) /* swap the bytes of BAR0 */
  295. #define HIFN_DMACNFG2_BAR1_SWAP8 (1<<16) /* swap the bits of BAR0 */
  296. #define HIFN_DMACNFG2_INIT_WRITE_BURST_SHIFT 12
  297. #define HIFN_DMACNFG2_INIT_READ_BURST_SHIFT 8
  298. #define HIFN_DMACNFG2_TGT_WRITE_BURST_SHIFT 4
  299. #define HIFN_DMACNFG2_TGT_READ_BURST_SHIFT 0
  300. /* 7811 RNG Enable Register (HIFN_1_7811_RNGENA) */
  301. #define HIFN_7811_RNGENA_ENA 0x00000001 /* enable RNG */
  302. /* 7811 RNG Config Register (HIFN_1_7811_RNGCFG) */
  303. #define HIFN_7811_RNGCFG_PRE1 0x00000f00 /* first prescalar */
  304. #define HIFN_7811_RNGCFG_OPRE 0x00000080 /* output prescalar */
  305. #define HIFN_7811_RNGCFG_DEFL 0x00000f80 /* 2 words/ 1/100 sec */
  306. /* 7811 RNG Status Register (HIFN_1_7811_RNGSTS) */
  307. #define HIFN_7811_RNGSTS_RDY 0x00004000 /* two numbers in FIFO */
  308. #define HIFN_7811_RNGSTS_UFL 0x00001000 /* rng underflow */
  309. /* 7811 MIPS Reset Register (HIFN_1_7811_MIPSRST) */
  310. #define HIFN_MIPSRST_BAR2SIZE 0xffff0000 /* sdram size */
  311. #define HIFN_MIPSRST_GPRAMINIT 0x00008000 /* gpram can be accessed */
  312. #define HIFN_MIPSRST_CRAMINIT 0x00004000 /* ctxram can be accessed */
  313. #define HIFN_MIPSRST_LED2 0x00000400 /* external LED2 */
  314. #define HIFN_MIPSRST_LED1 0x00000200 /* external LED1 */
  315. #define HIFN_MIPSRST_LED0 0x00000100 /* external LED0 */
  316. #define HIFN_MIPSRST_MIPSDIS 0x00000004 /* disable MIPS */
  317. #define HIFN_MIPSRST_MIPSRST 0x00000002 /* warm reset MIPS */
  318. #define HIFN_MIPSRST_MIPSCOLD 0x00000001 /* cold reset MIPS */
  319. /* Public key reset register (HIFN_1_PUB_RESET) */
  320. #define HIFN_PUBRST_RESET 0x00000001 /* reset public/rng unit */
  321. /* Public operation register (HIFN_1_PUB_OP) */
  322. #define HIFN_PUBOP_AOFFSET 0x0000003e /* A offset */
  323. #define HIFN_PUBOP_BOFFSET 0x00000fc0 /* B offset */
  324. #define HIFN_PUBOP_MOFFSET 0x0003f000 /* M offset */
  325. #define HIFN_PUBOP_OP_MASK 0x003c0000 /* Opcode: */
  326. #define HIFN_PUBOP_OP_NOP 0x00000000 /* NOP */
  327. #define HIFN_PUBOP_OP_ADD 0x00040000 /* ADD */
  328. #define HIFN_PUBOP_OP_ADDC 0x00080000 /* ADD w/carry */
  329. #define HIFN_PUBOP_OP_SUB 0x000c0000 /* SUB */
  330. #define HIFN_PUBOP_OP_SUBC 0x00100000 /* SUB w/carry */
  331. #define HIFN_PUBOP_OP_MODADD 0x00140000 /* Modular ADD */
  332. #define HIFN_PUBOP_OP_MODSUB 0x00180000 /* Modular SUB */
  333. #define HIFN_PUBOP_OP_INCA 0x001c0000 /* INC A */
  334. #define HIFN_PUBOP_OP_DECA 0x00200000 /* DEC A */
  335. #define HIFN_PUBOP_OP_MULT 0x00240000 /* MULT */
  336. #define HIFN_PUBOP_OP_MODMULT 0x00280000 /* Modular MULT */
  337. #define HIFN_PUBOP_OP_MODRED 0x002c0000 /* Modular Red */
  338. #define HIFN_PUBOP_OP_MODEXP 0x00300000 /* Modular Exp */
  339. /* Public operand length register (HIFN_1_PUB_OPLEN) */
  340. #define HIFN_PUBOPLEN_MODLEN 0x0000007f
  341. #define HIFN_PUBOPLEN_EXPLEN 0x0003ff80
  342. #define HIFN_PUBOPLEN_REDLEN 0x003c0000
  343. /* Public status register (HIFN_1_PUB_STATUS) */
  344. #define HIFN_PUBSTS_DONE 0x00000001 /* operation done */
  345. #define HIFN_PUBSTS_CARRY 0x00000002 /* carry */
  346. #define HIFN_PUBSTS_FIFO_EMPTY 0x00000100 /* fifo empty */
  347. #define HIFN_PUBSTS_FIFO_FULL 0x00000200 /* fifo full */
  348. #define HIFN_PUBSTS_FIFO_OVFL 0x00000400 /* fifo overflow */
  349. #define HIFN_PUBSTS_FIFO_WRITE 0x000f0000 /* fifo write */
  350. #define HIFN_PUBSTS_FIFO_READ 0x0f000000 /* fifo read */
  351. /* Public interrupt enable register (HIFN_1_PUB_IEN) */
  352. #define HIFN_PUBIEN_DONE 0x00000001 /* operation done interrupt */
  353. /* Random number generator config register (HIFN_1_RNG_CONFIG) */
  354. #define HIFN_RNGCFG_ENA 0x00000001 /* enable rng */
  355. /*
  356. * Register offsets in register set 1
  357. */
  358. #define HIFN_UNLOCK_SECRET1 0xf4
  359. #define HIFN_UNLOCK_SECRET2 0xfc
  360. /*
  361. * PLL config register
  362. *
  363. * This register is present only on 7954/7955/7956 parts. It must be
  364. * programmed according to the bus interface method used by the h/w.
  365. * Note that the parts require a stable clock. Since the PCI clock
  366. * may vary the reference clock must usually be used. To avoid
  367. * overclocking the core logic, setup must be done carefully, refer
  368. * to the driver for details. The exact multiplier required varies
  369. * by part and system configuration; refer to the Hifn documentation.
  370. */
  371. #define HIFN_PLL_REF_SEL 0x00000001 /* REF/HBI clk selection */
  372. #define HIFN_PLL_BP 0x00000002 /* bypass (used during setup) */
  373. /* bit 2 reserved */
  374. #define HIFN_PLL_PK_CLK_SEL 0x00000008 /* public key clk select */
  375. #define HIFN_PLL_PE_CLK_SEL 0x00000010 /* packet engine clk select */
  376. /* bits 5-9 reserved */
  377. #define HIFN_PLL_MBSET 0x00000400 /* must be set to 1 */
  378. #define HIFN_PLL_ND 0x00003800 /* Fpll_ref multiplier select */
  379. #define HIFN_PLL_ND_SHIFT 11
  380. #define HIFN_PLL_ND_2 0x00000000 /* 2x */
  381. #define HIFN_PLL_ND_4 0x00000800 /* 4x */
  382. #define HIFN_PLL_ND_6 0x00001000 /* 6x */
  383. #define HIFN_PLL_ND_8 0x00001800 /* 8x */
  384. #define HIFN_PLL_ND_10 0x00002000 /* 10x */
  385. #define HIFN_PLL_ND_12 0x00002800 /* 12x */
  386. /* bits 14-15 reserved */
  387. #define HIFN_PLL_IS 0x00010000 /* charge pump current select */
  388. /* bits 17-31 reserved */
  389. /*
  390. * Board configuration specifies only these bits.
  391. */
  392. #define HIFN_PLL_CONFIG (HIFN_PLL_IS|HIFN_PLL_ND|HIFN_PLL_REF_SEL)
  393. /*
  394. * Public Key Engine Mode Register
  395. */
  396. #define HIFN_PKMODE_HOSTINVERT (1 << 0) /* HOST INVERT */
  397. #define HIFN_PKMODE_ENHANCED (1 << 1) /* Enable enhanced mode */
  398. /*********************************************************************
  399. * Structs for board commands
  400. *
  401. *********************************************************************/
  402. /*
  403. * Structure to help build up the command data structure.
  404. */
  405. typedef struct hifn_base_command {
  406. volatile u_int16_t masks;
  407. volatile u_int16_t session_num;
  408. volatile u_int16_t total_source_count;
  409. volatile u_int16_t total_dest_count;
  410. } hifn_base_command_t;
  411. #define HIFN_BASE_CMD_MAC 0x0400
  412. #define HIFN_BASE_CMD_CRYPT 0x0800
  413. #define HIFN_BASE_CMD_DECODE 0x2000
  414. #define HIFN_BASE_CMD_SRCLEN_M 0xc000
  415. #define HIFN_BASE_CMD_SRCLEN_S 14
  416. #define HIFN_BASE_CMD_DSTLEN_M 0x3000
  417. #define HIFN_BASE_CMD_DSTLEN_S 12
  418. #define HIFN_BASE_CMD_LENMASK_HI 0x30000
  419. #define HIFN_BASE_CMD_LENMASK_LO 0x0ffff
  420. /*
  421. * Structure to help build up the command data structure.
  422. */
  423. typedef struct hifn_crypt_command {
  424. volatile u_int16_t masks;
  425. volatile u_int16_t header_skip;
  426. volatile u_int16_t source_count;
  427. volatile u_int16_t reserved;
  428. } hifn_crypt_command_t;
  429. #define HIFN_CRYPT_CMD_ALG_MASK 0x0003 /* algorithm: */
  430. #define HIFN_CRYPT_CMD_ALG_DES 0x0000 /* DES */
  431. #define HIFN_CRYPT_CMD_ALG_3DES 0x0001 /* 3DES */
  432. #define HIFN_CRYPT_CMD_ALG_RC4 0x0002 /* RC4 */
  433. #define HIFN_CRYPT_CMD_ALG_AES 0x0003 /* AES */
  434. #define HIFN_CRYPT_CMD_MODE_MASK 0x0018 /* Encrypt mode: */
  435. #define HIFN_CRYPT_CMD_MODE_ECB 0x0000 /* ECB */
  436. #define HIFN_CRYPT_CMD_MODE_CBC 0x0008 /* CBC */
  437. #define HIFN_CRYPT_CMD_MODE_CFB 0x0010 /* CFB */
  438. #define HIFN_CRYPT_CMD_MODE_OFB 0x0018 /* OFB */
  439. #define HIFN_CRYPT_CMD_CLR_CTX 0x0040 /* clear context */
  440. #define HIFN_CRYPT_CMD_NEW_KEY 0x0800 /* expect new key */
  441. #define HIFN_CRYPT_CMD_NEW_IV 0x1000 /* expect new iv */
  442. #define HIFN_CRYPT_CMD_SRCLEN_M 0xc000
  443. #define HIFN_CRYPT_CMD_SRCLEN_S 14
  444. #define HIFN_CRYPT_CMD_KSZ_MASK 0x0600 /* AES key size: */
  445. #define HIFN_CRYPT_CMD_KSZ_128 0x0000 /* 128 bit */
  446. #define HIFN_CRYPT_CMD_KSZ_192 0x0200 /* 192 bit */
  447. #define HIFN_CRYPT_CMD_KSZ_256 0x0400 /* 256 bit */
  448. /*
  449. * Structure to help build up the command data structure.
  450. */
  451. typedef struct hifn_mac_command {
  452. volatile u_int16_t masks;
  453. volatile u_int16_t header_skip;
  454. volatile u_int16_t source_count;
  455. volatile u_int16_t reserved;
  456. } hifn_mac_command_t;
  457. #define HIFN_MAC_CMD_ALG_MASK 0x0001
  458. #define HIFN_MAC_CMD_ALG_SHA1 0x0000
  459. #define HIFN_MAC_CMD_ALG_MD5 0x0001
  460. #define HIFN_MAC_CMD_MODE_MASK 0x000c
  461. #define HIFN_MAC_CMD_MODE_HMAC 0x0000
  462. #define HIFN_MAC_CMD_MODE_SSL_MAC 0x0004
  463. #define HIFN_MAC_CMD_MODE_HASH 0x0008
  464. #define HIFN_MAC_CMD_MODE_FULL 0x0004
  465. #define HIFN_MAC_CMD_TRUNC 0x0010
  466. #define HIFN_MAC_CMD_RESULT 0x0020
  467. #define HIFN_MAC_CMD_APPEND 0x0040
  468. #define HIFN_MAC_CMD_SRCLEN_M 0xc000
  469. #define HIFN_MAC_CMD_SRCLEN_S 14
  470. /*
  471. * MAC POS IPsec initiates authentication after encryption on encodes
  472. * and before decryption on decodes.
  473. */
  474. #define HIFN_MAC_CMD_POS_IPSEC 0x0200
  475. #define HIFN_MAC_CMD_NEW_KEY 0x0800
  476. /*
  477. * The poll frequency and poll scalar defines are unshifted values used
  478. * to set fields in the DMA Configuration Register.
  479. */
  480. #ifndef HIFN_POLL_FREQUENCY
  481. #define HIFN_POLL_FREQUENCY 0x1
  482. #endif
  483. #ifndef HIFN_POLL_SCALAR
  484. #define HIFN_POLL_SCALAR 0x0
  485. #endif
  486. #define HIFN_MAX_SEGLEN 0xffff /* maximum dma segment len */
  487. #define HIFN_MAX_DMALEN 0x3ffff /* maximum dma length */
  488. #endif /* __HIFN_H__ */