nv50.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright 2012 Nouveau Community
  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: Martin Peres <martin.peres@labri.fr>
  23. * Ben Skeggs
  24. */
  25. #include "priv.h"
  26. #include <subdev/therm.h>
  27. #include <subdev/timer.h>
  28. static int
  29. nv50_bus_hwsq_exec(struct nvkm_bus *bus, u32 *data, u32 size)
  30. {
  31. struct nvkm_device *device = bus->subdev.device;
  32. int i;
  33. nvkm_mask(device, 0x001098, 0x00000008, 0x00000000);
  34. nvkm_wr32(device, 0x001304, 0x00000000);
  35. for (i = 0; i < size; i++)
  36. nvkm_wr32(device, 0x001400 + (i * 4), data[i]);
  37. nvkm_mask(device, 0x001098, 0x00000018, 0x00000018);
  38. nvkm_wr32(device, 0x00130c, 0x00000003);
  39. if (nvkm_msec(device, 2000,
  40. if (!(nvkm_rd32(device, 0x001308) & 0x00000100))
  41. break;
  42. ) < 0)
  43. return -ETIMEDOUT;
  44. return 0;
  45. }
  46. void
  47. nv50_bus_intr(struct nvkm_bus *bus)
  48. {
  49. struct nvkm_subdev *subdev = &bus->subdev;
  50. struct nvkm_device *device = subdev->device;
  51. u32 stat = nvkm_rd32(device, 0x001100) & nvkm_rd32(device, 0x001140);
  52. if (stat & 0x00000008) {
  53. u32 addr = nvkm_rd32(device, 0x009084);
  54. u32 data = nvkm_rd32(device, 0x009088);
  55. nvkm_error(subdev, "MMIO %s of %08x FAULT at %06x\n",
  56. (addr & 0x00000002) ? "write" : "read", data,
  57. (addr & 0x00fffffc));
  58. stat &= ~0x00000008;
  59. nvkm_wr32(device, 0x001100, 0x00000008);
  60. }
  61. if (stat & 0x00010000) {
  62. struct nvkm_therm *therm = device->therm;
  63. if (therm)
  64. nvkm_subdev_intr(&therm->subdev);
  65. stat &= ~0x00010000;
  66. nvkm_wr32(device, 0x001100, 0x00010000);
  67. }
  68. if (stat) {
  69. nvkm_error(subdev, "intr %08x\n", stat);
  70. nvkm_mask(device, 0x001140, stat, 0);
  71. }
  72. }
  73. void
  74. nv50_bus_init(struct nvkm_bus *bus)
  75. {
  76. struct nvkm_device *device = bus->subdev.device;
  77. nvkm_wr32(device, 0x001100, 0xffffffff);
  78. nvkm_wr32(device, 0x001140, 0x00010008);
  79. }
  80. static const struct nvkm_bus_func
  81. nv50_bus = {
  82. .init = nv50_bus_init,
  83. .intr = nv50_bus_intr,
  84. .hwsq_exec = nv50_bus_hwsq_exec,
  85. .hwsq_size = 64,
  86. };
  87. int
  88. nv50_bus_new(struct nvkm_device *device, int index, struct nvkm_bus **pbus)
  89. {
  90. return nvkm_bus_new_(&nv50_bus, device, index, pbus);
  91. }