1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * linux/arch/arm/mm/proc-fa526.S: MMU functions for FA526
5 * Written by : Luke Lee
6 * Copyright (C) 2005 Faraday Corp.
7 * Copyright (C) 2008-2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
9 * These are the low level assembler for performing cache and TLB
10 * functions on the fa526.
12 #include <linux/linkage.h>
13 #include <linux/init.h>
14 #include <linux/cfi_types.h>
15 #include <linux/pgtable.h>
16 #include <asm/assembler.h>
17 #include <asm/hwcap.h>
18 #include <asm/pgtable-hwdef.h>
20 #include <asm/ptrace.h>
22 #include "proc-macros.S"
24 #define CACHE_DLINESIZE 16
28 * cpu_fa526_proc_init()
30 SYM_TYPED_FUNC_START(cpu_fa526_proc_init)
32 SYM_FUNC_END(cpu_fa526_proc_init)
35 * cpu_fa526_proc_fin()
37 SYM_TYPED_FUNC_START(cpu_fa526_proc_fin)
38 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
39 bic r0, r0, #0x1000 @ ...i............
40 bic r0, r0, #0x000e @ ............wca.
41 mcr p15, 0, r0, c1, c0, 0 @ disable caches
45 SYM_FUNC_END(cpu_fa526_proc_fin)
48 * cpu_fa526_reset(loc)
50 * Perform a soft reset of the system. Put the CPU into the
51 * same state as it would be if it had been reset, and branch
52 * to what would be the reset vector.
54 * loc: location to jump to for soft reset
57 .pushsection .idmap.text, "ax"
58 SYM_TYPED_FUNC_START(cpu_fa526_reset)
59 /* TODO: Use CP8 if possible... */
61 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
62 mcr p15, 0, ip, c7, c10, 4 @ drain WB
64 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
66 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
67 bic ip, ip, #0x000f @ ............wcam
68 bic ip, ip, #0x1100 @ ...i...s........
69 bic ip, ip, #0x0800 @ BTB off
70 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
74 SYM_FUNC_END(cpu_fa526_reset)
81 SYM_TYPED_FUNC_START(cpu_fa526_do_idle)
83 SYM_FUNC_END(cpu_fa526_do_idle)
85 SYM_TYPED_FUNC_START(cpu_fa526_dcache_clean_area)
86 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
87 add r0, r0, #CACHE_DLINESIZE
88 subs r1, r1, #CACHE_DLINESIZE
90 mcr p15, 0, r0, c7, c10, 4 @ drain WB
92 SYM_FUNC_END(cpu_fa526_dcache_clean_area)
94 /* =============================== PageTable ============================== */
97 * cpu_fa526_switch_mm(pgd)
99 * Set the translation base pointer to be as described by pgd.
101 * pgd: new page tables
104 SYM_TYPED_FUNC_START(cpu_fa526_switch_mm)
107 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
108 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
110 mcr p15, 0, ip, c7, c14, 0 @ clean and invalidate whole D cache
112 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
113 mcr p15, 0, ip, c7, c5, 6 @ invalidate BTB since mm changed
114 mcr p15, 0, ip, c7, c10, 4 @ data write barrier
115 mcr p15, 0, ip, c7, c5, 4 @ prefetch flush
116 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
117 mcr p15, 0, ip, c8, c7, 0 @ invalidate UTLB
120 SYM_FUNC_END(cpu_fa526_switch_mm)
123 * cpu_fa526_set_pte_ext(ptep, pte, ext)
125 * Set a PTE and flush it out
128 SYM_TYPED_FUNC_START(cpu_fa526_set_pte_ext)
132 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
134 mcr p15, 0, r0, c7, c10, 4 @ drain WB
137 SYM_FUNC_END(cpu_fa526_set_pte_ext)
139 .type __fa526_setup, #function
141 /* On return of this routine, r0 must carry correct flags for CFG register */
143 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
144 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
146 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
148 mcr p15, 0, r0, c7, c5, 5 @ invalidate IScratchpad RAM
151 mcr p15, 0, r0, c1, c1, 0 @ turn-on ECR
154 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB All
155 mcr p15, 0, r0, c7, c10, 4 @ data write barrier
156 mcr p15, 0, r0, c7, c5, 4 @ prefetch flush
158 mov r0, #0x1f @ Domains 0, 1 = manager, 2 = client
159 mcr p15, 0, r0, c3, c0 @ load domain access register
161 mrc p15, 0, r0, c1, c0 @ get control register v4
162 ldr r5, fa526_cr1_clear
164 ldr r5, fa526_cr1_set
167 .size __fa526_setup, . - __fa526_setup
170 * .RVI ZFRS BLDP WCAM
171 * ..11 1001 .111 1101
174 .type fa526_cr1_clear, #object
175 .type fa526_cr1_set, #object
183 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
184 define_processor_functions fa526, dabort=v4_early_abort, pabort=legacy_pabort
188 string cpu_arch_name, "armv4"
189 string cpu_elf_name, "v4"
190 string cpu_fa526_name, "FA526"
194 .section ".proc.info.init", "a"
196 .type __fa526_proc_info,#object
200 .long PMD_TYPE_SECT | \
201 PMD_SECT_BUFFERABLE | \
202 PMD_SECT_CACHEABLE | \
204 PMD_SECT_AP_WRITE | \
206 .long PMD_TYPE_SECT | \
208 PMD_SECT_AP_WRITE | \
210 initfn __fa526_setup, __fa526_proc_info
213 .long HWCAP_SWP | HWCAP_HALF
215 .long fa526_processor_functions
219 .size __fa526_proc_info, . - __fa526_proc_info