nv50.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2010 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 "mem.h"
  25. #include "vmm.h"
  26. #include <nvif/class.h>
  27. const u8 *
  28. nv50_mmu_kind(struct nvkm_mmu *base, int *count)
  29. {
  30. /* 0x01: no bank swizzle
  31. * 0x02: bank swizzled
  32. * 0x7f: invalid
  33. *
  34. * 0x01/0x02 are values understood by the VRAM allocator,
  35. * and are required to avoid mixing the two types within
  36. * a certain range.
  37. */
  38. static const u8
  39. kind[128] = {
  40. 0x01, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x00 */
  41. 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
  42. 0x01, 0x01, 0x01, 0x01, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x10 */
  43. 0x02, 0x02, 0x02, 0x02, 0x7f, 0x7f, 0x7f, 0x7f,
  44. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7f, /* 0x20 */
  45. 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7f,
  46. 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x30 */
  47. 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
  48. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, /* 0x40 */
  49. 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7f, 0x7f,
  50. 0x7f, 0x7f, 0x7f, 0x7f, 0x01, 0x01, 0x01, 0x7f, /* 0x50 */
  51. 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
  52. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7f, /* 0x60 */
  53. 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
  54. 0x01, 0x7f, 0x02, 0x7f, 0x01, 0x7f, 0x02, 0x7f, /* 0x70 */
  55. 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x7f, 0x7f
  56. };
  57. *count = ARRAY_SIZE(kind);
  58. return kind;
  59. }
  60. static const struct nvkm_mmu_func
  61. nv50_mmu = {
  62. .dma_bits = 40,
  63. .mmu = {{ -1, -1, NVIF_CLASS_MMU_NV50}},
  64. .mem = {{ -1, 0, NVIF_CLASS_MEM_NV50}, nv50_mem_new, nv50_mem_map },
  65. .vmm = {{ -1, -1, NVIF_CLASS_VMM_NV50}, nv50_vmm_new, false, 0x1400 },
  66. .kind = nv50_mmu_kind,
  67. };
  68. int
  69. nv50_mmu_new(struct nvkm_device *device, int index, struct nvkm_mmu **pmmu)
  70. {
  71. return nvkm_mmu_new_(&nv50_mmu, device, index, pmmu);
  72. }