powerdomain-common.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. /*
  23. * OMAP3 and OMAP4 specific register bit initialisations
  24. * Notice that the names here are not according to each power
  25. * domain but the bit mapping used applies to all of them
  26. */
  27. /* OMAP3 and OMAP4 Memory Onstate Masks (common across all power domains) */
  28. #define OMAP_MEM0_ONSTATE_MASK OMAP3430_SHAREDL1CACHEFLATONSTATE_MASK
  29. #define OMAP_MEM1_ONSTATE_MASK OMAP3430_L1FLATMEMONSTATE_MASK
  30. #define OMAP_MEM2_ONSTATE_MASK OMAP3430_SHAREDL2CACHEFLATONSTATE_MASK
  31. #define OMAP_MEM3_ONSTATE_MASK OMAP3430_L2FLATMEMONSTATE_MASK
  32. #define OMAP_MEM4_ONSTATE_MASK OMAP4430_OCP_NRET_BANK_ONSTATE_MASK
  33. /* OMAP3 and OMAP4 Memory Retstate Masks (common across all power domains) */
  34. #define OMAP_MEM0_RETSTATE_MASK OMAP3430_SHAREDL1CACHEFLATRETSTATE_MASK
  35. #define OMAP_MEM1_RETSTATE_MASK OMAP3430_L1FLATMEMRETSTATE_MASK
  36. #define OMAP_MEM2_RETSTATE_MASK OMAP3430_SHAREDL2CACHEFLATRETSTATE_MASK
  37. #define OMAP_MEM3_RETSTATE_MASK OMAP3430_L2FLATMEMRETSTATE_MASK
  38. #define OMAP_MEM4_RETSTATE_MASK OMAP4430_OCP_NRET_BANK_RETSTATE_MASK
  39. /* OMAP3 and OMAP4 Memory Status bits */
  40. #define OMAP_MEM0_STATEST_MASK OMAP3430_SHAREDL1CACHEFLATSTATEST_MASK
  41. #define OMAP_MEM1_STATEST_MASK OMAP3430_L1FLATMEMSTATEST_MASK
  42. #define OMAP_MEM2_STATEST_MASK OMAP3430_SHAREDL2CACHEFLATSTATEST_MASK
  43. #define OMAP_MEM3_STATEST_MASK OMAP3430_L2FLATMEMSTATEST_MASK
  44. #define OMAP_MEM4_STATEST_MASK OMAP4430_OCP_NRET_BANK_STATEST_MASK
  45. /* Common Internal functions used across OMAP rev's*/
  46. u32 omap2_pwrdm_get_mem_bank_onstate_mask(u8 bank)
  47. {
  48. switch (bank) {
  49. case 0:
  50. return OMAP_MEM0_ONSTATE_MASK;
  51. case 1:
  52. return OMAP_MEM1_ONSTATE_MASK;
  53. case 2:
  54. return OMAP_MEM2_ONSTATE_MASK;
  55. case 3:
  56. return OMAP_MEM3_ONSTATE_MASK;
  57. case 4:
  58. return OMAP_MEM4_ONSTATE_MASK;
  59. default:
  60. WARN_ON(1); /* should never happen */
  61. return -EEXIST;
  62. }
  63. return 0;
  64. }
  65. u32 omap2_pwrdm_get_mem_bank_retst_mask(u8 bank)
  66. {
  67. switch (bank) {
  68. case 0:
  69. return OMAP_MEM0_RETSTATE_MASK;
  70. case 1:
  71. return OMAP_MEM1_RETSTATE_MASK;
  72. case 2:
  73. return OMAP_MEM2_RETSTATE_MASK;
  74. case 3:
  75. return OMAP_MEM3_RETSTATE_MASK;
  76. case 4:
  77. return OMAP_MEM4_RETSTATE_MASK;
  78. default:
  79. WARN_ON(1); /* should never happen */
  80. return -EEXIST;
  81. }
  82. return 0;
  83. }
  84. u32 omap2_pwrdm_get_mem_bank_stst_mask(u8 bank)
  85. {
  86. switch (bank) {
  87. case 0:
  88. return OMAP_MEM0_STATEST_MASK;
  89. case 1:
  90. return OMAP_MEM1_STATEST_MASK;
  91. case 2:
  92. return OMAP_MEM2_STATEST_MASK;
  93. case 3:
  94. return OMAP_MEM3_STATEST_MASK;
  95. case 4:
  96. return OMAP_MEM4_STATEST_MASK;
  97. default:
  98. WARN_ON(1); /* should never happen */
  99. return -EEXIST;
  100. }
  101. return 0;
  102. }