ddc_regs.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright 2012-16 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_GPIO_DDC_REGS_H_
  26. #define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_GPIO_DDC_REGS_H_
  27. #include "gpio_regs.h"
  28. /****************************** new register headers */
  29. /*** following in header */
  30. #define DDC_GPIO_REG_LIST_ENTRY(type,cd,id) \
  31. .type ## _reg = REG(DC_GPIO_DDC ## id ## _ ## type),\
  32. .type ## _mask = DC_GPIO_DDC ## id ## _ ## type ## __DC_GPIO_DDC ## id ## cd ## _ ## type ## _MASK,\
  33. .type ## _shift = DC_GPIO_DDC ## id ## _ ## type ## __DC_GPIO_DDC ## id ## cd ## _ ## type ## __SHIFT
  34. #define DDC_GPIO_REG_LIST(cd,id) \
  35. {\
  36. DDC_GPIO_REG_LIST_ENTRY(MASK,cd,id),\
  37. DDC_GPIO_REG_LIST_ENTRY(A,cd,id),\
  38. DDC_GPIO_REG_LIST_ENTRY(EN,cd,id),\
  39. DDC_GPIO_REG_LIST_ENTRY(Y,cd,id)\
  40. }
  41. #define DDC_REG_LIST(cd,id) \
  42. DDC_GPIO_REG_LIST(cd,id),\
  43. .ddc_setup = REG(DC_I2C_DDC ## id ## _SETUP)
  44. #define DDC_GPIO_VGA_REG_LIST_ENTRY(type,cd)\
  45. .type ## _reg = REG(DC_GPIO_DDCVGA_ ## type),\
  46. .type ## _mask = DC_GPIO_DDCVGA_ ## type ## __DC_GPIO_DDCVGA ## cd ## _ ## type ## _MASK,\
  47. .type ## _shift = DC_GPIO_DDCVGA_ ## type ## __DC_GPIO_DDCVGA ## cd ## _ ## type ## __SHIFT
  48. #define DDC_GPIO_VGA_REG_LIST(cd) \
  49. {\
  50. DDC_GPIO_VGA_REG_LIST_ENTRY(MASK,cd),\
  51. DDC_GPIO_VGA_REG_LIST_ENTRY(A,cd),\
  52. DDC_GPIO_VGA_REG_LIST_ENTRY(EN,cd),\
  53. DDC_GPIO_VGA_REG_LIST_ENTRY(Y,cd)\
  54. }
  55. #define DDC_VGA_REG_LIST(cd) \
  56. DDC_GPIO_VGA_REG_LIST(cd),\
  57. .ddc_setup = mmDC_I2C_DDCVGA_SETUP
  58. #define DDC_GPIO_I2C_REG_LIST_ENTRY(type,cd) \
  59. .type ## _reg = REG(DC_GPIO_I2CPAD_ ## type),\
  60. .type ## _mask = DC_GPIO_I2CPAD_ ## type ## __DC_GPIO_ ## cd ## _ ## type ## _MASK,\
  61. .type ## _shift = DC_GPIO_I2CPAD_ ## type ## __DC_GPIO_ ## cd ## _ ## type ## __SHIFT
  62. #define DDC_GPIO_I2C_REG_LIST(cd) \
  63. {\
  64. DDC_GPIO_I2C_REG_LIST_ENTRY(MASK,cd),\
  65. DDC_GPIO_I2C_REG_LIST_ENTRY(A,cd),\
  66. DDC_GPIO_I2C_REG_LIST_ENTRY(EN,cd),\
  67. DDC_GPIO_I2C_REG_LIST_ENTRY(Y,cd)\
  68. }
  69. #define DDC_I2C_REG_LIST(cd) \
  70. DDC_GPIO_I2C_REG_LIST(cd),\
  71. .ddc_setup = 0
  72. #define DDC_MASK_SH_LIST(mask_sh) \
  73. SF_DDC(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_ENABLE, mask_sh),\
  74. SF_DDC(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_EDID_DETECT_ENABLE, mask_sh),\
  75. SF_DDC(DC_I2C_DDC1_SETUP, DC_I2C_DDC1_EDID_DETECT_MODE, mask_sh),\
  76. SF_DDC(DC_GPIO_DDC1_MASK, DC_GPIO_DDC1DATA_PD_EN, mask_sh),\
  77. SF_DDC(DC_GPIO_DDC1_MASK, DC_GPIO_DDC1CLK_PD_EN, mask_sh),\
  78. SF_DDC(DC_GPIO_DDC1_MASK, AUX_PAD1_MODE, mask_sh),\
  79. SF_DDC(DC_GPIO_I2CPAD_MASK, DC_GPIO_SDA_PD_DIS, mask_sh),\
  80. SF_DDC(DC_GPIO_I2CPAD_MASK, DC_GPIO_SCL_PD_DIS, mask_sh)
  81. struct ddc_registers {
  82. struct gpio_registers gpio;
  83. uint32_t ddc_setup;
  84. };
  85. struct ddc_sh_mask {
  86. /* i2c_dd_setup */
  87. uint32_t DC_I2C_DDC1_ENABLE;
  88. uint32_t DC_I2C_DDC1_EDID_DETECT_ENABLE;
  89. uint32_t DC_I2C_DDC1_EDID_DETECT_MODE;
  90. /* ddc1_mask */
  91. uint32_t DC_GPIO_DDC1DATA_PD_EN;
  92. uint32_t DC_GPIO_DDC1CLK_PD_EN;
  93. uint32_t AUX_PAD1_MODE;
  94. /* i2cpad_mask */
  95. uint32_t DC_GPIO_SDA_PD_DIS;
  96. uint32_t DC_GPIO_SCL_PD_DIS;
  97. };
  98. /*** following in dc_resource */
  99. #define ddc_data_regs(id) \
  100. {\
  101. DDC_REG_LIST(DATA,id)\
  102. }
  103. #define ddc_clk_regs(id) \
  104. {\
  105. DDC_REG_LIST(CLK,id)\
  106. }
  107. #define ddc_vga_data_regs \
  108. {\
  109. DDC_VGA_REG_LIST(DATA)\
  110. }
  111. #define ddc_vga_clk_regs \
  112. {\
  113. DDC_VGA_REG_LIST(CLK)\
  114. }
  115. #define ddc_i2c_data_regs \
  116. {\
  117. DDC_I2C_REG_LIST(SDA)\
  118. }
  119. #define ddc_i2c_clk_regs \
  120. {\
  121. DDC_I2C_REG_LIST(SCL)\
  122. }
  123. #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_GPIO_DDC_REGS_H_ */