blob: beecfdd56ea31c7d2621474475be046a2b3551a3 [file] [log] [blame]
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -07001/*
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
Tony Lindgren741e3a82011-05-17 03:51:26 -070022#include <plat/irqs.h>
23
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070024#include <mach/hardware.h>
Tony Lindgren4e653312011-11-10 22:45:17 +010025
26#include "common.h"
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070027
28#ifdef CONFIG_CACHE_L2X0
29void __iomem *l2cache_base;
30#endif
31
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070032void __init gic_init_irq(void)
33{
Marc Zyngierab65be22011-11-15 17:22:45 +000034 void __iomem *omap_irq_base;
35 void __iomem *gic_dist_base_addr;
36
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070037 /* Static mapping, never released */
38 gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K);
39 BUG_ON(!gic_dist_base_addr);
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070040
41 /* Static mapping, never released */
Tony Lindgren741e3a82011-05-17 03:51:26 -070042 omap_irq_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512);
43 BUG_ON(!omap_irq_base);
Russell Kingb580b892010-12-04 15:55:14 +000044
Tony Lindgren741e3a82011-05-17 03:51:26 -070045 gic_init(0, 29, gic_dist_base_addr, omap_irq_base);
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070046}
47
48#ifdef CONFIG_CACHE_L2X0
Santosh Shilimkar4e803c42010-07-31 21:40:10 +053049
50static void omap4_l2x0_disable(void)
51{
52 /* Disable PL310 L2 Cache controller */
53 omap_smc1(0x102, 0x0);
54}
55
Santosh Shilimkar4bdb1572011-02-22 10:00:44 +010056static void omap4_l2x0_set_debug(unsigned long val)
57{
58 /* Program PL310 L2 Cache controller debug register */
59 omap_smc1(0x100, val);
60}
61
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070062static int __init omap_l2_cache_init(void)
63{
Santosh Shilimkar1773e602010-11-19 23:01:03 +053064 u32 aux_ctrl = 0;
65
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070066 /*
67 * To avoid code running on other OMAPs in
68 * multi-omap builds
69 */
70 if (!cpu_is_omap44xx())
71 return -ENODEV;
72
73 /* Static mapping, never released */
74 l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
75 BUG_ON(!l2cache_base);
76
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070077 /*
Santosh Shilimkara777b722010-09-16 18:44:47 +053078 * 16-way associativity, parity disabled
79 * Way size - 32KB (es1.0)
80 * Way size - 64KB (es2.0 +)
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070081 */
Santosh Shilimkar1773e602010-11-19 23:01:03 +053082 aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) |
83 (0x1 << 25) |
84 (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
85 (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT));
86
Mans Rullgard11e02642010-11-19 23:01:04 +053087 if (omap_rev() == OMAP4430_REV_ES1_0) {
Santosh Shilimkar1773e602010-11-19 23:01:03 +053088 aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT;
Mans Rullgard11e02642010-11-19 23:01:04 +053089 } else {
90 aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) |
Santosh Shilimkarb0f20ff2010-11-19 23:01:05 +053091 (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) |
Mans Rullgard11e02642010-11-19 23:01:04 +053092 (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
Santosh Shilimkarb89cd712010-11-19 23:01:06 +053093 (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) |
94 (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT));
Mans Rullgard11e02642010-11-19 23:01:04 +053095 }
96 if (omap_rev() != OMAP4430_REV_ES1_0)
97 omap_smc1(0x109, aux_ctrl);
98
99 /* Enable PL310 L2 Cache controller */
100 omap_smc1(0x102, 0x1);
Santosh Shilimkar1773e602010-11-19 23:01:03 +0530101
102 l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK);
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -0700103
Santosh Shilimkar4e803c42010-07-31 21:40:10 +0530104 /*
105 * Override default outer_cache.disable with a OMAP4
106 * specific one
107 */
108 outer_cache.disable = omap4_l2x0_disable;
Santosh Shilimkar4bdb1572011-02-22 10:00:44 +0100109 outer_cache.set_debug = omap4_l2x0_set_debug;
Santosh Shilimkar4e803c42010-07-31 21:40:10 +0530110
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -0700111 return 0;
112}
113early_initcall(omap_l2_cache_init);
114#endif