init.c 2.7 KB

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