g98.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright 2012 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. #include <engine/sec.h>
  25. #include <engine/fifo.h>
  26. #include "fuc/g98.fuc0s.h"
  27. #include <core/client.h>
  28. #include <core/enum.h>
  29. #include <core/gpuobj.h>
  30. #include <nvif/class.h>
  31. static const struct nvkm_enum g98_sec_isr_error_name[] = {
  32. { 0x0000, "ILLEGAL_MTHD" },
  33. { 0x0001, "INVALID_BITFIELD" },
  34. { 0x0002, "INVALID_ENUM" },
  35. { 0x0003, "QUERY" },
  36. {}
  37. };
  38. static void
  39. g98_sec_intr(struct nvkm_falcon *sec, struct nvkm_fifo_chan *chan)
  40. {
  41. struct nvkm_subdev *subdev = &sec->engine.subdev;
  42. struct nvkm_device *device = subdev->device;
  43. u32 ssta = nvkm_rd32(device, 0x087040) & 0x0000ffff;
  44. u32 addr = nvkm_rd32(device, 0x087040) >> 16;
  45. u32 mthd = (addr & 0x07ff) << 2;
  46. u32 subc = (addr & 0x3800) >> 11;
  47. u32 data = nvkm_rd32(device, 0x087044);
  48. const struct nvkm_enum *en =
  49. nvkm_enum_find(g98_sec_isr_error_name, ssta);
  50. nvkm_error(subdev, "DISPATCH_ERROR %04x [%s] ch %d [%010llx %s] "
  51. "subc %d mthd %04x data %08x\n", ssta,
  52. en ? en->name : "UNKNOWN", chan ? chan->chid : -1,
  53. chan ? chan->inst->addr : 0,
  54. chan ? chan->object.client->name : "unknown",
  55. subc, mthd, data);
  56. }
  57. static const struct nvkm_falcon_func
  58. g98_sec = {
  59. .code.data = g98_sec_code,
  60. .code.size = sizeof(g98_sec_code),
  61. .data.data = g98_sec_data,
  62. .data.size = sizeof(g98_sec_data),
  63. .intr = g98_sec_intr,
  64. .sclass = {
  65. { -1, -1, G98_SEC },
  66. {}
  67. }
  68. };
  69. int
  70. g98_sec_new(struct nvkm_device *device, int index,
  71. struct nvkm_engine **pengine)
  72. {
  73. return nvkm_falcon_new_(&g98_sec, device, index,
  74. true, 0x087000, pengine);
  75. }