power_suspend.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include <linux/kernel.h>
  2. #include <linux/init.h>
  3. #include <linux/mm.h>
  4. #include <linux/sched.h>
  5. #include <linux/interrupt.h>
  6. #include <linux/ioport.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/io.h>
  9. #include <linux/dma-mapping.h>
  10. #include <linux/mtd/mtd.h>
  11. #include <linux/mtd/nand.h>
  12. #include <linux/mtd/nand_ecc.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/device.h>
  15. #include <linux/spi/flash.h>
  16. #include <mach/hardware.h>
  17. #include <plat/platform.h>
  18. #include <mach/memory.h>
  19. #include <mach/clock.h>
  20. #include <asm/mach-types.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/setup.h>
  23. //#include <mach/lm.h>
  24. #include <asm/memory.h>
  25. #include <asm/mach/map.h>
  26. #include <mach/nand.h>
  27. #include <linux/i2c.h>
  28. #include <linux/i2c-aml.h>
  29. #include <mach/power_gate.h>
  30. #include <linux/aml_bl.h>
  31. #include <linux/delay.h>
  32. #include <mach/usbclock.h>
  33. #include <mach/am_regs.h>
  34. #include <linux/file.h>
  35. #include <asm/cacheflush.h>
  36. #include <plat/regops.h>
  37. #include <linux/reboot.h>
  38. //appf functions
  39. #define APPF_INITIALIZE 0
  40. #define APPF_POWER_DOWN_CPU 1
  41. #define APPF_POWER_UP_CPUS 2
  42. //appf flags
  43. #define APPF_SAVE_PMU (1<<0)
  44. #define APPF_SAVE_TIMERS (1<<1)
  45. #define APPF_SAVE_VFP (1<<2)
  46. #define APPF_SAVE_DEBUG (1<<3)
  47. #define APPF_SAVE_L2 (1<<4)
  48. #ifdef CONFIG_HARDWARE_WATCHDOG
  49. void disable_watchdog(void)
  50. {
  51. printk(KERN_INFO "** disable watchdog\n");
  52. aml_write_reg32(P_WATCHDOG_RESET, 0);
  53. aml_clr_reg32_mask(P_WATCHDOG_TC,(1 << WATCHDOG_ENABLE_BIT));
  54. }
  55. void enable_watchdog(void)
  56. {
  57. printk(KERN_INFO "** enable watchdog\n");
  58. aml_write_reg32(P_WATCHDOG_RESET, 0);
  59. aml_write_reg32(P_WATCHDOG_TC, 1 << WATCHDOG_ENABLE_BIT | 0x1FFFFF);//about 20sec
  60. aml_write_reg32(P_AO_RTI_STATUS_REG1, MESON_NORMAL_BOOT);
  61. }
  62. void reset_watchdog(void)
  63. {
  64. //printk(KERN_INFO "** reset watchdog\n");
  65. aml_write_reg32(P_WATCHDOG_RESET, 0);
  66. }
  67. #endif /* CONFIG_HARDWARE_WATCHDOG */
  68. int meson_power_suspend(void)
  69. {
  70. static int test_flag = 0;
  71. unsigned addr;
  72. unsigned p_addr;
  73. void (*pwrtest_entry)(unsigned,unsigned,unsigned,unsigned);
  74. flush_cache_all();
  75. addr = 0x9FF04400;
  76. p_addr = (unsigned)__phys_to_virt(addr);
  77. pwrtest_entry = (void (*)(unsigned,unsigned,unsigned,unsigned))p_addr;
  78. if(test_flag != 1234){
  79. test_flag = 1234;
  80. printk("initial appf\n");
  81. pwrtest_entry(APPF_INITIALIZE,0,0,0);
  82. }
  83. #ifdef CONFIG_SUSPEND_WATCHDOG
  84. disable_watchdog();
  85. #endif
  86. printk("power down cpu --\n");
  87. pwrtest_entry(APPF_POWER_DOWN_CPU,0,0,APPF_SAVE_PMU|APPF_SAVE_VFP|APPF_SAVE_L2);
  88. #ifdef CONFIG_SUSPEND_WATCHDOG
  89. enable_watchdog();
  90. #endif
  91. return 0;
  92. }