FS#11417 by Joe Balough: fix audio/tuner on philips hdd6330
[kugel-rb.git] / firmware / target / arm / mmu-armv6.S
blob58e03d6614cd77f31e7353c5002fd2dbe3014539
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id$
9  *
10  * Copyright (C) 2006,2007 by Greg White
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18  * KIND, either express or implied.
19  *
20  ****************************************************************************/
21 #include "config.h"
22 #include "cpu.h"
24 /* TTB routines not used */
26 /** Cache coherency **/
28 #if 0 /* unused */
31  * Invalidate DCache for this range
32  * will do write back
33  * void invalidate_dcache_range(const void *base, unsigned int size)
34  */
35     .section   .text, "ax", %progbits
36     .align      2
37     .global     invalidate_dcache_range
38     .type       invalidate_dcache_range, %function
39     @ MVA format: 31:5 = Modified virtual address, 4:0 = Ignored
40 invalidate_dcache_range:
41     add     r1, r0, r1              @ size -> end
42     cmp     r1, r0                  @ end <= start?
43     subhi   r1, r1, #1              @ round it down
44     movhi   r2, #0                  @
45     mcrrhi  p15, 0, r1, r0, c14     @ Clean and invalidate DCache range
46     mcrhi   p15, 0, r2, c7, c10, 4  @ Data synchronization barrier
47     bx      lr                      @
48     .size   invalidate_dcache_range, .-invalidate_dcache_range
50 #endif /* unused function */
53  * clean DCache for this range
54  * forces DCache writeback for the specified range
55  * void clean_dcache_range(const void *base, unsigned int size);
56  */
57     .section   .text, "ax", %progbits
58     .align      2
59     .global     clean_dcache_range
60     .type       clean_dcache_range, %function
61     @ MVA format: 31:5 = Modified virtual address, 4:0 = Ignored
62 clean_dcache_range:
63     add     r1, r0, r1              @ size -> end
64     cmp     r1, r0                  @ end <= start?
65     subhi   r1, r1, #1              @ round it down
66     movhi   r2, #0                  @
67     mcrrhi  p15, 0, r1, r0, c12     @ Clean DCache range
68     mcrhi   p15, 0, r2, c7, c10, 4  @ Data synchronization barrier
69     bx      lr                      @
70     .size   clean_dcache_range, .-clean_dcache_range
73  * Dump DCache for this range
74  * will *NOT* do write back except for buffer edges not on a line boundary
75  * void dump_dcache_range(const void *base, unsigned int size);
76  */
77     .section   .text, "ax", %progbits
78     .align      2
79     .global     dump_dcache_range
80     .type       dump_dcache_range, %function
81     @ MVA format (mcr):  31:5 = Modified virtual address, 4:0 = SBZ
82     @ MVA format (mcrr): 31:5 = Modified virtual address, 4:0 = Ignored
83  dump_dcache_range:
84     add     r1, r0, r1              @ size -> end
85     cmp     r1, r0                  @ end <= start?
86     bxls    lr                      @ 
87     tst     r0, #31                 @ Check first line for bits set
88     bicne   r0, r0, #31             @ Clear low five bits (down)
89     mcrne   p15, 0, r0, c7, c14, 1  @ Clean and invalidate line by MVA
90                                     @ if not cache aligned
91     addne   r0, r0, #32             @ Move to the next cache line
92                                     @
93     tst     r1, #31                 @ Check last line for bits set
94     bicne   r1, r1, #31             @ Clear low five bits (down)
95     mcrne   p15, 0, r1, c7, c14, 1  @ Clean and invalidate line by MVA
96                                     @ if not cache aligned
97     sub     r1, r1, #32             @ Move to the previous cache line
98     cmp     r1, r0                  @ end < start now?
99     mcrrhs  p15, 0, r1, r0, c6      @ Invalidate DCache range
100     mov     r0, #0                  @
101     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
102     bx      lr                      @
103     .size   dump_dcache_range, .-dump_dcache_range
107  * Cleans entire DCache
108  * void clean_dcache(void);
109  */
110     .section   .text, "ax", %progbits
111     .align      2
112     .global     clean_dcache
113     .type       clean_dcache, %function
114     .global     cpucache_flush      @ Alias
115 clean_dcache:
116 cpucache_flush:
117     mov     r0, #0                  @
118     mcr     p15, 0, r0, c7, c10, 0  @ Clean entire DCache
119     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
120     bx      lr                      @
121     .size   clean_dcache, .-clean_dcache
124  * Invalidate entire DCache
125  * will do writeback
126  * void invalidate_dcache(void);
127  */
128     .section   .text, "ax", %progbits
129     .align      2
130     .global     invalidate_dcache
131     .type       invalidate_dcache, %function
132 invalidate_dcache:
133     mov     r0, #0                  @
134     mcr     p15, 0, r0, c7, c14, 0  @ Clean and invalidate entire DCache
135     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
136     bx      lr                      @
137     .size   invalidate_dcache, .-invalidate_dcache
138     
140  * Invalidate entire ICache and DCache
141  * will do writeback
142  * void invalidate_idcache(void);
143  */
144     .section   .icode, "ax", %progbits
145     .align      2
146     .global     invalidate_idcache
147     .type       invalidate_idcache, %function
148     .global     cpucache_invalidate @ Alias
149 invalidate_idcache:
150 cpucache_invalidate:
151     mov     r0, #0                  @
152     mcr     p15, 0, r0, c7, c14, 0  @ Clean and invalidate entire DCache
153     mcr     p15, 0, r0, c7, c5, 0   @ Invalidate entire ICache
154                                     @ Also flushes the branch target cache
155     mcr     p15, 0, r0, c7, c10, 4  @ Data synchronization barrier
156     mcr     p15, 0, r0, c7, c5, 4   @ Flush prefetch buffer (IMB)
157     bx      lr                      @
158     .size   invalidate_idcache, .-invalidate_idcache