omap_dmm_priv.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/
  4. * Author: Rob Clark <rob@ti.com>
  5. * Andy Gross <andy.gross@ti.com>
  6. */
  7. #ifndef OMAP_DMM_PRIV_H
  8. #define OMAP_DMM_PRIV_H
  9. #define DMM_REVISION 0x000
  10. #define DMM_HWINFO 0x004
  11. #define DMM_LISA_HWINFO 0x008
  12. #define DMM_DMM_SYSCONFIG 0x010
  13. #define DMM_LISA_LOCK 0x01C
  14. #define DMM_LISA_MAP__0 0x040
  15. #define DMM_LISA_MAP__1 0x044
  16. #define DMM_TILER_HWINFO 0x208
  17. #define DMM_TILER_OR__0 0x220
  18. #define DMM_TILER_OR__1 0x224
  19. #define DMM_PAT_HWINFO 0x408
  20. #define DMM_PAT_GEOMETRY 0x40C
  21. #define DMM_PAT_CONFIG 0x410
  22. #define DMM_PAT_VIEW__0 0x420
  23. #define DMM_PAT_VIEW__1 0x424
  24. #define DMM_PAT_VIEW_MAP__0 0x440
  25. #define DMM_PAT_VIEW_MAP_BASE 0x460
  26. #define DMM_PAT_IRQ_EOI 0x478
  27. #define DMM_PAT_IRQSTATUS_RAW 0x480
  28. #define DMM_PAT_IRQSTATUS 0x490
  29. #define DMM_PAT_IRQENABLE_SET 0x4A0
  30. #define DMM_PAT_IRQENABLE_CLR 0x4B0
  31. #define DMM_PAT_STATUS__0 0x4C0
  32. #define DMM_PAT_STATUS__1 0x4C4
  33. #define DMM_PAT_STATUS__2 0x4C8
  34. #define DMM_PAT_STATUS__3 0x4CC
  35. #define DMM_PAT_DESCR__0 0x500
  36. #define DMM_PAT_DESCR__1 0x510
  37. #define DMM_PAT_DESCR__2 0x520
  38. #define DMM_PAT_DESCR__3 0x530
  39. #define DMM_PEG_HWINFO 0x608
  40. #define DMM_PEG_PRIO 0x620
  41. #define DMM_PEG_PRIO_PAT 0x640
  42. #define DMM_IRQSTAT_DST (1<<0)
  43. #define DMM_IRQSTAT_LST (1<<1)
  44. #define DMM_IRQSTAT_ERR_INV_DSC (1<<2)
  45. #define DMM_IRQSTAT_ERR_INV_DATA (1<<3)
  46. #define DMM_IRQSTAT_ERR_UPD_AREA (1<<4)
  47. #define DMM_IRQSTAT_ERR_UPD_CTRL (1<<5)
  48. #define DMM_IRQSTAT_ERR_UPD_DATA (1<<6)
  49. #define DMM_IRQSTAT_ERR_LUT_MISS (1<<7)
  50. #define DMM_IRQSTAT_ERR_MASK (DMM_IRQSTAT_ERR_INV_DSC | \
  51. DMM_IRQSTAT_ERR_INV_DATA | \
  52. DMM_IRQSTAT_ERR_UPD_AREA | \
  53. DMM_IRQSTAT_ERR_UPD_CTRL | \
  54. DMM_IRQSTAT_ERR_UPD_DATA | \
  55. DMM_IRQSTAT_ERR_LUT_MISS)
  56. #define DMM_PATSTATUS_READY (1<<0)
  57. #define DMM_PATSTATUS_VALID (1<<1)
  58. #define DMM_PATSTATUS_RUN (1<<2)
  59. #define DMM_PATSTATUS_DONE (1<<3)
  60. #define DMM_PATSTATUS_LINKED (1<<4)
  61. #define DMM_PATSTATUS_BYPASSED (1<<7)
  62. #define DMM_PATSTATUS_ERR_INV_DESCR (1<<10)
  63. #define DMM_PATSTATUS_ERR_INV_DATA (1<<11)
  64. #define DMM_PATSTATUS_ERR_UPD_AREA (1<<12)
  65. #define DMM_PATSTATUS_ERR_UPD_CTRL (1<<13)
  66. #define DMM_PATSTATUS_ERR_UPD_DATA (1<<14)
  67. #define DMM_PATSTATUS_ERR_ACCESS (1<<15)
  68. /* note: don't treat DMM_PATSTATUS_ERR_ACCESS as an error */
  69. #define DMM_PATSTATUS_ERR (DMM_PATSTATUS_ERR_INV_DESCR | \
  70. DMM_PATSTATUS_ERR_INV_DATA | \
  71. DMM_PATSTATUS_ERR_UPD_AREA | \
  72. DMM_PATSTATUS_ERR_UPD_CTRL | \
  73. DMM_PATSTATUS_ERR_UPD_DATA)
  74. enum {
  75. PAT_STATUS,
  76. PAT_DESCR
  77. };
  78. struct pat_ctrl {
  79. u32 start:4;
  80. u32 dir:4;
  81. u32 lut_id:8;
  82. u32 sync:12;
  83. u32 ini:4;
  84. };
  85. struct pat {
  86. u32 next_pa;
  87. struct pat_area area;
  88. struct pat_ctrl ctrl;
  89. u32 data_pa;
  90. };
  91. #define DMM_FIXED_RETRY_COUNT 1000
  92. /* create refill buffer big enough to refill all slots, plus 3 descriptors..
  93. * 3 descriptors is probably the worst-case for # of 2d-slices in a 1d area,
  94. * but I guess you don't hit that worst case at the same time as full area
  95. * refill
  96. */
  97. #define DESCR_SIZE 128
  98. #define REFILL_BUFFER_SIZE ((4 * 128 * 256) + (3 * DESCR_SIZE))
  99. /* For OMAP5, a fixed offset is added to all Y coordinates for 1D buffers.
  100. * This is used in programming to address the upper portion of the LUT
  101. */
  102. #define OMAP5_LUT_OFFSET 128
  103. struct dmm;
  104. struct dmm_txn {
  105. void *engine_handle;
  106. struct tcm *tcm;
  107. u8 *current_va;
  108. dma_addr_t current_pa;
  109. struct pat *last_pat;
  110. };
  111. struct refill_engine {
  112. int id;
  113. struct dmm *dmm;
  114. struct tcm *tcm;
  115. u8 *refill_va;
  116. dma_addr_t refill_pa;
  117. /* only one trans per engine for now */
  118. struct dmm_txn txn;
  119. bool async;
  120. struct completion compl;
  121. struct list_head idle_node;
  122. };
  123. struct dmm_platform_data {
  124. u32 cpu_cache_flags;
  125. };
  126. struct dmm {
  127. struct device *dev;
  128. dma_addr_t phys_base;
  129. void __iomem *base;
  130. int irq;
  131. struct page *dummy_page;
  132. dma_addr_t dummy_pa;
  133. void *refill_va;
  134. dma_addr_t refill_pa;
  135. /* refill engines */
  136. wait_queue_head_t engine_queue;
  137. struct list_head idle_head;
  138. struct refill_engine *engines;
  139. int num_engines;
  140. atomic_t engine_counter;
  141. /* container information */
  142. int container_width;
  143. int container_height;
  144. int lut_width;
  145. int lut_height;
  146. int num_lut;
  147. /* array of LUT - TCM containers */
  148. struct tcm **tcm;
  149. /* allocation list and lock */
  150. struct list_head alloc_head;
  151. const struct dmm_platform_data *plat_data;
  152. bool dmm_workaround;
  153. spinlock_t wa_lock;
  154. u32 *wa_dma_data;
  155. dma_addr_t wa_dma_handle;
  156. struct dma_chan *wa_dma_chan;
  157. };
  158. #endif