1*54fd6939SJiyong Park /* SPDX-License-Identifier: BSD-3-Clause */ 2*54fd6939SJiyong Park /* 3*54fd6939SJiyong Park * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved. 4*54fd6939SJiyong Park * Copyright (c) 2019, Linaro Limited 5*54fd6939SJiyong Park */ 6*54fd6939SJiyong Park 7*54fd6939SJiyong Park #ifndef SCMI_MSG_CLOCK_H 8*54fd6939SJiyong Park #define SCMI_MSG_CLOCK_H 9*54fd6939SJiyong Park 10*54fd6939SJiyong Park #include <stdint.h> 11*54fd6939SJiyong Park 12*54fd6939SJiyong Park #include <lib/utils_def.h> 13*54fd6939SJiyong Park 14*54fd6939SJiyong Park #define SCMI_PROTOCOL_VERSION_CLOCK 0x20000U 15*54fd6939SJiyong Park 16*54fd6939SJiyong Park /* 17*54fd6939SJiyong Park * Identifiers of the SCMI Clock Management Protocol commands 18*54fd6939SJiyong Park */ 19*54fd6939SJiyong Park enum scmi_clock_command_id { 20*54fd6939SJiyong Park SCMI_CLOCK_ATTRIBUTES = 0x003, 21*54fd6939SJiyong Park SCMI_CLOCK_DESCRIBE_RATES = 0x004, 22*54fd6939SJiyong Park SCMI_CLOCK_RATE_SET = 0x005, 23*54fd6939SJiyong Park SCMI_CLOCK_RATE_GET = 0x006, 24*54fd6939SJiyong Park SCMI_CLOCK_CONFIG_SET = 0x007, 25*54fd6939SJiyong Park }; 26*54fd6939SJiyong Park 27*54fd6939SJiyong Park /* Protocol attributes */ 28*54fd6939SJiyong Park #define SCMI_CLOCK_CLOCK_COUNT_MASK GENMASK(15, 0) 29*54fd6939SJiyong Park #define SCMI_CLOCK_MAX_PENDING_TRANSITIONS_MASK GENMASK(23, 16) 30*54fd6939SJiyong Park 31*54fd6939SJiyong Park #define SCMI_CLOCK_PROTOCOL_ATTRIBUTES(_max_pending, _clk_count) \ 32*54fd6939SJiyong Park ((((_max_pending) << 16) & SCMI_CLOCK_MAX_PENDING_TRANSITIONS_MASK) | \ 33*54fd6939SJiyong Park (((_clk_count) & SCMI_CLOCK_CLOCK_COUNT_MASK))) 34*54fd6939SJiyong Park 35*54fd6939SJiyong Park struct scmi_clock_attributes_a2p { 36*54fd6939SJiyong Park uint32_t clock_id; 37*54fd6939SJiyong Park }; 38*54fd6939SJiyong Park 39*54fd6939SJiyong Park #define SCMI_CLOCK_NAME_LENGTH_MAX 16U 40*54fd6939SJiyong Park 41*54fd6939SJiyong Park struct scmi_clock_attributes_p2a { 42*54fd6939SJiyong Park int32_t status; 43*54fd6939SJiyong Park uint32_t attributes; 44*54fd6939SJiyong Park char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX]; 45*54fd6939SJiyong Park }; 46*54fd6939SJiyong Park 47*54fd6939SJiyong Park /* 48*54fd6939SJiyong Park * Clock Rate Get 49*54fd6939SJiyong Park */ 50*54fd6939SJiyong Park 51*54fd6939SJiyong Park struct scmi_clock_rate_get_a2p { 52*54fd6939SJiyong Park uint32_t clock_id; 53*54fd6939SJiyong Park }; 54*54fd6939SJiyong Park 55*54fd6939SJiyong Park struct scmi_clock_rate_get_p2a { 56*54fd6939SJiyong Park int32_t status; 57*54fd6939SJiyong Park uint32_t rate[2]; 58*54fd6939SJiyong Park }; 59*54fd6939SJiyong Park 60*54fd6939SJiyong Park /* 61*54fd6939SJiyong Park * Clock Rate Set 62*54fd6939SJiyong Park */ 63*54fd6939SJiyong Park 64*54fd6939SJiyong Park /* If set, set the new clock rate asynchronously */ 65*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_SET_ASYNC_POS 0 66*54fd6939SJiyong Park /* If set, do not send a delayed asynchronous response */ 67*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_SET_NO_DELAYED_RESPONSE_POS 1 68*54fd6939SJiyong Park /* Round up, if set, otherwise round down */ 69*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_SET_ROUND_UP_POS 2 70*54fd6939SJiyong Park /* If set, the platform chooses the appropriate rounding mode */ 71*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_SET_ROUND_AUTO_POS 3 72*54fd6939SJiyong Park 73*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_SET_ASYNC_MASK \ 74*54fd6939SJiyong Park BIT(SCMI_CLOCK_RATE_SET_ASYNC_POS) 75*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_SET_NO_DELAYED_RESPONSE_MASK \ 76*54fd6939SJiyong Park BIT(SCMI_CLOCK_RATE_SET_NO_DELAYED_RESPONSE_POS) 77*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_SET_ROUND_UP_MASK \ 78*54fd6939SJiyong Park BIT(SCMI_CLOCK_RATE_SET_ROUND_UP_POS) 79*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_SET_ROUND_AUTO_MASK \ 80*54fd6939SJiyong Park BIT(SCMI_CLOCK_RATE_SET_ROUND_AUTO_POS) 81*54fd6939SJiyong Park 82*54fd6939SJiyong Park struct scmi_clock_rate_set_a2p { 83*54fd6939SJiyong Park uint32_t flags; 84*54fd6939SJiyong Park uint32_t clock_id; 85*54fd6939SJiyong Park uint32_t rate[2]; 86*54fd6939SJiyong Park }; 87*54fd6939SJiyong Park 88*54fd6939SJiyong Park struct scmi_clock_rate_set_p2a { 89*54fd6939SJiyong Park int32_t status; 90*54fd6939SJiyong Park }; 91*54fd6939SJiyong Park 92*54fd6939SJiyong Park /* 93*54fd6939SJiyong Park * Clock Config Set 94*54fd6939SJiyong Park */ 95*54fd6939SJiyong Park 96*54fd6939SJiyong Park #define SCMI_CLOCK_CONFIG_SET_ENABLE_POS 0 97*54fd6939SJiyong Park 98*54fd6939SJiyong Park #define SCMI_CLOCK_CONFIG_SET_ENABLE_MASK \ 99*54fd6939SJiyong Park BIT(SCMI_CLOCK_CONFIG_SET_ENABLE_POS) 100*54fd6939SJiyong Park 101*54fd6939SJiyong Park struct scmi_clock_config_set_a2p { 102*54fd6939SJiyong Park uint32_t clock_id; 103*54fd6939SJiyong Park uint32_t attributes; 104*54fd6939SJiyong Park }; 105*54fd6939SJiyong Park 106*54fd6939SJiyong Park struct scmi_clock_config_set_p2a { 107*54fd6939SJiyong Park int32_t status; 108*54fd6939SJiyong Park }; 109*54fd6939SJiyong Park 110*54fd6939SJiyong Park /* 111*54fd6939SJiyong Park * Clock Describe Rates 112*54fd6939SJiyong Park */ 113*54fd6939SJiyong Park 114*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_FORMAT_RANGE 1U 115*54fd6939SJiyong Park #define SCMI_CLOCK_RATE_FORMAT_LIST 0U 116*54fd6939SJiyong Park 117*54fd6939SJiyong Park #define SCMI_CLOCK_DESCRIBE_RATES_REMAINING_MASK GENMASK_32(31, 16) 118*54fd6939SJiyong Park #define SCMI_CLOCK_DESCRIBE_RATES_REMAINING_POS 16 119*54fd6939SJiyong Park 120*54fd6939SJiyong Park #define SCMI_CLOCK_DESCRIBE_RATES_FORMAT_MASK BIT(12) 121*54fd6939SJiyong Park #define SCMI_CLOCK_DESCRIBE_RATES_FORMAT_POS 12 122*54fd6939SJiyong Park 123*54fd6939SJiyong Park #define SCMI_CLOCK_DESCRIBE_RATES_COUNT_MASK GENMASK_32(11, 0) 124*54fd6939SJiyong Park 125*54fd6939SJiyong Park #define SCMI_CLOCK_DESCRIBE_RATES_NUM_RATES_FLAGS(_count, _fmt, _rem_rates) \ 126*54fd6939SJiyong Park ( \ 127*54fd6939SJiyong Park ((_count) & SCMI_CLOCK_DESCRIBE_RATES_COUNT_MASK) | \ 128*54fd6939SJiyong Park (((_rem_rates) << SCMI_CLOCK_DESCRIBE_RATES_REMAINING_POS) & \ 129*54fd6939SJiyong Park SCMI_CLOCK_DESCRIBE_RATES_REMAINING_MASK) | \ 130*54fd6939SJiyong Park (((_fmt) << SCMI_CLOCK_DESCRIBE_RATES_FORMAT_POS) & \ 131*54fd6939SJiyong Park SCMI_CLOCK_DESCRIBE_RATES_FORMAT_MASK) \ 132*54fd6939SJiyong Park ) 133*54fd6939SJiyong Park 134*54fd6939SJiyong Park struct scmi_clock_rate { 135*54fd6939SJiyong Park uint32_t low; 136*54fd6939SJiyong Park uint32_t high; 137*54fd6939SJiyong Park }; 138*54fd6939SJiyong Park 139*54fd6939SJiyong Park struct scmi_clock_describe_rates_a2p { 140*54fd6939SJiyong Park uint32_t clock_id; 141*54fd6939SJiyong Park uint32_t rate_index; 142*54fd6939SJiyong Park }; 143*54fd6939SJiyong Park 144*54fd6939SJiyong Park struct scmi_clock_describe_rates_p2a { 145*54fd6939SJiyong Park int32_t status; 146*54fd6939SJiyong Park uint32_t num_rates_flags; 147*54fd6939SJiyong Park struct scmi_clock_rate rates[]; 148*54fd6939SJiyong Park }; 149*54fd6939SJiyong Park 150*54fd6939SJiyong Park #endif /* SCMI_MSG_CLOCK_H */ 151