powerdomain-common.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Common powerdomain framework functions
  3. *
  4. * Copyright (C) 2010-2011 Texas Instruments, Inc.
  5. * Copyright (C) 2010 Nokia Corporation
  6. *
  7. * Derived from mach-omap2/powerdomain.c written by Paul Walmsley
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/errno.h>
  14. #include <linux/kernel.h>
  15. #include <linux/bug.h>
  16. #include "pm.h"
  17. #include "cm.h"
  18. #include "cm-regbits-34xx.h"
  19. #include "prm-regbits-34xx.h"
  20. #include "prm-regbits-44xx.h"
  21. /*
  22. * OMAP3 and OMAP4 specific register bit initialisations
  23. * Notice that the names here are not according to each power
  24. * domain but the bit mapping used applies to all of them
  25. */
  26. /* OMAP3 and OMAP4 Memory Onstate Masks (common across all power domains) */
  27. #define OMAP_MEM0_ONSTATE_MASK OMAP3430_SHAREDL1CACHEFLATONSTATE_MASK
  28. #define OMAP_MEM1_ONSTATE_MASK OMAP3430_L1FLATMEMONSTATE_MASK
  29. #define OMAP_MEM2_ONSTATE_MASK OMAP3430_SHAREDL2CACHEFLATONSTATE_MASK
  30. #define OMAP_MEM3_ONSTATE_MASK OMAP3430_L2FLATMEMONSTATE_MASK
  31. #define OMAP_MEM4_ONSTATE_MASK OMAP4430_OCP_NRET_BANK_ONSTATE_MASK
  32. /* OMAP3 and OMAP4 Memory Retstate Masks (common across all power domains) */
  33. #define OMAP_MEM0_RETSTATE_MASK OMAP3430_SHAREDL1CACHEFLATRETSTATE_MASK
  34. #define OMAP_MEM1_RETSTATE_MASK OMAP3430_L1FLATMEMRETSTATE_MASK
  35. #define OMAP_MEM2_RETSTATE_MASK OMAP3430_SHAREDL2CACHEFLATRETSTATE_MASK
  36. #define OMAP_MEM3_RETSTATE_MASK OMAP3430_L2FLATMEMRETSTATE_MASK
  37. #define OMAP_MEM4_RETSTATE_MASK OMAP4430_OCP_NRET_BANK_RETSTATE_MASK
  38. /* OMAP3 and OMAP4 Memory Status bits */
  39. #define OMAP_MEM0_STATEST_MASK OMAP3430_SHAREDL1CACHEFLATSTATEST_MASK
  40. #define OMAP_MEM1_STATEST_MASK OMAP3430_L1FLATMEMSTATEST_MASK
  41. #define OMAP_MEM2_STATEST_MASK OMAP3430_SHAREDL2CACHEFLATSTATEST_MASK
  42. #define OMAP_MEM3_STATEST_MASK OMAP3430_L2FLATMEMSTATEST_MASK
  43. #define OMAP_MEM4_STATEST_MASK OMAP4430_OCP_NRET_BANK_STATEST_MASK
  44. /* Common Internal functions used across OMAP rev's*/
  45. u32 omap2_pwrdm_get_mem_bank_onstate_mask(u8 bank)
  46. {
  47. switch (bank) {
  48. case 0:
  49. return OMAP_MEM0_ONSTATE_MASK;
  50. case 1:
  51. return OMAP_MEM1_ONSTATE_MASK;
  52. case 2:
  53. return OMAP_MEM2_ONSTATE_MASK;
  54. case 3:
  55. return OMAP_MEM3_ONSTATE_MASK;
  56. case 4:
  57. return OMAP_MEM4_ONSTATE_MASK;
  58. default:
  59. WARN_ON(1); /* should never happen */
  60. return -EEXIST;
  61. }
  62. return 0;
  63. }
  64. u32 omap2_pwrdm_get_mem_bank_retst_mask(u8 bank)
  65. {
  66. switch (bank) {
  67. case 0:
  68. return OMAP_MEM0_RETSTATE_MASK;
  69. case 1:
  70. return OMAP_MEM1_RETSTATE_MASK;
  71. case 2:
  72. return OMAP_MEM2_RETSTATE_MASK;
  73. case 3:
  74. return OMAP_MEM3_RETSTATE_MASK;
  75. case 4:
  76. return OMAP_MEM4_RETSTATE_MASK;
  77. default:
  78. WARN_ON(1); /* should never happen */
  79. return -EEXIST;
  80. }
  81. return 0;
  82. }
  83. u32 omap2_pwrdm_get_mem_bank_stst_mask(u8 bank)
  84. {
  85. switch (bank) {
  86. case 0:
  87. return OMAP_MEM0_STATEST_MASK;
  88. case 1:
  89. return OMAP_MEM1_STATEST_MASK;
  90. case 2:
  91. return OMAP_MEM2_STATEST_MASK;
  92. case 3:
  93. return OMAP_MEM3_STATEST_MASK;
  94. case 4:
  95. return OMAP_MEM4_STATEST_MASK;
  96. default:
  97. WARN_ON(1); /* should never happen */
  98. return -EEXIST;
  99. }
  100. return 0;
  101. }