~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to arch/arm/mach-omap2/omap4-common.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <mach/hardware.h>
23
23
#include <mach/omap4-common.h>
24
24
 
 
25
#include "omap4-sar-layout.h"
 
26
 
25
27
#ifdef CONFIG_CACHE_L2X0
 
28
#define L2X0_POR_OFFSET_VALUE           0x9
26
29
void __iomem *l2cache_base;
27
30
#endif
28
31
 
29
32
void __iomem *gic_dist_base_addr;
30
 
 
 
33
static void __iomem *gic_cpu_base;
 
34
static void __iomem *sar_ram_base;
 
35
 
 
36
void __iomem *omap4_get_gic_dist_base(void)
 
37
{
 
38
        return gic_dist_base_addr;
 
39
}
 
40
 
 
41
void __iomem *omap4_get_gic_cpu_base(void)
 
42
{
 
43
        return gic_cpu_base;
 
44
}
31
45
 
32
46
void __init gic_init_irq(void)
33
47
{
34
 
        void __iomem *gic_cpu_base;
35
48
 
36
49
        /* Static mapping, never released */
37
50
        gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K);
46
59
 
47
60
#ifdef CONFIG_CACHE_L2X0
48
61
 
 
62
void __iomem *omap4_get_l2cache_base(void)
 
63
{
 
64
        return l2cache_base;
 
65
}
 
66
 
49
67
static void omap4_l2x0_disable(void)
50
68
{
51
69
        /* Disable PL310 L2 Cache controller */
61
79
static int __init omap_l2_cache_init(void)
62
80
{
63
81
        u32 aux_ctrl = 0;
 
82
        u32 por_ctrl = 0;
 
83
        u32 lockdown = 0;
64
84
 
65
85
        /*
66
86
         * To avoid code running on other OMAPs in
78
98
         * Way size - 32KB (es1.0)
79
99
         * Way size - 64KB (es2.0 +)
80
100
         */
81
 
        aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) |
82
 
                        (0x1 << 25) |
83
 
                        (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) |
84
 
                        (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT));
 
101
        aux_ctrl = readl_relaxed(l2cache_base + L2X0_AUX_CTRL);
85
102
 
86
103
        if (omap_rev() == OMAP4430_REV_ES1_0) {
87
104
                aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT;
88
 
        } else {
89
 
                aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) |
90
 
                        (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) |
91
 
                        (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
92
 
                        (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) |
93
 
                        (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT));
94
 
        }
95
 
        if (omap_rev() != OMAP4430_REV_ES1_0)
96
 
                omap_smc1(0x109, aux_ctrl);
97
 
 
 
105
                goto skip_aux_por_api;
 
106
        }
 
107
 
 
108
        /*
 
109
         * Drop instruction prefetch hint since it degrades the
 
110
         * the performance.
 
111
         */
 
112
        aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) |
 
113
                (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) |
 
114
                (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) |
 
115
                (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT));
 
116
 
 
117
        omap_smc1(0x109, aux_ctrl);
 
118
 
 
119
        /* Setup POR Control register */
 
120
        por_ctrl = readl_relaxed(l2cache_base + L2X0_PREFETCH_CTRL);
 
121
 
 
122
        /*
 
123
         * Double linefill is available only on OMAP4460 L2X0.
 
124
         * Undocumented bit 25 is set for better performance.
 
125
         */
 
126
        if (cpu_is_omap446x())
 
127
                por_ctrl |= ((1 << L2X0_PREFETCH_DATA_PREFETCH_SHIFT) |
 
128
                        (1 << L2X0_PREFETCH_DOUBLE_LINEFILL_SHIFT) |
 
129
                        (1 << 25));
 
130
 
 
131
        if (cpu_is_omap446x() || (omap_rev() >= OMAP4430_REV_ES2_2)) {
 
132
                por_ctrl |= L2X0_POR_OFFSET_VALUE;
 
133
                omap_smc1(0x113, por_ctrl);
 
134
        }
 
135
 
 
136
        if (cpu_is_omap446x()) {
 
137
                writel_relaxed(0xa5a5, l2cache_base + 0x900);
 
138
                writel_relaxed(0xa5a5, l2cache_base + 0x908);
 
139
                writel_relaxed(0xa5a5, l2cache_base + 0x904);
 
140
                writel_relaxed(0xa5a5, l2cache_base + 0x90C);
 
141
        }
 
142
 
 
143
        /*
 
144
         * FIXME: Temporary WA for OMAP4460 stability issue.
 
145
         * Lock-down specific L2 cache ways which  makes effective
 
146
         * L2 size as 512 KB instead of 1 MB
 
147
         */
 
148
        if (cpu_is_omap446x()) {
 
149
                lockdown = 0xa5a5;
 
150
                writel_relaxed(lockdown, l2cache_base + L2X0_LOCKDOWN_WAY_D0);
 
151
                writel_relaxed(lockdown, l2cache_base + L2X0_LOCKDOWN_WAY_D1);
 
152
                writel_relaxed(lockdown, l2cache_base + L2X0_LOCKDOWN_WAY_I0);
 
153
                writel_relaxed(lockdown, l2cache_base + L2X0_LOCKDOWN_WAY_I1);
 
154
        }
 
155
 
 
156
skip_aux_por_api:
98
157
        /* Enable PL310 L2 Cache controller */
99
158
        omap_smc1(0x102, 0x1);
100
159
 
111
170
}
112
171
early_initcall(omap_l2_cache_init);
113
172
#endif
 
173
 
 
174
void __iomem *omap4_get_sar_ram_base(void)
 
175
{
 
176
        return sar_ram_base;
 
177
}
 
178
 
 
179
/*
 
180
 * SAR RAM used to save and restore the HW
 
181
 * context in low power modes
 
182
 */
 
183
static int __init omap4_sar_ram_init(void)
 
184
{
 
185
        /*
 
186
         * To avoid code running on other OMAPs in
 
187
         * multi-omap builds
 
188
         */
 
189
        if (!cpu_is_omap44xx())
 
190
                return -ENODEV;
 
191
 
 
192
        /* Static mapping, never released */
 
193
        sar_ram_base = ioremap(OMAP44XX_SAR_RAM_BASE, SZ_8K);
 
194
        if (WARN_ON(!sar_ram_base))
 
195
                return -ENODEV;
 
196
 
 
197
        return 0;
 
198
}
 
199
early_initcall(omap4_sar_ram_init);