gm20b.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
  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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. #include "acr.h"
  23. #include "gm200.h"
  24. #ifdef CONFIG_ARCH_TEGRA
  25. #define TEGRA_MC_BASE 0x70019000
  26. #define MC_SECURITY_CARVEOUT2_CFG0 0xc58
  27. #define MC_SECURITY_CARVEOUT2_BOM_0 0xc5c
  28. #define MC_SECURITY_CARVEOUT2_BOM_HI_0 0xc60
  29. #define MC_SECURITY_CARVEOUT2_SIZE_128K 0xc64
  30. #define TEGRA_MC_SECURITY_CARVEOUT_CFG_LOCKED (1 << 1)
  31. /**
  32. * sb_tegra_read_wpr() - read the WPR registers on Tegra
  33. *
  34. * On dGPU, we can manage the WPR region ourselves, but on Tegra the WPR region
  35. * is reserved from system memory by the bootloader and irreversibly locked.
  36. * This function reads the address and size of the pre-configured WPR region.
  37. */
  38. static int
  39. gm20b_tegra_read_wpr(struct gm200_secboot *gsb)
  40. {
  41. struct nvkm_secboot *sb = &gsb->base;
  42. void __iomem *mc;
  43. u32 cfg;
  44. mc = ioremap(TEGRA_MC_BASE, 0xd00);
  45. if (!mc) {
  46. nvkm_error(&sb->subdev, "Cannot map Tegra MC registers\n");
  47. return PTR_ERR(mc);
  48. }
  49. sb->wpr_addr = ioread32_native(mc + MC_SECURITY_CARVEOUT2_BOM_0) |
  50. ((u64)ioread32_native(mc + MC_SECURITY_CARVEOUT2_BOM_HI_0) << 32);
  51. sb->wpr_size = ioread32_native(mc + MC_SECURITY_CARVEOUT2_SIZE_128K)
  52. << 17;
  53. cfg = ioread32_native(mc + MC_SECURITY_CARVEOUT2_CFG0);
  54. iounmap(mc);
  55. /* Check that WPR settings are valid */
  56. if (sb->wpr_size == 0) {
  57. nvkm_error(&sb->subdev, "WPR region is empty\n");
  58. return -EINVAL;
  59. }
  60. if (!(cfg & TEGRA_MC_SECURITY_CARVEOUT_CFG_LOCKED)) {
  61. nvkm_error(&sb->subdev, "WPR region not locked\n");
  62. return -EINVAL;
  63. }
  64. return 0;
  65. }
  66. #else
  67. static int
  68. gm20b_tegra_read_wpr(struct gm200_secboot *gsb)
  69. {
  70. nvkm_error(&gsb->base.subdev, "Tegra support not compiled in\n");
  71. return -EINVAL;
  72. }
  73. #endif
  74. static int
  75. gm20b_secboot_oneinit(struct nvkm_secboot *sb)
  76. {
  77. struct gm200_secboot *gsb = gm200_secboot(sb);
  78. int ret;
  79. ret = gm20b_tegra_read_wpr(gsb);
  80. if (ret)
  81. return ret;
  82. return gm200_secboot_oneinit(sb);
  83. }
  84. static const struct nvkm_secboot_func
  85. gm20b_secboot = {
  86. .dtor = gm200_secboot_dtor,
  87. .oneinit = gm20b_secboot_oneinit,
  88. .fini = gm200_secboot_fini,
  89. .run_blob = gm200_secboot_run_blob,
  90. };
  91. int
  92. gm20b_secboot_new(struct nvkm_device *device, int index,
  93. struct nvkm_secboot **psb)
  94. {
  95. int ret;
  96. struct gm200_secboot *gsb;
  97. struct nvkm_acr *acr;
  98. acr = acr_r352_new(BIT(NVKM_SECBOOT_FALCON_FECS));
  99. if (IS_ERR(acr))
  100. return PTR_ERR(acr);
  101. gsb = kzalloc(sizeof(*gsb), GFP_KERNEL);
  102. if (!gsb) {
  103. psb = NULL;
  104. return -ENOMEM;
  105. }
  106. *psb = &gsb->base;
  107. ret = nvkm_secboot_ctor(&gm20b_secboot, acr, device, index, &gsb->base);
  108. if (ret)
  109. return ret;
  110. return 0;
  111. }
  112. MODULE_FIRMWARE("nvidia/gm20b/acr/bl.bin");
  113. MODULE_FIRMWARE("nvidia/gm20b/acr/ucode_load.bin");
  114. MODULE_FIRMWARE("nvidia/gm20b/gr/fecs_bl.bin");
  115. MODULE_FIRMWARE("nvidia/gm20b/gr/fecs_inst.bin");
  116. MODULE_FIRMWARE("nvidia/gm20b/gr/fecs_data.bin");
  117. MODULE_FIRMWARE("nvidia/gm20b/gr/fecs_sig.bin");
  118. MODULE_FIRMWARE("nvidia/gm20b/gr/gpccs_inst.bin");
  119. MODULE_FIRMWARE("nvidia/gm20b/gr/gpccs_data.bin");
  120. MODULE_FIRMWARE("nvidia/gm20b/gr/sw_ctx.bin");
  121. MODULE_FIRMWARE("nvidia/gm20b/gr/sw_nonctx.bin");
  122. MODULE_FIRMWARE("nvidia/gm20b/gr/sw_bundle_init.bin");
  123. MODULE_FIRMWARE("nvidia/gm20b/gr/sw_method_init.bin");