dsi_ctrl_hw_2_2.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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_kickoff_non_embedded_mode()-Kickoff cmd in non-embedded mode
  45. * @ctrl: - Pointer to the controller host hardware.
  46. * @dsi_ctrl_cmd_dma_info: - command buffer information.
  47. * @flags: - DSI CTRL Flags.
  48. */
  49. void dsi_ctrl_hw_kickoff_non_embedded_mode(struct dsi_ctrl_hw *ctrl,
  50. struct dsi_ctrl_cmd_dma_info *cmd,
  51. u32 flags)
  52. {
  53. u32 reg = 0;
  54. reg = DSI_R32(ctrl, DSI_COMMAND_MODE_DMA_CTRL);
  55. reg &= ~BIT(31);/* disable broadcast */
  56. reg &= ~BIT(30);
  57. if (cmd->use_lpm)
  58. reg |= BIT(26);
  59. else
  60. reg &= ~BIT(26);
  61. /* Select non EMBEDDED_MODE, pick the packet header from register */
  62. reg &= ~BIT(28);
  63. reg |= BIT(24);/* long packet */
  64. reg |= BIT(29);/* wc_sel = 1 */
  65. reg |= (((cmd->datatype) & 0x03f) << 16);/* data type */
  66. DSI_W32(ctrl, DSI_COMMAND_MODE_DMA_CTRL, reg);
  67. /* Enable WRITE_WATERMARK_DISABLE and READ_WATERMARK_DISABLE bits */
  68. reg = DSI_R32(ctrl, DSI_DMA_FIFO_CTRL);
  69. reg |= BIT(20);
  70. reg |= BIT(16);
  71. reg |= 0x33;/* Set READ and WRITE watermark levels to maximum */
  72. DSI_W32(ctrl, DSI_DMA_FIFO_CTRL, reg);
  73. DSI_W32(ctrl, DSI_DMA_CMD_OFFSET, cmd->offset);
  74. DSI_W32(ctrl, DSI_DMA_CMD_LENGTH, ((cmd->length) & 0xFFFFFF));
  75. /* wait for writes to complete before kick off */
  76. wmb();
  77. if (!(flags & DSI_CTRL_HW_CMD_WAIT_FOR_TRIGGER))
  78. DSI_W32(ctrl, DSI_CMD_MODE_DMA_SW_TRIGGER, 0x1);
  79. }
  80. /*
  81. * dsi_ctrl_hw_22_config_clk_gating() - enable/disable clk gating on DSI PHY
  82. * @ctrl: Pointer to the controller host hardware.
  83. * @enable: bool to notify enable/disable.
  84. * @clk_selection: clock to enable/disable clock gating.
  85. *
  86. */
  87. void dsi_ctrl_hw_22_config_clk_gating(struct dsi_ctrl_hw *ctrl, bool enable,
  88. enum dsi_clk_gate_type clk_selection)
  89. {
  90. u32 reg = 0;
  91. u32 enable_select = 0;
  92. reg = DSI_DISP_CC_R32(ctrl, DISP_CC_MISC_CMD_REG_OFF);
  93. if (clk_selection & PIXEL_CLK)
  94. enable_select |= ctrl->index ? BIT(6) : BIT(5);
  95. if (clk_selection & BYTE_CLK)
  96. enable_select |= ctrl->index ? BIT(8) : BIT(7);
  97. if (clk_selection & DSI_PHY)
  98. enable_select |= ctrl->index ? BIT(10) : BIT(9);
  99. if (enable)
  100. reg |= enable_select;
  101. else
  102. reg &= ~enable_select;
  103. DSI_DISP_CC_W32(ctrl, DISP_CC_MISC_CMD_REG_OFF, reg);
  104. }