power_suspend.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 <plat/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. //appf functions
  38. #define APPF_INITIALIZE 0
  39. #define APPF_POWER_DOWN_CPU 1
  40. #define APPF_POWER_UP_CPUS 2
  41. //appf flags
  42. #define APPF_SAVE_PMU (1<<0)
  43. #define APPF_SAVE_TIMERS (1<<1)
  44. #define APPF_SAVE_VFP (1<<2)
  45. #define APPF_SAVE_DEBUG (1<<3)
  46. #define APPF_SAVE_L2 (1<<4)
  47. #ifdef CONFIG_SUSPEND_WATCHDOG
  48. void disable_watchdog(void)
  49. {
  50. printk(KERN_INFO "** disable watchdog\n");
  51. aml_write_reg32(P_WATCHDOG_RESET, 0);
  52. aml_clr_reg32_mask(P_WATCHDOG_TC,(1 << WATCHDOG_ENABLE_BIT));
  53. }
  54. void enable_watchdog(void)
  55. {
  56. printk(KERN_INFO "** enable watchdog\n");
  57. aml_write_reg32(P_WATCHDOG_RESET, 0);
  58. aml_write_reg32(P_WATCHDOG_TC, 1 << WATCHDOG_ENABLE_BIT | 0x1FFFFF);//about 20sec
  59. }
  60. void reset_watchdog(void)
  61. {
  62. printk(KERN_INFO "** reset watchdog\n");
  63. aml_write_reg32(P_WATCHDOG_RESET, 0);
  64. }
  65. #endif
  66. int meson_power_suspend(void)
  67. {
  68. static int test_flag = 0;
  69. unsigned addr;
  70. unsigned p_addr;
  71. void (*pwrtest_entry)(unsigned,unsigned,unsigned,unsigned);
  72. flush_cache_all();
  73. addr = 0x1FF04400;
  74. p_addr = (unsigned)virt_to_phys((void*)addr);
  75. pwrtest_entry = (void (*)(unsigned,unsigned,unsigned,unsigned))p_addr;
  76. if(test_flag != 1234){
  77. test_flag = 1234;
  78. printk("initial appf\n");
  79. pwrtest_entry(APPF_INITIALIZE,0,0,0);
  80. }
  81. #ifdef CONFIG_SUSPEND_WATCHDOG
  82. disable_watchdog();
  83. #endif
  84. printk("power down cpu --\n");
  85. pwrtest_entry(APPF_POWER_DOWN_CPU,0,0,APPF_SAVE_PMU|APPF_SAVE_VFP|APPF_SAVE_L2);
  86. #ifdef CONFIG_SUSPEND_WATCHDOG
  87. enable_watchdog();
  88. #endif
  89. return 0;
  90. }