blob: 1b93d31fe8e9092045dc1fe5aef01f87ed5df755 [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>
Santosh Shilimkarfcf6efa2010-06-16 22:19:47 +053025#include <mach/omap-wakeupgen.h>
Tony Lindgren4e653312011-11-10 22:45:17 +010026
27#include "common.h"
Santosh Shilimkar501f0c72011-01-01 19:56:04 +053028#include "omap4-sar-layout.h"
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070029
30#ifdef CONFIG_CACHE_L2X0
Santosh Shilimkar02afe8a2011-03-03 18:03:25 +053031static void __iomem *l2cache_base;
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070032#endif
33
Santosh Shilimkar501f0c72011-01-01 19:56:04 +053034static void __iomem *sar_ram_base;
35
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070036void __init gic_init_irq(void)
37{
Marc Zyngierab65be22011-11-15 17:22:45 +000038 void __iomem *omap_irq_base;
39 void __iomem *gic_dist_base_addr;
40
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070041 /* Static mapping, never released */
42 gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K);
43 BUG_ON(!gic_dist_base_addr);
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070044
45 /* Static mapping, never released */
Tony Lindgren741e3a82011-05-17 03:51:26 -070046 omap_irq_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512);
47 BUG_ON(!omap_irq_base);
Russell Kingb580b892010-12-04 15:55:14 +000048
Santosh Shilimkarfcf6efa2010-06-16 22:19:47 +053049 omap_wakeupgen_init();
50
Tony Lindgren741e3a82011-05-17 03:51:26 -070051 gic_init(0, 29, gic_dist_base_addr, omap_irq_base);
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070052}
53
54#ifdef CONFIG_CACHE_L2X0
Santosh Shilimkar4e803c42010-07-31 21:40:10 +053055
Santosh Shilimkar02afe8a2011-03-03 18:03:25 +053056void __iomem *omap4_get_l2cache_base(void)
57{
58 return l2cache_base;
59}
60
Santosh Shilimkar4e803c42010-07-31 21:40:10 +053061static void omap4_l2x0_disable(void)
62{
63 /* Disable PL310 L2 Cache controller */
64 omap_smc1(0x102, 0x0);
65}
66
Santosh Shilimkar4bdb1572011-02-22 10:00:44 +010067static void omap4_l2x0_set_debug(unsigned long val)
68{
69 /* Program PL310 L2 Cache controller debug register */
70 omap_smc1(0x100, val);
71}
72
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070073static int __init omap_l2_cache_init(void)
74{
Santosh Shilimkar1773e602010-11-19 23:01:03 +053075 u32 aux_ctrl = 0;
76
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070077 /*
78 * To avoid code running on other OMAPs in
79 * multi-omap builds
80 */
81 if (!cpu_is_omap44xx())
82 return -ENODEV;
83
84 /* Static mapping, never released */
85 l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K);
Santosh Shilimkar0db18032011-03-03 17:36:52 +053086 if (WARN_ON(!l2cache_base))
87 return -ENOMEM;
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070088
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070089 /*
Santosh Shilimkara777b722010-09-16 18:44:47 +053090 * 16-way associativity, parity disabled
91 * Way size - 32KB (es1.0)
92 * Way size - 64KB (es2.0 +)
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -070093 */
Santosh Shilimkar1773e602010-11-19 23:01:03 +053094 aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) |
95 (0x1 << 25) |
96 (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
97 (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT));
98
Mans Rullgard11e02642010-11-19 23:01:04 +053099 if (omap_rev() == OMAP4430_REV_ES1_0) {
Santosh Shilimkar1773e602010-11-19 23:01:03 +0530100 aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT;
Mans Rullgard11e02642010-11-19 23:01:04 +0530101 } else {
102 aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) |
Santosh Shilimkarb0f20ff2010-11-19 23:01:05 +0530103 (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) |
Mans Rullgard11e02642010-11-19 23:01:04 +0530104 (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
Santosh Shilimkarb89cd712010-11-19 23:01:06 +0530105 (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) |
106 (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT));
Mans Rullgard11e02642010-11-19 23:01:04 +0530107 }
108 if (omap_rev() != OMAP4430_REV_ES1_0)
109 omap_smc1(0x109, aux_ctrl);
110
111 /* Enable PL310 L2 Cache controller */
112 omap_smc1(0x102, 0x1);
Santosh Shilimkar1773e602010-11-19 23:01:03 +0530113
114 l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK);
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -0700115
Santosh Shilimkar4e803c42010-07-31 21:40:10 +0530116 /*
117 * Override default outer_cache.disable with a OMAP4
118 * specific one
119 */
120 outer_cache.disable = omap4_l2x0_disable;
Santosh Shilimkar4bdb1572011-02-22 10:00:44 +0100121 outer_cache.set_debug = omap4_l2x0_set_debug;
Santosh Shilimkar4e803c42010-07-31 21:40:10 +0530122
Santosh Shilimkarfbc9be12010-05-14 12:05:26 -0700123 return 0;
124}
125early_initcall(omap_l2_cache_init);
126#endif
Santosh Shilimkar501f0c72011-01-01 19:56:04 +0530127
128void __iomem *omap4_get_sar_ram_base(void)
129{
130 return sar_ram_base;
131}
132
133/*
134 * SAR RAM used to save and restore the HW
135 * context in low power modes
136 */
137static int __init omap4_sar_ram_init(void)
138{
139 /*
140 * To avoid code running on other OMAPs in
141 * multi-omap builds
142 */
143 if (!cpu_is_omap44xx())
144 return -ENOMEM;
145
146 /* Static mapping, never released */
147 sar_ram_base = ioremap(OMAP44XX_SAR_RAM_BASE, SZ_16K);
148 if (WARN_ON(!sar_ram_base))
149 return -ENOMEM;
150
151 return 0;
152}
153early_initcall(omap4_sar_ram_init);