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