init.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 <string.h>
  28. #include <platform/mt_typedefs.h>
  29. #include <block_generic_interface.h>
  30. #include "part_dev.h"
  31. #if defined(MTK_UFS_SUPPORT)
  32. #include "ufs_aio_interface.h"
  33. #endif
  34. #define EXPAND(NAME) #NAME
  35. #define TARGET(NAME) EXPAND(NAME)
  36. /*
  37. * default implementations of these routines, if the target code
  38. * chooses not to implement.
  39. */
  40. extern unsigned long long g_emmc_size;
  41. extern unsigned long g_nand_size;
  42. __WEAK void target_early_init(void)
  43. {
  44. }
  45. __WEAK void target_init(void)
  46. {
  47. }
  48. __WEAK void *target_get_scratch_address(void)
  49. {
  50. return (void *)(SCRATCH_ADDR);
  51. }
  52. #if 0
  53. __WEAK unsigned target_get_max_flash_size(void)
  54. {
  55. return (120 * 1024 * 1024);
  56. }
  57. __WEAK int target_is_emmc_boot(void)
  58. {
  59. #if _EMMC_BOOT
  60. return 1;
  61. #else
  62. return 0;
  63. #endif
  64. }
  65. #endif
  66. __WEAK unsigned long long target_get_max_flash_size(void)
  67. {
  68. #if (defined(MTK_EMMC_SUPPORT) || defined(MTK_UFS_SUPPORT))
  69. part_dev_t *dev;
  70. dev = mt_part_get_device();
  71. #if defined(MTK_EMMC_SUPPORT)
  72. if (dev->blkdev->type == BOOTDEV_SDMMC)
  73. return g_emmc_size;
  74. #endif
  75. #if defined(MTK_UFS_SUPPORT)
  76. if (dev->blkdev->type == BOOTDEV_UFS)
  77. return ufs_lk_get_device_size();
  78. #endif
  79. return 0;
  80. #else
  81. return (unsigned long long)g_nand_size;
  82. #endif
  83. }
  84. __WEAK int target_is_emmc_boot(void)
  85. {
  86. #if defined(MTK_EMMC_SUPPORT) || defined(MTK_UFS_SUPPORT)
  87. return 1;
  88. #else
  89. return 0;
  90. #endif
  91. }
  92. __WEAK unsigned check_reboot_mode(void)
  93. {
  94. return 0;
  95. }
  96. __WEAK void reboot_device(unsigned reboot_reason)
  97. {
  98. }
  99. __WEAK unsigned target_pause_for_battery_charge(void)
  100. {
  101. return 0;
  102. }
  103. __WEAK unsigned target_baseband()
  104. {
  105. return 0;
  106. }
  107. __WEAK void target_serialno(unsigned char *buf)
  108. {
  109. int err;
  110. err = snprintf((char *) buf, 13, "%s",TARGET(BOARD));
  111. if (err < 0 || (unsigned)err >= 13)
  112. strlcpy((char *) buf, "unknown error", 13);
  113. }
  114. __WEAK void target_fastboot_init()
  115. {
  116. }
  117. __WEAK int emmc_recovery_init(void)
  118. {
  119. return 0;
  120. }
  121. __WEAK bool target_use_signed_kernel(void)
  122. {
  123. #if _SIGNED_KERNEL
  124. return 1;
  125. #else
  126. return 0;
  127. #endif
  128. }