gk104.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright 2013 Red Hat 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: Ben Skeggs
  23. */
  24. #define gf119_pmu_code gk104_pmu_code
  25. #define gf119_pmu_data gk104_pmu_data
  26. #include "priv.h"
  27. #include "fuc/gf119.fuc4.h"
  28. #include <core/option.h>
  29. #include <subdev/timer.h>
  30. static void
  31. magic_(struct nvkm_device *device, u32 ctrl, int size)
  32. {
  33. nvkm_wr32(device, 0x00c800, 0x00000000);
  34. nvkm_wr32(device, 0x00c808, 0x00000000);
  35. nvkm_wr32(device, 0x00c800, ctrl);
  36. nvkm_msec(device, 2000,
  37. if (nvkm_rd32(device, 0x00c800) & 0x40000000) {
  38. while (size--)
  39. nvkm_wr32(device, 0x00c804, 0x00000000);
  40. break;
  41. }
  42. );
  43. nvkm_wr32(device, 0x00c800, 0x00000000);
  44. }
  45. static void
  46. magic(struct nvkm_device *device, u32 ctrl)
  47. {
  48. magic_(device, 0x8000a41f | ctrl, 6);
  49. magic_(device, 0x80000421 | ctrl, 1);
  50. }
  51. static void
  52. gk104_pmu_pgob(struct nvkm_pmu *pmu, bool enable)
  53. {
  54. struct nvkm_device *device = pmu->subdev.device;
  55. nvkm_mask(device, 0x000200, 0x00001000, 0x00000000);
  56. nvkm_rd32(device, 0x000200);
  57. nvkm_mask(device, 0x000200, 0x08000000, 0x08000000);
  58. msleep(50);
  59. nvkm_mask(device, 0x10a78c, 0x00000002, 0x00000002);
  60. nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000001);
  61. nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000000);
  62. nvkm_mask(device, 0x020004, 0xc0000000, enable ? 0xc0000000 : 0x40000000);
  63. msleep(50);
  64. nvkm_mask(device, 0x10a78c, 0x00000002, 0x00000000);
  65. nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000001);
  66. nvkm_mask(device, 0x10a78c, 0x00000001, 0x00000000);
  67. nvkm_mask(device, 0x000200, 0x08000000, 0x00000000);
  68. nvkm_mask(device, 0x000200, 0x00001000, 0x00001000);
  69. nvkm_rd32(device, 0x000200);
  70. if ( nvkm_boolopt(device->cfgopt, "War00C800_0",
  71. device->quirk ? device->quirk->War00C800_0 : false)) {
  72. nvkm_info(&pmu->subdev, "hw bug workaround enabled\n");
  73. switch (device->chipset) {
  74. case 0xe4:
  75. magic(device, 0x04000000);
  76. magic(device, 0x06000000);
  77. magic(device, 0x0c000000);
  78. magic(device, 0x0e000000);
  79. break;
  80. case 0xe6:
  81. magic(device, 0x02000000);
  82. magic(device, 0x04000000);
  83. magic(device, 0x0a000000);
  84. break;
  85. case 0xe7:
  86. magic(device, 0x02000000);
  87. break;
  88. default:
  89. break;
  90. }
  91. }
  92. }
  93. static const struct nvkm_pmu_func
  94. gk104_pmu = {
  95. .code.data = gk104_pmu_code,
  96. .code.size = sizeof(gk104_pmu_code),
  97. .data.data = gk104_pmu_data,
  98. .data.size = sizeof(gk104_pmu_data),
  99. .pgob = gk104_pmu_pgob,
  100. };
  101. int
  102. gk104_pmu_new(struct nvkm_device *device, int index, struct nvkm_pmu **ppmu)
  103. {
  104. return nvkm_pmu_new_(&gk104_pmu, device, index, ppmu);
  105. }