treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 120
[linux-block.git] / arch / riscv / kernel / setup.c
CommitLineData
588cb88c 1// SPDX-License-Identifier: GPL-2.0-or-later
76d2a049
PD
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
76d2a049
PD
7 */
8
9#include <linux/init.h>
10#include <linux/mm.h>
11#include <linux/memblock.h>
12#include <linux/sched.h>
76d2a049
PD
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>
10314e09 18#include <linux/swiotlb.h>
76d2a049
PD
19
20#include <asm/setup.h>
21#include <asm/sections.h>
22#include <asm/pgtable.h>
23#include <asm/smp.h>
76d2a049
PD
24#include <asm/tlbflush.h>
25#include <asm/thread_info.h>
26
76d2a049
PD
27#ifdef CONFIG_DUMMY_CONSOLE
28struct screen_info screen_info = {
29 .orig_video_lines = 30,
30 .orig_video_cols = 80,
31 .orig_video_mode = 0,
32 .orig_video_ega_bx = 0,
33 .orig_video_isVGA = 1,
34 .orig_video_points = 8
35};
36#endif
37
76d2a049
PD
38/* The lucky hart to first increment this variable will boot the other cores */
39atomic_t hart_lottery;
f99fb607 40unsigned long boot_cpu_hartid;
76d2a049 41
ba9c0141 42void __init parse_dtb(phys_addr_t dtb_phys)
76d2a049 43{
ba9c0141
CH
44 void *dtb = __va(dtb_phys);
45
46 if (early_init_dt_scan(dtb))
8fd6e05c
PW
47 return;
48
49 pr_err("No DTB passed to the kernel\n");
50#ifdef CONFIG_CMDLINE_FORCE
51 strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
52 pr_info("Forcing kernel command line to: %s\n", boot_command_line);
53#endif
76d2a049
PD
54}
55
76d2a049
PD
56void __init setup_arch(char **cmdline_p)
57{
76d2a049
PD
58 init_mm.start_code = (unsigned long) _stext;
59 init_mm.end_code = (unsigned long) _etext;
60 init_mm.end_data = (unsigned long) _edata;
61 init_mm.brk = (unsigned long) _end;
62
680f9b8e
AP
63 *cmdline_p = boot_command_line;
64
65 parse_early_param();
66
76d2a049
PD
67 setup_bootmem();
68 paging_init();
69 unflatten_device_tree();
51858aaf
ZL
70
71#ifdef CONFIG_SWIOTLB
10314e09 72 swiotlb_init(1);
51858aaf 73#endif
76d2a049
PD
74
75#ifdef CONFIG_SMP
76 setup_smp();
77#endif
78
79#ifdef CONFIG_DUMMY_CONSOLE
80 conswitchp = &dummy_con;
81#endif
82
83 riscv_fill_hwcap();
84}