acr_r364.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright (c) 2017, 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_r361.h"
  23. #include <core/gpuobj.h>
  24. /*
  25. * r364 ACR: hsflcn_desc structure has changed to introduce the shadow_mem
  26. * parameter.
  27. */
  28. struct acr_r364_hsflcn_desc {
  29. union {
  30. u8 reserved_dmem[0x200];
  31. u32 signatures[4];
  32. } ucode_reserved_space;
  33. u32 wpr_region_id;
  34. u32 wpr_offset;
  35. u32 mmu_memory_range;
  36. struct {
  37. u32 no_regions;
  38. struct {
  39. u32 start_addr;
  40. u32 end_addr;
  41. u32 region_id;
  42. u32 read_mask;
  43. u32 write_mask;
  44. u32 client_mask;
  45. u32 shadow_mem_start_addr;
  46. } region_props[2];
  47. } regions;
  48. u32 ucode_blob_size;
  49. u64 ucode_blob_base __aligned(8);
  50. struct {
  51. u32 vpr_enabled;
  52. u32 vpr_start;
  53. u32 vpr_end;
  54. u32 hdcp_policies;
  55. } vpr_desc;
  56. };
  57. static void
  58. acr_r364_fixup_hs_desc(struct acr_r352 *acr, struct nvkm_secboot *sb,
  59. void *_desc)
  60. {
  61. struct acr_r364_hsflcn_desc *desc = _desc;
  62. struct nvkm_gpuobj *ls_blob = acr->ls_blob;
  63. /* WPR region information if WPR is not fixed */
  64. if (sb->wpr_size == 0) {
  65. u64 wpr_start = ls_blob->addr;
  66. u64 wpr_end = ls_blob->addr + ls_blob->size;
  67. if (acr->func->shadow_blob)
  68. wpr_start += ls_blob->size / 2;
  69. desc->wpr_region_id = 1;
  70. desc->regions.no_regions = 2;
  71. desc->regions.region_props[0].start_addr = wpr_start >> 8;
  72. desc->regions.region_props[0].end_addr = wpr_end >> 8;
  73. desc->regions.region_props[0].region_id = 1;
  74. desc->regions.region_props[0].read_mask = 0xf;
  75. desc->regions.region_props[0].write_mask = 0xc;
  76. desc->regions.region_props[0].client_mask = 0x2;
  77. if (acr->func->shadow_blob)
  78. desc->regions.region_props[0].shadow_mem_start_addr =
  79. ls_blob->addr >> 8;
  80. else
  81. desc->regions.region_props[0].shadow_mem_start_addr = 0;
  82. } else {
  83. desc->ucode_blob_base = ls_blob->addr;
  84. desc->ucode_blob_size = ls_blob->size;
  85. }
  86. }
  87. const struct acr_r352_func
  88. acr_r364_func = {
  89. .fixup_hs_desc = acr_r364_fixup_hs_desc,
  90. .generate_hs_bl_desc = acr_r361_generate_hs_bl_desc,
  91. .hs_bl_desc_size = sizeof(struct acr_r361_flcn_bl_desc),
  92. .ls_ucode_img_load = acr_r352_ls_ucode_img_load,
  93. .ls_fill_headers = acr_r352_ls_fill_headers,
  94. .ls_write_wpr = acr_r352_ls_write_wpr,
  95. .ls_func = {
  96. [NVKM_SECBOOT_FALCON_FECS] = &acr_r361_ls_fecs_func,
  97. [NVKM_SECBOOT_FALCON_GPCCS] = &acr_r361_ls_gpccs_func,
  98. [NVKM_SECBOOT_FALCON_PMU] = &acr_r361_ls_pmu_func,
  99. },
  100. };
  101. struct nvkm_acr *
  102. acr_r364_new(unsigned long managed_falcons)
  103. {
  104. return acr_r352_new_(&acr_r364_func, NVKM_SECBOOT_FALCON_PMU,
  105. managed_falcons);
  106. }