realizationOfDataCalculation.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * OMAP3 Power Management Routines
  3. *
  4. * Copyright (C) 2006-2008 Nokia Corporation
  5. * Tony Lindgren <tony@atomide.com>
  6. * Jouni Hogander
  7. *
  8. * Copyright (C) 2007 Texas Instruments, Inc.
  9. * Rajendra Nayak <rnayak@ti.com>
  10. *
  11. * Copyright (C) 2005 Texas Instruments, Inc.
  12. * Richard Woodruff <r-woodruff2@ti.com>
  13. *
  14. * Based on pm.c for omap1
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License version 2 as
  18. * published by the Free Software Foundation.
  19. */
  20. #include <linux/pm.h>
  21. #include <linux/suspend.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/module.h>
  24. #include <linux/list.h>
  25. #include <linux/err.h>
  26. #include <linux/gpio.h>
  27. #include <linux/clk.h>
  28. #include <linux/delay.h>
  29. #include <linux/slab.h>
  30. #include <linux/omap-dma.h>
  31. #include <linux/platform_data/gpio-omap.h>
  32. #include <trace/events/power.h>
  33. #include <asm/fncpy.h>
  34. #include <asm/suspend.h>
  35. #include <asm/system_misc.h>
  36. #include "clockdomain.h"
  37. #include "powerdomain.h"
  38. #include "soc.h"
  39. #include "common.h"
  40. #include "cm3xxx.h"
  41. #include "cm-regbits-34xx.h"
  42. #include "gpmc.h"
  43. #include "prm-regbits-34xx.h"
  44. #include "prm3xxx.h"
  45. #include "pm.h"
  46. #include "sdrc.h"
  47. #include "sram.h"
  48. #include "control.h"
  49. /* pm34xx errata defined in pm.h */
  50. u16 pm34xx_errata;
  51. struct power_state {
  52. struct powerdomain *pwrdm;
  53. u32 next_state;
  54. #ifdef CONFIG_SUSPEND
  55. u32 saved_state;
  56. #endif
  57. struct list_head node;
  58. };
  59. static LIST_HEAD(pwrst_list);
  60. static int (*_omap_save_secure_sram)(u32 *addr);
  61. void (*omap3_do_wfi_sram)(void);
  62. static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
  63. static struct powerdomain *core_pwrdm, *per_pwrdm;
  64. static void omap3_core_save_context(void)
  65. {
  66. omap3_ctrl_save_padconf();
  67. /*
  68. * Force write last pad into memory, as this can fail in some
  69. * cases according to errata 1.157, 1.185
  70. */
  71. omap_ctrl_writel(omap_ctrl_readl(OMAP343X_PADCONF_ETK_D14),
  72. OMAP343X_CONTROL_MEM_WKUP + 0x2a0);
  73. /* Save the Interrupt controller context */
  74. omap_intc_save_context();
  75. /* Save the GPMC context */
  76. omap3_gpmc_save_context();
  77. /* Save the system control module context, padconf already save above*/
  78. omap3_control_save_context();
  79. omap_dma_global_context_save();
  80. }
  81. static void omap3_core_restore_context(void)
  82. {
  83. /* Restore the control module context, padconf restored by h/w */
  84. omap3_control_restore_context();
  85. /* Restore the GPMC context */
  86. omap3_gpmc_restore_context();
  87. /* Restore the interrupt controller context */
  88. omap_intc_restore_context();
  89. omap_dma_global_context_restore();
  90. }
  91. /*
  92. * FIXME: This function should be called before entering off-mode after
  93. * OMAP3 secure services have been accessed. Currently it is only called
  94. * once during boot sequence, but this works as we are not using secure
  95. * services.
  96. */
  97. static void omap3_save_secure_ram_context(void)
  98. {
  99. u32 ret;
  100. int mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
  101. if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
  102. /*
  103. * MPU next state must be set to POWER_ON temporarily,
  104. * otherwise the WFI executed inside the ROM code
  105. * will hang the system.
  106. */
  107. pwrdm_set_next_pwrst(mpu_pwrdm, PWRDM_POWER_ON);
  108. ret = _omap_save_secure_sram((u32 *)
  109. __pa(omap3_secure_ram_storage));
  110. pwrdm_set_next_pwrst(mpu_pwrdm, mpu_next_state);
  111. /* Following is for error tracking, it should not happen */
  112. if (ret) {
  113. pr_err("save_secure_sram() returns %08x\n", ret);
  114. while (1)
  115. ;
  116. }
  117. }
  118. }
  119. /*
  120. * PRCM Interrupt Handler Helper Function
  121. *
  122. * The purpose of this function is to clear any wake-up events latched
  123. * in the PRCM PM_WKST_x registers. It is possible that a wake-up event
  124. * may occur whilst attempting to clear a PM_WKST_x register and thus
  125. * set another bit in this register. A while loop is used to ensure
  126. * that any peripheral wake-up events occurring while attempting to
  127. * clear the PM_WKST_x are detected and cleared.
  128. */
  129. static int prcm_clear_mod_irqs(s16 module, u8 regs, u32 ignore_bits)
  130. {
  131. u32 wkst, fclk, iclk, clken;
  132. u16 wkst_off = (regs == 3) ? OMAP3430ES2_PM_WKST3 : PM_WKST1;
  133. u16 fclk_off = (regs == 3) ? OMAP3430ES2_CM_FCLKEN3 : CM_FCLKEN1;
  134. u16 iclk_off = (regs == 3) ? CM_ICLKEN3 : CM_ICLKEN1;
  135. u16 grpsel_off = (regs == 3) ?
  136. OMAP3430ES2_PM_MPUGRPSEL3 : OMAP3430_PM_MPUGRPSEL;
  137. int c = 0;
  138. wkst = omap2_prm_read_mod_reg(module, wkst_off);