powerdomain-common.c 3.1 KB

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