tilcdc_regs.h 6.4 KB

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