1*d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 29b7fc907SRajendra Nayak /* 38179488aSPaul Walmsley * Common powerdomain framework functions 49b7fc907SRajendra Nayak * 58179488aSPaul Walmsley * Copyright (C) 2010-2011 Texas Instruments, Inc. 69b7fc907SRajendra Nayak * Copyright (C) 2010 Nokia Corporation 79b7fc907SRajendra Nayak * 89b7fc907SRajendra Nayak * Derived from mach-omap2/powerdomain.c written by Paul Walmsley 99b7fc907SRajendra Nayak */ 109b7fc907SRajendra Nayak 119b7fc907SRajendra Nayak #include <linux/errno.h> 129b7fc907SRajendra Nayak #include <linux/kernel.h> 13d9a5f4ddSTony Lindgren #include <linux/bug.h> 149b7fc907SRajendra Nayak #include "pm.h" 159b7fc907SRajendra Nayak #include "cm.h" 169b7fc907SRajendra Nayak #include "cm-regbits-34xx.h" 179b7fc907SRajendra Nayak #include "prm-regbits-34xx.h" 189b7fc907SRajendra Nayak #include "prm-regbits-44xx.h" 199b7fc907SRajendra Nayak 209b7fc907SRajendra Nayak /* 219b7fc907SRajendra Nayak * OMAP3 and OMAP4 specific register bit initialisations 229b7fc907SRajendra Nayak * Notice that the names here are not according to each power 239b7fc907SRajendra Nayak * domain but the bit mapping used applies to all of them 249b7fc907SRajendra Nayak */ 259b7fc907SRajendra Nayak /* OMAP3 and OMAP4 Memory Onstate Masks (common across all power domains) */ 269b7fc907SRajendra Nayak #define OMAP_MEM0_ONSTATE_MASK OMAP3430_SHAREDL1CACHEFLATONSTATE_MASK 279b7fc907SRajendra Nayak #define OMAP_MEM1_ONSTATE_MASK OMAP3430_L1FLATMEMONSTATE_MASK 289b7fc907SRajendra Nayak #define OMAP_MEM2_ONSTATE_MASK OMAP3430_SHAREDL2CACHEFLATONSTATE_MASK 299b7fc907SRajendra Nayak #define OMAP_MEM3_ONSTATE_MASK OMAP3430_L2FLATMEMONSTATE_MASK 309b7fc907SRajendra Nayak #define OMAP_MEM4_ONSTATE_MASK OMAP4430_OCP_NRET_BANK_ONSTATE_MASK 319b7fc907SRajendra Nayak 329b7fc907SRajendra Nayak /* OMAP3 and OMAP4 Memory Retstate Masks (common across all power domains) */ 339b7fc907SRajendra Nayak #define OMAP_MEM0_RETSTATE_MASK OMAP3430_SHAREDL1CACHEFLATRETSTATE_MASK 349b7fc907SRajendra Nayak #define OMAP_MEM1_RETSTATE_MASK OMAP3430_L1FLATMEMRETSTATE_MASK 359b7fc907SRajendra Nayak #define OMAP_MEM2_RETSTATE_MASK OMAP3430_SHAREDL2CACHEFLATRETSTATE_MASK 369b7fc907SRajendra Nayak #define OMAP_MEM3_RETSTATE_MASK OMAP3430_L2FLATMEMRETSTATE_MASK 379b7fc907SRajendra Nayak #define OMAP_MEM4_RETSTATE_MASK OMAP4430_OCP_NRET_BANK_RETSTATE_MASK 389b7fc907SRajendra Nayak 399b7fc907SRajendra Nayak /* OMAP3 and OMAP4 Memory Status bits */ 409b7fc907SRajendra Nayak #define OMAP_MEM0_STATEST_MASK OMAP3430_SHAREDL1CACHEFLATSTATEST_MASK 419b7fc907SRajendra Nayak #define OMAP_MEM1_STATEST_MASK OMAP3430_L1FLATMEMSTATEST_MASK 429b7fc907SRajendra Nayak #define OMAP_MEM2_STATEST_MASK OMAP3430_SHAREDL2CACHEFLATSTATEST_MASK 439b7fc907SRajendra Nayak #define OMAP_MEM3_STATEST_MASK OMAP3430_L2FLATMEMSTATEST_MASK 449b7fc907SRajendra Nayak #define OMAP_MEM4_STATEST_MASK OMAP4430_OCP_NRET_BANK_STATEST_MASK 459b7fc907SRajendra Nayak 469b7fc907SRajendra Nayak /* Common Internal functions used across OMAP rev's*/ omap2_pwrdm_get_mem_bank_onstate_mask(u8 bank)479b7fc907SRajendra Nayaku32 omap2_pwrdm_get_mem_bank_onstate_mask(u8 bank) 489b7fc907SRajendra Nayak { 499b7fc907SRajendra Nayak switch (bank) { 509b7fc907SRajendra Nayak case 0: 519b7fc907SRajendra Nayak return OMAP_MEM0_ONSTATE_MASK; 529b7fc907SRajendra Nayak case 1: 539b7fc907SRajendra Nayak return OMAP_MEM1_ONSTATE_MASK; 549b7fc907SRajendra Nayak case 2: 559b7fc907SRajendra Nayak return OMAP_MEM2_ONSTATE_MASK; 569b7fc907SRajendra Nayak case 3: 579b7fc907SRajendra Nayak return OMAP_MEM3_ONSTATE_MASK; 589b7fc907SRajendra Nayak case 4: 599b7fc907SRajendra Nayak return OMAP_MEM4_ONSTATE_MASK; 609b7fc907SRajendra Nayak default: 619b7fc907SRajendra Nayak WARN_ON(1); /* should never happen */ 629b7fc907SRajendra Nayak return -EEXIST; 639b7fc907SRajendra Nayak } 649b7fc907SRajendra Nayak return 0; 659b7fc907SRajendra Nayak } 669b7fc907SRajendra Nayak omap2_pwrdm_get_mem_bank_retst_mask(u8 bank)679b7fc907SRajendra Nayaku32 omap2_pwrdm_get_mem_bank_retst_mask(u8 bank) 689b7fc907SRajendra Nayak { 699b7fc907SRajendra Nayak switch (bank) { 709b7fc907SRajendra Nayak case 0: 719b7fc907SRajendra Nayak return OMAP_MEM0_RETSTATE_MASK; 729b7fc907SRajendra Nayak case 1: 739b7fc907SRajendra Nayak return OMAP_MEM1_RETSTATE_MASK; 749b7fc907SRajendra Nayak case 2: 759b7fc907SRajendra Nayak return OMAP_MEM2_RETSTATE_MASK; 769b7fc907SRajendra Nayak case 3: 779b7fc907SRajendra Nayak return OMAP_MEM3_RETSTATE_MASK; 789b7fc907SRajendra Nayak case 4: 799b7fc907SRajendra Nayak return OMAP_MEM4_RETSTATE_MASK; 809b7fc907SRajendra Nayak default: 819b7fc907SRajendra Nayak WARN_ON(1); /* should never happen */ 829b7fc907SRajendra Nayak return -EEXIST; 839b7fc907SRajendra Nayak } 849b7fc907SRajendra Nayak return 0; 859b7fc907SRajendra Nayak } 869b7fc907SRajendra Nayak omap2_pwrdm_get_mem_bank_stst_mask(u8 bank)879b7fc907SRajendra Nayaku32 omap2_pwrdm_get_mem_bank_stst_mask(u8 bank) 889b7fc907SRajendra Nayak { 899b7fc907SRajendra Nayak switch (bank) { 909b7fc907SRajendra Nayak case 0: 919b7fc907SRajendra Nayak return OMAP_MEM0_STATEST_MASK; 929b7fc907SRajendra Nayak case 1: 939b7fc907SRajendra Nayak return OMAP_MEM1_STATEST_MASK; 949b7fc907SRajendra Nayak case 2: 959b7fc907SRajendra Nayak return OMAP_MEM2_STATEST_MASK; 969b7fc907SRajendra Nayak case 3: 979b7fc907SRajendra Nayak return OMAP_MEM3_STATEST_MASK; 989b7fc907SRajendra Nayak case 4: 999b7fc907SRajendra Nayak return OMAP_MEM4_STATEST_MASK; 1009b7fc907SRajendra Nayak default: 1019b7fc907SRajendra Nayak WARN_ON(1); /* should never happen */ 1029b7fc907SRajendra Nayak return -EEXIST; 1039b7fc907SRajendra Nayak } 1049b7fc907SRajendra Nayak return 0; 1059b7fc907SRajendra Nayak } 1069b7fc907SRajendra Nayak 107