dsi_ctrl_hw_2_2.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #define pr_fmt(fmt) "dsi-hw:" fmt
  6. #include "dsi_ctrl_hw.h"
  7. #include "dsi_ctrl_reg.h"
  8. #include "dsi_hw.h"
  9. #include "dsi_catalog.h"
  10. #define DISP_CC_MISC_CMD_REG_OFF 0x00
  11. /* register to configure DMA scheduling */
  12. #define DSI_DMA_SCHEDULE_CTRL 0x100
  13. /**
  14. * dsi_ctrl_hw_22_phy_reset_config() - to configure clamp control during ulps
  15. * @ctrl: Pointer to the controller host hardware.
  16. * @enable: boolean to specify enable/disable.
  17. */
  18. void dsi_ctrl_hw_22_phy_reset_config(struct dsi_ctrl_hw *ctrl,
  19. bool enable)
  20. {
  21. u32 reg = 0;
  22. reg = DSI_DISP_CC_R32(ctrl, DISP_CC_MISC_CMD_REG_OFF);
  23. /* Mask/unmask disable PHY reset bit */
  24. if (enable)
  25. reg &= ~BIT(ctrl->index);
  26. else
  27. reg |= BIT(ctrl->index);
  28. DSI_DISP_CC_W32(ctrl, DISP_CC_MISC_CMD_REG_OFF, reg);
  29. }
  30. /**
  31. * dsi_ctrl_hw_22_schedule_dma_cmd() - to schedule DMA command transfer
  32. * @ctrl: Pointer to the controller host hardware.
  33. * @line_no: Line number at which command needs to be sent.
  34. */
  35. void dsi_ctrl_hw_22_schedule_dma_cmd(struct dsi_ctrl_hw *ctrl, int line_no)
  36. {
  37. u32 reg = 0;
  38. reg = DSI_R32(ctrl, DSI_DMA_SCHEDULE_CTRL);
  39. reg |= BIT(28);
  40. reg |= (line_no & 0xffff);
  41. DSI_W32(ctrl, DSI_DMA_SCHEDULE_CTRL, reg);
  42. }
  43. /*
  44. * dsi_ctrl_hw_22_get_cont_splash_status() - to verify whether continuous
  45. * splash is enabled or not
  46. * @ctrl: Pointer to the controller host hardware.
  47. *
  48. * Return: Return Continuous splash status
  49. */
  50. bool dsi_ctrl_hw_22_get_cont_splash_status(struct dsi_ctrl_hw *ctrl)
  51. {
  52. u32 reg = 0;
  53. /**
  54. * DSI scratch register 1 is used to notify whether continuous
  55. * splash is enabled or not by bootloader
  56. */
  57. reg = DSI_R32(ctrl, DSI_SCRATCH_REGISTER_1);
  58. return reg == 0x1;
  59. }
  60. /*
  61. * dsi_ctrl_hw_kickoff_non_embedded_mode()-Kickoff cmd in non-embedded mode
  62. * @ctrl: - Pointer to the controller host hardware.
  63. * @dsi_ctrl_cmd_dma_info: - command buffer information.
  64. * @flags: - DSI CTRL Flags.
  65. */
  66. void dsi_ctrl_hw_kickoff_non_embedded_mode(struct dsi_ctrl_hw *ctrl,
  67. struct dsi_ctrl_cmd_dma_info *cmd,
  68. u32 flags)
  69. {
  70. u32 reg = 0;
  71. reg = DSI_R32(ctrl, DSI_COMMAND_MODE_DMA_CTRL);
  72. reg &= ~BIT(31);/* disable broadcast */
  73. reg &= ~BIT(30);
  74. if (cmd->use_lpm)
  75. reg |= BIT(26);
  76. else
  77. reg &= ~BIT(26);
  78. /* Select non EMBEDDED_MODE, pick the packet header from register */
  79. reg &= ~BIT(28);
  80. reg |= BIT(24);/* long packet */
  81. reg |= BIT(29);/* wc_sel = 1 */
  82. reg |= (((cmd->datatype) & 0x03f) << 16);/* data type */
  83. DSI_W32(ctrl, DSI_COMMAND_MODE_DMA_CTRL, reg);
  84. /* Enable WRITE_WATERMARK_DISABLE and READ_WATERMARK_DISABLE bits */
  85. reg = DSI_R32(ctrl, DSI_DMA_FIFO_CTRL);
  86. reg |= BIT(20);
  87. reg |= BIT(16);
  88. reg |= 0x33;/* Set READ and WRITE watermark levels to maximum */
  89. DSI_W32(ctrl, DSI_DMA_FIFO_CTRL, reg);
  90. DSI_W32(ctrl, DSI_DMA_CMD_OFFSET, cmd->offset);
  91. DSI_W32(ctrl, DSI_DMA_CMD_LENGTH, ((cmd->length) & 0xFFFFFF));
  92. /* wait for writes to complete before kick off */
  93. wmb();
  94. if (!(flags & DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER))
  95. DSI_W32(ctrl, DSI_CMD_MODE_DMA_SW_TRIGGER, 0x1);
  96. }
  97. /*
  98. * dsi_ctrl_hw_22_config_clk_gating() - enable/disable clk gating on DSI PHY
  99. * @ctrl: Pointer to the controller host hardware.
  100. * @enable: bool to notify enable/disable.
  101. * @clk_selection: clock to enable/disable clock gating.
  102. *
  103. */
  104. void dsi_ctrl_hw_22_config_clk_gating(struct dsi_ctrl_hw *ctrl, bool enable,
  105. enum dsi_clk_gate_type clk_selection)
  106. {
  107. u32 reg = 0;
  108. u32 enable_select = 0;
  109. reg = DSI_DISP_CC_R32(ctrl, DISP_CC_MISC_CMD_REG_OFF);
  110. if (clk_selection & PIXEL_CLK)
  111. enable_select |= ctrl->index ? BIT(6) : BIT(5);
  112. if (clk_selection & BYTE_CLK)
  113. enable_select |= ctrl->index ? BIT(8) : BIT(7);
  114. if (clk_selection & DSI_PHY)
  115. enable_select |= ctrl->index ? BIT(10) : BIT(9);
  116. if (enable)
  117. reg |= enable_select;
  118. else
  119. reg &= ~enable_select;
  120. DSI_DISP_CC_W32(ctrl, DISP_CC_MISC_CMD_REG_OFF, reg);
  121. }