jr.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2008-2014 Freescale Semiconductor, Inc.
  4. *
  5. */
  6. #ifndef __JR_H
  7. #define __JR_H
  8. #include <linux/compiler.h>
  9. #define JR_SIZE 4
  10. /* Timeout currently defined as 90 sec */
  11. #define CONFIG_SEC_DEQ_TIMEOUT 90000000U
  12. #define DEFAULT_JR_ID 0
  13. #define DEFAULT_JR_LIODN 0
  14. #define DEFAULT_IRQ 0 /* Interrupts not to be configured */
  15. #define MCFGR_SWRST ((uint32_t)(1)<<31) /* Software Reset */
  16. #define MCFGR_DMA_RST ((uint32_t)(1)<<28) /* DMA Reset */
  17. #define MCFGR_PS_SHIFT 16
  18. #define MCFGR_AWCACHE_SHIFT 8
  19. #define MCFGR_AWCACHE_MASK (0xf << MCFGR_AWCACHE_SHIFT)
  20. #define MCFGR_ARCACHE_SHIFT 12
  21. #define MCFGR_ARCACHE_MASK (0xf << MCFGR_ARCACHE_SHIFT)
  22. #define JR_INTMASK 0x00000001
  23. #define JRCR_RESET 0x01
  24. #define JRINT_ERR_HALT_INPROGRESS 0x4
  25. #define JRINT_ERR_HALT_MASK 0xc
  26. #define JRNSLIODN_SHIFT 16
  27. #define JRNSLIODN_MASK 0x0fff0000
  28. #define JRSLIODN_SHIFT 0
  29. #define JRSLIODN_MASK 0x00000fff
  30. #define JROWN_NS 0x00000008
  31. #define JRMID_NS 0x00000001
  32. #define JQ_DEQ_ERR -1
  33. #define JQ_DEQ_TO_ERR -2
  34. #define JQ_ENQ_ERR -3
  35. #define RNG4_MAX_HANDLES 2
  36. struct op_ring {
  37. phys_addr_t desc;
  38. uint32_t status;
  39. } __packed;
  40. struct jr_info {
  41. void (*callback)(uint32_t status, void *arg);
  42. phys_addr_t desc_phys_addr;
  43. uint32_t desc_len;
  44. uint32_t op_done;
  45. void *arg;
  46. };
  47. struct jobring {
  48. int jq_id;
  49. int irq;
  50. int liodn;
  51. /* Head is the index where software would enq the descriptor in
  52. * the i/p ring
  53. */
  54. int head;
  55. /* Tail index would be used by s/w ehile enqueuing to determine if
  56. * there is any space left in the s/w maintained i/p rings
  57. */
  58. /* Also in case of deq tail will be incremented only in case of
  59. * in-order job completion
  60. */
  61. int tail;
  62. /* Read index of the output ring. It may not match with tail in case
  63. * of out of order completetion
  64. */
  65. int read_idx;
  66. /* Write index to input ring. Would be always equal to head */
  67. int write_idx;
  68. /* Size of the rings. */
  69. int size;
  70. /* Op ring size aligned to cache line size */
  71. int op_size;
  72. /* The ip and output rings have to be accessed by SEC. So the
  73. * pointers will ahve to point to the housekeeping region provided
  74. * by SEC
  75. */
  76. /*Circular Ring of i/p descriptors */
  77. dma_addr_t *input_ring;
  78. /* Circular Ring of o/p descriptors */
  79. /* Circula Ring containing info regarding descriptors in i/p
  80. * and o/p ring
  81. */
  82. /* This ring can be on the stack */
  83. struct jr_info info[JR_SIZE];
  84. struct op_ring *output_ring;
  85. /* Offset in CCSR to the SEC engine to which this JR belongs */
  86. uint32_t sec_offset;
  87. };
  88. struct result {
  89. int done;
  90. uint32_t status;
  91. };
  92. void caam_jr_strstatus(u32 status);
  93. int run_descriptor_jr(uint32_t *desc);
  94. #endif