xref: /openbmc/linux/arch/riscv/kernel/setup.c (revision 3098f5eb)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
4  *  Chen Liqin <liqin.chen@sunplusct.com>
5  *  Lennox Wu <lennox.wu@sunplusct.com>
6  * Copyright (C) 2012 Regents of the University of California
7  */
8 
9 #include <linux/init.h>
10 #include <linux/mm.h>
11 #include <linux/memblock.h>
12 #include <linux/sched.h>
13 #include <linux/console.h>
14 #include <linux/screen_info.h>
15 #include <linux/of_fdt.h>
16 #include <linux/of_platform.h>
17 #include <linux/sched/task.h>
18 #include <linux/swiotlb.h>
19 
20 #include <asm/clint.h>
21 #include <asm/setup.h>
22 #include <asm/sections.h>
23 #include <asm/pgtable.h>
24 #include <asm/smp.h>
25 #include <asm/tlbflush.h>
26 #include <asm/thread_info.h>
27 
28 #include "head.h"
29 
30 #ifdef CONFIG_DUMMY_CONSOLE
31 struct screen_info screen_info = {
32 	.orig_video_lines	= 30,
33 	.orig_video_cols	= 80,
34 	.orig_video_mode	= 0,
35 	.orig_video_ega_bx	= 0,
36 	.orig_video_isVGA	= 1,
37 	.orig_video_points	= 8
38 };
39 #endif
40 
41 /* The lucky hart to first increment this variable will boot the other cores */
42 atomic_t hart_lottery;
43 unsigned long boot_cpu_hartid;
44 
45 void __init parse_dtb(void)
46 {
47 	if (early_init_dt_scan(dtb_early_va))
48 		return;
49 
50 	pr_err("No DTB passed to the kernel\n");
51 #ifdef CONFIG_CMDLINE_FORCE
52 	strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
53 	pr_info("Forcing kernel command line to: %s\n", boot_command_line);
54 #endif
55 }
56 
57 void __init setup_arch(char **cmdline_p)
58 {
59 	init_mm.start_code = (unsigned long) _stext;
60 	init_mm.end_code   = (unsigned long) _etext;
61 	init_mm.end_data   = (unsigned long) _edata;
62 	init_mm.brk        = (unsigned long) _end;
63 
64 	*cmdline_p = boot_command_line;
65 
66 	parse_early_param();
67 
68 	setup_bootmem();
69 	paging_init();
70 	unflatten_device_tree();
71 	clint_init_boot_cpu();
72 
73 #ifdef CONFIG_SWIOTLB
74 	swiotlb_init(1);
75 #endif
76 
77 #ifdef CONFIG_SMP
78 	setup_smp();
79 #endif
80 
81 #ifdef CONFIG_DUMMY_CONSOLE
82 	conswitchp = &dummy_con;
83 #endif
84 
85 	riscv_fill_hwcap();
86 }
87