David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/mm.h> |
| 11 | #include <linux/memblock.h> |
| 12 | #include <linux/sched.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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/setup.h> |
| 21 | #include <asm/sections.h> |
| 22 | #include <asm/pgtable.h> |
| 23 | #include <asm/smp.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 24 | #include <asm/tlbflush.h> |
| 25 | #include <asm/thread_info.h> |
| 26 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 27 | #include "head.h" |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 28 | |
| 29 | #ifdef CONFIG_DUMMY_CONSOLE |
| 30 | struct screen_info screen_info = { |
| 31 | .orig_video_lines = 30, |
| 32 | .orig_video_cols = 80, |
| 33 | .orig_video_mode = 0, |
| 34 | .orig_video_ega_bx = 0, |
| 35 | .orig_video_isVGA = 1, |
| 36 | .orig_video_points = 8 |
| 37 | }; |
| 38 | #endif |
| 39 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 40 | /* The lucky hart to first increment this variable will boot the other cores */ |
| 41 | atomic_t hart_lottery; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 42 | unsigned long boot_cpu_hartid; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 43 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 44 | void __init parse_dtb(void) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 45 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 46 | if (early_init_dt_scan(dtb_early_va)) |
| 47 | return; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 48 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 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); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 53 | #endif |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | void __init setup_arch(char **cmdline_p) |
| 57 | { |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 63 | *cmdline_p = boot_command_line; |
| 64 | |
| 65 | parse_early_param(); |
| 66 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 67 | setup_bootmem(); |
| 68 | paging_init(); |
| 69 | unflatten_device_tree(); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 70 | |
| 71 | #ifdef CONFIG_SWIOTLB |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 72 | swiotlb_init(1); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 73 | #endif |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 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 | } |