18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (C) 2012-2014 Broadcom Corporation 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or 58c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License as 68c2ecf20Sopenharmony_ci * published by the Free Software Foundation version 2. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This program is distributed "as is" WITHOUT ANY WARRANTY of any 98c2ecf20Sopenharmony_ci * kind, whether express or implied; without even the implied warranty 108c2ecf20Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 118c2ecf20Sopenharmony_ci * GNU General Public License for more details. 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/init.h> 168c2ecf20Sopenharmony_ci#include <linux/printk.h> 178c2ecf20Sopenharmony_ci#include <asm/hardware/cache-l2x0.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include "bcm_kona_smc.h" 208c2ecf20Sopenharmony_ci#include "kona_l2_cache.h" 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_civoid __init kona_l2_cache_init(void) 238c2ecf20Sopenharmony_ci{ 248c2ecf20Sopenharmony_ci unsigned int result; 258c2ecf20Sopenharmony_ci int ret; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci ret = bcm_kona_smc_init(); 288c2ecf20Sopenharmony_ci if (ret) { 298c2ecf20Sopenharmony_ci pr_info("Secure API not available (%d). Skipping L2 init.\n", 308c2ecf20Sopenharmony_ci ret); 318c2ecf20Sopenharmony_ci return; 328c2ecf20Sopenharmony_ci } 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci result = bcm_kona_smc(SSAPI_ENABLE_L2_CACHE, 0, 0, 0, 0); 358c2ecf20Sopenharmony_ci if (result != SEC_ROM_RET_OK) { 368c2ecf20Sopenharmony_ci pr_err("Secure Monitor call failed (%u)! Skipping L2 init.\n", 378c2ecf20Sopenharmony_ci result); 388c2ecf20Sopenharmony_ci return; 398c2ecf20Sopenharmony_ci } 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci /* 428c2ecf20Sopenharmony_ci * The aux_val and aux_mask have no effect since L2 cache is already 438c2ecf20Sopenharmony_ci * enabled. Pass 0s for aux_val and 1s for aux_mask for default value. 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_ci ret = l2x0_of_init(0, ~0); 468c2ecf20Sopenharmony_ci if (ret) 478c2ecf20Sopenharmony_ci pr_err("Couldn't enable L2 cache: %d\n", ret); 488c2ecf20Sopenharmony_ci} 49