factory.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*This file implements MTK boot mode.*/
  2. #include <sys/types.h>
  3. #include <debug.h>
  4. #include <err.h>
  5. #include <reg.h>
  6. #include <platform/mt_typedefs.h>
  7. #include <platform/boot_mode.h>
  8. #include <platform/mt_reg_base.h>
  9. #include <platform/mtk_key.h>
  10. #include <platform/mt_gpt.h>
  11. #include <target/cust_key.h>
  12. #define MODULE_NAME "[FACTORY]"
  13. BOOL factory_check_key_trigger(void)
  14. {
  15. #if 1
  16. //wait
  17. ulong begin = get_timer(0);
  18. dprintf(CRITICAL, "\n%s Check factory boot\n",MODULE_NAME);
  19. dprintf(CRITICAL, "%s Wait 50ms for special keys\n",MODULE_NAME);
  20. /* If the boot reason is RESET and volume down is uesd as reset key, than we will NOT enter factory mode. */
  21. //this function is marked because we use volume up to reset phone on ROME
  22. /*
  23. if(mtk_detect_pmic_just_rst())
  24. {
  25. return false;
  26. }
  27. */
  28. while (get_timer(begin)<50) {
  29. if (mtk_detect_key(MT65XX_FACTORY_KEY)) {
  30. dprintf(CRITICAL, "%s Detect key\n",MODULE_NAME);
  31. dprintf(CRITICAL, "%s Enable factory mode\n",MODULE_NAME);
  32. g_boot_mode = FACTORY_BOOT;
  33. //video_printf("%s : detect factory mode !\n",MODULE_NAME);
  34. return TRUE;
  35. }
  36. }
  37. #endif
  38. return FALSE;
  39. }
  40. extern BOOT_ARGUMENT *g_boot_arg;
  41. BOOL factory_detection(void)
  42. {
  43. // int forbid_mode = 0;
  44. if (g_boot_arg->sec_limit.magic_num == 0x4C4C4C4C) {
  45. if (g_boot_arg->sec_limit.forbid_mode == F_FACTORY_MODE) {
  46. //Forbid to enter factory mode
  47. dprintf(INFO, "%s Forbidden\n",MODULE_NAME);
  48. return FALSE;
  49. }
  50. }
  51. //forbid_mode =
  52. g_boot_arg->boot_mode &= 0x000000FF;
  53. if (factory_check_key_trigger()) {
  54. return TRUE;
  55. }
  56. return FALSE;
  57. }