warmboot.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * (C) Copyright 2010, 2011
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _WARM_BOOT_H_
  8. #define _WARM_BOOT_H_
  9. #define STRAP_OPT_A_RAM_CODE_SHIFT 4
  10. #define STRAP_OPT_A_RAM_CODE_MASK (0xf << STRAP_OPT_A_RAM_CODE_SHIFT)
  11. /* Defines the supported operating modes */
  12. enum fuse_operating_mode {
  13. MODE_PRODUCTION = 3,
  14. MODE_UNDEFINED,
  15. };
  16. /* Defines the CMAC-AES-128 hash length in 32 bit words. (128 bits = 4 words) */
  17. enum {
  18. HASH_LENGTH = 4
  19. };
  20. /* Defines the storage for a hash value (128 bits) */
  21. struct hash {
  22. u32 hash[HASH_LENGTH];
  23. };
  24. /*
  25. * Defines the code header information for the boot rom.
  26. *
  27. * The code immediately follows the code header.
  28. *
  29. * Note that the code header needs to be 16 bytes aligned to preserve
  30. * the alignment of relevant data for hash and decryption computations without
  31. * requiring extra copies to temporary memory areas.
  32. */
  33. struct wb_header {
  34. u32 length_insecure; /* length of the code header */
  35. u32 reserved[3];
  36. struct hash hash; /* hash of header+code, starts next field*/
  37. struct hash random_aes_block; /* a data block to aid security. */
  38. u32 length_secure; /* length of the code header */
  39. u32 destination; /* destination address to put the wb code */
  40. u32 entry_point; /* execution address of the wb code */
  41. u32 code_length; /* length of the code */
  42. };
  43. /*
  44. * The warm boot code needs direct access to these registers since it runs in
  45. * SRAM and cannot call other U-Boot code.
  46. */
  47. union osc_ctrl_reg {
  48. struct {
  49. u32 xoe:1;
  50. u32 xobp:1;
  51. u32 reserved0:2;
  52. u32 xofs:6;
  53. u32 reserved1:2;
  54. u32 xods:5;
  55. u32 reserved2:3;
  56. u32 oscfi_spare:8;
  57. u32 pll_ref_div:2;
  58. u32 osc_freq:2;
  59. };
  60. u32 word;
  61. };
  62. union pllx_base_reg {
  63. struct {
  64. u32 divm:5;
  65. u32 reserved0:3;
  66. u32 divn:10;
  67. u32 reserved1:2;
  68. u32 divp:3;
  69. u32 reserved2:4;
  70. u32 lock:1;
  71. u32 reserved3:1;
  72. u32 ref_dis:1;
  73. u32 enable:1;
  74. u32 bypass:1;
  75. };
  76. u32 word;
  77. };
  78. union pllx_misc_reg {
  79. struct {
  80. u32 vcocon:4;
  81. u32 lfcon:4;
  82. u32 cpcon:4;
  83. u32 lock_sel:6;
  84. u32 reserved0:1;
  85. u32 lock_enable:1;
  86. u32 reserved1:1;
  87. u32 dccon:1;
  88. u32 pts:2;
  89. u32 reserved2:6;
  90. u32 out1_div_byp:1;
  91. u32 out1_inv_clk:1;
  92. };
  93. u32 word;
  94. };
  95. /*
  96. * TODO: This register is not documented in the TRM yet. We could move this
  97. * into the EMC and give it a proper interface, but not while it is
  98. * undocumented.
  99. */
  100. union scratch3_reg {
  101. struct {
  102. u32 pllx_base_divm:5;
  103. u32 pllx_base_divn:10;
  104. u32 pllx_base_divp:3;
  105. u32 pllx_misc_lfcon:4;
  106. u32 pllx_misc_cpcon:4;
  107. };
  108. u32 word;
  109. };
  110. /**
  111. * Save warmboot memory settings for a later resume
  112. *
  113. * @return 0 if ok, -1 on error
  114. */
  115. int warmboot_save_sdram_params(void);
  116. int warmboot_prepare_code(u32 seg_address, u32 seg_length);
  117. int sign_data_block(u8 *source, u32 length, u8 *signature);
  118. void wb_start(void); /* Start of WB assembly code */
  119. void wb_end(void); /* End of WB assembly code */
  120. #endif