xref: /linux/arch/arm/mm/proc-mohawk.S (revision 4853f1f6ace32c68a04287353e428c4cfc3fa8ed)
11a59d1b8SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-or-later */
249cbe786SEric Miao/*
349cbe786SEric Miao *  linux/arch/arm/mm/proc-mohawk.S: MMU functions for Marvell PJ1 core
449cbe786SEric Miao *
549cbe786SEric Miao *  PJ1 (codename Mohawk) is a hybrid of the xscale3 and Marvell's own core.
649cbe786SEric Miao *
749cbe786SEric Miao *  Heavily based on proc-arm926.S and proc-xsc3.S
849cbe786SEric Miao */
949cbe786SEric Miao
1049cbe786SEric Miao#include <linux/linkage.h>
1149cbe786SEric Miao#include <linux/init.h>
121036b895SLinus Walleij#include <linux/cfi_types.h>
1365fddcfcSMike Rapoport#include <linux/pgtable.h>
1449cbe786SEric Miao#include <asm/assembler.h>
1549cbe786SEric Miao#include <asm/hwcap.h>
1649cbe786SEric Miao#include <asm/pgtable-hwdef.h>
1749cbe786SEric Miao#include <asm/page.h>
1849cbe786SEric Miao#include <asm/ptrace.h>
1949cbe786SEric Miao#include "proc-macros.S"
2049cbe786SEric Miao
2149cbe786SEric Miao/*
2249cbe786SEric Miao * This is the maximum size of an area which will be flushed.  If the
2349cbe786SEric Miao * area is larger than this, then we flush the whole cache.
2449cbe786SEric Miao */
2549cbe786SEric Miao#define CACHE_DLIMIT	32768
2649cbe786SEric Miao
2749cbe786SEric Miao/*
2849cbe786SEric Miao * The cache line size of the L1 D cache.
2949cbe786SEric Miao */
3049cbe786SEric Miao#define CACHE_DLINESIZE	32
3149cbe786SEric Miao
3249cbe786SEric Miao/*
3349cbe786SEric Miao * cpu_mohawk_proc_init()
3449cbe786SEric Miao */
3551db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_proc_init)
366ebbf2ceSRussell King	ret	lr
3751db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_proc_init)
3849cbe786SEric Miao
3949cbe786SEric Miao/*
4049cbe786SEric Miao * cpu_mohawk_proc_fin()
4149cbe786SEric Miao */
4251db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_proc_fin)
4349cbe786SEric Miao	mrc	p15, 0, r0, c1, c0, 0		@ ctrl register
4449cbe786SEric Miao	bic	r0, r0, #0x1800			@ ...iz...........
4549cbe786SEric Miao	bic	r0, r0, #0x0006			@ .............ca.
4649cbe786SEric Miao	mcr	p15, 0, r0, c1, c0, 0		@ disable caches
476ebbf2ceSRussell King	ret	lr
4851db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_proc_fin)
4949cbe786SEric Miao
5049cbe786SEric Miao/*
5149cbe786SEric Miao * cpu_mohawk_reset(loc)
5249cbe786SEric Miao *
5349cbe786SEric Miao * Perform a soft reset of the system.  Put the CPU into the
5449cbe786SEric Miao * same state as it would be if it had been reset, and branch
5549cbe786SEric Miao * to what would be the reset vector.
5649cbe786SEric Miao *
5749cbe786SEric Miao * loc: location to jump to for soft reset
5849cbe786SEric Miao *
5949cbe786SEric Miao * (same as arm926)
6049cbe786SEric Miao */
6149cbe786SEric Miao	.align	5
621a4baafaSWill Deacon	.pushsection	.idmap.text, "ax"
6351db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_reset)
6449cbe786SEric Miao	mov	ip, #0
6549cbe786SEric Miao	mcr	p15, 0, ip, c7, c7, 0		@ invalidate I,D caches
6649cbe786SEric Miao	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
6749cbe786SEric Miao	mcr	p15, 0, ip, c8, c7, 0		@ invalidate I & D TLBs
6849cbe786SEric Miao	mrc	p15, 0, ip, c1, c0, 0		@ ctrl register
6949cbe786SEric Miao	bic	ip, ip, #0x0007			@ .............cam
7049cbe786SEric Miao	bic	ip, ip, #0x1100			@ ...i...s........
7149cbe786SEric Miao	mcr	p15, 0, ip, c1, c0, 0		@ ctrl register
726ebbf2ceSRussell King	ret	r0
7351db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_reset)
741a4baafaSWill Deacon	.popsection
7549cbe786SEric Miao
7649cbe786SEric Miao/*
7749cbe786SEric Miao * cpu_mohawk_do_idle()
7849cbe786SEric Miao *
7949cbe786SEric Miao * Called with IRQs disabled
8049cbe786SEric Miao */
8149cbe786SEric Miao	.align	5
8251db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_do_idle)
8349cbe786SEric Miao	mov	r0, #0
8449cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
8549cbe786SEric Miao	mcr	p15, 0, r0, c7, c0, 4		@ wait for interrupt
866ebbf2ceSRussell King	ret	lr
8751db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_do_idle)
8849cbe786SEric Miao
8949cbe786SEric Miao/*
90a39a3218SDave Martin *	flush_icache_all()
91a39a3218SDave Martin *
92a39a3218SDave Martin *	Unconditionally clean and invalidate the entire icache.
93a39a3218SDave Martin */
941036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_flush_icache_all)
95a39a3218SDave Martin	mov	r0, #0
96a39a3218SDave Martin	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
976ebbf2ceSRussell King	ret	lr
981036b895SLinus WalleijSYM_FUNC_END(mohawk_flush_icache_all)
99a39a3218SDave Martin
100a39a3218SDave Martin/*
10149cbe786SEric Miao *	flush_user_cache_all()
10249cbe786SEric Miao *
10349cbe786SEric Miao *	Clean and invalidate all cache entries in a particular
10449cbe786SEric Miao *	address space.
10549cbe786SEric Miao */
1062074beebSLinus WalleijSYM_FUNC_ALIAS(mohawk_flush_user_cache_all, mohawk_flush_kern_cache_all)
10749cbe786SEric Miao
10849cbe786SEric Miao/*
10949cbe786SEric Miao *	flush_kern_cache_all()
11049cbe786SEric Miao *
11149cbe786SEric Miao *	Clean and invalidate the entire cache.
11249cbe786SEric Miao */
1131036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_flush_kern_cache_all)
11449cbe786SEric Miao	mov	r2, #VM_EXEC
11549cbe786SEric Miao	mov	ip, #0
11649cbe786SEric Miao__flush_whole_cache:
11749cbe786SEric Miao	mcr	p15, 0, ip, c7, c14, 0		@ clean & invalidate all D cache
11849cbe786SEric Miao	tst	r2, #VM_EXEC
11949cbe786SEric Miao	mcrne	p15, 0, ip, c7, c5, 0		@ invalidate I cache
12049cbe786SEric Miao	mcrne	p15, 0, ip, c7, c10, 0		@ drain write buffer
1216ebbf2ceSRussell King	ret	lr
1221036b895SLinus WalleijSYM_FUNC_END(mohawk_flush_kern_cache_all)
12349cbe786SEric Miao
12449cbe786SEric Miao/*
12549cbe786SEric Miao *	flush_user_cache_range(start, end, flags)
12649cbe786SEric Miao *
12749cbe786SEric Miao *	Clean and invalidate a range of cache entries in the
12849cbe786SEric Miao *	specified address range.
12949cbe786SEric Miao *
13049cbe786SEric Miao *	- start	- start address (inclusive)
13149cbe786SEric Miao *	- end	- end address (exclusive)
13249cbe786SEric Miao *	- flags	- vm_flags describing address space
13349cbe786SEric Miao *
13449cbe786SEric Miao * (same as arm926)
13549cbe786SEric Miao */
1361036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_flush_user_cache_range)
13749cbe786SEric Miao	mov	ip, #0
13849cbe786SEric Miao	sub	r3, r1, r0			@ calculate total size
13949cbe786SEric Miao	cmp	r3, #CACHE_DLIMIT
14049cbe786SEric Miao	bgt	__flush_whole_cache
14149cbe786SEric Miao1:	tst	r2, #VM_EXEC
14249cbe786SEric Miao	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
14349cbe786SEric Miao	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
14449cbe786SEric Miao	add	r0, r0, #CACHE_DLINESIZE
14549cbe786SEric Miao	mcr	p15, 0, r0, c7, c14, 1		@ clean and invalidate D entry
14649cbe786SEric Miao	mcrne	p15, 0, r0, c7, c5, 1		@ invalidate I entry
14749cbe786SEric Miao	add	r0, r0, #CACHE_DLINESIZE
14849cbe786SEric Miao	cmp	r0, r1
14949cbe786SEric Miao	blo	1b
15049cbe786SEric Miao	tst	r2, #VM_EXEC
15149cbe786SEric Miao	mcrne	p15, 0, ip, c7, c10, 4		@ drain WB
1526ebbf2ceSRussell King	ret	lr
1531036b895SLinus WalleijSYM_FUNC_END(mohawk_flush_user_cache_range)
15449cbe786SEric Miao
15549cbe786SEric Miao/*
15649cbe786SEric Miao *	coherent_kern_range(start, end)
15749cbe786SEric Miao *
15849cbe786SEric Miao *	Ensure coherency between the Icache and the Dcache in the
15949cbe786SEric Miao *	region described by start, end.  If you have non-snooping
16049cbe786SEric Miao *	Harvard caches, you need to implement this function.
16149cbe786SEric Miao *
16249cbe786SEric Miao *	- start	- virtual start address
16349cbe786SEric Miao *	- end	- virtual end address
16449cbe786SEric Miao */
1651036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_coherent_kern_range)
166*7b749aadSLinus Walleij#ifdef CONFIG_CFI_CLANG /* Fallthrough if !CFI */
1671036b895SLinus Walleij	b	mohawk_coherent_user_range
168*7b749aadSLinus Walleij#endif
1691036b895SLinus WalleijSYM_FUNC_END(mohawk_coherent_kern_range)
17049cbe786SEric Miao
17149cbe786SEric Miao/*
17249cbe786SEric Miao *	coherent_user_range(start, end)
17349cbe786SEric Miao *
17449cbe786SEric Miao *	Ensure coherency between the Icache and the Dcache in the
17549cbe786SEric Miao *	region described by start, end.  If you have non-snooping
17649cbe786SEric Miao *	Harvard caches, you need to implement this function.
17749cbe786SEric Miao *
17849cbe786SEric Miao *	- start	- virtual start address
17949cbe786SEric Miao *	- end	- virtual end address
18049cbe786SEric Miao *
18149cbe786SEric Miao * (same as arm926)
18249cbe786SEric Miao */
1831036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_coherent_user_range)
18449cbe786SEric Miao	bic	r0, r0, #CACHE_DLINESIZE - 1
18549cbe786SEric Miao1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
18649cbe786SEric Miao	mcr	p15, 0, r0, c7, c5, 1		@ invalidate I entry
18749cbe786SEric Miao	add	r0, r0, #CACHE_DLINESIZE
18849cbe786SEric Miao	cmp	r0, r1
18949cbe786SEric Miao	blo	1b
19049cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
191c5102f59SWill Deacon	mov	r0, #0
1926ebbf2ceSRussell King	ret	lr
1931036b895SLinus WalleijSYM_FUNC_END(mohawk_coherent_user_range)
19449cbe786SEric Miao
19549cbe786SEric Miao/*
1962c9b9c84SRussell King *	flush_kern_dcache_area(void *addr, size_t size)
19749cbe786SEric Miao *
19849cbe786SEric Miao *	Ensure no D cache aliasing occurs, either with itself or
19949cbe786SEric Miao *	the I cache
20049cbe786SEric Miao *
2012c9b9c84SRussell King *	- addr	- kernel address
2022c9b9c84SRussell King *	- size	- region size
20349cbe786SEric Miao */
2041036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_flush_kern_dcache_area)
2052c9b9c84SRussell King	add	r1, r0, r1
20649cbe786SEric Miao1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
20749cbe786SEric Miao	add	r0, r0, #CACHE_DLINESIZE
20849cbe786SEric Miao	cmp	r0, r1
20949cbe786SEric Miao	blo	1b
21049cbe786SEric Miao	mov	r0, #0
21149cbe786SEric Miao	mcr	p15, 0, r0, c7, c5, 0		@ invalidate I cache
21249cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
2136ebbf2ceSRussell King	ret	lr
2141036b895SLinus WalleijSYM_FUNC_END(mohawk_flush_kern_dcache_area)
21549cbe786SEric Miao
21649cbe786SEric Miao/*
21749cbe786SEric Miao *	dma_inv_range(start, end)
21849cbe786SEric Miao *
21949cbe786SEric Miao *	Invalidate (discard) the specified virtual address range.
22049cbe786SEric Miao *	May not write back any entries.  If 'start' or 'end'
22149cbe786SEric Miao *	are not cache line aligned, those lines must be written
22249cbe786SEric Miao *	back.
22349cbe786SEric Miao *
22449cbe786SEric Miao *	- start	- virtual start address
22549cbe786SEric Miao *	- end	- virtual end address
22649cbe786SEric Miao *
22749cbe786SEric Miao * (same as v4wb)
22849cbe786SEric Miao */
229702b94bfSRussell Kingmohawk_dma_inv_range:
23049cbe786SEric Miao	tst	r0, #CACHE_DLINESIZE - 1
23149cbe786SEric Miao	mcrne	p15, 0, r0, c7, c10, 1		@ clean D entry
23249cbe786SEric Miao	tst	r1, #CACHE_DLINESIZE - 1
23349cbe786SEric Miao	mcrne	p15, 0, r1, c7, c10, 1		@ clean D entry
23449cbe786SEric Miao	bic	r0, r0, #CACHE_DLINESIZE - 1
23549cbe786SEric Miao1:	mcr	p15, 0, r0, c7, c6, 1		@ invalidate D entry
23649cbe786SEric Miao	add	r0, r0, #CACHE_DLINESIZE
23749cbe786SEric Miao	cmp	r0, r1
23849cbe786SEric Miao	blo	1b
23949cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
2406ebbf2ceSRussell King	ret	lr
24149cbe786SEric Miao
24249cbe786SEric Miao/*
24349cbe786SEric Miao *	dma_clean_range(start, end)
24449cbe786SEric Miao *
24549cbe786SEric Miao *	Clean the specified virtual address range.
24649cbe786SEric Miao *
24749cbe786SEric Miao *	- start	- virtual start address
24849cbe786SEric Miao *	- end	- virtual end address
24949cbe786SEric Miao *
25049cbe786SEric Miao * (same as v4wb)
25149cbe786SEric Miao */
252702b94bfSRussell Kingmohawk_dma_clean_range:
25349cbe786SEric Miao	bic	r0, r0, #CACHE_DLINESIZE - 1
25449cbe786SEric Miao1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
25549cbe786SEric Miao	add	r0, r0, #CACHE_DLINESIZE
25649cbe786SEric Miao	cmp	r0, r1
25749cbe786SEric Miao	blo	1b
25849cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
2596ebbf2ceSRussell King	ret	lr
26049cbe786SEric Miao
26149cbe786SEric Miao/*
26249cbe786SEric Miao *	dma_flush_range(start, end)
26349cbe786SEric Miao *
26449cbe786SEric Miao *	Clean and invalidate the specified virtual address range.
26549cbe786SEric Miao *
26649cbe786SEric Miao *	- start	- virtual start address
26749cbe786SEric Miao *	- end	- virtual end address
26849cbe786SEric Miao */
2691036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_dma_flush_range)
27049cbe786SEric Miao	bic	r0, r0, #CACHE_DLINESIZE - 1
27149cbe786SEric Miao1:
27249cbe786SEric Miao	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
27349cbe786SEric Miao	add	r0, r0, #CACHE_DLINESIZE
27449cbe786SEric Miao	cmp	r0, r1
27549cbe786SEric Miao	blo	1b
27649cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
2776ebbf2ceSRussell King	ret	lr
2781036b895SLinus WalleijSYM_FUNC_END(mohawk_dma_flush_range)
27949cbe786SEric Miao
280a9c9147eSRussell King/*
281a9c9147eSRussell King *	dma_map_area(start, size, dir)
282a9c9147eSRussell King *	- start	- kernel virtual start address
283a9c9147eSRussell King *	- size	- size of region
284a9c9147eSRussell King *	- dir	- DMA direction
285a9c9147eSRussell King */
2861036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_dma_map_area)
287a9c9147eSRussell King	add	r1, r1, r0
288a9c9147eSRussell King	cmp	r2, #DMA_TO_DEVICE
289a9c9147eSRussell King	beq	mohawk_dma_clean_range
290a9c9147eSRussell King	bcs	mohawk_dma_inv_range
291a9c9147eSRussell King	b	mohawk_dma_flush_range
2921036b895SLinus WalleijSYM_FUNC_END(mohawk_dma_map_area)
293a9c9147eSRussell King
294a9c9147eSRussell King/*
295a9c9147eSRussell King *	dma_unmap_area(start, size, dir)
296a9c9147eSRussell King *	- start	- kernel virtual start address
297a9c9147eSRussell King *	- size	- size of region
298a9c9147eSRussell King *	- dir	- DMA direction
299a9c9147eSRussell King */
3001036b895SLinus WalleijSYM_TYPED_FUNC_START(mohawk_dma_unmap_area)
3016ebbf2ceSRussell King	ret	lr
3021036b895SLinus WalleijSYM_FUNC_END(mohawk_dma_unmap_area)
303a9c9147eSRussell King
30451db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_dcache_clean_area)
30549cbe786SEric Miao1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
30649cbe786SEric Miao	add	r0, r0, #CACHE_DLINESIZE
30749cbe786SEric Miao	subs	r1, r1, #CACHE_DLINESIZE
30849cbe786SEric Miao	bhi	1b
30949cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
3106ebbf2ceSRussell King	ret	lr
31151db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_dcache_clean_area)
31249cbe786SEric Miao
31349cbe786SEric Miao/*
31449cbe786SEric Miao * cpu_mohawk_switch_mm(pgd)
31549cbe786SEric Miao *
31649cbe786SEric Miao * Set the translation base pointer to be as described by pgd.
31749cbe786SEric Miao *
31849cbe786SEric Miao * pgd: new page tables
31949cbe786SEric Miao */
32049cbe786SEric Miao	.align	5
32151db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_switch_mm)
32249cbe786SEric Miao	mov	ip, #0
32349cbe786SEric Miao	mcr	p15, 0, ip, c7, c14, 0		@ clean & invalidate all D cache
32449cbe786SEric Miao	mcr	p15, 0, ip, c7, c5, 0		@ invalidate I cache
32549cbe786SEric Miao	mcr	p15, 0, ip, c7, c10, 4		@ drain WB
32649cbe786SEric Miao	orr	r0, r0, #0x18			@ cache the page table in L2
32749cbe786SEric Miao	mcr	p15, 0, r0, c2, c0, 0		@ load page table pointer
32849cbe786SEric Miao	mcr	p15, 0, ip, c8, c7, 0		@ invalidate I & D TLBs
3296ebbf2ceSRussell King	ret	lr
33051db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_switch_mm)
33149cbe786SEric Miao
33249cbe786SEric Miao/*
33349cbe786SEric Miao * cpu_mohawk_set_pte_ext(ptep, pte, ext)
33449cbe786SEric Miao *
33549cbe786SEric Miao * Set a PTE and flush it out
33649cbe786SEric Miao */
33749cbe786SEric Miao	.align	5
33851db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_set_pte_ext)
3390f67b876SArnd Bergmann#ifdef CONFIG_MMU
34049cbe786SEric Miao	armv3_set_pte_ext
34149cbe786SEric Miao	mov	r0, r0
34249cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
34349cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain WB
3446ebbf2ceSRussell King	ret	lr
3450f67b876SArnd Bergmann#endif
34651db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_set_pte_ext)
34749cbe786SEric Miao
3483f5d0819SChao Xie.globl	cpu_mohawk_suspend_size
3493f5d0819SChao Xie.equ	cpu_mohawk_suspend_size, 4 * 6
350b6c7aabdSRussell King#ifdef CONFIG_ARM_CPU_SUSPEND
35151db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_do_suspend)
3523f5d0819SChao Xie	stmfd	sp!, {r4 - r9, lr}
3533f5d0819SChao Xie	mrc	p14, 0, r4, c6, c0, 0	@ clock configuration, for turbo mode
3543f5d0819SChao Xie	mrc	p15, 0, r5, c15, c1, 0	@ CP access reg
3553f5d0819SChao Xie	mrc	p15, 0, r6, c13, c0, 0	@ PID
3563f5d0819SChao Xie	mrc 	p15, 0, r7, c3, c0, 0	@ domain ID
3573f5d0819SChao Xie	mrc	p15, 0, r8, c1, c0, 1	@ auxiliary control reg
3583f5d0819SChao Xie	mrc 	p15, 0, r9, c1, c0, 0	@ control reg
3593f5d0819SChao Xie	bic	r4, r4, #2		@ clear frequency change bit
3603f5d0819SChao Xie	stmia	r0, {r4 - r9}		@ store cp regs
3613f5d0819SChao Xie	ldmia	sp!, {r4 - r9, pc}
36251db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_do_suspend)
3633f5d0819SChao Xie
36451db13aaSLinus WalleijSYM_TYPED_FUNC_START(cpu_mohawk_do_resume)
3653f5d0819SChao Xie	ldmia	r0, {r4 - r9}		@ load cp regs
3663f5d0819SChao Xie	mov	ip, #0
3673f5d0819SChao Xie	mcr	p15, 0, ip, c7, c7, 0	@ invalidate I & D caches, BTB
3683f5d0819SChao Xie	mcr	p15, 0, ip, c7, c10, 4	@ drain write (&fill) buffer
3693f5d0819SChao Xie	mcr	p15, 0, ip, c7, c5, 4	@ flush prefetch buffer
3703f5d0819SChao Xie	mcr	p15, 0, ip, c8, c7, 0	@ invalidate I & D TLBs
3713f5d0819SChao Xie	mcr	p14, 0, r4, c6, c0, 0	@ clock configuration, turbo mode.
3723f5d0819SChao Xie	mcr	p15, 0, r5, c15, c1, 0	@ CP access reg
3733f5d0819SChao Xie	mcr	p15, 0, r6, c13, c0, 0	@ PID
3743f5d0819SChao Xie	mcr	p15, 0, r7, c3, c0, 0	@ domain ID
3753f5d0819SChao Xie	orr	r1, r1, #0x18		@ cache the page table in L2
3763f5d0819SChao Xie	mcr	p15, 0, r1, c2, c0, 0	@ translation table base addr
3773f5d0819SChao Xie	mcr	p15, 0, r8, c1, c0, 1	@ auxiliary control reg
3783f5d0819SChao Xie	mov	r0, r9			@ control register
3793f5d0819SChao Xie	b	cpu_resume_mmu
38051db13aaSLinus WalleijSYM_FUNC_END(cpu_mohawk_do_resume)
3813f5d0819SChao Xie#endif
3823f5d0819SChao Xie
38349cbe786SEric Miao	.type	__mohawk_setup, #function
38449cbe786SEric Miao__mohawk_setup:
38549cbe786SEric Miao	mov	r0, #0
38649cbe786SEric Miao	mcr	p15, 0, r0, c7, c7		@ invalidate I,D caches
38749cbe786SEric Miao	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
38849cbe786SEric Miao	mcr	p15, 0, r0, c8, c7		@ invalidate I,D TLBs
38949cbe786SEric Miao	orr	r4, r4, #0x18			@ cache the page table in L2
39049cbe786SEric Miao	mcr	p15, 0, r4, c2, c0, 0		@ load page table pointer
39149cbe786SEric Miao
39249cbe786SEric Miao	mov	r0, #0				@ don't allow CP access
39349cbe786SEric Miao	mcr	p15, 0, r0, c15, c1, 0		@ write CP access register
39449cbe786SEric Miao
39549cbe786SEric Miao	adr	r5, mohawk_crval
39649cbe786SEric Miao	ldmia	r5, {r5, r6}
39749cbe786SEric Miao	mrc	p15, 0, r0, c1, c0		@ get control register
39849cbe786SEric Miao	bic	r0, r0, r5
39949cbe786SEric Miao	orr	r0, r0, r6
4006ebbf2ceSRussell King	ret	lr
40149cbe786SEric Miao
40249cbe786SEric Miao	.size	__mohawk_setup, . - __mohawk_setup
40349cbe786SEric Miao
40449cbe786SEric Miao	/*
40549cbe786SEric Miao	 *  R
40649cbe786SEric Miao	 * .RVI ZFRS BLDP WCAM
40749cbe786SEric Miao	 * .011 1001 ..00 0101
40849cbe786SEric Miao	 *
40949cbe786SEric Miao	 */
41049cbe786SEric Miao	.type	mohawk_crval, #object
41149cbe786SEric Miaomohawk_crval:
41249cbe786SEric Miao	crval	clear=0x00007f3f, mmuset=0x00003905, ucset=0x00001134
41349cbe786SEric Miao
41449cbe786SEric Miao	__INITDATA
41549cbe786SEric Miao
416a39a3218SDave Martin	@ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
417a39a3218SDave Martin	define_processor_functions mohawk, dabort=v5t_early_abort, pabort=legacy_pabort
41849cbe786SEric Miao
41949cbe786SEric Miao	.section ".rodata"
42049cbe786SEric Miao
421a39a3218SDave Martin	string	cpu_arch_name, "armv5te"
422a39a3218SDave Martin	string	cpu_elf_name, "v5"
423a39a3218SDave Martin	string	cpu_mohawk_name, "Marvell 88SV331x"
42449cbe786SEric Miao
42549cbe786SEric Miao	.align
42649cbe786SEric Miao
427790756c7SNick Desaulniers	.section ".proc.info.init", "a"
42849cbe786SEric Miao
42949cbe786SEric Miao	.type	__88sv331x_proc_info,#object
43049cbe786SEric Miao__88sv331x_proc_info:
43149cbe786SEric Miao	.long	0x56158000			@ Marvell 88SV331x (MOHAWK)
43249cbe786SEric Miao	.long	0xfffff000
43349cbe786SEric Miao	.long   PMD_TYPE_SECT | \
43449cbe786SEric Miao		PMD_SECT_BUFFERABLE | \
43549cbe786SEric Miao		PMD_SECT_CACHEABLE | \
43649cbe786SEric Miao		PMD_BIT4 | \
43749cbe786SEric Miao		PMD_SECT_AP_WRITE | \
43849cbe786SEric Miao		PMD_SECT_AP_READ
43949cbe786SEric Miao	.long   PMD_TYPE_SECT | \
44049cbe786SEric Miao		PMD_BIT4 | \
44149cbe786SEric Miao		PMD_SECT_AP_WRITE | \
44249cbe786SEric Miao		PMD_SECT_AP_READ
443bf35706fSArd Biesheuvel	initfn	__mohawk_setup, __88sv331x_proc_info
44449cbe786SEric Miao	.long	cpu_arch_name
44549cbe786SEric Miao	.long	cpu_elf_name
44649cbe786SEric Miao	.long	HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
44749cbe786SEric Miao	.long	cpu_mohawk_name
44849cbe786SEric Miao	.long	mohawk_processor_functions
44949cbe786SEric Miao	.long	v4wbi_tlb_fns
45049cbe786SEric Miao	.long	v4wb_user_fns
45149cbe786SEric Miao	.long	mohawk_cache_fns
45249cbe786SEric Miao	.size	__88sv331x_proc_info, . - __88sv331x_proc_info
453