omap_dmm_priv.h 5.0 KB

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