162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Common powerdomain framework functions 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2010-2011 Texas Instruments, Inc. 662306a36Sopenharmony_ci * Copyright (C) 2010 Nokia Corporation 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Derived from mach-omap2/powerdomain.c written by Paul Walmsley 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/errno.h> 1262306a36Sopenharmony_ci#include <linux/kernel.h> 1362306a36Sopenharmony_ci#include <linux/bug.h> 1462306a36Sopenharmony_ci#include "pm.h" 1562306a36Sopenharmony_ci#include "cm.h" 1662306a36Sopenharmony_ci#include "cm-regbits-34xx.h" 1762306a36Sopenharmony_ci#include "prm-regbits-34xx.h" 1862306a36Sopenharmony_ci#include "prm-regbits-44xx.h" 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/* 2162306a36Sopenharmony_ci * OMAP3 and OMAP4 specific register bit initialisations 2262306a36Sopenharmony_ci * Notice that the names here are not according to each power 2362306a36Sopenharmony_ci * domain but the bit mapping used applies to all of them 2462306a36Sopenharmony_ci */ 2562306a36Sopenharmony_ci/* OMAP3 and OMAP4 Memory Onstate Masks (common across all power domains) */ 2662306a36Sopenharmony_ci#define OMAP_MEM0_ONSTATE_MASK OMAP3430_SHAREDL1CACHEFLATONSTATE_MASK 2762306a36Sopenharmony_ci#define OMAP_MEM1_ONSTATE_MASK OMAP3430_L1FLATMEMONSTATE_MASK 2862306a36Sopenharmony_ci#define OMAP_MEM2_ONSTATE_MASK OMAP3430_SHAREDL2CACHEFLATONSTATE_MASK 2962306a36Sopenharmony_ci#define OMAP_MEM3_ONSTATE_MASK OMAP3430_L2FLATMEMONSTATE_MASK 3062306a36Sopenharmony_ci#define OMAP_MEM4_ONSTATE_MASK OMAP4430_OCP_NRET_BANK_ONSTATE_MASK 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci/* OMAP3 and OMAP4 Memory Retstate Masks (common across all power domains) */ 3362306a36Sopenharmony_ci#define OMAP_MEM0_RETSTATE_MASK OMAP3430_SHAREDL1CACHEFLATRETSTATE_MASK 3462306a36Sopenharmony_ci#define OMAP_MEM1_RETSTATE_MASK OMAP3430_L1FLATMEMRETSTATE_MASK 3562306a36Sopenharmony_ci#define OMAP_MEM2_RETSTATE_MASK OMAP3430_SHAREDL2CACHEFLATRETSTATE_MASK 3662306a36Sopenharmony_ci#define OMAP_MEM3_RETSTATE_MASK OMAP3430_L2FLATMEMRETSTATE_MASK 3762306a36Sopenharmony_ci#define OMAP_MEM4_RETSTATE_MASK OMAP4430_OCP_NRET_BANK_RETSTATE_MASK 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci/* OMAP3 and OMAP4 Memory Status bits */ 4062306a36Sopenharmony_ci#define OMAP_MEM0_STATEST_MASK OMAP3430_SHAREDL1CACHEFLATSTATEST_MASK 4162306a36Sopenharmony_ci#define OMAP_MEM1_STATEST_MASK OMAP3430_L1FLATMEMSTATEST_MASK 4262306a36Sopenharmony_ci#define OMAP_MEM2_STATEST_MASK OMAP3430_SHAREDL2CACHEFLATSTATEST_MASK 4362306a36Sopenharmony_ci#define OMAP_MEM3_STATEST_MASK OMAP3430_L2FLATMEMSTATEST_MASK 4462306a36Sopenharmony_ci#define OMAP_MEM4_STATEST_MASK OMAP4430_OCP_NRET_BANK_STATEST_MASK 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci/* Common Internal functions used across OMAP rev's*/ 4762306a36Sopenharmony_ciu32 omap2_pwrdm_get_mem_bank_onstate_mask(u8 bank) 4862306a36Sopenharmony_ci{ 4962306a36Sopenharmony_ci switch (bank) { 5062306a36Sopenharmony_ci case 0: 5162306a36Sopenharmony_ci return OMAP_MEM0_ONSTATE_MASK; 5262306a36Sopenharmony_ci case 1: 5362306a36Sopenharmony_ci return OMAP_MEM1_ONSTATE_MASK; 5462306a36Sopenharmony_ci case 2: 5562306a36Sopenharmony_ci return OMAP_MEM2_ONSTATE_MASK; 5662306a36Sopenharmony_ci case 3: 5762306a36Sopenharmony_ci return OMAP_MEM3_ONSTATE_MASK; 5862306a36Sopenharmony_ci case 4: 5962306a36Sopenharmony_ci return OMAP_MEM4_ONSTATE_MASK; 6062306a36Sopenharmony_ci default: 6162306a36Sopenharmony_ci WARN_ON(1); /* should never happen */ 6262306a36Sopenharmony_ci return -EEXIST; 6362306a36Sopenharmony_ci } 6462306a36Sopenharmony_ci return 0; 6562306a36Sopenharmony_ci} 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ciu32 omap2_pwrdm_get_mem_bank_retst_mask(u8 bank) 6862306a36Sopenharmony_ci{ 6962306a36Sopenharmony_ci switch (bank) { 7062306a36Sopenharmony_ci case 0: 7162306a36Sopenharmony_ci return OMAP_MEM0_RETSTATE_MASK; 7262306a36Sopenharmony_ci case 1: 7362306a36Sopenharmony_ci return OMAP_MEM1_RETSTATE_MASK; 7462306a36Sopenharmony_ci case 2: 7562306a36Sopenharmony_ci return OMAP_MEM2_RETSTATE_MASK; 7662306a36Sopenharmony_ci case 3: 7762306a36Sopenharmony_ci return OMAP_MEM3_RETSTATE_MASK; 7862306a36Sopenharmony_ci case 4: 7962306a36Sopenharmony_ci return OMAP_MEM4_RETSTATE_MASK; 8062306a36Sopenharmony_ci default: 8162306a36Sopenharmony_ci WARN_ON(1); /* should never happen */ 8262306a36Sopenharmony_ci return -EEXIST; 8362306a36Sopenharmony_ci } 8462306a36Sopenharmony_ci return 0; 8562306a36Sopenharmony_ci} 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ciu32 omap2_pwrdm_get_mem_bank_stst_mask(u8 bank) 8862306a36Sopenharmony_ci{ 8962306a36Sopenharmony_ci switch (bank) { 9062306a36Sopenharmony_ci case 0: 9162306a36Sopenharmony_ci return OMAP_MEM0_STATEST_MASK; 9262306a36Sopenharmony_ci case 1: 9362306a36Sopenharmony_ci return OMAP_MEM1_STATEST_MASK; 9462306a36Sopenharmony_ci case 2: 9562306a36Sopenharmony_ci return OMAP_MEM2_STATEST_MASK; 9662306a36Sopenharmony_ci case 3: 9762306a36Sopenharmony_ci return OMAP_MEM3_STATEST_MASK; 9862306a36Sopenharmony_ci case 4: 9962306a36Sopenharmony_ci return OMAP_MEM4_STATEST_MASK; 10062306a36Sopenharmony_ci default: 10162306a36Sopenharmony_ci WARN_ON(1); /* should never happen */ 10262306a36Sopenharmony_ci return -EEXIST; 10362306a36Sopenharmony_ci } 10462306a36Sopenharmony_ci return 0; 10562306a36Sopenharmony_ci} 10662306a36Sopenharmony_ci 107