diff options
Diffstat (limited to 'arch/sh/mm')
-rw-r--r-- | arch/sh/mm/Kconfig | 1 | ||||
-rw-r--r-- | arch/sh/mm/Makefile_32 | 11 | ||||
-rw-r--r-- | arch/sh/mm/cache-sh2.c | 45 | ||||
-rw-r--r-- | arch/sh/mm/cache-sh2a.c | 129 | ||||
-rw-r--r-- | arch/sh/mm/tlb-sh5.c | 20 |
5 files changed, 178 insertions, 28 deletions
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig index 56d0a7daa34b..9c131cac91a4 100644 --- a/arch/sh/mm/Kconfig +++ b/arch/sh/mm/Kconfig | |||
@@ -237,7 +237,6 @@ choice | |||
237 | 237 | ||
238 | config CACHE_WRITEBACK | 238 | config CACHE_WRITEBACK |
239 | bool "Write-back" | 239 | bool "Write-back" |
240 | depends on CPU_SH2A || CPU_SH3 || CPU_SH4 || CPU_SH5 | ||
241 | 240 | ||
242 | config CACHE_WRITETHROUGH | 241 | config CACHE_WRITETHROUGH |
243 | bool "Write-through" | 242 | bool "Write-through" |
diff --git a/arch/sh/mm/Makefile_32 b/arch/sh/mm/Makefile_32 index e295db60b91b..70e0906023cc 100644 --- a/arch/sh/mm/Makefile_32 +++ b/arch/sh/mm/Makefile_32 | |||
@@ -5,12 +5,15 @@ | |||
5 | obj-y := init.o extable_32.o consistent.o | 5 | obj-y := init.o extable_32.o consistent.o |
6 | 6 | ||
7 | ifndef CONFIG_CACHE_OFF | 7 | ifndef CONFIG_CACHE_OFF |
8 | obj-$(CONFIG_CPU_SH2) += cache-sh2.o | 8 | cache-$(CONFIG_CPU_SH2) := cache-sh2.o |
9 | obj-$(CONFIG_CPU_SH3) += cache-sh3.o | 9 | cache-$(CONFIG_CPU_SH2A) := cache-sh2a.o |
10 | obj-$(CONFIG_CPU_SH4) += cache-sh4.o | 10 | cache-$(CONFIG_CPU_SH3) := cache-sh3.o |
11 | obj-$(CONFIG_SH7705_CACHE_32KB) += cache-sh7705.o | 11 | cache-$(CONFIG_CPU_SH4) := cache-sh4.o |
12 | cache-$(CONFIG_SH7705_CACHE_32KB) += cache-sh7705.o | ||
12 | endif | 13 | endif |
13 | 14 | ||
15 | obj-y += $(cache-y) | ||
16 | |||
14 | mmu-y := tlb-nommu.o pg-nommu.o | 17 | mmu-y := tlb-nommu.o pg-nommu.o |
15 | mmu-$(CONFIG_MMU) := fault_32.o tlbflush_32.o ioremap_32.o | 18 | mmu-$(CONFIG_MMU) := fault_32.o tlbflush_32.o ioremap_32.o |
16 | 19 | ||
diff --git a/arch/sh/mm/cache-sh2.c b/arch/sh/mm/cache-sh2.c index 6614033f6be9..c4e80d2b764b 100644 --- a/arch/sh/mm/cache-sh2.c +++ b/arch/sh/mm/cache-sh2.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * arch/sh/mm/cache-sh2.c | 2 | * arch/sh/mm/cache-sh2.c |
3 | * | 3 | * |
4 | * Copyright (C) 2002 Paul Mundt | 4 | * Copyright (C) 2002 Paul Mundt |
5 | * Copyright (C) 2008 Yoshinori Sato | ||
5 | * | 6 | * |
6 | * Released under the terms of the GNU GPL v2.0. | 7 | * Released under the terms of the GNU GPL v2.0. |
7 | */ | 8 | */ |
@@ -24,8 +25,15 @@ void __flush_wback_region(void *start, int size) | |||
24 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) | 25 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) |
25 | & ~(L1_CACHE_BYTES-1); | 26 | & ~(L1_CACHE_BYTES-1); |
26 | for (v = begin; v < end; v+=L1_CACHE_BYTES) { | 27 | for (v = begin; v < end; v+=L1_CACHE_BYTES) { |
27 | /* FIXME cache purge */ | 28 | unsigned long addr = CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0); |
28 | ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008); | 29 | int way; |
30 | for (way = 0; way < 4; way++) { | ||
31 | unsigned long data = ctrl_inl(addr | (way << 12)); | ||
32 | if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) { | ||
33 | data &= ~SH_CACHE_UPDATED; | ||
34 | ctrl_outl(data, addr | (way << 12)); | ||
35 | } | ||
36 | } | ||
29 | } | 37 | } |
30 | } | 38 | } |
31 | 39 | ||
@@ -37,21 +45,40 @@ void __flush_purge_region(void *start, int size) | |||
37 | begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); | 45 | begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); |
38 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) | 46 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) |
39 | & ~(L1_CACHE_BYTES-1); | 47 | & ~(L1_CACHE_BYTES-1); |
40 | for (v = begin; v < end; v+=L1_CACHE_BYTES) { | 48 | |
41 | ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008); | 49 | for (v = begin; v < end; v+=L1_CACHE_BYTES) |
42 | } | 50 | ctrl_outl((v & CACHE_PHYSADDR_MASK), |
51 | CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0) | 0x00000008); | ||
43 | } | 52 | } |
44 | 53 | ||
45 | void __flush_invalidate_region(void *start, int size) | 54 | void __flush_invalidate_region(void *start, int size) |
46 | { | 55 | { |
56 | #ifdef CONFIG_CACHE_WRITEBACK | ||
57 | /* | ||
58 | * SH-2 does not support individual line invalidation, only a | ||
59 | * global invalidate. | ||
60 | */ | ||
61 | unsigned long ccr; | ||
62 | unsigned long flags; | ||
63 | local_irq_save(flags); | ||
64 | jump_to_uncached(); | ||
65 | |||
66 | ccr = ctrl_inl(CCR); | ||
67 | ccr |= CCR_CACHE_INVALIDATE; | ||
68 | ctrl_outl(ccr, CCR); | ||
69 | |||
70 | back_to_cached(); | ||
71 | local_irq_restore(flags); | ||
72 | #else | ||
47 | unsigned long v; | 73 | unsigned long v; |
48 | unsigned long begin, end; | 74 | unsigned long begin, end; |
49 | 75 | ||
50 | begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); | 76 | begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); |
51 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) | 77 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) |
52 | & ~(L1_CACHE_BYTES-1); | 78 | & ~(L1_CACHE_BYTES-1); |
53 | for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
54 | ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008); | ||
55 | } | ||
56 | } | ||
57 | 79 | ||
80 | for (v = begin; v < end; v+=L1_CACHE_BYTES) | ||
81 | ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
82 | CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0) | 0x00000008); | ||
83 | #endif | ||
84 | } | ||
diff --git a/arch/sh/mm/cache-sh2a.c b/arch/sh/mm/cache-sh2a.c new file mode 100644 index 000000000000..62c0c5f35120 --- /dev/null +++ b/arch/sh/mm/cache-sh2a.c | |||
@@ -0,0 +1,129 @@ | |||
1 | /* | ||
2 | * arch/sh/mm/cache-sh2a.c | ||
3 | * | ||
4 | * Copyright (C) 2008 Yoshinori Sato | ||
5 | * | ||
6 | * Released under the terms of the GNU GPL v2.0. | ||
7 | */ | ||
8 | |||
9 | #include <linux/init.h> | ||
10 | #include <linux/mm.h> | ||
11 | |||
12 | #include <asm/cache.h> | ||
13 | #include <asm/addrspace.h> | ||
14 | #include <asm/processor.h> | ||
15 | #include <asm/cacheflush.h> | ||
16 | #include <asm/io.h> | ||
17 | |||
18 | void __flush_wback_region(void *start, int size) | ||
19 | { | ||
20 | unsigned long v; | ||
21 | unsigned long begin, end; | ||
22 | unsigned long flags; | ||
23 | |||
24 | begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); | ||
25 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) | ||
26 | & ~(L1_CACHE_BYTES-1); | ||
27 | |||
28 | local_irq_save(flags); | ||
29 | jump_to_uncached(); | ||
30 | |||
31 | for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
32 | unsigned long addr = CACHE_OC_ADDRESS_ARRAY | (v & 0x000007f0); | ||
33 | int way; | ||
34 | for (way = 0; way < 4; way++) { | ||
35 | unsigned long data = ctrl_inl(addr | (way << 11)); | ||
36 | if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) { | ||
37 | data &= ~SH_CACHE_UPDATED; | ||
38 | ctrl_outl(data, addr | (way << 11)); | ||
39 | } | ||
40 | } | ||
41 | } | ||
42 | |||
43 | back_to_cached(); | ||
44 | local_irq_restore(flags); | ||
45 | } | ||
46 | |||
47 | void __flush_purge_region(void *start, int size) | ||
48 | { | ||
49 | unsigned long v; | ||
50 | unsigned long begin, end; | ||
51 | unsigned long flags; | ||
52 | |||
53 | begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); | ||
54 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) | ||
55 | & ~(L1_CACHE_BYTES-1); | ||
56 | |||
57 | local_irq_save(flags); | ||
58 | jump_to_uncached(); | ||
59 | |||
60 | for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
61 | ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
62 | CACHE_OC_ADDRESS_ARRAY | (v & 0x000003f0) | 0x00000008); | ||
63 | } | ||
64 | back_to_cached(); | ||
65 | local_irq_restore(flags); | ||
66 | } | ||
67 | |||
68 | void __flush_invalidate_region(void *start, int size) | ||
69 | { | ||
70 | unsigned long v; | ||
71 | unsigned long begin, end; | ||
72 | unsigned long flags; | ||
73 | |||
74 | begin = (unsigned long)start & ~(L1_CACHE_BYTES-1); | ||
75 | end = ((unsigned long)start + size + L1_CACHE_BYTES-1) | ||
76 | & ~(L1_CACHE_BYTES-1); | ||
77 | local_irq_save(flags); | ||
78 | jump_to_uncached(); | ||
79 | |||
80 | #ifdef CONFIG_CACHE_WRITEBACK | ||
81 | ctrl_outl(ctrl_inl(CCR) | CCR_OCACHE_INVALIDATE, CCR); | ||
82 | /* I-cache invalidate */ | ||
83 | for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
84 | ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
85 | CACHE_IC_ADDRESS_ARRAY | (v & 0x000003f0) | 0x00000008); | ||
86 | } | ||
87 | #else | ||
88 | for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
89 | ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
90 | CACHE_IC_ADDRESS_ARRAY | (v & 0x000003f0) | 0x00000008); | ||
91 | ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
92 | CACHE_OC_ADDRESS_ARRAY | (v & 0x000003f0) | 0x00000008); | ||
93 | } | ||
94 | #endif | ||
95 | back_to_cached(); | ||
96 | local_irq_restore(flags); | ||
97 | } | ||
98 | |||
99 | /* WBack O-Cache and flush I-Cache */ | ||
100 | void flush_icache_range(unsigned long start, unsigned long end) | ||
101 | { | ||
102 | unsigned long v; | ||
103 | unsigned long flags; | ||
104 | |||
105 | start = start & ~(L1_CACHE_BYTES-1); | ||
106 | end = (end + L1_CACHE_BYTES-1) & ~(L1_CACHE_BYTES-1); | ||
107 | |||
108 | local_irq_save(flags); | ||
109 | jump_to_uncached(); | ||
110 | |||
111 | for (v = start; v < end; v+=L1_CACHE_BYTES) { | ||
112 | unsigned long addr = (v & 0x000007f0); | ||
113 | int way; | ||
114 | /* O-Cache writeback */ | ||
115 | for (way = 0; way < 4; way++) { | ||
116 | unsigned long data = ctrl_inl(CACHE_OC_ADDRESS_ARRAY | addr | (way << 11)); | ||
117 | if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) { | ||
118 | data &= ~SH_CACHE_UPDATED; | ||
119 | ctrl_outl(data, CACHE_OC_ADDRESS_ARRAY | addr | (way << 11)); | ||
120 | } | ||
121 | } | ||
122 | /* I-Cache invalidate */ | ||
123 | ctrl_outl(addr, | ||
124 | CACHE_IC_ADDRESS_ARRAY | addr | 0x00000008); | ||
125 | } | ||
126 | |||
127 | back_to_cached(); | ||
128 | local_irq_restore(flags); | ||
129 | } | ||
diff --git a/arch/sh/mm/tlb-sh5.c b/arch/sh/mm/tlb-sh5.c index f34274a1ded3..dae131243bcc 100644 --- a/arch/sh/mm/tlb-sh5.c +++ b/arch/sh/mm/tlb-sh5.c | |||
@@ -15,9 +15,7 @@ | |||
15 | #include <asm/mmu_context.h> | 15 | #include <asm/mmu_context.h> |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * sh64_tlb_init | 18 | * sh64_tlb_init - Perform initial setup for the DTLB and ITLB. |
19 | * | ||
20 | * Perform initial setup for the DTLB and ITLB. | ||
21 | */ | 19 | */ |
22 | int __init sh64_tlb_init(void) | 20 | int __init sh64_tlb_init(void) |
23 | { | 21 | { |
@@ -46,9 +44,7 @@ int __init sh64_tlb_init(void) | |||
46 | } | 44 | } |
47 | 45 | ||
48 | /** | 46 | /** |
49 | * sh64_next_free_dtlb_entry | 47 | * sh64_next_free_dtlb_entry - Find the next available DTLB entry |
50 | * | ||
51 | * Find the next available DTLB entry | ||
52 | */ | 48 | */ |
53 | unsigned long long sh64_next_free_dtlb_entry(void) | 49 | unsigned long long sh64_next_free_dtlb_entry(void) |
54 | { | 50 | { |
@@ -56,9 +52,7 @@ unsigned long long sh64_next_free_dtlb_entry(void) | |||
56 | } | 52 | } |
57 | 53 | ||
58 | /** | 54 | /** |
59 | * sh64_get_wired_dtlb_entry | 55 | * sh64_get_wired_dtlb_entry - Allocate a wired (locked-in) entry in the DTLB |
60 | * | ||
61 | * Allocate a wired (locked-in) entry in the DTLB | ||
62 | */ | 56 | */ |
63 | unsigned long long sh64_get_wired_dtlb_entry(void) | 57 | unsigned long long sh64_get_wired_dtlb_entry(void) |
64 | { | 58 | { |
@@ -71,12 +65,10 @@ unsigned long long sh64_get_wired_dtlb_entry(void) | |||
71 | } | 65 | } |
72 | 66 | ||
73 | /** | 67 | /** |
74 | * sh64_put_wired_dtlb_entry | 68 | * sh64_put_wired_dtlb_entry - Free a wired (locked-in) entry in the DTLB. |
75 | * | 69 | * |
76 | * @entry: Address of TLB slot. | 70 | * @entry: Address of TLB slot. |
77 | * | 71 | * |
78 | * Free a wired (locked-in) entry in the DTLB. | ||
79 | * | ||
80 | * Works like a stack, last one to allocate must be first one to free. | 72 | * Works like a stack, last one to allocate must be first one to free. |
81 | */ | 73 | */ |
82 | int sh64_put_wired_dtlb_entry(unsigned long long entry) | 74 | int sh64_put_wired_dtlb_entry(unsigned long long entry) |
@@ -115,7 +107,7 @@ int sh64_put_wired_dtlb_entry(unsigned long long entry) | |||
115 | } | 107 | } |
116 | 108 | ||
117 | /** | 109 | /** |
118 | * sh64_setup_tlb_slot | 110 | * sh64_setup_tlb_slot - Load up a translation in a wired slot. |
119 | * | 111 | * |
120 | * @config_addr: Address of TLB slot. | 112 | * @config_addr: Address of TLB slot. |
121 | * @eaddr: Virtual address. | 113 | * @eaddr: Virtual address. |
@@ -154,7 +146,7 @@ inline void sh64_setup_tlb_slot(unsigned long long config_addr, | |||
154 | } | 146 | } |
155 | 147 | ||
156 | /** | 148 | /** |
157 | * sh64_teardown_tlb_slot | 149 | * sh64_teardown_tlb_slot - Teardown a translation. |
158 | * | 150 | * |
159 | * @config_addr: Address of TLB slot. | 151 | * @config_addr: Address of TLB slot. |
160 | * | 152 | * |