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