init.c 2.8 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/boot_mode.h>
  37. #include <target/cust_key.h>
  38. #include <platform/mt_gpt.h> // for get_timer()
  39. #include <platform/mt_rtc.h> // for Check_RTC_PDN1_bit13(), Set_Clr_RTC_PDN1_bit13()
  40. #include <platform/mtk_key.h> // for mtk_detect_key()
  41. void target_early_init(void)
  42. {
  43. }
  44. void target_init(void)
  45. {
  46. }
  47. unsigned board_machtype(void)
  48. {
  49. return MACH_TYPE;
  50. }
  51. /* Do any target specific intialization needed before entering fastboot mode */
  52. void target_fastboot_init(void)
  53. {
  54. }
  55. extern BOOTMODE g_boot_mode;
  56. BOOL fastboot_trigger(void)
  57. {
  58. ulong begin = get_timer(0);
  59. dprintf(INFO,"\n Check FASTBOOT\n");
  60. /*Check Fastboot RTC bit*/
  61. #if 1
  62. if(Check_RTC_PDN1_bit13())
  63. {
  64. dprintf(INFO,"[FASTBOOT] reboot to boot loader\n");
  65. g_boot_mode = FASTBOOT;
  66. Set_Clr_RTC_PDN1_bit13(false);
  67. return TRUE;
  68. }
  69. #endif
  70. dprintf(INFO,"Wait 50ms for special keys\n");
  71. while(get_timer(begin)<50)
  72. {
  73. if(mtk_detect_key(MT_CAMERA_KEY))
  74. {
  75. dprintf(INFO,"[FASTBOOT]Key Detect\n");
  76. g_boot_mode = FASTBOOT;
  77. return TRUE;
  78. }
  79. }
  80. return FALSE;
  81. }