init.c 2.9 KB

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