OhGodAPet

Untitled

Jan 21st, 2021
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. diff --git a/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c b/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
  2. index 5c7d769aee3f..aa14744847af 100644
  3. --- a/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
  4. +++ b/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
  5. @@ -117,8 +117,7 @@ static void smu_v11_0_i2c_set_address(struct i2c_adapter *control, uint8_t addre
  6. {
  7. struct amdgpu_device *adev = to_amdgpu_device(control);
  8.  
  9. - /* Convert fromr 8-bit to 7-bit address */
  10. - address >>= 1;
  11. + /* We take 7-bit addresses raw */
  12. WREG32_SOC15(SMUIO, 0, mmCKSVII2C_IC_TAR, (address & 0xFF));
  13. }
  14.  
  15. @@ -531,22 +530,14 @@ static bool smu_v11_0_i2c_bus_unlock(struct i2c_adapter *control)
  16. /***************************** I2C GLUE ****************************/
  17.  
  18. static uint32_t smu_v11_0_i2c_read_data(struct i2c_adapter *control,
  19. - uint8_t address,
  20. - uint8_t *data,
  21. - uint32_t numbytes)
  22. + struct i2c_msg *msg)
  23. {
  24. uint32_t ret = 0;
  25.  
  26. - /* First 2 bytes are dummy write to set EEPROM address */
  27. - ret = smu_v11_0_i2c_transmit(control, address, data, 2, I2C_NO_STOP);
  28. - if (ret != I2C_OK)
  29. - goto Fail;
  30. -
  31. /* Now read data starting with that address */
  32. - ret = smu_v11_0_i2c_receive(control, address, data + 2, numbytes - 2,
  33. + ret = smu_v11_0_i2c_receive(control, msg->addr, msg->buf, msg->len,
  34. I2C_RESTART);
  35.  
  36. -Fail:
  37. if (ret != I2C_OK)
  38. DRM_ERROR("ReadData() - I2C error occurred :%x", ret);
  39.  
  40. @@ -554,28 +545,16 @@ static uint32_t smu_v11_0_i2c_read_data(struct i2c_adapter *control,
  41. }
  42.  
  43. static uint32_t smu_v11_0_i2c_write_data(struct i2c_adapter *control,
  44. - uint8_t address,
  45. - uint8_t *data,
  46. - uint32_t numbytes)
  47. + struct i2c_msg *msg)
  48. {
  49. uint32_t ret;
  50.  
  51. - ret = smu_v11_0_i2c_transmit(control, address, data, numbytes, 0);
  52. + /* Send I2C_NO_STOP unless requested to stop. */
  53. + ret = smu_v11_0_i2c_transmit(control, msg->addr, msg->buf, msg->len, ((msg->flags & I2C_M_STOP) ? 0 : I2C_NO_STOP));
  54.  
  55. if (ret != I2C_OK)
  56. DRM_ERROR("WriteI2CData() - I2C error occurred :%x", ret);
  57. - else
  58. - /*
  59. - * According to EEPROM spec there is a MAX of 10 ms required for
  60. - * EEPROM to flush internal RX buffer after STOP was issued at the
  61. - * end of write transaction. During this time the EEPROM will not be
  62. - * responsive to any more commands - so wait a bit more.
  63. - *
  64. - * TODO Improve to wait for first ACK for slave address after
  65. - * internal write cycle done.
  66. - */
  67. - msleep(10);
  68. -
  69. +
  70. return ret;
  71.  
  72. }
  73. @@ -622,22 +601,15 @@ static int smu_v11_0_i2c_xfer(struct i2c_adapter *i2c_adap,
  74. int i, ret;
  75. struct amdgpu_device *adev = to_amdgpu_device(i2c_adap);
  76.  
  77. - if (!adev->pm.bus_locked) {
  78. - DRM_ERROR("I2C bus unlocked, stopping transaction!");
  79. - return -EIO;
  80. - }
  81. -
  82. smu_v11_0_i2c_init(i2c_adap);
  83.  
  84. for (i = 0; i < num; i++) {
  85. if (msgs[i].flags & I2C_M_RD)
  86. ret = smu_v11_0_i2c_read_data(i2c_adap,
  87. - (uint8_t)msgs[i].addr,
  88. - msgs[i].buf, msgs[i].len);
  89. + msgs + i);
  90. else
  91. ret = smu_v11_0_i2c_write_data(i2c_adap,
  92. - (uint8_t)msgs[i].addr,
  93. - msgs[i].buf, msgs[i].len);
  94. + msgs + i);
  95.  
  96. if (ret != I2C_OK) {
  97. num = -EIO;
  98. @@ -666,7 +638,7 @@ int smu_v11_0_i2c_control_init(struct i2c_adapter *control)
  99. int res;
  100.  
  101. control->owner = THIS_MODULE;
  102. - control->class = I2C_CLASS_SPD;
  103. + control->class = I2C_CLASS_HWMON;
  104. control->dev.parent = &adev->pdev->dev;
  105. control->algo = &smu_v11_0_i2c_algo;
  106. snprintf(control->name, sizeof(control->name), "AMDGPU SMU");
  107.  
Advertisement
Add Comment
Please, Sign In to add comment