18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Common powerdomain framework functions 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2010-2011 Texas Instruments, Inc. 68c2ecf20Sopenharmony_ci * Copyright (C) 2010 Nokia Corporation 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Derived from mach-omap2/powerdomain.c written by Paul Walmsley 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/errno.h> 128c2ecf20Sopenharmony_ci#include <linux/kernel.h> 138c2ecf20Sopenharmony_ci#include <linux/bug.h> 148c2ecf20Sopenharmony_ci#include "pm.h" 158c2ecf20Sopenharmony_ci#include "cm.h" 168c2ecf20Sopenharmony_ci#include "cm-regbits-34xx.h" 178c2ecf20Sopenharmony_ci#include "prm-regbits-34xx.h" 188c2ecf20Sopenharmony_ci#include "prm-regbits-44xx.h" 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * OMAP3 and OMAP4 specific register bit initialisations 228c2ecf20Sopenharmony_ci * Notice that the names here are not according to each power 238c2ecf20Sopenharmony_ci * domain but the bit mapping used applies to all of them 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci/* OMAP3 and OMAP4 Memory Onstate Masks (common across all power domains) */ 268c2ecf20Sopenharmony_ci#define OMAP_MEM0_ONSTATE_MASK OMAP3430_SHAREDL1CACHEFLATONSTATE_MASK 278c2ecf20Sopenharmony_ci#define OMAP_MEM1_ONSTATE_MASK OMAP3430_L1FLATMEMONSTATE_MASK 288c2ecf20Sopenharmony_ci#define OMAP_MEM2_ONSTATE_MASK OMAP3430_SHAREDL2CACHEFLATONSTATE_MASK 298c2ecf20Sopenharmony_ci#define OMAP_MEM3_ONSTATE_MASK OMAP3430_L2FLATMEMONSTATE_MASK 308c2ecf20Sopenharmony_ci#define OMAP_MEM4_ONSTATE_MASK OMAP4430_OCP_NRET_BANK_ONSTATE_MASK 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* OMAP3 and OMAP4 Memory Retstate Masks (common across all power domains) */ 338c2ecf20Sopenharmony_ci#define OMAP_MEM0_RETSTATE_MASK OMAP3430_SHAREDL1CACHEFLATRETSTATE_MASK 348c2ecf20Sopenharmony_ci#define OMAP_MEM1_RETSTATE_MASK OMAP3430_L1FLATMEMRETSTATE_MASK 358c2ecf20Sopenharmony_ci#define OMAP_MEM2_RETSTATE_MASK OMAP3430_SHAREDL2CACHEFLATRETSTATE_MASK 368c2ecf20Sopenharmony_ci#define OMAP_MEM3_RETSTATE_MASK OMAP3430_L2FLATMEMRETSTATE_MASK 378c2ecf20Sopenharmony_ci#define OMAP_MEM4_RETSTATE_MASK OMAP4430_OCP_NRET_BANK_RETSTATE_MASK 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* OMAP3 and OMAP4 Memory Status bits */ 408c2ecf20Sopenharmony_ci#define OMAP_MEM0_STATEST_MASK OMAP3430_SHAREDL1CACHEFLATSTATEST_MASK 418c2ecf20Sopenharmony_ci#define OMAP_MEM1_STATEST_MASK OMAP3430_L1FLATMEMSTATEST_MASK 428c2ecf20Sopenharmony_ci#define OMAP_MEM2_STATEST_MASK OMAP3430_SHAREDL2CACHEFLATSTATEST_MASK 438c2ecf20Sopenharmony_ci#define OMAP_MEM3_STATEST_MASK OMAP3430_L2FLATMEMSTATEST_MASK 448c2ecf20Sopenharmony_ci#define OMAP_MEM4_STATEST_MASK OMAP4430_OCP_NRET_BANK_STATEST_MASK 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* Common Internal functions used across OMAP rev's*/ 478c2ecf20Sopenharmony_ciu32 omap2_pwrdm_get_mem_bank_onstate_mask(u8 bank) 488c2ecf20Sopenharmony_ci{ 498c2ecf20Sopenharmony_ci switch (bank) { 508c2ecf20Sopenharmony_ci case 0: 518c2ecf20Sopenharmony_ci return OMAP_MEM0_ONSTATE_MASK; 528c2ecf20Sopenharmony_ci case 1: 538c2ecf20Sopenharmony_ci return OMAP_MEM1_ONSTATE_MASK; 548c2ecf20Sopenharmony_ci case 2: 558c2ecf20Sopenharmony_ci return OMAP_MEM2_ONSTATE_MASK; 568c2ecf20Sopenharmony_ci case 3: 578c2ecf20Sopenharmony_ci return OMAP_MEM3_ONSTATE_MASK; 588c2ecf20Sopenharmony_ci case 4: 598c2ecf20Sopenharmony_ci return OMAP_MEM4_ONSTATE_MASK; 608c2ecf20Sopenharmony_ci default: 618c2ecf20Sopenharmony_ci WARN_ON(1); /* should never happen */ 628c2ecf20Sopenharmony_ci return -EEXIST; 638c2ecf20Sopenharmony_ci } 648c2ecf20Sopenharmony_ci return 0; 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ciu32 omap2_pwrdm_get_mem_bank_retst_mask(u8 bank) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci switch (bank) { 708c2ecf20Sopenharmony_ci case 0: 718c2ecf20Sopenharmony_ci return OMAP_MEM0_RETSTATE_MASK; 728c2ecf20Sopenharmony_ci case 1: 738c2ecf20Sopenharmony_ci return OMAP_MEM1_RETSTATE_MASK; 748c2ecf20Sopenharmony_ci case 2: 758c2ecf20Sopenharmony_ci return OMAP_MEM2_RETSTATE_MASK; 768c2ecf20Sopenharmony_ci case 3: 778c2ecf20Sopenharmony_ci return OMAP_MEM3_RETSTATE_MASK; 788c2ecf20Sopenharmony_ci case 4: 798c2ecf20Sopenharmony_ci return OMAP_MEM4_RETSTATE_MASK; 808c2ecf20Sopenharmony_ci default: 818c2ecf20Sopenharmony_ci WARN_ON(1); /* should never happen */ 828c2ecf20Sopenharmony_ci return -EEXIST; 838c2ecf20Sopenharmony_ci } 848c2ecf20Sopenharmony_ci return 0; 858c2ecf20Sopenharmony_ci} 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ciu32 omap2_pwrdm_get_mem_bank_stst_mask(u8 bank) 888c2ecf20Sopenharmony_ci{ 898c2ecf20Sopenharmony_ci switch (bank) { 908c2ecf20Sopenharmony_ci case 0: 918c2ecf20Sopenharmony_ci return OMAP_MEM0_STATEST_MASK; 928c2ecf20Sopenharmony_ci case 1: 938c2ecf20Sopenharmony_ci return OMAP_MEM1_STATEST_MASK; 948c2ecf20Sopenharmony_ci case 2: 958c2ecf20Sopenharmony_ci return OMAP_MEM2_STATEST_MASK; 968c2ecf20Sopenharmony_ci case 3: 978c2ecf20Sopenharmony_ci return OMAP_MEM3_STATEST_MASK; 988c2ecf20Sopenharmony_ci case 4: 998c2ecf20Sopenharmony_ci return OMAP_MEM4_STATEST_MASK; 1008c2ecf20Sopenharmony_ci default: 1018c2ecf20Sopenharmony_ci WARN_ON(1); /* should never happen */ 1028c2ecf20Sopenharmony_ci return -EEXIST; 1038c2ecf20Sopenharmony_ci } 1048c2ecf20Sopenharmony_ci return 0; 1058c2ecf20Sopenharmony_ci} 1068c2ecf20Sopenharmony_ci 107