|
| 1 | +/* |
| 2 | + * Copyright 2024 NXP |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * @file |
| 9 | + * @brief SCMI power domain protocol helpers |
| 10 | + */ |
| 11 | + |
| 12 | +#ifndef _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_POWER_H_ |
| 13 | +#define _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_POWER_H_ |
| 14 | + |
| 15 | +#include <zephyr/drivers/firmware/scmi/protocol.h> |
| 16 | + |
| 17 | +#define SCMI_POWER_STATE_SET_FLAGS_ASYNC BIT(0) |
| 18 | + |
| 19 | +/** |
| 20 | + * @struct scmi_power_state_config |
| 21 | + * |
| 22 | + * @brief Describes the parameters for the POWER_STATE_SET |
| 23 | + * command |
| 24 | + */ |
| 25 | +struct scmi_power_state_config { |
| 26 | + uint32_t flags; |
| 27 | + uint32_t domain_id; |
| 28 | + uint32_t power_state; |
| 29 | +}; |
| 30 | + |
| 31 | +/** |
| 32 | + * @brief Power domain protocol command message IDs |
| 33 | + */ |
| 34 | +enum scmi_power_domain_message { |
| 35 | + SCMI_POWER_DOMAIN_MSG_PROTOCOL_VERSION = 0x0, |
| 36 | + SCMI_POWER_DOMAIN_MSG_PROTOCOL_ATTRIBUTES = 0x1, |
| 37 | + SCMI_POWER_DOMAIN_MSG_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2, |
| 38 | + SCMI_POWER_DOMAIN_MSG_POWER_DOMAIN_ATTRIBUTES = 0x3, |
| 39 | + SCMI_POWER_DOMAIN_MSG_POWER_STATE_SET = 0x4, |
| 40 | + SCMI_POWER_DOMAIN_MSG_POWER_STATE_GET = 0x5, |
| 41 | + SCMI_POWER_DOMAIN_MSG_POWER_STATE_NOTIFY = 0x6, |
| 42 | + SCMI_POWER_DOMAIN_MSG_POWER_STATE_CHANGE_REQEUSTED_NOTIFY = 0x7, |
| 43 | + SCMI_POWER_DOMAIN_MSG_POWER_DOMAIN_NAME_GET = 0x8, |
| 44 | + SCMI_POWER_DOMAIN_MSG_NEGOTIATE_PROTOCOL_VERSION = 0x10, |
| 45 | +}; |
| 46 | + |
| 47 | +/** |
| 48 | + * @brief Send the POWER_STATE_SET command and get its reply |
| 49 | + * |
| 50 | + * @param cfg pointer to structure containing configuration |
| 51 | + * to be set |
| 52 | + * |
| 53 | + * @retval 0 if successful |
| 54 | + * @retval negative errno if failure |
| 55 | + */ |
| 56 | +int scmi_power_state_set(struct scmi_power_state_config *cfg); |
| 57 | +/** |
| 58 | + * @brief Query the power domain state |
| 59 | + * |
| 60 | + * @param domain_id ID of the power domain for which the query is done |
| 61 | + * @param power_state pointer to be set via this command |
| 62 | + * |
| 63 | + * @retval 0 if successful |
| 64 | + * @retval negative errno if failure |
| 65 | + */ |
| 66 | +int scmi_power_state_get(uint32_t domain_id, uint32_t *power_state); |
| 67 | + |
| 68 | +#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_POWER_H_ */ |
0 commit comments