tilcdc_regs.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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_1 0x0
  32. #define LCDC_DMA_BURST_2 0x1
  33. #define LCDC_DMA_BURST_4 0x2
  34. #define LCDC_DMA_BURST_8 0x3
  35. #define LCDC_DMA_BURST_16 0x4
  36. #define LCDC_V1_END_OF_FRAME_INT_ENA BIT(2)
  37. #define LCDC_V2_END_OF_FRAME0_INT_ENA BIT(8)
  38. #define LCDC_V2_END_OF_FRAME1_INT_ENA BIT(9)
  39. #define LCDC_DUAL_FRAME_BUFFER_ENABLE BIT(0)
  40. /* LCDC Control Register */
  41. #define LCDC_CLK_DIVISOR(x) ((x) << 8)
  42. #define LCDC_RASTER_MODE 0x01
  43. /* LCDC Raster Control Register */
  44. #define LCDC_PALETTE_LOAD_MODE(x) ((x) << 20)
  45. #define PALETTE_AND_DATA 0x00
  46. #define PALETTE_ONLY 0x01
  47. #define DATA_ONLY 0x02
  48. #define LCDC_MONO_8BIT_MODE BIT(9)
  49. #define LCDC_RASTER_ORDER BIT(8)
  50. #define LCDC_TFT_MODE BIT(7)
  51. #define LCDC_V1_UNDERFLOW_INT_ENA BIT(6)
  52. #define LCDC_V2_UNDERFLOW_INT_ENA BIT(5)
  53. #define LCDC_V1_PL_INT_ENA BIT(4)
  54. #define LCDC_V2_PL_INT_ENA BIT(6)
  55. #define LCDC_MONOCHROME_MODE BIT(1)
  56. #define LCDC_RASTER_ENABLE BIT(0)
  57. #define LCDC_TFT_ALT_ENABLE BIT(23)
  58. #define LCDC_STN_565_ENABLE BIT(24)
  59. #define LCDC_V2_DMA_CLK_EN BIT(2)
  60. #define LCDC_V2_LIDD_CLK_EN BIT(1)
  61. #define LCDC_V2_CORE_CLK_EN BIT(0)
  62. #define LCDC_V2_LPP_B10 26
  63. #define LCDC_V2_TFT_24BPP_MODE BIT(25)
  64. #define LCDC_V2_TFT_24BPP_UNPACK BIT(26)
  65. /* LCDC Raster Timing 2 Register */
  66. #define LCDC_AC_BIAS_TRANSITIONS_PER_INT(x) ((x) << 16)
  67. #define LCDC_AC_BIAS_FREQUENCY(x) ((x) << 8)
  68. #define LCDC_SYNC_CTRL BIT(25)
  69. #define LCDC_SYNC_EDGE BIT(24)
  70. #define LCDC_INVERT_PIXEL_CLOCK BIT(22)
  71. #define LCDC_INVERT_HSYNC BIT(21)
  72. #define LCDC_INVERT_VSYNC BIT(20)
  73. #define LCDC_LPP_B10 BIT(26)
  74. /* LCDC Block */
  75. #define LCDC_PID_REG 0x0
  76. #define LCDC_CTRL_REG 0x4
  77. #define LCDC_STAT_REG 0x8
  78. #define LCDC_RASTER_CTRL_REG 0x28
  79. #define LCDC_RASTER_TIMING_0_REG 0x2c
  80. #define LCDC_RASTER_TIMING_1_REG 0x30
  81. #define LCDC_RASTER_TIMING_2_REG 0x34
  82. #define LCDC_DMA_CTRL_REG 0x40
  83. #define LCDC_DMA_FB_BASE_ADDR_0_REG 0x44
  84. #define LCDC_DMA_FB_CEILING_ADDR_0_REG 0x48
  85. #define LCDC_DMA_FB_BASE_ADDR_1_REG 0x4c
  86. #define LCDC_DMA_FB_CEILING_ADDR_1_REG 0x50
  87. /* Interrupt Registers available only in Version 2 */
  88. #define LCDC_RAW_STAT_REG 0x58
  89. #define LCDC_MASKED_STAT_REG 0x5c
  90. #define LCDC_INT_ENABLE_SET_REG 0x60
  91. #define LCDC_INT_ENABLE_CLR_REG 0x64
  92. #define LCDC_END_OF_INT_IND_REG 0x68
  93. /* Clock registers available only on Version 2 */
  94. #define LCDC_CLK_ENABLE_REG 0x6c
  95. #define LCDC_CLK_RESET_REG 0x70
  96. #define LCDC_CLK_MAIN_RESET BIT(3)
  97. /*
  98. * Helpers:
  99. */
  100. static inline void tilcdc_write(struct drm_device *dev, u32 reg, u32 data)
  101. {
  102. struct tilcdc_drm_private *priv = dev->dev_private;
  103. iowrite32(data, priv->mmio + reg);
  104. }
  105. static inline u32 tilcdc_read(struct drm_device *dev, u32 reg)
  106. {
  107. struct tilcdc_drm_private *priv = dev->dev_private;
  108. return ioread32(priv->mmio + reg);
  109. }
  110. static inline void tilcdc_set(struct drm_device *dev, u32 reg, u32 mask)
  111. {
  112. tilcdc_write(dev, reg, tilcdc_read(dev, reg) | mask);
  113. }
  114. static inline void tilcdc_clear(struct drm_device *dev, u32 reg, u32 mask)
  115. {
  116. tilcdc_write(dev, reg, tilcdc_read(dev, reg) & ~mask);
  117. }
  118. /* the register to read/clear irqstatus differs between v1 and v2 of the IP */
  119. static inline u32 tilcdc_irqstatus_reg(struct drm_device *dev)
  120. {
  121. struct tilcdc_drm_private *priv = dev->dev_private;
  122. return (priv->rev == 2) ? LCDC_MASKED_STAT_REG : LCDC_STAT_REG;
  123. }
  124. static inline u32 tilcdc_read_irqstatus(struct drm_device *dev)
  125. {
  126. return tilcdc_read(dev, tilcdc_irqstatus_reg(dev));
  127. }
  128. static inline void tilcdc_clear_irqstatus(struct drm_device *dev, u32 mask)
  129. {
  130. tilcdc_write(dev, tilcdc_irqstatus_reg(dev), mask);
  131. }
  132. #endif /* __TILCDC_REGS_H__ */