bfin_crc.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * bfin_crc.h - interface to Blackfin CRC controllers
  3. *
  4. * Copyright 2012 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #ifndef __BFIN_CRC_H__
  9. #define __BFIN_CRC_H__
  10. /* Function driver which use hardware crc must initialize the structure */
  11. struct crc_info {
  12. /* Input data address */
  13. unsigned char *in_addr;
  14. /* Output data address */
  15. unsigned char *out_addr;
  16. /* Input or output bytes */
  17. unsigned long datasize;
  18. union {
  19. /* CRC to compare with that of input buffer */
  20. unsigned long crc_compare;
  21. /* Value to compare with input data */
  22. unsigned long val_verify;
  23. /* Value to fill */
  24. unsigned long val_fill;
  25. };
  26. /* Value to program the 32b CRC Polynomial */
  27. unsigned long crc_poly;
  28. union {
  29. /* CRC calculated from the input data */
  30. unsigned long crc_result;
  31. /* First failed position to verify input data */
  32. unsigned long pos_verify;
  33. };
  34. /* CRC mirror flags */
  35. unsigned int bitmirr:1;
  36. unsigned int bytmirr:1;
  37. unsigned int w16swp:1;
  38. unsigned int fdsel:1;
  39. unsigned int rsltmirr:1;
  40. unsigned int polymirr:1;
  41. unsigned int cmpmirr:1;
  42. };
  43. /* Userspace interface */
  44. #define CRC_IOC_MAGIC 'C'
  45. #define CRC_IOC_CALC_CRC _IOWR('C', 0x01, unsigned int)
  46. #define CRC_IOC_MEMCPY_CRC _IOWR('C', 0x02, unsigned int)
  47. #define CRC_IOC_VERIFY_VAL _IOWR('C', 0x03, unsigned int)
  48. #define CRC_IOC_FILL_VAL _IOWR('C', 0x04, unsigned int)
  49. #ifdef __KERNEL__
  50. #include <linux/types.h>
  51. #include <linux/spinlock.h>
  52. struct crc_register {
  53. u32 control;
  54. u32 datacnt;
  55. u32 datacntrld;
  56. u32 __pad_1[2];
  57. u32 compare;
  58. u32 fillval;
  59. u32 datafifo;
  60. u32 intren;
  61. u32 intrenset;
  62. u32 intrenclr;
  63. u32 poly;
  64. u32 __pad_2[4];
  65. u32 status;
  66. u32 datacntcap;
  67. u32 __pad_3;
  68. u32 result;
  69. u32 curresult;
  70. u32 __pad_4[3];
  71. u32 revid;
  72. };
  73. /* CRC_STATUS Masks */
  74. #define CMPERR 0x00000002 /* Compare error */
  75. #define DCNTEXP 0x00000010 /* datacnt register expired */
  76. #define IBR 0x00010000 /* Input buffer ready */
  77. #define OBR 0x00020000 /* Output buffer ready */
  78. #define IRR 0x00040000 /* Immediate result readt */
  79. #define LUTDONE 0x00080000 /* Look-up table generation done */
  80. #define FSTAT 0x00700000 /* FIFO status */
  81. #define MAX_FIFO 4 /* Max fifo size */
  82. /* CRC_CONTROL Masks */
  83. #define BLKEN 0x00000001 /* Block enable */
  84. #define OPMODE 0x000000F0 /* Operation mode */
  85. #define OPMODE_OFFSET 4 /* Operation mode mask offset*/
  86. #define MODE_DMACPY_CRC 1 /* MTM CRC compute and compare */
  87. #define MODE_DATA_FILL 2 /* MTM data fill */
  88. #define MODE_CALC_CRC 3 /* MSM CRC compute and compare */
  89. #define MODE_DATA_VERIFY 4 /* MSM data verify */
  90. #define AUTOCLRZ 0x00000100 /* Auto clear to zero */
  91. #define AUTOCLRF 0x00000200 /* Auto clear to one */
  92. #define OBRSTALL 0x00001000 /* Stall on output buffer ready */
  93. #define IRRSTALL 0x00002000 /* Stall on immediate result ready */
  94. #define BITMIRR 0x00010000 /* Mirror bits within each byte of 32-bit input data */
  95. #define BITMIRR_OFFSET 16 /* Mirror bits offset */
  96. #define BYTMIRR 0x00020000 /* Mirror bytes of 32-bit input data */
  97. #define BYTMIRR_OFFSET 17 /* Mirror bytes offset */
  98. #define W16SWP 0x00040000 /* Mirror uppper and lower 16-bit word of 32-bit input data */
  99. #define W16SWP_OFFSET 18 /* Mirror 16-bit word offset */
  100. #define FDSEL 0x00080000 /* FIFO is written after input data is mirrored */
  101. #define FDSEL_OFFSET 19 /* Mirror FIFO offset */
  102. #define RSLTMIRR 0x00100000 /* CRC result registers are mirrored. */
  103. #define RSLTMIRR_OFFSET 20 /* Mirror CRC result offset. */
  104. #define POLYMIRR 0x00200000 /* CRC poly register is mirrored. */
  105. #define POLYMIRR_OFFSET 21 /* Mirror CRC poly offset. */
  106. #define CMPMIRR 0x00400000 /* CRC compare register is mirrored. */
  107. #define CMPMIRR_OFFSET 22 /* Mirror CRC compare offset. */
  108. /* CRC_INTREN Masks */
  109. #define CMPERRI 0x02 /* CRC_ERROR_INTR */
  110. #define DCNTEXPI 0x10 /* CRC_STATUS_INTR */
  111. #endif
  112. #endif