blob: f4bbb28026f8be3006890fe236989db791c79e1d [file] [log] [blame]
Chris Zankel7282bee2005-06-23 22:01:33 -07001/*
2 *
3 * arch/xtensa/platform-iss/setup.c
4 *
5 * Platform specific initialization.
6 *
7 * Authors: Chris Zankel <chris@zankel.net>
8 * Joe Taylor <joe@tensilica.com>
9 *
10 * Copyright 2001 - 2005 Tensilica Inc.
Max Filippovfbe22d22017-03-13 10:34:36 -070011 * Copyright 2017 Cadence Design Systems Inc.
Chris Zankel7282bee2005-06-23 22:01:33 -070012 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 *
18 */
Max Filippovfbe22d22017-03-13 10:34:36 -070019#include <linux/bootmem.h>
Chris Zankel7282bee2005-06-23 22:01:33 -070020#include <linux/stddef.h>
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/errno.h>
24#include <linux/reboot.h>
Chris Zankel7282bee2005-06-23 22:01:33 -070025#include <linux/kdev_t.h>
26#include <linux/types.h>
27#include <linux/major.h>
28#include <linux/blkdev.h>
29#include <linux/console.h>
30#include <linux/delay.h>
31#include <linux/stringify.h>
32#include <linux/notifier.h>
33
34#include <asm/platform.h>
35#include <asm/bootparam.h>
Max Filippov3ced9732017-03-13 10:28:33 -070036#include <asm/setup.h>
Chris Zankel7282bee2005-06-23 22:01:33 -070037
Max Filippovfeec2732016-09-20 17:26:48 -070038#include <platform/simcall.h>
39
Chris Zankel7282bee2005-06-23 22:01:33 -070040
41void __init platform_init(bp_tag_t* bootparam)
42{
Chris Zankel7282bee2005-06-23 22:01:33 -070043}
44
45void platform_halt(void)
46{
Max Filippov23753172012-09-17 05:44:47 +040047 pr_info(" ** Called platform_halt() **\n");
Max Filippovfeec2732016-09-20 17:26:48 -070048 simc_exit(0);
Chris Zankel7282bee2005-06-23 22:01:33 -070049}
50
51void platform_power_off(void)
52{
Max Filippov23753172012-09-17 05:44:47 +040053 pr_info(" ** Called platform_power_off() **\n");
Max Filippovfeec2732016-09-20 17:26:48 -070054 simc_exit(0);
Chris Zankel7282bee2005-06-23 22:01:33 -070055}
56void platform_restart(void)
57{
58 /* Flush and reset the mmu, simulate a processor reset, and
59 * jump to the reset vector. */
Max Filippov4f205682016-09-07 13:33:47 -070060 cpu_reset();
Chris Zankel7282bee2005-06-23 22:01:33 -070061 /* control never gets here */
62}
63
Chris Zankel7282bee2005-06-23 22:01:33 -070064void platform_heartbeat(void)
65{
Chris Zankel7282bee2005-06-23 22:01:33 -070066}
67
Chris Zankel7282bee2005-06-23 22:01:33 -070068static int
69iss_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
70{
Max Filippovfeec2732016-09-20 17:26:48 -070071 simc_exit(1);
Chris Zankel7282bee2005-06-23 22:01:33 -070072 return NOTIFY_DONE;
73}
74
75static struct notifier_block iss_panic_block = {
Max Filippov3ced9732017-03-13 10:28:33 -070076 .notifier_call = iss_panic_event,
Chris Zankel7282bee2005-06-23 22:01:33 -070077};
78
79void __init platform_setup(char **p_cmdline)
80{
Max Filippovfbe22d22017-03-13 10:34:36 -070081 int argc = simc_argc();
82 int argv_size = simc_argv_size();
83
84 if (argc > 1) {
85 void **argv = alloc_bootmem(argv_size);
86 char *cmdline = alloc_bootmem(argv_size);
87 int i;
88
89 cmdline[0] = 0;
90 simc_argv((void *)argv);
91
92 for (i = 1; i < argc; ++i) {
93 if (i > 1)
94 strcat(cmdline, " ");
95 strcat(cmdline, argv[i]);
96 }
97 *p_cmdline = cmdline;
98 }
99
Alan Sterne041c682006-03-27 01:16:30 -0800100 atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block);
Chris Zankel7282bee2005-06-23 22:01:33 -0700101}