18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * arch/xtensa/platform-iss/setup.c 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Platform specific initialization. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Authors: Chris Zankel <chris@zankel.net> 98c2ecf20Sopenharmony_ci * Joe Taylor <joe@tensilica.com> 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * Copyright 2001 - 2005 Tensilica Inc. 128c2ecf20Sopenharmony_ci * Copyright 2017 Cadence Design Systems Inc. 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci#include <linux/init.h> 158c2ecf20Sopenharmony_ci#include <linux/kernel.h> 168c2ecf20Sopenharmony_ci#include <linux/notifier.h> 178c2ecf20Sopenharmony_ci#include <linux/printk.h> 188c2ecf20Sopenharmony_ci#include <linux/string.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <asm/platform.h> 218c2ecf20Sopenharmony_ci#include <asm/setup.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#include <platform/simcall.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_civoid platform_halt(void) 278c2ecf20Sopenharmony_ci{ 288c2ecf20Sopenharmony_ci pr_info(" ** Called platform_halt() **\n"); 298c2ecf20Sopenharmony_ci simc_exit(0); 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_civoid platform_power_off(void) 338c2ecf20Sopenharmony_ci{ 348c2ecf20Sopenharmony_ci pr_info(" ** Called platform_power_off() **\n"); 358c2ecf20Sopenharmony_ci simc_exit(0); 368c2ecf20Sopenharmony_ci} 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_civoid platform_restart(void) 398c2ecf20Sopenharmony_ci{ 408c2ecf20Sopenharmony_ci /* Flush and reset the mmu, simulate a processor reset, and 418c2ecf20Sopenharmony_ci * jump to the reset vector. */ 428c2ecf20Sopenharmony_ci cpu_reset(); 438c2ecf20Sopenharmony_ci /* control never gets here */ 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic int 478c2ecf20Sopenharmony_ciiss_panic_event(struct notifier_block *this, unsigned long event, void *ptr) 488c2ecf20Sopenharmony_ci{ 498c2ecf20Sopenharmony_ci simc_exit(1); 508c2ecf20Sopenharmony_ci return NOTIFY_DONE; 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic struct notifier_block iss_panic_block = { 548c2ecf20Sopenharmony_ci .notifier_call = iss_panic_event, 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_civoid __init platform_setup(char **p_cmdline) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci static void *argv[COMMAND_LINE_SIZE / sizeof(void *)] __initdata; 608c2ecf20Sopenharmony_ci static char cmdline[COMMAND_LINE_SIZE] __initdata; 618c2ecf20Sopenharmony_ci int argc = simc_argc(); 628c2ecf20Sopenharmony_ci int argv_size = simc_argv_size(); 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci if (argc > 1) { 658c2ecf20Sopenharmony_ci if (argv_size > sizeof(argv)) { 668c2ecf20Sopenharmony_ci pr_err("%s: command line too long: argv_size = %d\n", 678c2ecf20Sopenharmony_ci __func__, argv_size); 688c2ecf20Sopenharmony_ci } else { 698c2ecf20Sopenharmony_ci int i; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci cmdline[0] = 0; 728c2ecf20Sopenharmony_ci simc_argv((void *)argv); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci for (i = 1; i < argc; ++i) { 758c2ecf20Sopenharmony_ci if (i > 1) 768c2ecf20Sopenharmony_ci strcat(cmdline, " "); 778c2ecf20Sopenharmony_ci strcat(cmdline, argv[i]); 788c2ecf20Sopenharmony_ci } 798c2ecf20Sopenharmony_ci *p_cmdline = cmdline; 808c2ecf20Sopenharmony_ci } 818c2ecf20Sopenharmony_ci } 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block); 848c2ecf20Sopenharmony_ci} 85