xref: /linux/arch/arm/mm/proc-arm1020.S (revision 4853f1f6ace32c68a04287353e428c4cfc3fa8ed)
11a59d1b8SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-or-later */
21da177e4SLinus Torvalds/*
31da177e4SLinus Torvalds *  linux/arch/arm/mm/proc-arm1020.S: MMU functions for ARM1020
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds *  Copyright (C) 2000 ARM Limited
61da177e4SLinus Torvalds *  Copyright (C) 2000 Deep Blue Solutions Ltd.
7d090dddaSHyok S. Choi *  hacked for non-paged-MM by Hyok S. Choi, 2003.
81da177e4SLinus Torvalds *
91da177e4SLinus Torvalds * These are the low level assembler for performing cache and TLB
101da177e4SLinus Torvalds * functions on the arm1020.
111da177e4SLinus Torvalds */
121da177e4SLinus Torvalds#include <linux/linkage.h>
131da177e4SLinus Torvalds#include <linux/init.h>
141036b895SLinus Walleij#include <linux/cfi_types.h>
1565fddcfcSMike Rapoport#include <linux/pgtable.h>
161da177e4SLinus Torvalds#include <asm/assembler.h>
17e6ae744dSSam Ravnborg#include <asm/asm-offsets.h>
185ec9407dSRussell King#include <asm/hwcap.h>
1974945c86SRussell King#include <asm/pgtable-hwdef.h>
201da177e4SLinus Torvalds#include <asm/ptrace.h>
211da177e4SLinus Torvalds
2200eb0f6bSRussell King#include "proc-macros.S"
2300eb0f6bSRussell King
241da177e4SLinus Torvalds/*
251da177e4SLinus Torvalds * This is the maximum size of an area which will be invalidated
261da177e4SLinus Torvalds * using the single invalidate entry instructions.  Anything larger
271da177e4SLinus Torvalds * than this, and we go for the whole cache.
281da177e4SLinus Torvalds *
291da177e4SLinus Torvalds * This value should be chosen such that we choose the cheapest
301da177e4SLinus Torvalds * alternative.
311da177e4SLinus Torvalds */
321da177e4SLinus Torvalds#define MAX_AREA_SIZE	32768
331da177e4SLinus Torvalds
341da177e4SLinus Torvalds/*
351da177e4SLinus Torvalds * The size of one data cache line.
361da177e4SLinus Torvalds */
371da177e4SLinus Torvalds#define CACHE_DLINESIZE	32
381da177e4SLinus Torvalds
391da177e4SLinus Torvalds/*
401da177e4SLinus Torvalds * The number of data cache segments.
411da177e4SLinus Torvalds */
421da177e4SLinus Torvalds#define CACHE_DSEGMENTS	16
431da177e4SLinus Torvalds
441da177e4SLinus Torvalds/*
451da177e4SLinus Torvalds * The number of lines in a cache segment.
461da177e4SLinus Torvalds */
471da177e4SLinus Torvalds#define CACHE_DENTRIES	64
481da177e4SLinus Torvalds
491da177e4SLinus Torvalds/*
501da177e4SLinus Torvalds * This is the size at which it becomes more efficient to
511da177e4SLinus Torvalds * clean the whole cache, rather than using the individual
5225985edcSLucas De Marchi * cache line maintenance instructions.
531da177e4SLinus Torvalds */
541da177e4SLinus Torvalds#define CACHE_DLIMIT	32768
551da177e4SLinus Torvalds
561da177e4SLinus Torvalds	.text
571da177e4SLinus Torvalds/*
581da177e4SLinus Torvalds * cpu_arm1020_proc_init()
591da177e4SLinus Torvalds */
6051db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_arm1020_proc_init)
616ebbf2ceSRussell King	ret	lr
6251db13aaSLinus WalleijSYM_FUNC_END(cpu_arm1020_proc_init)
631da177e4SLinus Torvalds
641da177e4SLinus Torvalds/*
651da177e4SLinus Torvalds * cpu_arm1020_proc_fin()
661da177e4SLinus Torvalds */
6751db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_arm1020_proc_fin)
681da177e4SLinus Torvalds	mrc	p15, 0, r0, c1, c0, 0		@ ctrl register
691da177e4SLinus Torvalds	bic	r0, r0, #0x1000 		@ ...i............
701da177e4SLinus Torvalds	bic	r0, r0, #0x000e 		@ ............wca.
711da177e4SLinus Torvalds	mcr	p15, 0, r0, c1, c0, 0		@ disable caches
726ebbf2ceSRussell King	ret	lr
7351db13aaSLinus WalleijSYM_FUNC_END(cpu_arm1020_proc_fin)
741da177e4SLinus Torvalds
751da177e4SLinus Torvalds/*
761da177e4SLinus Torvalds * cpu_arm1020_reset(loc)
771da177e4SLinus Torvalds *
781da177e4SLinus Torvalds * Perform a soft reset of the system.	Put the CPU into the
791da177e4SLinus Torvalds * same state as it would be if it had been reset, and branch
801da177e4SLinus Torvalds * to what would be the reset vector.
811da177e4SLinus Torvalds *
821da177e4SLinus Torvalds * loc: location to jump to for soft reset
831da177e4SLinus Torvalds */
841da177e4SLinus Torvalds	.align	5
851a4baafaSWill Deacon	.pushsection	.idmap.text, "ax"
8651db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_arm1020_reset)
871da177e4SLinus Torvalds	mov	ip, #0
881da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c7, 0		@ invalidate I,D caches
891da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
90d090dddaSHyok S. Choi#ifdef CONFIG_MMU
911da177e4SLinus Torvalds	mcr	p15, 0, ip, c8, c7, 0		@ invalidate I & D TLBs
92d090dddaSHyok S. Choi#endif
931da177e4SLinus Torvalds	mrc	p15, 0, ip, c1, c0, 0		@ ctrl register
941da177e4SLinus Torvalds	bic	ip, ip, #0x000f 		@ ............wcam
951da177e4SLinus Torvalds	bic	ip, ip, #0x1100 		@ ...i...s........
961da177e4SLinus Torvalds	mcr	p15, 0, ip, c1, c0, 0		@ ctrl register
976ebbf2ceSRussell King	ret	r0
9851db13aaSLinus WalleijSYM_FUNC_END(cpu_arm1020_reset)
991a4baafaSWill Deacon	.popsection
1001da177e4SLinus Torvalds
1011da177e4SLinus Torvalds/*
1021da177e4SLinus Torvalds * cpu_arm1020_do_idle()
1031da177e4SLinus Torvalds */
1041da177e4SLinus Torvalds	.align	5
10551db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_arm1020_do_idle)
1061da177e4SLinus Torvalds	mcr	p15, 0, r0, c7, c0, 4		@ Wait for interrupt
1076ebbf2ceSRussell King	ret	lr
10851db13aaSLinus WalleijSYM_FUNC_END(cpu_arm1020_do_idle)
1091da177e4SLinus Torvalds
1101da177e4SLinus Torvalds/* ================================= CACHE ================================ */
1111da177e4SLinus Torvalds
1121da177e4SLinus Torvalds	.align	5
113c8c90860SMika Westerberg
114c8c90860SMika Westerberg/*
115c8c90860SMika Westerberg *	flush_icache_all()
116c8c90860SMika Westerberg *
117c8c90860SMika Westerberg *	Unconditionally clean and invalidate the entire icache.
118c8c90860SMika Westerberg */
1191036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_flush_icache_all)
120c8c90860SMika Westerberg#ifndef CONFIG_CPU_ICACHE_DISABLE
121c8c90860SMika Westerberg	mov	r0, #0
122c8c90860SMika Westerberg	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
123c8c90860SMika Westerberg#endif
1246ebbf2ceSRussell King	ret	lr
1251036b895SLinus WalleijSYM_FUNC_END(arm1020_flush_icache_all)
126c8c90860SMika Westerberg
1271da177e4SLinus Torvalds/*
1281da177e4SLinus Torvalds *	flush_user_cache_all()
1291da177e4SLinus Torvalds *
1301da177e4SLinus Torvalds *	Invalidate all cache entries in a particular address
1311da177e4SLinus Torvalds *	space.
1321da177e4SLinus Torvalds */
1332074beebSLinus WalleijSYM_FUNC_ALIAS(arm1020_flush_user_cache_all, arm1020_flush_kern_cache_all)
1341036b895SLinus Walleij
1351da177e4SLinus Torvalds/*
1361da177e4SLinus Torvalds *	flush_kern_cache_all()
1371da177e4SLinus Torvalds *
1381da177e4SLinus Torvalds *	Clean and invalidate the entire cache.
1391da177e4SLinus Torvalds */
1401036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_flush_kern_cache_all)
1411da177e4SLinus Torvalds	mov	r2, #VM_EXEC
1421da177e4SLinus Torvalds	mov	ip, #0
1431da177e4SLinus Torvalds__flush_whole_cache:
1441da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
1451da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
1461da177e4SLinus Torvalds	mov	r1, #(CACHE_DSEGMENTS - 1) << 5	@ 16 segments
1471da177e4SLinus Torvalds1:	orr	r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
1481da177e4SLinus Torvalds2:	mcr	p15, 0, r3, c7, c14, 2		@ clean+invalidate D index
1491da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
1501da177e4SLinus Torvalds	subs	r3, r3, #1 << 26
1511da177e4SLinus Torvalds	bcs	2b				@ entries 63 to 0
1521da177e4SLinus Torvalds	subs	r1, r1, #1 << 5
1531da177e4SLinus Torvalds	bcs	1b				@ segments 15 to 0
1541da177e4SLinus Torvalds#endif
1551da177e4SLinus Torvalds	tst	r2, #VM_EXEC
1561da177e4SLinus Torvalds#ifndef CONFIG_CPU_ICACHE_DISABLE
1571da177e4SLinus Torvalds	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
1581da177e4SLinus Torvalds#endif
1591da177e4SLinus Torvalds	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
1606ebbf2ceSRussell King	ret	lr
1611036b895SLinus WalleijSYM_FUNC_END(arm1020_flush_kern_cache_all)
1621da177e4SLinus Torvalds
1631da177e4SLinus Torvalds/*
1641da177e4SLinus Torvalds *	flush_user_cache_range(start, end, flags)
1651da177e4SLinus Torvalds *
1661da177e4SLinus Torvalds *	Invalidate a range of cache entries in the specified
1671da177e4SLinus Torvalds *	address space.
1681da177e4SLinus Torvalds *
1691da177e4SLinus Torvalds *	- start	- start address (inclusive)
1701da177e4SLinus Torvalds *	- end	- end address (exclusive)
1711da177e4SLinus Torvalds *	- flags	- vm_flags for this space
1721da177e4SLinus Torvalds */
1731036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_flush_user_cache_range)
1741da177e4SLinus Torvalds	mov	ip, #0
1751da177e4SLinus Torvalds	sub	r3, r1, r0			@ calculate total size
1761da177e4SLinus Torvalds	cmp	r3, #CACHE_DLIMIT
1771da177e4SLinus Torvalds	bhs	__flush_whole_cache
1781da177e4SLinus Torvalds
1791da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
1801da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4
1811da177e4SLinus Torvalds1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
1821da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
1831da177e4SLinus Torvalds	add	r0, r0, #CACHE_DLINESIZE
1841da177e4SLinus Torvalds	cmp	r0, r1
1851da177e4SLinus Torvalds	blo	1b
1861da177e4SLinus Torvalds#endif
1871da177e4SLinus Torvalds	tst	r2, #VM_EXEC
1881da177e4SLinus Torvalds#ifndef CONFIG_CPU_ICACHE_DISABLE
1891da177e4SLinus Torvalds	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
1901da177e4SLinus Torvalds#endif
1911da177e4SLinus Torvalds	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
1926ebbf2ceSRussell King	ret	lr
1931036b895SLinus WalleijSYM_FUNC_END(arm1020_flush_user_cache_range)
1941da177e4SLinus Torvalds
1951da177e4SLinus Torvalds/*
1961da177e4SLinus Torvalds *	coherent_kern_range(start, end)
1971da177e4SLinus Torvalds *
1981da177e4SLinus Torvalds *	Ensure coherency between the Icache and the Dcache in the
1991da177e4SLinus Torvalds *	region described by start.  If you have non-snooping
2001da177e4SLinus Torvalds *	Harvard caches, you need to implement this function.
2011da177e4SLinus Torvalds *
2021da177e4SLinus Torvalds *	- start	- virtual start address
2031da177e4SLinus Torvalds *	- end	- virtual end address
2041da177e4SLinus Torvalds */
2051036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_coherent_kern_range)
206*7b749aadSLinus Walleij#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
2071036b895SLinus Walleij	b	arm1020_coherent_user_range
208*7b749aadSLinus Walleij#endif
2091036b895SLinus WalleijSYM_FUNC_END(arm1020_coherent_kern_range)
2101da177e4SLinus Torvalds
2111da177e4SLinus Torvalds/*
2121da177e4SLinus Torvalds *	coherent_user_range(start, end)
2131da177e4SLinus Torvalds *
2141da177e4SLinus Torvalds *	Ensure coherency between the Icache and the Dcache in the
2151da177e4SLinus Torvalds *	region described by start.  If you have non-snooping
2161da177e4SLinus Torvalds *	Harvard caches, you need to implement this function.
2171da177e4SLinus Torvalds *
2181da177e4SLinus Torvalds *	- start	- virtual start address
2191da177e4SLinus Torvalds *	- end	- virtual end address
2201da177e4SLinus Torvalds */
2211036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_coherent_user_range)
2221da177e4SLinus Torvalds	mov	ip, #0
2231da177e4SLinus Torvalds	bic	r0, r0, #CACHE_DLINESIZE - 1
2241da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4
2251da177e4SLinus Torvalds1:
2261da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
2271da177e4SLinus Torvalds	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
2281da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
2291da177e4SLinus Torvalds#endif
2301da177e4SLinus Torvalds#ifndef CONFIG_CPU_ICACHE_DISABLE
2311da177e4SLinus Torvalds	mcr	p15, 0, r0, c7, c5, 1		@ invalidate I entry
2321da177e4SLinus Torvalds#endif
2331da177e4SLinus Torvalds	add	r0, r0, #CACHE_DLINESIZE
2341da177e4SLinus Torvalds	cmp	r0, r1
2351da177e4SLinus Torvalds	blo	1b
2361da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
237c5102f59SWill Deacon	mov	r0, #0
2386ebbf2ceSRussell King	ret	lr
2391036b895SLinus WalleijSYM_FUNC_END(arm1020_coherent_user_range)
2401da177e4SLinus Torvalds
2411da177e4SLinus Torvalds/*
2422c9b9c84SRussell King *	flush_kern_dcache_area(void *addr, size_t size)
2431da177e4SLinus Torvalds *
2441da177e4SLinus Torvalds *	Ensure no D cache aliasing occurs, either with itself or
2451da177e4SLinus Torvalds *	the I cache
2461da177e4SLinus Torvalds *
2472c9b9c84SRussell King *	- addr	- kernel address
2482c9b9c84SRussell King *	- size	- region size
2491da177e4SLinus Torvalds */
2501036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_flush_kern_dcache_area)
2511da177e4SLinus Torvalds	mov	ip, #0
2521da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
2532c9b9c84SRussell King	add	r1, r0, r1
2541da177e4SLinus Torvalds1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
2551da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
2561da177e4SLinus Torvalds	add	r0, r0, #CACHE_DLINESIZE
2571da177e4SLinus Torvalds	cmp	r0, r1
2581da177e4SLinus Torvalds	blo	1b
2591da177e4SLinus Torvalds#endif
2601da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
2616ebbf2ceSRussell King	ret	lr
2621036b895SLinus WalleijSYM_FUNC_END(arm1020_flush_kern_dcache_area)
2631da177e4SLinus Torvalds
2641da177e4SLinus Torvalds/*
2651da177e4SLinus Torvalds *	dma_inv_range(start, end)
2661da177e4SLinus Torvalds *
2671da177e4SLinus Torvalds *	Invalidate (discard) the specified virtual address range.
2681da177e4SLinus Torvalds *	May not write back any entries.  If 'start' or 'end'
2691da177e4SLinus Torvalds *	are not cache line aligned, those lines must be written
2701da177e4SLinus Torvalds *	back.
2711da177e4SLinus Torvalds *
2721da177e4SLinus Torvalds *	- start	- virtual start address
2731da177e4SLinus Torvalds *	- end	- virtual end address
2741da177e4SLinus Torvalds *
2751da177e4SLinus Torvalds * (same as v4wb)
2761da177e4SLinus Torvalds */
277702b94bfSRussell Kingarm1020_dma_inv_range:
2781da177e4SLinus Torvalds	mov	ip, #0
2791da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
2801da177e4SLinus Torvalds	tst	r0, #CACHE_DLINESIZE - 1
2811da177e4SLinus Torvalds	bic	r0, r0, #CACHE_DLINESIZE - 1
2821da177e4SLinus Torvalds	mcrne	p15, 0, ip, c7, c10, 4
2831da177e4SLinus Torvalds	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
2841da177e4SLinus Torvalds	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
2851da177e4SLinus Torvalds	tst	r1, #CACHE_DLINESIZE - 1
2861da177e4SLinus Torvalds	mcrne	p15, 0, ip, c7, c10, 4
2871da177e4SLinus Torvalds	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
2881da177e4SLinus Torvalds	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
2891da177e4SLinus Torvalds1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
2901da177e4SLinus Torvalds	add	r0, r0, #CACHE_DLINESIZE
2911da177e4SLinus Torvalds	cmp	r0, r1
2921da177e4SLinus Torvalds	blo	1b
2931da177e4SLinus Torvalds#endif
2941da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
2956ebbf2ceSRussell King	ret	lr
2961da177e4SLinus Torvalds
2971da177e4SLinus Torvalds/*
2981da177e4SLinus Torvalds *	dma_clean_range(start, end)
2991da177e4SLinus Torvalds *
3001da177e4SLinus Torvalds *	Clean the specified virtual address range.
3011da177e4SLinus Torvalds *
3021da177e4SLinus Torvalds *	- start	- virtual start address
3031da177e4SLinus Torvalds *	- end	- virtual end address
3041da177e4SLinus Torvalds *
3051da177e4SLinus Torvalds * (same as v4wb)
3061da177e4SLinus Torvalds */
307702b94bfSRussell Kingarm1020_dma_clean_range:
3081da177e4SLinus Torvalds	mov	ip, #0
3091da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
3101da177e4SLinus Torvalds	bic	r0, r0, #CACHE_DLINESIZE - 1
3111da177e4SLinus Torvalds1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
3121da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
3131da177e4SLinus Torvalds	add	r0, r0, #CACHE_DLINESIZE
3141da177e4SLinus Torvalds	cmp	r0, r1
3151da177e4SLinus Torvalds	blo	1b
3161da177e4SLinus Torvalds#endif
3171da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
3186ebbf2ceSRussell King	ret	lr
3191da177e4SLinus Torvalds
3201da177e4SLinus Torvalds/*
3211da177e4SLinus Torvalds *	dma_flush_range(start, end)
3221da177e4SLinus Torvalds *
3231da177e4SLinus Torvalds *	Clean and invalidate the specified virtual address range.
3241da177e4SLinus Torvalds *
3251da177e4SLinus Torvalds *	- start	- virtual start address
3261da177e4SLinus Torvalds *	- end	- virtual end address
3271da177e4SLinus Torvalds */
3281036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_dma_flush_range)
3291da177e4SLinus Torvalds	mov	ip, #0
3301da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
3311da177e4SLinus Torvalds	bic	r0, r0, #CACHE_DLINESIZE - 1
3321da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4
3331da177e4SLinus Torvalds1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
3341da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
3351da177e4SLinus Torvalds	add	r0, r0, #CACHE_DLINESIZE
3361da177e4SLinus Torvalds	cmp	r0, r1
3371da177e4SLinus Torvalds	blo	1b
3381da177e4SLinus Torvalds#endif
3391da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
3406ebbf2ceSRussell King	ret	lr
3411036b895SLinus WalleijSYM_FUNC_END(arm1020_dma_flush_range)
3421da177e4SLinus Torvalds
343a9c9147eSRussell King/*
344a9c9147eSRussell King *	dma_map_area(start, size, dir)
345a9c9147eSRussell King *	- start	- kernel virtual start address
346a9c9147eSRussell King *	- size	- size of region
347a9c9147eSRussell King *	- dir	- DMA direction
348a9c9147eSRussell King */
3491036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_dma_map_area)
350a9c9147eSRussell King	add	r1, r1, r0
351a9c9147eSRussell King	cmp	r2, #DMA_TO_DEVICE
352a9c9147eSRussell King	beq	arm1020_dma_clean_range
353a9c9147eSRussell King	bcs	arm1020_dma_inv_range
354a9c9147eSRussell King	b	arm1020_dma_flush_range
3551036b895SLinus WalleijSYM_FUNC_END(arm1020_dma_map_area)
356a9c9147eSRussell King
357a9c9147eSRussell King/*
358a9c9147eSRussell King *	dma_unmap_area(start, size, dir)
359a9c9147eSRussell King *	- start	- kernel virtual start address
360a9c9147eSRussell King *	- size	- size of region
361a9c9147eSRussell King *	- dir	- DMA direction
362a9c9147eSRussell King */
3631036b895SLinus WalleijSYM_TYPED_FUNC_START(arm1020_dma_unmap_area)
3646ebbf2ceSRussell King	ret	lr
3651036b895SLinus WalleijSYM_FUNC_END(arm1020_dma_unmap_area)
366a9c9147eSRussell King
3671da177e4SLinus Torvalds	.align	5
36851db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_arm1020_dcache_clean_area)
3691da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
3701da177e4SLinus Torvalds	mov	ip, #0
3711da177e4SLinus Torvalds1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
3721da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
3731da177e4SLinus Torvalds	add	r0, r0, #CACHE_DLINESIZE
3741da177e4SLinus Torvalds	subs	r1, r1, #CACHE_DLINESIZE
3751da177e4SLinus Torvalds	bhi	1b
3761da177e4SLinus Torvalds#endif
3776ebbf2ceSRussell King	ret	lr
37851db13aaSLinus WalleijSYM_FUNC_END(cpu_arm1020_dcache_clean_area)
3791da177e4SLinus Torvalds
3801da177e4SLinus Torvalds/* =============================== PageTable ============================== */
3811da177e4SLinus Torvalds
3821da177e4SLinus Torvalds/*
3831da177e4SLinus Torvalds * cpu_arm1020_switch_mm(pgd)
3841da177e4SLinus Torvalds *
3851da177e4SLinus Torvalds * Set the translation base pointer to be as described by pgd.
3861da177e4SLinus Torvalds *
3871da177e4SLinus Torvalds * pgd: new page tables
3881da177e4SLinus Torvalds */
3891da177e4SLinus Torvalds	.align	5
39051db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_arm1020_switch_mm)
391d090dddaSHyok S. Choi#ifdef CONFIG_MMU
3921da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
3931da177e4SLinus Torvalds	mcr	p15, 0, r3, c7, c10, 4
3941da177e4SLinus Torvalds	mov	r1, #0xF			@ 16 segments
3951da177e4SLinus Torvalds1:	mov	r3, #0x3F			@ 64 entries
3961da177e4SLinus Torvalds2:	mov	ip, r3, LSL #26 		@ shift up entry
3971da177e4SLinus Torvalds	orr	ip, ip, r1, LSL #5		@ shift in/up index
3981da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c14, 2		@ Clean & Inval DCache entry
3991da177e4SLinus Torvalds	mov	ip, #0
4001da177e4SLinus Torvalds	mcr	p15, 0, ip, c7, c10, 4
4011da177e4SLinus Torvalds	subs	r3, r3, #1
4021da177e4SLinus Torvalds	cmp	r3, #0
4031da177e4SLinus Torvalds	bge	2b				@ entries 3F to 0
4041da177e4SLinus Torvalds	subs	r1, r1, #1
4051da177e4SLinus Torvalds	cmp	r1, #0
4061da177e4SLinus Torvalds	bge	1b				@ segments 15 to 0
4071da177e4SLinus Torvalds
4081da177e4SLinus Torvalds#endif
4091da177e4SLinus Torvalds	mov	r1, #0
4101da177e4SLinus Torvalds#ifndef CONFIG_CPU_ICACHE_DISABLE
4111da177e4SLinus Torvalds	mcr	p15, 0, r1, c7, c5, 0		@ invalidate I cache
4121da177e4SLinus Torvalds#endif
4131da177e4SLinus Torvalds	mcr	p15, 0, r1, c7, c10, 4		@ drain WB
4141da177e4SLinus Torvalds	mcr	p15, 0, r0, c2, c0, 0		@ load page table pointer
4151da177e4SLinus Torvalds	mcr	p15, 0, r1, c8, c7, 0		@ invalidate I & D TLBs
416d090dddaSHyok S. Choi#endif /* CONFIG_MMU */
4176ebbf2ceSRussell King	ret	lr
41851db13aaSLinus WalleijSYM_FUNC_END(cpu_arm1020_switch_mm)
4191da177e4SLinus Torvalds
4201da177e4SLinus Torvalds/*
4211da177e4SLinus Torvalds * cpu_arm1020_set_pte(ptep, pte)
4221da177e4SLinus Torvalds *
4231da177e4SLinus Torvalds * Set a PTE and flush it out
4241da177e4SLinus Torvalds */
4251da177e4SLinus Torvalds	.align	5
42651db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_arm1020_set_pte_ext)
427d090dddaSHyok S. Choi#ifdef CONFIG_MMU
428da091653SRussell King	armv3_set_pte_ext
4291da177e4SLinus Torvalds	mov	r0, r0
4301da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
4311da177e4SLinus Torvalds	mcr	p15, 0, r0, c7, c10, 4
4321da177e4SLinus Torvalds	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
4331da177e4SLinus Torvalds#endif
4341da177e4SLinus Torvalds	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
435d090dddaSHyok S. Choi#endif /* CONFIG_MMU */
4366ebbf2ceSRussell King	ret	lr
43751db13aaSLinus WalleijSYM_FUNC_END(cpu_arm1020_set_pte_ext)
4381da177e4SLinus Torvalds
4391da177e4SLinus Torvalds	.type	__arm1020_setup, #function
4401da177e4SLinus Torvalds__arm1020_setup:
4411da177e4SLinus Torvalds	mov	r0, #0
4421da177e4SLinus Torvalds	mcr	p15, 0, r0, c7, c7		@ invalidate I,D caches on v4
4431da177e4SLinus Torvalds	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer on v4
444d090dddaSHyok S. Choi#ifdef CONFIG_MMU
4451da177e4SLinus Torvalds	mcr	p15, 0, r0, c8, c7		@ invalidate I,D TLBs on v4
446d090dddaSHyok S. Choi#endif
44722b19086SRussell King
44822b19086SRussell King	adr	r5, arm1020_crval
44922b19086SRussell King	ldmia	r5, {r5, r6}
4501da177e4SLinus Torvalds	mrc	p15, 0, r0, c1, c0		@ get control register v4
4511da177e4SLinus Torvalds	bic	r0, r0, r5
45222b19086SRussell King	orr	r0, r0, r6
4531da177e4SLinus Torvalds#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
4541da177e4SLinus Torvalds	orr	r0, r0, #0x4000 		@ .R.. .... .... ....
4551da177e4SLinus Torvalds#endif
4566ebbf2ceSRussell King	ret	lr
4571da177e4SLinus Torvalds	.size	__arm1020_setup, . - __arm1020_setup
4581da177e4SLinus Torvalds
4591da177e4SLinus Torvalds	/*
4601da177e4SLinus Torvalds	 *  R
4611da177e4SLinus Torvalds	 * .RVI ZFRS BLDP WCAM
462abaf48a0SCatalin Marinas	 * .011 1001 ..11 0101
4631da177e4SLinus Torvalds	 */
46422b19086SRussell King	.type	arm1020_crval, #object
46522b19086SRussell Kingarm1020_crval:
46622b19086SRussell King	crval	clear=0x0000593f, mmuset=0x00003935, ucset=0x00001930
4671da177e4SLinus Torvalds
4681da177e4SLinus Torvalds	__INITDATA
46956d91650SDave Martin	@ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
47056d91650SDave Martin	define_processor_functions arm1020, dabort=v4t_early_abort, pabort=legacy_pabort
4711da177e4SLinus Torvalds
4721da177e4SLinus Torvalds
4731da177e4SLinus Torvalds	.section ".rodata"
4741da177e4SLinus Torvalds
47556d91650SDave Martin	string	cpu_arch_name, "armv5t"
47656d91650SDave Martin	string	cpu_elf_name, "v5"
4771da177e4SLinus Torvalds
4781da177e4SLinus Torvalds	.type	cpu_arm1020_name, #object
4791da177e4SLinus Torvaldscpu_arm1020_name:
4801da177e4SLinus Torvalds	.ascii	"ARM1020"
4811da177e4SLinus Torvalds#ifndef CONFIG_CPU_ICACHE_DISABLE
4821da177e4SLinus Torvalds	.ascii	"i"
4831da177e4SLinus Torvalds#endif
4841da177e4SLinus Torvalds#ifndef CONFIG_CPU_DCACHE_DISABLE
4851da177e4SLinus Torvalds	.ascii	"d"
4861da177e4SLinus Torvalds#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
4871da177e4SLinus Torvalds	.ascii	"(wt)"
4881da177e4SLinus Torvalds#else
4891da177e4SLinus Torvalds	.ascii	"(wb)"
4901da177e4SLinus Torvalds#endif
4911da177e4SLinus Torvalds#endif
4921da177e4SLinus Torvalds#ifndef CONFIG_CPU_BPREDICT_DISABLE
4931da177e4SLinus Torvalds	.ascii	"B"
4941da177e4SLinus Torvalds#endif
4951da177e4SLinus Torvalds#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
4961da177e4SLinus Torvalds	.ascii	"RR"
4971da177e4SLinus Torvalds#endif
4981da177e4SLinus Torvalds	.ascii	"\0"
4991da177e4SLinus Torvalds	.size	cpu_arm1020_name, . - cpu_arm1020_name
5001da177e4SLinus Torvalds
5011da177e4SLinus Torvalds	.align
5021da177e4SLinus Torvalds
503790756c7SNick Desaulniers	.section ".proc.info.init", "a"
5041da177e4SLinus Torvalds
5051da177e4SLinus Torvalds	.type	__arm1020_proc_info,#object
5061da177e4SLinus Torvalds__arm1020_proc_info:
5071da177e4SLinus Torvalds	.long	0x4104a200			@ ARM 1020T (Architecture v5T)
5081da177e4SLinus Torvalds	.long	0xff0ffff0
5091da177e4SLinus Torvalds	.long   PMD_TYPE_SECT | \
5101da177e4SLinus Torvalds		PMD_SECT_AP_WRITE | \
5111da177e4SLinus Torvalds		PMD_SECT_AP_READ
5128799ee9fSRussell King	.long   PMD_TYPE_SECT | \
5138799ee9fSRussell King		PMD_SECT_AP_WRITE | \
5148799ee9fSRussell King		PMD_SECT_AP_READ
515bf35706fSArd Biesheuvel	initfn	__arm1020_setup, __arm1020_proc_info
5161da177e4SLinus Torvalds	.long	cpu_arch_name
5171da177e4SLinus Torvalds	.long	cpu_elf_name
5181da177e4SLinus Torvalds	.long	HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
5191da177e4SLinus Torvalds	.long	cpu_arm1020_name
5201da177e4SLinus Torvalds	.long	arm1020_processor_functions
5211da177e4SLinus Torvalds	.long	v4wbi_tlb_fns
5221da177e4SLinus Torvalds	.long	v4wb_user_fns
5231da177e4SLinus Torvalds	.long	arm1020_cache_fns
5241da177e4SLinus Torvalds	.size	__arm1020_proc_info, . - __arm1020_proc_info
525