jr.h 2.3 KB

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