tilcdc_regs.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Copyright (C) 2012 Texas Instruments
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __TILCDC_REGS_H__
  18. #define __TILCDC_REGS_H__
  19. /* LCDC register definitions, based on da8xx-fb */
  20. #include <linux/bitops.h>
  21. #include "tilcdc_drv.h"
  22. /* LCDC Status Register */
  23. #define LCDC_END_OF_FRAME1 BIT(9)
  24. #define LCDC_END_OF_FRAME0 BIT(8)
  25. #define LCDC_PL_LOAD_DONE BIT(6)
  26. #define LCDC_FIFO_UNDERFLOW BIT(5)
  27. #define LCDC_SYNC_LOST BIT(2)
  28. #define LCDC_FRAME_DONE BIT(0)
  29. /* LCDC DMA Control Register */
  30. #define LCDC_DMA_BURST_SIZE(x) ((x) << 4)
  31. #define LCDC_DMA_BURST_SIZE_MASK ((0x7) << 4)
  32. #define LCDC_DMA_BURST_1 0x0
  33. #define LCDC_DMA_BURST_2 0x1
  34. #define LCDC_DMA_BURST_4 0x2
  35. #define LCDC_DMA_BURST_8 0x3
  36. #define LCDC_DMA_BURST_16 0x4
  37. #define LCDC_DMA_FIFO_THRESHOLD(x) ((x) << 8)
  38. #define LCDC_DMA_FIFO_THRESHOLD_MASK ((0x3) << 8)
  39. #define LCDC_V1_END_OF_FRAME_INT_ENA BIT(2)
  40. #define LCDC_V2_END_OF_FRAME0_INT_ENA BIT(8)
  41. #define LCDC_V2_END_OF_FRAME1_INT_ENA BIT(9)
  42. #define LCDC_DUAL_FRAME_BUFFER_ENABLE BIT(0)
  43. /* LCDC Control Register */
  44. #define LCDC_CLK_DIVISOR(x) ((x) << 8)
  45. #define LCDC_CLK_DIVISOR_MASK ((0xFF) << 8)
  46. #define LCDC_RASTER_MODE 0x01
  47. /* LCDC Raster Control Register */
  48. #define LCDC_PALETTE_LOAD_MODE(x) ((x) << 20)
  49. #define LCDC_PALETTE_LOAD_MODE_MASK ((0x3) << 20)
  50. #define PALETTE_AND_DATA 0x00
  51. #define PALETTE_ONLY 0x01
  52. #define DATA_ONLY 0x02
  53. #define LCDC_MONO_8BIT_MODE BIT(9)
  54. #define LCDC_RASTER_ORDER BIT(8)
  55. #define LCDC_TFT_MODE BIT(7)
  56. #define LCDC_V1_UNDERFLOW_INT_ENA BIT(6)
  57. #define LCDC_V2_UNDERFLOW_INT_ENA BIT(5)
  58. #define LCDC_V1_PL_INT_ENA BIT(4)
  59. #define LCDC_V2_PL_INT_ENA BIT(6)
  60. #define LCDC_V1_SYNC_LOST_INT_ENA BIT(5)
  61. #define LCDC_V1_FRAME_DONE_INT_ENA BIT(3)
  62. #define LCDC_MONOCHROME_MODE BIT(1)
  63. #define LCDC_RASTER_ENABLE BIT(0)
  64. #define LCDC_TFT_ALT_ENABLE BIT(23)
  65. #define LCDC_STN_565_ENABLE BIT(24)
  66. #define LCDC_V2_DMA_CLK_EN BIT(2)
  67. #define LCDC_V2_LIDD_CLK_EN BIT(1)
  68. #define LCDC_V2_CORE_CLK_EN BIT(0)
  69. #define LCDC_V2_LPP_B10 26
  70. #define LCDC_V2_TFT_24BPP_MODE BIT(25)
  71. #define LCDC_V2_TFT_24BPP_UNPACK BIT(26)
  72. /* LCDC Raster Timing 2 Register */
  73. #define LCDC_AC_BIAS_TRANSITIONS_PER_INT(x) ((x) << 16)
  74. #define LCDC_AC_BIAS_TRANSITIONS_PER_INT_MASK ((0xF) << 16)
  75. #define LCDC_AC_BIAS_FREQUENCY(x) ((x) << 8)
  76. #define LCDC_AC_BIAS_FREQUENCY_MASK ((0xFF) << 8)
  77. #define LCDC_SYNC_CTRL BIT(25)
  78. #define LCDC_SYNC_EDGE BIT(24)
  79. #define LCDC_INVERT_PIXEL_CLOCK BIT(22)
  80. #define LCDC_INVERT_HSYNC BIT(21)
  81. #define LCDC_INVERT_VSYNC BIT(20)
  82. #define LCDC_LPP_B10 BIT(26)
  83. /* LCDC Block */
  84. #define LCDC_PID_REG 0x0
  85. #define LCDC_CTRL_REG 0x4
  86. #define LCDC_STAT_REG 0x8
  87. #define LCDC_RASTER_CTRL_REG 0x28
  88. #define LCDC_RASTER_TIMING_0_REG 0x2c
  89. #define LCDC_RASTER_TIMING_1_REG 0x30
  90. #define LCDC_RASTER_TIMING_2_REG 0x34
  91. #define LCDC_DMA_CTRL_REG 0x40
  92. #define LCDC_DMA_FB_BASE_ADDR_0_REG 0x44
  93. #define LCDC_DMA_FB_CEILING_ADDR_0_REG 0x48
  94. #define LCDC_DMA_FB_BASE_ADDR_1_REG 0x4c
  95. #define LCDC_DMA_FB_CEILING_ADDR_1_REG 0x50
  96. /* Interrupt Registers available only in Version 2 */
  97. #define LCDC_RAW_STAT_REG 0x58
  98. #define LCDC_MASKED_STAT_REG 0x5c
  99. #define LCDC_INT_ENABLE_SET_REG 0x60
  100. #define LCDC_INT_ENABLE_CLR_REG 0x64
  101. #define LCDC_END_OF_INT_IND_REG 0x68
  102. /* Clock registers available only on Version 2 */
  103. #define LCDC_CLK_ENABLE_REG 0x6c
  104. #define LCDC_CLK_RESET_REG 0x70
  105. #define LCDC_CLK_MAIN_RESET BIT(3)
  106. /*
  107. * Helpers:
  108. */
  109. static inline void tilcdc_write(struct drm_device *dev, u32 reg, u32 data)
  110. {
  111. struct tilcdc_drm_private *priv = dev->dev_private;
  112. iowrite32(data, priv->mmio + reg);
  113. }
  114. static inline void tilcdc_write64(struct drm_device *dev, u32 reg, u64 data)
  115. {
  116. struct tilcdc_drm_private *priv = dev->dev_private;
  117. volatile void __iomem *addr = priv->mmio + reg;
  118. #if defined(iowrite64) && !defined(iowrite64_is_nonatomic)
  119. iowrite64(data, addr);
  120. #else
  121. __iowmb();
  122. /* This compiles to strd (=64-bit write) on ARM7 */
  123. *(volatile u64 __force *)addr = __cpu_to_le64(data);
  124. #endif
  125. }
  126. static inline u32 tilcdc_read(struct drm_device *dev, u32 reg)
  127. {
  128. struct tilcdc_drm_private *priv = dev->dev_private;
  129. return ioread32(priv->mmio + reg);
  130. }
  131. static inline void tilcdc_write_mask(struct drm_device *dev, u32 reg,
  132. u32 val, u32 mask)
  133. {
  134. tilcdc_write(dev, reg, (tilcdc_read(dev, reg) & ~mask) | (val & mask));
  135. }
  136. static inline void tilcdc_set(struct drm_device *dev, u32 reg, u32 mask)
  137. {
  138. tilcdc_write(dev, reg, tilcdc_read(dev, reg) | mask);
  139. }
  140. static inline void tilcdc_clear(struct drm_device *dev, u32 reg, u32 mask)
  141. {
  142. tilcdc_write(dev, reg, tilcdc_read(dev, reg) & ~mask);
  143. }
  144. /* the register to read/clear irqstatus differs between v1 and v2 of the IP */
  145. static inline u32 tilcdc_irqstatus_reg(struct drm_device *dev)
  146. {
  147. struct tilcdc_drm_private *priv = dev->dev_private;
  148. return (priv->rev == 2) ? LCDC_MASKED_STAT_REG : LCDC_STAT_REG;
  149. }
  150. static inline u32 tilcdc_read_irqstatus(struct drm_device *dev)
  151. {
  152. return tilcdc_read(dev, tilcdc_irqstatus_reg(dev));
  153. }
  154. static inline void tilcdc_clear_irqstatus(struct drm_device *dev, u32 mask)
  155. {
  156. tilcdc_write(dev, tilcdc_irqstatus_reg(dev), mask);
  157. }
  158. #endif /* __TILCDC_REGS_H__ */