prm2xxx.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * OMAP2xxx PRM module functions
  3. *
  4. * Copyright (C) 2010-2012 Texas Instruments, Inc.
  5. * Copyright (C) 2010 Nokia Corporation
  6. * Benoît Cousson
  7. * Paul Walmsley
  8. * Rajendra Nayak <rnayak@ti.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/errno.h>
  16. #include <linux/err.h>
  17. #include <linux/io.h>
  18. #include <linux/irq.h>
  19. #include "common.h"
  20. #include <plat/cpu.h>
  21. #include "vp.h"
  22. #include "powerdomain.h"
  23. #include "clockdomain.h"
  24. #include "prm2xxx.h"
  25. #include "cm2xxx_3xxx.h"
  26. #include "prm-regbits-24xx.h"
  27. /*
  28. * omap2xxx_prm_reset_src_map - map from bits in the PRM_RSTST_WKUP
  29. * hardware register (which are specific to the OMAP2xxx SoCs) to
  30. * reset source ID bit shifts (which is an OMAP SoC-independent
  31. * enumeration)
  32. */
  33. static struct prm_reset_src_map omap2xxx_prm_reset_src_map[] = {
  34. { OMAP_GLOBALCOLD_RST_SHIFT, OMAP_GLOBAL_COLD_RST_SRC_ID_SHIFT },
  35. { OMAP_GLOBALWARM_RST_SHIFT, OMAP_GLOBAL_WARM_RST_SRC_ID_SHIFT },
  36. { OMAP24XX_SECU_VIOL_RST_SHIFT, OMAP_SECU_VIOL_RST_SRC_ID_SHIFT },
  37. { OMAP24XX_MPU_WD_RST_SHIFT, OMAP_MPU_WD_RST_SRC_ID_SHIFT },
  38. { OMAP24XX_SECU_WD_RST_SHIFT, OMAP_SECU_WD_RST_SRC_ID_SHIFT },
  39. { OMAP24XX_EXTWMPU_RST_SHIFT, OMAP_EXTWARM_RST_SRC_ID_SHIFT },
  40. { -1, -1 },
  41. };
  42. /**
  43. * omap2xxx_prm_read_reset_sources - return the last SoC reset source
  44. *
  45. * Return a u32 representing the last reset sources of the SoC. The
  46. * returned reset source bits are standardized across OMAP SoCs.
  47. */
  48. static u32 omap2xxx_prm_read_reset_sources(void)
  49. {
  50. struct prm_reset_src_map *p;
  51. u32 r = 0;
  52. u32 v;
  53. v = omap2_prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTST);
  54. p = omap2xxx_prm_reset_src_map;
  55. while (p->reg_shift >= 0 && p->std_shift >= 0) {
  56. if (v & (1 << p->reg_shift))
  57. r |= 1 << p->std_shift;
  58. p++;
  59. }
  60. return r;
  61. }
  62. /**
  63. * omap2xxx_prm_dpll_reset - use DPLL reset to reboot the OMAP SoC
  64. *
  65. * Set the DPLL reset bit, which should reboot the SoC. This is the
  66. * recommended way to restart the SoC. No return value.
  67. */
  68. void omap2xxx_prm_dpll_reset(void)
  69. {
  70. omap2_prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK, WKUP_MOD,
  71. OMAP2_RM_RSTCTRL);
  72. /* OCP barrier */
  73. omap2_prm_read_mod_reg(WKUP_MOD, OMAP2_RM_RSTCTRL);
  74. }
  75. int omap2xxx_clkdm_sleep(struct clockdomain *clkdm)
  76. {
  77. omap2_prm_set_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
  78. clkdm->pwrdm.ptr->prcm_offs,
  79. OMAP2_PM_PWSTCTRL);
  80. return 0;
  81. }
  82. int omap2xxx_clkdm_wakeup(struct clockdomain *clkdm)
  83. {
  84. omap2_prm_clear_mod_reg_bits(OMAP24XX_FORCESTATE_MASK,
  85. clkdm->pwrdm.ptr->prcm_offs,
  86. OMAP2_PM_PWSTCTRL);
  87. return 0;
  88. }
  89. struct pwrdm_ops omap2_pwrdm_operations = {
  90. .pwrdm_set_next_pwrst = omap2_pwrdm_set_next_pwrst,
  91. .pwrdm_read_next_pwrst = omap2_pwrdm_read_next_pwrst,
  92. .pwrdm_read_pwrst = omap2_pwrdm_read_pwrst,
  93. .pwrdm_set_logic_retst = omap2_pwrdm_set_logic_retst,
  94. .pwrdm_set_mem_onst = omap2_pwrdm_set_mem_onst,
  95. .pwrdm_set_mem_retst = omap2_pwrdm_set_mem_retst,
  96. .pwrdm_read_mem_pwrst = omap2_pwrdm_read_mem_pwrst,
  97. .pwrdm_read_mem_retst = omap2_pwrdm_read_mem_retst,
  98. .pwrdm_wait_transition = omap2_pwrdm_wait_transition,
  99. };
  100. /*
  101. *
  102. */
  103. static struct prm_ll_data omap2xxx_prm_ll_data = {
  104. .read_reset_sources = &omap2xxx_prm_read_reset_sources,
  105. };
  106. int __init omap2xxx_prm_init(void)
  107. {
  108. if (!cpu_is_omap24xx())
  109. return 0;
  110. return prm_register(&omap2xxx_prm_ll_data);
  111. }
  112. static void __exit omap2xxx_prm_exit(void)
  113. {
  114. if (!cpu_is_omap24xx())
  115. return;
  116. /* Should never happen */
  117. WARN(prm_unregister(&omap2xxx_prm_ll_data),
  118. "%s: prm_ll_data function pointer mismatch\n", __func__);
  119. }
  120. __exitcall(omap2xxx_prm_exit);