pl111_drm.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. *
  4. * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved.
  5. *
  6. * Parts of this file were based on sources as follows:
  7. *
  8. * Copyright (c) 2006-2008 Intel Corporation
  9. * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
  10. * Copyright (C) 2011 Texas Instruments
  11. */
  12. #ifndef _PL111_DRM_H_
  13. #define _PL111_DRM_H_
  14. #include <linux/clk-provider.h>
  15. #include <linux/interrupt.h>
  16. #include <drm/drm_bridge.h>
  17. #include <drm/drm_connector.h>
  18. #include <drm/drm_encoder.h>
  19. #include <drm/drm_gem.h>
  20. #include <drm/drm_panel.h>
  21. #include <drm/drm_simple_kms_helper.h>
  22. /*
  23. * CLCD Controller Internal Register addresses
  24. */
  25. #define CLCD_TIM0 0x00000000
  26. #define CLCD_TIM1 0x00000004
  27. #define CLCD_TIM2 0x00000008
  28. #define CLCD_TIM3 0x0000000c
  29. #define CLCD_UBAS 0x00000010
  30. #define CLCD_LBAS 0x00000014
  31. #define CLCD_PL110_IENB 0x00000018
  32. #define CLCD_PL110_CNTL 0x0000001c
  33. #define CLCD_PL110_STAT 0x00000020
  34. #define CLCD_PL110_INTR 0x00000024
  35. #define CLCD_PL110_UCUR 0x00000028
  36. #define CLCD_PL110_LCUR 0x0000002C
  37. #define CLCD_PL111_CNTL 0x00000018
  38. #define CLCD_PL111_IENB 0x0000001c
  39. #define CLCD_PL111_RIS 0x00000020
  40. #define CLCD_PL111_MIS 0x00000024
  41. #define CLCD_PL111_ICR 0x00000028
  42. #define CLCD_PL111_UCUR 0x0000002c
  43. #define CLCD_PL111_LCUR 0x00000030
  44. #define CLCD_PALL 0x00000200
  45. #define CLCD_PALETTE 0x00000200
  46. #define TIM2_PCD_LO_MASK GENMASK(4, 0)
  47. #define TIM2_PCD_LO_BITS 5
  48. #define TIM2_CLKSEL (1 << 5)
  49. #define TIM2_ACB_MASK GENMASK(10, 6)
  50. #define TIM2_IVS (1 << 11)
  51. #define TIM2_IHS (1 << 12)
  52. #define TIM2_IPC (1 << 13)
  53. #define TIM2_IOE (1 << 14)
  54. #define TIM2_BCD (1 << 26)
  55. #define TIM2_PCD_HI_MASK GENMASK(31, 27)
  56. #define TIM2_PCD_HI_BITS 5
  57. #define TIM2_PCD_HI_SHIFT 27
  58. #define CNTL_LCDEN (1 << 0)
  59. #define CNTL_LCDBPP1 (0 << 1)
  60. #define CNTL_LCDBPP2 (1 << 1)
  61. #define CNTL_LCDBPP4 (2 << 1)
  62. #define CNTL_LCDBPP8 (3 << 1)
  63. #define CNTL_LCDBPP16 (4 << 1)
  64. #define CNTL_LCDBPP16_565 (6 << 1)
  65. #define CNTL_LCDBPP16_444 (7 << 1)
  66. #define CNTL_LCDBPP24 (5 << 1)
  67. #define CNTL_LCDBW (1 << 4)
  68. #define CNTL_LCDTFT (1 << 5)
  69. #define CNTL_LCDMONO8 (1 << 6)
  70. #define CNTL_LCDDUAL (1 << 7)
  71. #define CNTL_BGR (1 << 8)
  72. #define CNTL_BEBO (1 << 9)
  73. #define CNTL_BEPO (1 << 10)
  74. #define CNTL_LCDPWR (1 << 11)
  75. #define CNTL_LCDVCOMP(x) ((x) << 12)
  76. #define CNTL_LDMAFIFOTIME (1 << 15)
  77. #define CNTL_WATERMARK (1 << 16)
  78. /* ST Microelectronics variant bits */
  79. #define CNTL_ST_1XBPP_444 0x0
  80. #define CNTL_ST_1XBPP_5551 (1 << 17)
  81. #define CNTL_ST_1XBPP_565 (1 << 18)
  82. #define CNTL_ST_CDWID_12 0x0
  83. #define CNTL_ST_CDWID_16 (1 << 19)
  84. #define CNTL_ST_CDWID_18 (1 << 20)
  85. #define CNTL_ST_CDWID_24 ((1 << 19) | (1 << 20))
  86. #define CNTL_ST_CEAEN (1 << 21)
  87. #define CNTL_ST_LCDBPP24_PACKED (6 << 1)
  88. #define CLCD_IRQ_NEXTBASE_UPDATE BIT(2)
  89. struct drm_minor;
  90. /**
  91. * struct pl111_variant_data - encodes IP differences
  92. * @name: the name of this variant
  93. * @is_pl110: this is the early PL110 variant
  94. * @is_lcdc: this is the ST Microelectronics Nomadik LCDC variant
  95. * @external_bgr: this is the Versatile Pl110 variant with external
  96. * BGR/RGB routing
  97. * @broken_clockdivider: the clock divider is broken and we need to
  98. * use the supplied clock directly
  99. * @broken_vblank: the vblank IRQ is broken on this variant
  100. * @st_bitmux_control: this variant is using the ST Micro bitmux
  101. * extensions to the control register
  102. * @formats: array of supported pixel formats on this variant
  103. * @nformats: the length of the array of supported pixel formats
  104. * @fb_depth: desired depth per pixel on the default framebuffer
  105. */
  106. struct pl111_variant_data {
  107. const char *name;
  108. bool is_pl110;
  109. bool is_lcdc;
  110. bool external_bgr;
  111. bool broken_clockdivider;
  112. bool broken_vblank;
  113. bool st_bitmux_control;
  114. const u32 *formats;
  115. unsigned int nformats;
  116. unsigned int fb_depth;
  117. };
  118. struct pl111_drm_dev_private {
  119. struct drm_device *drm;
  120. struct drm_connector *connector;
  121. struct drm_panel *panel;
  122. struct drm_bridge *bridge;
  123. struct drm_simple_display_pipe pipe;
  124. void *regs;
  125. u32 memory_bw;
  126. u32 ienb;
  127. u32 ctrl;
  128. /* The pixel clock (a reference to our clock divider off of CLCDCLK). */
  129. struct clk *clk;
  130. /* pl111's internal clock divider. */
  131. struct clk_hw clk_div;
  132. /* Lock to sync access to CLCD_TIM2 between the common clock
  133. * subsystem and pl111_display_enable().
  134. */
  135. spinlock_t tim2_lock;
  136. const struct pl111_variant_data *variant;
  137. void (*variant_display_enable) (struct drm_device *drm, u32 format);
  138. void (*variant_display_disable) (struct drm_device *drm);
  139. bool use_device_memory;
  140. };
  141. int pl111_display_init(struct drm_device *dev);
  142. irqreturn_t pl111_irq(int irq, void *data);
  143. void pl111_debugfs_init(struct drm_minor *minor);
  144. #endif /* _PL111_DRM_H_ */