init.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2009, Google Inc.
  3. * All rights reserved.
  4. * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in
  13. * the documentation and/or other materials provided with the
  14. * distribution.
  15. * * Neither the name of Google, Inc. nor the names of its contributors
  16. * may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  29. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. */
  32. #include <debug.h>
  33. #include <reg.h>
  34. #include <target.h>
  35. #include <platform/mt_reg_base.h>
  36. #include <platform/mmc_core.h>
  37. #include <platform/boot_mode.h>
  38. #include <target/cust_key.h>
  39. #include <platform/mt_gpt.h> // for get_timer()
  40. #include <platform/mt_rtc.h> // for Check_RTC_PDN1_bit13(), Set_Clr_RTC_PDN1_bit13()
  41. #include <platform/mtk_key.h> // for mtk_detect_key()
  42. void target_early_init(void)
  43. {
  44. }
  45. void target_init(void)
  46. {
  47. }
  48. unsigned board_machtype(void)
  49. {
  50. return MACH_TYPE;
  51. }
  52. /* Do any target specific intialization needed before entering fastboot mode */
  53. void target_fastboot_init(void)
  54. {
  55. }
  56. extern BOOTMODE g_boot_mode;
  57. BOOL fastboot_trigger(void)
  58. {
  59. ulong begin = get_timer(0);
  60. dprintf(INFO,"\n Check FASTBOOT\n");
  61. /*Check Fastboot RTC bit*/
  62. #if 1
  63. if(Check_RTC_PDN1_bit13())
  64. {
  65. dprintf(INFO,"[FASTBOOT] reboot to boot loader\n");
  66. g_boot_mode = FASTBOOT;
  67. Set_Clr_RTC_PDN1_bit13(false);
  68. return TRUE;
  69. }
  70. #endif
  71. dprintf(INFO,"Wait 50ms for special keys\n");
  72. while(get_timer(begin)<50)
  73. {
  74. if(mtk_detect_key(MT_CAMERA_KEY))
  75. {
  76. dprintf(INFO,"[FASTBOOT]Key Detect\n");
  77. g_boot_mode = FASTBOOT;
  78. return TRUE;
  79. }
  80. }
  81. return FALSE;
  82. }