init.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (c) 2008 Travis Geiselbrecht
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files
  6. * (the "Software"), to deal in the Software without restriction,
  7. * including without limitation the rights to use, copy, modify, merge,
  8. * publish, distribute, sublicense, and/or sell copies of the Software,
  9. * and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #include <err.h>
  24. #include <debug.h>
  25. #include <target.h>
  26. #include <compiler.h>
  27. #include <platform/mt_typedefs.h>
  28. #include <block_generic_interface.h>
  29. #include "part_dev.h"
  30. #if defined(MTK_UFS_SUPPORT)
  31. #include "ufs_aio_interface.h"
  32. #endif
  33. #define EXPAND(NAME) #NAME
  34. #define TARGET(NAME) EXPAND(NAME)
  35. /*
  36. * default implementations of these routines, if the target code
  37. * chooses not to implement.
  38. */
  39. extern unsigned long long g_emmc_size;
  40. extern unsigned long g_nand_size;
  41. __WEAK void target_early_init(void)
  42. {
  43. }
  44. __WEAK void target_init(void)
  45. {
  46. }
  47. __WEAK void *target_get_scratch_address(void)
  48. {
  49. return (void *)(SCRATCH_ADDR);
  50. }
  51. #if 0
  52. __WEAK unsigned target_get_max_flash_size(void)
  53. {
  54. return (120 * 1024 * 1024);
  55. }
  56. __WEAK int target_is_emmc_boot(void)
  57. {
  58. #if _EMMC_BOOT
  59. return 1;
  60. #else
  61. return 0;
  62. #endif
  63. }
  64. #endif
  65. __WEAK unsigned long long target_get_max_flash_size(void)
  66. {
  67. #if (defined(MTK_EMMC_SUPPORT) || defined(MTK_UFS_SUPPORT))
  68. part_dev_t *dev;
  69. dev = mt_part_get_device();
  70. #if defined(MTK_EMMC_SUPPORT)
  71. if (dev->blkdev->type == BOOTDEV_SDMMC)
  72. return g_emmc_size;
  73. #endif
  74. #if defined(MTK_UFS_SUPPORT)
  75. if (dev->blkdev->type == BOOTDEV_UFS)
  76. return ufs_lk_get_device_size();
  77. #endif
  78. return 0;
  79. #else
  80. return (unsigned long long)g_nand_size;
  81. #endif
  82. }
  83. __WEAK int target_is_emmc_boot(void)
  84. {
  85. #if defined(MTK_EMMC_SUPPORT) || defined(MTK_UFS_SUPPORT)
  86. return 1;
  87. #else
  88. return 0;
  89. #endif
  90. }
  91. __WEAK unsigned check_reboot_mode(void)
  92. {
  93. return 0;
  94. }
  95. __WEAK void reboot_device(unsigned reboot_reason)
  96. {
  97. }
  98. __WEAK unsigned target_pause_for_battery_charge(void)
  99. {
  100. return 0;
  101. }
  102. __WEAK unsigned target_baseband()
  103. {
  104. return 0;
  105. }
  106. __WEAK void target_serialno(unsigned char *buf)
  107. {
  108. snprintf((char *) buf, 13, "%s",TARGET(BOARD));
  109. }
  110. __WEAK void target_fastboot_init()
  111. {
  112. }
  113. __WEAK int emmc_recovery_init(void)
  114. {
  115. return 0;
  116. }
  117. __WEAK bool target_use_signed_kernel(void)
  118. {
  119. #if _SIGNED_KERNEL
  120. return 1;
  121. #else
  122. return 0;
  123. #endif
  124. }