dsi_ctrl_hw_2_2.c 3.4 KB

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