xref: /rk3399_ARM-atf/plat/socionext/synquacer/drivers/scpi/sq_scpi.h (revision eb9da9e182e0499b2c684f3829df687bee4782c8)
1b7ad0444SSumit Garg /*
2b7ad0444SSumit Garg  * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3b7ad0444SSumit Garg  *
4b7ad0444SSumit Garg  * SPDX-License-Identifier: BSD-3-Clause
5b7ad0444SSumit Garg  */
6b7ad0444SSumit Garg 
7c3cf06f1SAntonio Nino Diaz #ifndef SQ_SCPI_H
8c3cf06f1SAntonio Nino Diaz #define SQ_SCPI_H
9b7ad0444SSumit Garg 
10b7ad0444SSumit Garg #include <stddef.h>
11b7ad0444SSumit Garg #include <stdint.h>
12b7ad0444SSumit Garg 
13b7ad0444SSumit Garg /*
14b7ad0444SSumit Garg  * An SCPI command consists of a header and a payload.
15b7ad0444SSumit Garg  * The following structure describes the header. It is 64-bit long.
16b7ad0444SSumit Garg  */
17b7ad0444SSumit Garg typedef struct {
18b7ad0444SSumit Garg 	/* Command ID */
19b7ad0444SSumit Garg 	uint32_t id		: 7;
20b7ad0444SSumit Garg 	/* Set ID. Identifies whether this is a standard or extended command. */
21b7ad0444SSumit Garg 	uint32_t set		: 1;
22b7ad0444SSumit Garg 	/* Sender ID to match a reply. The value is sender specific. */
23b7ad0444SSumit Garg 	uint32_t sender		: 8;
24b7ad0444SSumit Garg 	/* Size of the payload in bytes (0 - 511) */
25b7ad0444SSumit Garg 	uint32_t size		: 9;
26b7ad0444SSumit Garg 	uint32_t reserved	: 7;
27b7ad0444SSumit Garg 	/*
28b7ad0444SSumit Garg 	 * Status indicating the success of a command.
29b7ad0444SSumit Garg 	 * See the enum below.
30b7ad0444SSumit Garg 	 */
31b7ad0444SSumit Garg 	uint32_t status;
32b7ad0444SSumit Garg } scpi_cmd_t;
33b7ad0444SSumit Garg 
34b7ad0444SSumit Garg typedef enum {
35b7ad0444SSumit Garg 	SCPI_SET_NORMAL = 0,	/* Normal SCPI commands */
36b7ad0444SSumit Garg 	SCPI_SET_EXTENDED	/* Extended SCPI commands */
37b7ad0444SSumit Garg } scpi_set_t;
38b7ad0444SSumit Garg 
39b7ad0444SSumit Garg enum {
40b7ad0444SSumit Garg 	SCP_OK = 0,	/* Success */
41b7ad0444SSumit Garg 	SCP_E_PARAM,	/* Invalid parameter(s) */
42b7ad0444SSumit Garg 	SCP_E_ALIGN,	/* Invalid alignment */
43b7ad0444SSumit Garg 	SCP_E_SIZE,	/* Invalid size */
44b7ad0444SSumit Garg 	SCP_E_HANDLER,	/* Invalid handler or callback */
45b7ad0444SSumit Garg 	SCP_E_ACCESS,	/* Invalid access or permission denied */
46b7ad0444SSumit Garg 	SCP_E_RANGE,	/* Value out of range */
47b7ad0444SSumit Garg 	SCP_E_TIMEOUT,	/* Time out has ocurred */
48b7ad0444SSumit Garg 	SCP_E_NOMEM,	/* Invalid memory area or pointer */
49b7ad0444SSumit Garg 	SCP_E_PWRSTATE,	/* Invalid power state */
50b7ad0444SSumit Garg 	SCP_E_SUPPORT,	/* Feature not supported or disabled */
51b7ad0444SSumit Garg 	SCPI_E_DEVICE,	/* Device error */
52b7ad0444SSumit Garg 	SCPI_E_BUSY,	/* Device is busy */
53b7ad0444SSumit Garg };
54b7ad0444SSumit Garg 
55b7ad0444SSumit Garg typedef uint32_t scpi_status_t;
56b7ad0444SSumit Garg 
57b7ad0444SSumit Garg typedef enum {
58b7ad0444SSumit Garg 	SCPI_CMD_SCP_READY = 0x01,
59b7ad0444SSumit Garg 	SCPI_CMD_SET_POWER_STATE = 0x03,
60b7ad0444SSumit Garg 	SCPI_CMD_SYS_POWER_STATE = 0x05
61b7ad0444SSumit Garg } scpi_command_t;
62b7ad0444SSumit Garg 
63b7ad0444SSumit Garg typedef enum {
64b7ad0444SSumit Garg 	scpi_power_on = 0,
65b7ad0444SSumit Garg 	scpi_power_retention = 1,
66b7ad0444SSumit Garg 	scpi_power_off = 3,
67b7ad0444SSumit Garg } scpi_power_state_t;
68b7ad0444SSumit Garg 
69b7ad0444SSumit Garg typedef enum {
70b7ad0444SSumit Garg 	scpi_system_shutdown = 0,
71b7ad0444SSumit Garg 	scpi_system_reboot = 1,
72b7ad0444SSumit Garg 	scpi_system_reset = 2
73b7ad0444SSumit Garg } scpi_system_state_t;
74b7ad0444SSumit Garg 
75b7ad0444SSumit Garg extern int scpi_wait_ready(void);
76b7ad0444SSumit Garg extern void scpi_set_sq_power_state(unsigned int mpidr,
77b7ad0444SSumit Garg 					scpi_power_state_t cpu_state,
78b7ad0444SSumit Garg 					scpi_power_state_t cluster_state,
79b7ad0444SSumit Garg 					scpi_power_state_t css_state);
80b7ad0444SSumit Garg uint32_t scpi_sys_power_state(scpi_system_state_t system_state);
81*b67d2029SMasahisa Kojima uint32_t scpi_get_draminfo(struct draminfo *info);
82b7ad0444SSumit Garg 
83c3cf06f1SAntonio Nino Diaz #endif /* SQ_SCPI_H */
84