f4975cdc88eb743cde09977a561c7c43334c6ad6
[openembedded.git] /
1 From 72e1ab470e483c91ab3aa38bec31faf3dad52735 Mon Sep 17 00:00:00 2001
2 From: Mans Rullgard <mans@mansr.com>
3 Date: Wed, 14 Apr 2010 12:08:00 +0100
4 Subject: [PATCH 28/50] OMAP3: fix and clean up L2 cache enable/disable functions
5
6 On OMAP34xx ES1.0, the L2 enable bit can only be set in secure mode,
7 so an SMC call to the ROM monitor is required.  On later versions,
8 and on newer devices, this bit is banked and we can set it directly.
9
10 The code checked only the ES revision of the chip, and hence incorrectly
11 used the ROM call on ES1.0 versions of other devices.
12
13 This patch adds a check for chip family as well as revision, and also
14 removes some code duplication between the enable and disable functions.
15
16 Signed-off-by: Mans Rullgard <mans@mansr.com>
17 ---
18  cpu/arm_cortexa8/omap3/cache.S |   74 +++++++++++-----------------------------
19  1 files changed, 20 insertions(+), 54 deletions(-)
20
21 diff --git a/cpu/arm_cortexa8/omap3/cache.S b/cpu/arm_cortexa8/omap3/cache.S
22 index 0f63815..16afb5d 100644
23 --- a/cpu/arm_cortexa8/omap3/cache.S
24 +++ b/cpu/arm_cortexa8/omap3/cache.S
25 @@ -128,64 +128,30 @@ finished_inval:
26  
27         ldmfd   r13!, {r0 - r5, r7, r9 - r12, pc}
28  
29 -
30 -l2_cache_enable:
31 -       push    {r0, r1, r2, lr}
32 -       @ ES2 onwards we can disable/enable L2 ourselves
33 +l2_cache_set:
34 +       push    {r4-r6, lr}
35 +       mov     r5,  r0
36         bl      get_cpu_rev
37 -       cmp     r0, #CPU_3XX_ES20
38 -       blt     l2_cache_disable_EARLIER_THAN_ES2
39 -       mrc     15, 0, r3, cr1, cr0, 1
40 -       orr     r3, r3, #2
41 -       mcr     15, 0, r3, cr1, cr0, 1
42 -       b       l2_cache_enable_END
43 -l2_cache_enable_EARLIER_THAN_ES2:
44 -       @ Save r0, r12 and restore them after usage
45 -       mov     r3, ip
46 -       str     r3, [sp, #4]
47 -       mov     r3, r0
48 -       @
49 +       mov     r4,  r0
50 +       bl      get_cpu_family
51 +       @ ES2 onwards we can disable/enable L2 ourselves
52 +       cmp     r0,  #CPU_OMAP34XX
53 +       cmpeq   r4,  #CPU_3XX_ES10
54 +       mrc     15, 0, r0, cr1, cr0, 1
55 +       bic     r0, r0, #2
56 +       orr     r0, r0, r5, lsl #1
57 +       mcreq   15, 0, r0, cr1, cr0, 1
58         @ GP Device ROM code API usage here
59         @ r12 = AUXCR Write function and r0 value
60 -       @
61         mov     ip, #3
62 -       mrc     15, 0, r0, cr1, cr0, 1
63 -       orr     r0, r0, #2
64 -       @ SMI instruction to call ROM Code API
65 -       .word   0xe1600070
66 -       mov     r0, r3
67 -       mov     ip, r3
68 -       str     r3, [sp, #4]
69 -l2_cache_enable_END:
70 -       pop     {r1, r2, r3, pc}
71 +       @ SMCNE instruction to call ROM Code API
72 +       .word   0x11600070
73 +       pop     {r4-r6, pc}
74  
75 +l2_cache_enable:
76 +       mov     r0, #1
77 +       b       l2_cache_set
78  
79  l2_cache_disable:
80 -       push    {r0, r1, r2, lr}
81 -       @ ES2 onwards we can disable/enable L2 ourselves
82 -       bl      get_cpu_rev
83 -       cmp     r0, #CPU_3XX_ES20
84 -       blt     l2_cache_disable_EARLIER_THAN_ES2
85 -       mrc     15, 0, r3, cr1, cr0, 1
86 -       bic     r3, r3, #2
87 -       mcr     15, 0, r3, cr1, cr0, 1
88 -       b       l2_cache_disable_END
89 -l2_cache_disable_EARLIER_THAN_ES2:
90 -       @ Save r0, r12 and restore them after usage
91 -       mov     r3, ip
92 -       str     r3, [sp, #4]
93 -       mov     r3, r0
94 -       @
95 -       @ GP Device ROM code API usage here
96 -       @ r12 = AUXCR Write function and r0 value
97 -       @
98 -       mov     ip, #3
99 -       mrc     15, 0, r0, cr1, cr0, 1
100 -       bic     r0, r0, #2
101 -       @ SMI instruction to call ROM Code API
102 -       .word   0xe1600070
103 -       mov     r0, r3
104 -       mov     ip, r3
105 -       str     r3, [sp, #4]
106 -l2_cache_disable_END:
107 -       pop     {r1, r2, r3, pc}
108 +       mov     r0, #0
109 +       b       l2_cache_set
110 -- 
111 1.6.6.1
112