warmboot.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * (C) Copyright 2010, 2011
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef _WARM_BOOT_H_
  24. #define _WARM_BOOT_H_
  25. #define STRAP_OPT_A_RAM_CODE_SHIFT 4
  26. #define STRAP_OPT_A_RAM_CODE_MASK (0xf << STRAP_OPT_A_RAM_CODE_SHIFT)
  27. /* Defines the supported operating modes */
  28. enum fuse_operating_mode {
  29. MODE_PRODUCTION = 3,
  30. MODE_UNDEFINED,
  31. };
  32. /* Defines the CMAC-AES-128 hash length in 32 bit words. (128 bits = 4 words) */
  33. enum {
  34. HASH_LENGTH = 4
  35. };
  36. /* Defines the storage for a hash value (128 bits) */
  37. struct hash {
  38. u32 hash[HASH_LENGTH];
  39. };
  40. /*
  41. * Defines the code header information for the boot rom.
  42. *
  43. * The code immediately follows the code header.
  44. *
  45. * Note that the code header needs to be 16 bytes aligned to preserve
  46. * the alignment of relevant data for hash and decryption computations without
  47. * requiring extra copies to temporary memory areas.
  48. */
  49. struct wb_header {
  50. u32 length_insecure; /* length of the code header */
  51. u32 reserved[3];
  52. struct hash hash; /* hash of header+code, starts next field*/
  53. struct hash random_aes_block; /* a data block to aid security. */
  54. u32 length_secure; /* length of the code header */
  55. u32 destination; /* destination address to put the wb code */
  56. u32 entry_point; /* execution address of the wb code */
  57. u32 code_length; /* length of the code */
  58. };
  59. /*
  60. * The warm boot code needs direct access to these registers since it runs in
  61. * SRAM and cannot call other U-Boot code.
  62. */
  63. union osc_ctrl_reg {
  64. struct {
  65. u32 xoe:1;
  66. u32 xobp:1;
  67. u32 reserved0:2;
  68. u32 xofs:6;
  69. u32 reserved1:2;
  70. u32 xods:5;
  71. u32 reserved2:3;
  72. u32 oscfi_spare:8;
  73. u32 pll_ref_div:2;
  74. u32 osc_freq:2;
  75. };
  76. u32 word;
  77. };
  78. union pllx_base_reg {
  79. struct {
  80. u32 divm:5;
  81. u32 reserved0:3;
  82. u32 divn:10;
  83. u32 reserved1:2;
  84. u32 divp:3;
  85. u32 reserved2:4;
  86. u32 lock:1;
  87. u32 reserved3:1;
  88. u32 ref_dis:1;
  89. u32 enable:1;
  90. u32 bypass:1;
  91. };
  92. u32 word;
  93. };
  94. union pllx_misc_reg {
  95. struct {
  96. u32 vcocon:4;
  97. u32 lfcon:4;
  98. u32 cpcon:4;
  99. u32 lock_sel:6;
  100. u32 reserved0:1;
  101. u32 lock_enable:1;
  102. u32 reserved1:1;
  103. u32 dccon:1;
  104. u32 pts:2;
  105. u32 reserved2:6;
  106. u32 out1_div_byp:1;
  107. u32 out1_inv_clk:1;
  108. };
  109. u32 word;
  110. };
  111. /*
  112. * TODO: This register is not documented in the TRM yet. We could move this
  113. * into the EMC and give it a proper interface, but not while it is
  114. * undocumented.
  115. */
  116. union scratch3_reg {
  117. struct {
  118. u32 pllx_base_divm:5;
  119. u32 pllx_base_divn:10;
  120. u32 pllx_base_divp:3;
  121. u32 pllx_misc_lfcon:4;
  122. u32 pllx_misc_cpcon:4;
  123. };
  124. u32 word;
  125. };
  126. /**
  127. * Save warmboot memory settings for a later resume
  128. *
  129. * @return 0 if ok, -1 on error
  130. */
  131. int warmboot_save_sdram_params(void);
  132. int warmboot_prepare_code(u32 seg_address, u32 seg_length);
  133. int sign_data_block(u8 *source, u32 length, u8 *signature);
  134. void wb_start(void); /* Start of WB assembly code */
  135. void wb_end(void); /* End of WB assembly code */
  136. #endif