Commit | Line | Data |
---|---|---|
fbc9be10 SS |
1 | /* |
2 | * OMAP4 specific common source file. | |
3 | * | |
4 | * Copyright (C) 2010 Texas Instruments, Inc. | |
5 | * Author: | |
6 | * Santosh Shilimkar <santosh.shilimkar@ti.com> | |
7 | * | |
8 | * | |
9 | * This program is free software,you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | */ | |
13 | ||
14 | #include <linux/kernel.h> | |
15 | #include <linux/init.h> | |
16 | #include <linux/io.h> | |
17 | #include <linux/platform_device.h> | |
18 | ||
19 | #include <asm/hardware/gic.h> | |
20 | #include <asm/hardware/cache-l2x0.h> | |
21 | ||
741e3a89 TL |
22 | #include <plat/irqs.h> |
23 | ||
fbc9be10 | 24 | #include <mach/hardware.h> |
4e65331c TL |
25 | |
26 | #include "common.h" | |
fbc9be10 SS |
27 | |
28 | #ifdef CONFIG_CACHE_L2X0 | |
02afe8a7 | 29 | static void __iomem *l2cache_base; |
fbc9be10 SS |
30 | #endif |
31 | ||
fbc9be10 SS |
32 | void __init gic_init_irq(void) |
33 | { | |
ab65be26 MZ |
34 | void __iomem *omap_irq_base; |
35 | void __iomem *gic_dist_base_addr; | |
36 | ||
fbc9be10 SS |
37 | /* Static mapping, never released */ |
38 | gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K); | |
39 | BUG_ON(!gic_dist_base_addr); | |
fbc9be10 SS |
40 | |
41 | /* Static mapping, never released */ | |
741e3a89 TL |
42 | omap_irq_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512); |
43 | BUG_ON(!omap_irq_base); | |
b580b899 | 44 | |
741e3a89 | 45 | gic_init(0, 29, gic_dist_base_addr, omap_irq_base); |
fbc9be10 SS |
46 | } |
47 | ||
48 | #ifdef CONFIG_CACHE_L2X0 | |
4e803c40 | 49 | |
02afe8a7 SS |
50 | void __iomem *omap4_get_l2cache_base(void) |
51 | { | |
52 | return l2cache_base; | |
53 | } | |
54 | ||
4e803c40 SS |
55 | static void omap4_l2x0_disable(void) |
56 | { | |
57 | /* Disable PL310 L2 Cache controller */ | |
58 | omap_smc1(0x102, 0x0); | |
59 | } | |
60 | ||
4bdb1577 SS |
61 | static void omap4_l2x0_set_debug(unsigned long val) |
62 | { | |
63 | /* Program PL310 L2 Cache controller debug register */ | |
64 | omap_smc1(0x100, val); | |
65 | } | |
66 | ||
fbc9be10 SS |
67 | static int __init omap_l2_cache_init(void) |
68 | { | |
1773e60a SS |
69 | u32 aux_ctrl = 0; |
70 | ||
fbc9be10 SS |
71 | /* |
72 | * To avoid code running on other OMAPs in | |
73 | * multi-omap builds | |
74 | */ | |
75 | if (!cpu_is_omap44xx()) | |
76 | return -ENODEV; | |
77 | ||
78 | /* Static mapping, never released */ | |
79 | l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K); | |
0db1803e SS |
80 | if (WARN_ON(!l2cache_base)) |
81 | return -ENOMEM; | |
fbc9be10 | 82 | |
fbc9be10 | 83 | /* |
a777b727 SS |
84 | * 16-way associativity, parity disabled |
85 | * Way size - 32KB (es1.0) | |
86 | * Way size - 64KB (es2.0 +) | |
fbc9be10 | 87 | */ |
1773e60a SS |
88 | aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) | |
89 | (0x1 << 25) | | |
90 | (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) | | |
91 | (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT)); | |
92 | ||
11e02640 | 93 | if (omap_rev() == OMAP4430_REV_ES1_0) { |
1773e60a | 94 | aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT; |
11e02640 MR |
95 | } else { |
96 | aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | | |
b0f20ff9 | 97 | (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | |
11e02640 | 98 | (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) | |
b89cd71a SS |
99 | (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) | |
100 | (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT)); | |
11e02640 MR |
101 | } |
102 | if (omap_rev() != OMAP4430_REV_ES1_0) | |
103 | omap_smc1(0x109, aux_ctrl); | |
104 | ||
105 | /* Enable PL310 L2 Cache controller */ | |
106 | omap_smc1(0x102, 0x1); | |
1773e60a SS |
107 | |
108 | l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK); | |
fbc9be10 | 109 | |
4e803c40 SS |
110 | /* |
111 | * Override default outer_cache.disable with a OMAP4 | |
112 | * specific one | |
113 | */ | |
114 | outer_cache.disable = omap4_l2x0_disable; | |
4bdb1577 | 115 | outer_cache.set_debug = omap4_l2x0_set_debug; |
4e803c40 | 116 | |
fbc9be10 SS |
117 | return 0; |
118 | } | |
119 | early_initcall(omap_l2_cache_init); | |
120 | #endif |