drm/panthor: Don't add write fences to the shared BOs
[drm/drm-misc.git] / arch / csky / kernel / setup.c
blob51012e90780d6b15583dd1f16d3e84f09ca85ecf
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
4 #include <linux/console.h>
5 #include <linux/memblock.h>
6 #include <linux/initrd.h>
7 #include <linux/of.h>
8 #include <linux/of_fdt.h>
9 #include <linux/start_kernel.h>
10 #include <linux/dma-map-ops.h>
11 #include <asm/sections.h>
12 #include <asm/mmu_context.h>
13 #include <asm/pgalloc.h>
15 static void __init csky_memblock_init(void)
17 unsigned long lowmem_size = PFN_DOWN(LOWMEM_LIMIT - PHYS_OFFSET_OFFSET);
18 unsigned long sseg_size = PFN_DOWN(SSEG_SIZE - PHYS_OFFSET_OFFSET);
19 unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
20 signed long size;
22 memblock_reserve(__pa(_start), _end - _start);
24 early_init_fdt_reserve_self();
25 early_init_fdt_scan_reserved_mem();
27 memblock_dump_all();
29 min_low_pfn = PFN_UP(memblock_start_of_DRAM());
30 max_low_pfn = max_pfn = PFN_DOWN(memblock_end_of_DRAM());
32 size = max_pfn - min_low_pfn;
34 if (size >= lowmem_size) {
35 max_low_pfn = min_low_pfn + lowmem_size;
36 #ifdef CONFIG_PAGE_OFFSET_80000000
37 write_mmu_msa1(read_mmu_msa0() + SSEG_SIZE);
38 #endif
39 } else if (size > sseg_size) {
40 max_low_pfn = min_low_pfn + sseg_size;
43 max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
45 mmu_init(min_low_pfn, max_low_pfn);
47 #ifdef CONFIG_HIGHMEM
48 max_zone_pfn[ZONE_HIGHMEM] = max_pfn;
50 highstart_pfn = max_low_pfn;
51 highend_pfn = max_pfn;
52 #endif
53 memblock_set_current_limit(PFN_PHYS(max_low_pfn));
55 dma_contiguous_reserve(0);
57 free_area_init(max_zone_pfn);
60 void __init setup_arch(char **cmdline_p)
62 *cmdline_p = boot_command_line;
64 console_verbose();
66 pr_info("Phys. mem: %ldMB\n",
67 (unsigned long) memblock_phys_mem_size()/1024/1024);
69 setup_initial_init_mm(_start, _etext, _edata, _end);
71 parse_early_param();
73 csky_memblock_init();
75 unflatten_and_copy_device_tree();
77 #ifdef CONFIG_SMP
78 setup_smp();
79 #endif
81 sparse_init();
83 fixaddr_init();
85 #ifdef CONFIG_HIGHMEM
86 kmap_init();
87 #endif
90 unsigned long va_pa_offset;
91 EXPORT_SYMBOL(va_pa_offset);
93 static inline unsigned long read_mmu_msa(void)
95 #ifdef CONFIG_PAGE_OFFSET_80000000
96 return read_mmu_msa0();
97 #endif
99 #ifdef CONFIG_PAGE_OFFSET_A0000000
100 return read_mmu_msa1();
101 #endif
104 asmlinkage __visible void __init csky_start(unsigned int unused,
105 void *dtb_start)
107 /* Clean up bss section */
108 memset(__bss_start, 0, __bss_stop - __bss_start);
110 va_pa_offset = read_mmu_msa() & ~(SSEG_SIZE - 1);
112 pre_trap_init();
114 if (dtb_start == NULL)
115 early_init_dt_scan(__dtb_start);
116 else
117 early_init_dt_scan(dtb_start);
119 start_kernel();
121 asm volatile("br .\n");