xref: /OK3568_Linux_fs/kernel/arch/arm/mach-bcm/kona_l2_cache.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (C) 2012-2014 Broadcom Corporation
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or
5*4882a593Smuzhiyun  * modify it under the terms of the GNU General Public License as
6*4882a593Smuzhiyun  * published by the Free Software Foundation version 2.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9*4882a593Smuzhiyun  * kind, whether express or implied; without even the implied warranty
10*4882a593Smuzhiyun  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11*4882a593Smuzhiyun  * GNU General Public License for more details.
12*4882a593Smuzhiyun  */
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #include <linux/init.h>
16*4882a593Smuzhiyun #include <linux/printk.h>
17*4882a593Smuzhiyun #include <asm/hardware/cache-l2x0.h>
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #include "bcm_kona_smc.h"
20*4882a593Smuzhiyun #include "kona_l2_cache.h"
21*4882a593Smuzhiyun 
kona_l2_cache_init(void)22*4882a593Smuzhiyun void __init kona_l2_cache_init(void)
23*4882a593Smuzhiyun {
24*4882a593Smuzhiyun 	unsigned int result;
25*4882a593Smuzhiyun 	int ret;
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun 	ret = bcm_kona_smc_init();
28*4882a593Smuzhiyun 	if (ret) {
29*4882a593Smuzhiyun 		pr_info("Secure API not available (%d). Skipping L2 init.\n",
30*4882a593Smuzhiyun 			ret);
31*4882a593Smuzhiyun 		return;
32*4882a593Smuzhiyun 	}
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun 	result = bcm_kona_smc(SSAPI_ENABLE_L2_CACHE, 0, 0, 0, 0);
35*4882a593Smuzhiyun 	if (result != SEC_ROM_RET_OK) {
36*4882a593Smuzhiyun 		pr_err("Secure Monitor call failed (%u)! Skipping L2 init.\n",
37*4882a593Smuzhiyun 			result);
38*4882a593Smuzhiyun 		return;
39*4882a593Smuzhiyun 	}
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun 	/*
42*4882a593Smuzhiyun 	 * The aux_val and aux_mask have no effect since L2 cache is already
43*4882a593Smuzhiyun 	 * enabled.  Pass 0s for aux_val and 1s for aux_mask for default value.
44*4882a593Smuzhiyun 	 */
45*4882a593Smuzhiyun 	ret = l2x0_of_init(0, ~0);
46*4882a593Smuzhiyun 	if (ret)
47*4882a593Smuzhiyun 		pr_err("Couldn't enable L2 cache: %d\n", ret);
48*4882a593Smuzhiyun }
49