xref: /openbmc/linux/arch/xtensa/platforms/iss/setup.c (revision 99a15348)
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/init.h>
15 #include <linux/kernel.h>
16 #include <linux/notifier.h>
17 #include <linux/panic_notifier.h>
18 #include <linux/printk.h>
19 #include <linux/string.h>
20 
21 #include <asm/platform.h>
22 #include <asm/setup.h>
23 
24 #include <platform/simcall.h>
25 
26 
27 void platform_halt(void)
28 {
29 	pr_info(" ** Called platform_halt() **\n");
30 	simc_exit(0);
31 }
32 
33 void platform_power_off(void)
34 {
35 	pr_info(" ** Called platform_power_off() **\n");
36 	simc_exit(0);
37 }
38 
39 void platform_restart(void)
40 {
41 	/* Flush and reset the mmu, simulate a processor reset, and
42 	 * jump to the reset vector. */
43 	cpu_reset();
44 	/* control never gets here */
45 }
46 
47 static int
48 iss_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
49 {
50 	simc_exit(1);
51 	return NOTIFY_DONE;
52 }
53 
54 static struct notifier_block iss_panic_block = {
55 	.notifier_call = iss_panic_event,
56 };
57 
58 void __init platform_setup(char **p_cmdline)
59 {
60 	static void *argv[COMMAND_LINE_SIZE / sizeof(void *)] __initdata;
61 	static char cmdline[COMMAND_LINE_SIZE] __initdata;
62 	int argc = simc_argc();
63 	int argv_size = simc_argv_size();
64 
65 	if (argc > 1) {
66 		if (argv_size > sizeof(argv)) {
67 			pr_err("%s: command line too long: argv_size = %d\n",
68 			       __func__, argv_size);
69 		} else {
70 			int i;
71 
72 			cmdline[0] = 0;
73 			simc_argv((void *)argv);
74 
75 			for (i = 1; i < argc; ++i) {
76 				if (i > 1)
77 					strcat(cmdline, " ");
78 				strcat(cmdline, argv[i]);
79 			}
80 			*p_cmdline = cmdline;
81 		}
82 	}
83 
84 	atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block);
85 }
86