mcde_drm.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2018 Linus Walleij <[email protected]>
  4. * Parts of this file were based on the MCDE driver by Marcus Lorentzon
  5. * (C) ST-Ericsson SA 2013
  6. */
  7. #include <drm/drm_simple_kms_helper.h>
  8. #ifndef _MCDE_DRM_H_
  9. #define _MCDE_DRM_H_
  10. /* Shared basic registers */
  11. #define MCDE_CR 0x00000000
  12. #define MCDE_CR_IFIFOEMPTYLINECOUNT_V422_SHIFT 0
  13. #define MCDE_CR_IFIFOEMPTYLINECOUNT_V422_MASK 0x0000003F
  14. #define MCDE_CR_IFIFOCTRLEN BIT(15)
  15. #define MCDE_CR_UFRECOVERY_MODE_V422 BIT(16)
  16. #define MCDE_CR_WRAP_MODE_V422_SHIFT BIT(17)
  17. #define MCDE_CR_AUTOCLKG_EN BIT(30)
  18. #define MCDE_CR_MCDEEN BIT(31)
  19. #define MCDE_CONF0 0x00000004
  20. #define MCDE_CONF0_SYNCMUX0 BIT(0)
  21. #define MCDE_CONF0_SYNCMUX1 BIT(1)
  22. #define MCDE_CONF0_SYNCMUX2 BIT(2)
  23. #define MCDE_CONF0_SYNCMUX3 BIT(3)
  24. #define MCDE_CONF0_SYNCMUX4 BIT(4)
  25. #define MCDE_CONF0_SYNCMUX5 BIT(5)
  26. #define MCDE_CONF0_SYNCMUX6 BIT(6)
  27. #define MCDE_CONF0_SYNCMUX7 BIT(7)
  28. #define MCDE_CONF0_IFIFOCTRLWTRMRKLVL_SHIFT 12
  29. #define MCDE_CONF0_IFIFOCTRLWTRMRKLVL_MASK 0x00007000
  30. #define MCDE_CONF0_OUTMUX0_SHIFT 16
  31. #define MCDE_CONF0_OUTMUX0_MASK 0x00070000
  32. #define MCDE_CONF0_OUTMUX1_SHIFT 19
  33. #define MCDE_CONF0_OUTMUX1_MASK 0x00380000
  34. #define MCDE_CONF0_OUTMUX2_SHIFT 22
  35. #define MCDE_CONF0_OUTMUX2_MASK 0x01C00000
  36. #define MCDE_CONF0_OUTMUX3_SHIFT 25
  37. #define MCDE_CONF0_OUTMUX3_MASK 0x0E000000
  38. #define MCDE_CONF0_OUTMUX4_SHIFT 28
  39. #define MCDE_CONF0_OUTMUX4_MASK 0x70000000
  40. #define MCDE_SSP 0x00000008
  41. #define MCDE_AIS 0x00000100
  42. #define MCDE_IMSCERR 0x00000110
  43. #define MCDE_RISERR 0x00000120
  44. #define MCDE_MISERR 0x00000130
  45. #define MCDE_SISERR 0x00000140
  46. enum mcde_flow_mode {
  47. /* One-shot mode: flow stops after one frame */
  48. MCDE_COMMAND_ONESHOT_FLOW,
  49. /* Command mode with tearing effect (TE) IRQ sync */
  50. MCDE_COMMAND_TE_FLOW,
  51. /*
  52. * Command mode with bus turn-around (BTA) and tearing effect
  53. * (TE) IRQ sync.
  54. */
  55. MCDE_COMMAND_BTA_TE_FLOW,
  56. /* Video mode with tearing effect (TE) sync IRQ */
  57. MCDE_VIDEO_TE_FLOW,
  58. /* Video mode with the formatter itself as sync source */
  59. MCDE_VIDEO_FORMATTER_FLOW,
  60. /* DPI video with the formatter itsels as sync source */
  61. MCDE_DPI_FORMATTER_FLOW,
  62. };
  63. struct mcde {
  64. struct drm_device drm;
  65. struct device *dev;
  66. struct drm_panel *panel;
  67. struct drm_bridge *bridge;
  68. struct drm_connector *connector;
  69. struct drm_simple_display_pipe pipe;
  70. struct mipi_dsi_device *mdsi;
  71. bool dpi_output;
  72. s16 stride;
  73. enum mcde_flow_mode flow_mode;
  74. unsigned int flow_active;
  75. spinlock_t flow_lock; /* Locks the channel flow control */
  76. void __iomem *regs;
  77. struct clk *mcde_clk;
  78. struct clk *lcd_clk;
  79. struct clk *hdmi_clk;
  80. /* Handles to the clock dividers for FIFO A and B */
  81. struct clk *fifoa_clk;
  82. struct clk *fifob_clk;
  83. /* Locks the MCDE FIFO control register A and B */
  84. spinlock_t fifo_crx1_lock;
  85. struct regulator *epod;
  86. struct regulator *vana;
  87. };
  88. #define to_mcde(dev) container_of(dev, struct mcde, drm)
  89. static inline bool mcde_flow_is_video(struct mcde *mcde)
  90. {
  91. return (mcde->flow_mode == MCDE_VIDEO_TE_FLOW ||
  92. mcde->flow_mode == MCDE_VIDEO_FORMATTER_FLOW);
  93. }
  94. bool mcde_dsi_irq(struct mipi_dsi_device *mdsi);
  95. void mcde_dsi_te_request(struct mipi_dsi_device *mdsi);
  96. void mcde_dsi_enable(struct drm_bridge *bridge);
  97. void mcde_dsi_disable(struct drm_bridge *bridge);
  98. extern struct platform_driver mcde_dsi_driver;
  99. void mcde_display_irq(struct mcde *mcde);
  100. void mcde_display_disable_irqs(struct mcde *mcde);
  101. int mcde_display_init(struct drm_device *drm);
  102. int mcde_init_clock_divider(struct mcde *mcde);
  103. #endif /* _MCDE_DRM_H_ */