1 /*
2  * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #if defined(CONFIG_IPM) || defined(CONFIG_MBOX)
8 
9 #include <stdlib.h>
10 
11 #include <zephyr/device.h>
12 #include <zephyr/drivers/regulator.h>
13 #include <zephyr/drivers/watchdog.h>
14 #include <zephyr/dt-bindings/gpio/nordic-npm6001-gpio.h>
15 #include <zephyr/dt-bindings/regulator/npm6001.h>
16 #include <zephyr/posix/unistd.h>
17 #include <zephyr/shell/shell.h>
18 #include <zephyr/sys/printk.h>
19 
20 /* Command usage info. */
21 #define START_HELP ("<cmd>\n\nStart the APPCPU")
22 #define STOP_HELP  ("<cmd>\n\nStop the APPCPU")
23 
24 void esp_appcpu_image_start(unsigned int hdr_offset);
25 void esp_appcpu_image_stop(void);
26 
cmd_appcpu_start(const struct shell * sh,size_t argc,char * argv[])27 static int cmd_appcpu_start(const struct shell *sh, size_t argc, char *argv[])
28 {
29 	ARG_UNUSED(sh);
30 	ARG_UNUSED(argc);
31 	ARG_UNUSED(argv);
32 
33 	printk("start appcpu\n");
34 
35 	esp_appcpu_image_start(0x20);
36 
37 	return 0;
38 }
39 
cmd_appcpu_stop(const struct shell * sh,size_t argc,char * argv[])40 static int cmd_appcpu_stop(const struct shell *sh, size_t argc, char *argv[])
41 {
42 	ARG_UNUSED(sh);
43 	ARG_UNUSED(argc);
44 	ARG_UNUSED(argv);
45 
46 	printk("stop appcpu\n");
47 
48 	esp_appcpu_image_stop();
49 
50 	return 0;
51 }
52 
53 SHELL_STATIC_SUBCMD_SET_CREATE(sub_amp,
54 			       /* Alphabetically sorted to ensure correct Tab autocompletion. */
55 			       SHELL_CMD_ARG(appstart, NULL, START_HELP, cmd_appcpu_start, 1, 0),
56 			       SHELL_CMD_ARG(appstop, NULL, STOP_HELP, cmd_appcpu_stop, 1, 0),
57 			       SHELL_SUBCMD_SET_END /* Array terminated. */
58 );
59 
60 SHELL_CMD_REGISTER(amp, &sub_amp, "AMP debug commands.", NULL);
61 #endif
62