xref: /openbmc/linux/arch/xtensa/platforms/iss/setup.c (revision 4b4f3acc)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *
4  * arch/xtensa/platform-iss/setup.c
5  *
6  * Platform specific initialization.
7  *
8  * Authors: Chris Zankel <chris@zankel.net>
9  *          Joe Taylor <joe@tensilica.com>
10  *
11  * Copyright 2001 - 2005 Tensilica Inc.
12  * Copyright 2017 Cadence Design Systems Inc.
13  */
14 #include <linux/memblock.h>
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/reboot.h>
20 #include <linux/kdev_t.h>
21 #include <linux/types.h>
22 #include <linux/major.h>
23 #include <linux/blkdev.h>
24 #include <linux/console.h>
25 #include <linux/delay.h>
26 #include <linux/stringify.h>
27 #include <linux/notifier.h>
28 
29 #include <asm/platform.h>
30 #include <asm/bootparam.h>
31 #include <asm/setup.h>
32 
33 #include <platform/simcall.h>
34 
35 
36 void __init platform_init(bp_tag_t* bootparam)
37 {
38 }
39 
40 void platform_halt(void)
41 {
42 	pr_info(" ** Called platform_halt() **\n");
43 	simc_exit(0);
44 }
45 
46 void platform_power_off(void)
47 {
48 	pr_info(" ** Called platform_power_off() **\n");
49 	simc_exit(0);
50 }
51 void platform_restart(void)
52 {
53 	/* Flush and reset the mmu, simulate a processor reset, and
54 	 * jump to the reset vector. */
55 	cpu_reset();
56 	/* control never gets here */
57 }
58 
59 void platform_heartbeat(void)
60 {
61 }
62 
63 static int
64 iss_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
65 {
66 	simc_exit(1);
67 	return NOTIFY_DONE;
68 }
69 
70 static struct notifier_block iss_panic_block = {
71 	.notifier_call = iss_panic_event,
72 };
73 
74 void __init platform_setup(char **p_cmdline)
75 {
76 	static void *argv[COMMAND_LINE_SIZE / sizeof(void *)] __initdata;
77 	static char cmdline[COMMAND_LINE_SIZE] __initdata;
78 	int argc = simc_argc();
79 	int argv_size = simc_argv_size();
80 
81 	if (argc > 1) {
82 		if (argv_size > sizeof(argv)) {
83 			pr_err("%s: command line too long: argv_size = %d\n",
84 			       __func__, argv_size);
85 		} else {
86 			int i;
87 
88 			cmdline[0] = 0;
89 			simc_argv((void *)argv);
90 
91 			for (i = 1; i < argc; ++i) {
92 				if (i > 1)
93 					strcat(cmdline, " ");
94 				strcat(cmdline, argv[i]);
95 			}
96 			*p_cmdline = cmdline;
97 		}
98 	}
99 
100 	atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block);
101 }
102