blob: 5bb8e3c61d850ca05cde23dbdf9872ffe7b262af [file] [log] [blame]
Johannes Weinere5083a62009-03-04 16:21:31 +01001/*
2 * xtensa mmu stuff
3 *
4 * Extracted from init.c
5 */
6#include <linux/percpu.h>
7#include <linux/init.h>
8#include <linux/string.h>
9#include <linux/slab.h>
10#include <linux/cache.h>
11
12#include <asm/tlb.h>
13#include <asm/tlbflush.h>
14#include <asm/mmu_context.h>
15#include <asm/page.h>
16
Johannes Weinere5083a62009-03-04 16:21:31 +010017void __init paging_init(void)
18{
19 memset(swapper_pg_dir, 0, PAGE_SIZE);
20}
21
22/*
23 * Flush the mmu and reset associated register to default values.
24 */
Max Filippovf6151362013-10-17 02:42:26 +040025void init_mmu(void)
Johannes Weinere5083a62009-03-04 16:21:31 +010026{
Max Filippove85e3352012-12-03 15:01:43 +040027#if !(XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY)
28 /*
29 * Writing zeros to the instruction and data TLBCFG special
30 * registers ensure that valid values exist in the register.
31 *
32 * For existing PGSZID<w> fields, zero selects the first element
33 * of the page-size array. For nonexistent PGSZID<w> fields,
34 * zero is the best value to write. Also, when changing PGSZID<w>
Johannes Weinere5083a62009-03-04 16:21:31 +010035 * fields, the corresponding TLB must be flushed.
36 */
37 set_itlbcfg_register(0);
38 set_dtlbcfg_register(0);
Max Filippove85e3352012-12-03 15:01:43 +040039#endif
Max Filippovf6151362013-10-17 02:42:26 +040040 local_flush_tlb_all();
Johannes Weinere5083a62009-03-04 16:21:31 +010041
42 /* Set rasid register to a known value. */
43
Max Filippovec747b22012-12-11 01:26:24 +040044 set_rasid_register(ASID_INSERT(ASID_USER_FIRST));
Johannes Weinere5083a62009-03-04 16:21:31 +010045
46 /* Set PTEVADDR special register to the start of the page
47 * table, which is in kernel mappable space (ie. not
48 * statically mapped). This register's value is undefined on
49 * reset.
50 */
51 set_ptevaddr_register(PGTABLE_START);
52}