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>
8 #include <linux/of_fdt.h>
9 #include <linux/start_kernel.h>
10 #include <linux/dma-map-ops.h>
11 #include <linux/screen_info.h>
12 #include <asm/sections.h>
13 #include <asm/mmu_context.h>
14 #include <asm/pgalloc.h>
16 #ifdef CONFIG_DUMMY_CONSOLE
17 struct screen_info screen_info
= {
18 .orig_video_lines
= 30,
19 .orig_video_cols
= 80,
21 .orig_video_ega_bx
= 0,
22 .orig_video_isVGA
= 1,
23 .orig_video_points
= 8
27 static void __init
csky_memblock_init(void)
29 unsigned long lowmem_size
= PFN_DOWN(LOWMEM_LIMIT
- PHYS_OFFSET_OFFSET
);
30 unsigned long sseg_size
= PFN_DOWN(SSEG_SIZE
- PHYS_OFFSET_OFFSET
);
31 unsigned long max_zone_pfn
[MAX_NR_ZONES
] = { 0 };
34 memblock_reserve(__pa(_stext
), _end
- _stext
);
36 early_init_fdt_reserve_self();
37 early_init_fdt_scan_reserved_mem();
41 min_low_pfn
= PFN_UP(memblock_start_of_DRAM());
42 max_low_pfn
= max_pfn
= PFN_DOWN(memblock_end_of_DRAM());
44 size
= max_pfn
- min_low_pfn
;
46 if (size
>= lowmem_size
) {
47 max_low_pfn
= min_low_pfn
+ lowmem_size
;
48 write_mmu_msa1(read_mmu_msa0() + SSEG_SIZE
);
49 } else if (size
> sseg_size
) {
50 max_low_pfn
= min_low_pfn
+ sseg_size
;
53 max_zone_pfn
[ZONE_NORMAL
] = max_low_pfn
;
56 max_zone_pfn
[ZONE_HIGHMEM
] = max_pfn
;
58 highstart_pfn
= max_low_pfn
;
59 highend_pfn
= max_pfn
;
61 memblock_set_current_limit(PFN_PHYS(max_low_pfn
));
63 dma_contiguous_reserve(0);
65 free_area_init(max_zone_pfn
);
68 void __init
setup_arch(char **cmdline_p
)
70 *cmdline_p
= boot_command_line
;
74 pr_info("Phys. mem: %ldMB\n",
75 (unsigned long) memblock_phys_mem_size()/1024/1024);
77 init_mm
.start_code
= (unsigned long) _stext
;
78 init_mm
.end_code
= (unsigned long) _etext
;
79 init_mm
.end_data
= (unsigned long) _edata
;
80 init_mm
.brk
= (unsigned long) _end
;
86 unflatten_and_copy_device_tree();
101 unsigned long va_pa_offset
;
102 EXPORT_SYMBOL(va_pa_offset
);
104 asmlinkage __visible
void __init
csky_start(unsigned int unused
,
107 /* Clean up bss section */
108 memset(__bss_start
, 0, __bss_stop
- __bss_start
);
110 va_pa_offset
= read_mmu_msa0() & ~(SSEG_SIZE
- 1);
115 if (dtb_start
== NULL
)
116 early_init_dt_scan(__dtb_start
);
118 early_init_dt_scan(dtb_start
);
122 asm volatile("br .\n");