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