diff options
Diffstat (limited to 'arch/sh/kernel/cpu/init.c')
-rw-r--r-- | arch/sh/kernel/cpu/init.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c index 868e68b28880..bfb90eb0b7a6 100644 --- a/arch/sh/kernel/cpu/init.c +++ b/arch/sh/kernel/cpu/init.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * CPU init code | 4 | * CPU init code |
5 | * | 5 | * |
6 | * Copyright (C) 2002, 2003 Paul Mundt | 6 | * Copyright (C) 2002, 2003 Paul Mundt |
7 | * Copyright (C) 2003 Richard Curnow | ||
7 | * | 8 | * |
8 | * This file is subject to the terms and conditions of the GNU General Public | 9 | * This file is subject to the terms and conditions of the GNU General Public |
9 | * License. See the file "COPYING" in the main directory of this archive | 10 | * License. See the file "COPYING" in the main directory of this archive |
@@ -13,6 +14,7 @@ | |||
13 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
14 | #include <asm/processor.h> | 15 | #include <asm/processor.h> |
15 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
17 | #include <asm/page.h> | ||
16 | #include <asm/system.h> | 18 | #include <asm/system.h> |
17 | #include <asm/cacheflush.h> | 19 | #include <asm/cacheflush.h> |
18 | #include <asm/cache.h> | 20 | #include <asm/cache.h> |
@@ -51,7 +53,15 @@ static void __init cache_init(void) | |||
51 | ccr = ctrl_inl(CCR); | 53 | ccr = ctrl_inl(CCR); |
52 | 54 | ||
53 | /* | 55 | /* |
54 | * If the cache is already enabled .. flush it. | 56 | * At this point we don't know whether the cache is enabled or not - a |
57 | * bootloader may have enabled it. There are at least 2 things that | ||
58 | * could be dirty in the cache at this point: | ||
59 | * 1. kernel command line set up by boot loader | ||
60 | * 2. spilled registers from the prolog of this function | ||
61 | * => before re-initialising the cache, we must do a purge of the whole | ||
62 | * cache out to memory for safety. As long as nothing is spilled | ||
63 | * during the loop to lines that have already been done, this is safe. | ||
64 | * - RPC | ||
55 | */ | 65 | */ |
56 | if (ccr & CCR_CACHE_ENABLE) { | 66 | if (ccr & CCR_CACHE_ENABLE) { |
57 | unsigned long ways, waysize, addrstart; | 67 | unsigned long ways, waysize, addrstart; |
@@ -98,6 +108,8 @@ static void __init cache_init(void) | |||
98 | /* Force EMODE if possible */ | 108 | /* Force EMODE if possible */ |
99 | if (cpu_data->dcache.ways > 1) | 109 | if (cpu_data->dcache.ways > 1) |
100 | flags |= CCR_CACHE_EMODE; | 110 | flags |= CCR_CACHE_EMODE; |
111 | else | ||
112 | flags &= ~CCR_CACHE_EMODE; | ||
101 | #endif | 113 | #endif |
102 | 114 | ||
103 | #ifdef CONFIG_SH_WRITETHROUGH | 115 | #ifdef CONFIG_SH_WRITETHROUGH |
@@ -112,6 +124,9 @@ static void __init cache_init(void) | |||
112 | /* Turn on OCRAM -- halve the OC */ | 124 | /* Turn on OCRAM -- halve the OC */ |
113 | flags |= CCR_CACHE_ORA; | 125 | flags |= CCR_CACHE_ORA; |
114 | cpu_data->dcache.sets >>= 1; | 126 | cpu_data->dcache.sets >>= 1; |
127 | |||
128 | cpu_data->dcache.way_size = cpu_data->dcache.sets * | ||
129 | cpu_data->dcache.linesz; | ||
115 | #endif | 130 | #endif |
116 | 131 | ||
117 | ctrl_outl(flags, CCR); | 132 | ctrl_outl(flags, CCR); |
@@ -184,6 +199,10 @@ asmlinkage void __init sh_cpu_init(void) | |||
184 | /* Init the cache */ | 199 | /* Init the cache */ |
185 | cache_init(); | 200 | cache_init(); |
186 | 201 | ||
202 | shm_align_mask = max_t(unsigned long, | ||
203 | cpu_data->dcache.way_size - 1, | ||
204 | PAGE_SIZE - 1); | ||
205 | |||
187 | /* Disable the FPU */ | 206 | /* Disable the FPU */ |
188 | if (fpu_disabled) { | 207 | if (fpu_disabled) { |
189 | printk("FPU Disabled\n"); | 208 | printk("FPU Disabled\n"); |