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