11afcdfc6SEtienne Carriere /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 21afcdfc6SEtienne Carriere /* 31afcdfc6SEtienne Carriere * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved. 41afcdfc6SEtienne Carriere * Copyright (C) 2019-2020, Linaro Limited 51afcdfc6SEtienne Carriere */ 61afcdfc6SEtienne Carriere #ifndef _SCMI_PROTOCOLS_H 71afcdfc6SEtienne Carriere #define _SCMI_PROTOCOLS_H 81afcdfc6SEtienne Carriere 91afcdfc6SEtienne Carriere #include <linux/bitops.h> 10*7c4b6f22SEtienne Carriere #include <asm/types.h> 111afcdfc6SEtienne Carriere 121afcdfc6SEtienne Carriere /* 131afcdfc6SEtienne Carriere * Subset the SCMI protocols definition 141afcdfc6SEtienne Carriere * based on SCMI specification v2.0 (DEN0056B) 151afcdfc6SEtienne Carriere * https://developer.arm.com/docs/den0056/b 161afcdfc6SEtienne Carriere */ 171afcdfc6SEtienne Carriere 181afcdfc6SEtienne Carriere enum scmi_std_protocol { 191afcdfc6SEtienne Carriere SCMI_PROTOCOL_ID_BASE = 0x10, 201afcdfc6SEtienne Carriere SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11, 211afcdfc6SEtienne Carriere SCMI_PROTOCOL_ID_SYSTEM = 0x12, 221afcdfc6SEtienne Carriere SCMI_PROTOCOL_ID_PERF = 0x13, 231afcdfc6SEtienne Carriere SCMI_PROTOCOL_ID_CLOCK = 0x14, 241afcdfc6SEtienne Carriere SCMI_PROTOCOL_ID_SENSOR = 0x15, 251afcdfc6SEtienne Carriere SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16, 261afcdfc6SEtienne Carriere }; 271afcdfc6SEtienne Carriere 281afcdfc6SEtienne Carriere enum scmi_status_code { 291afcdfc6SEtienne Carriere SCMI_SUCCESS = 0, 301afcdfc6SEtienne Carriere SCMI_NOT_SUPPORTED = -1, 311afcdfc6SEtienne Carriere SCMI_INVALID_PARAMETERS = -2, 321afcdfc6SEtienne Carriere SCMI_DENIED = -3, 331afcdfc6SEtienne Carriere SCMI_NOT_FOUND = -4, 341afcdfc6SEtienne Carriere SCMI_OUT_OF_RANGE = -5, 351afcdfc6SEtienne Carriere SCMI_BUSY = -6, 361afcdfc6SEtienne Carriere SCMI_COMMS_ERROR = -7, 371afcdfc6SEtienne Carriere SCMI_GENERIC_ERROR = -8, 381afcdfc6SEtienne Carriere SCMI_HARDWARE_ERROR = -9, 391afcdfc6SEtienne Carriere SCMI_PROTOCOL_ERROR = -10, 401afcdfc6SEtienne Carriere }; 411afcdfc6SEtienne Carriere 42*7c4b6f22SEtienne Carriere /* 43*7c4b6f22SEtienne Carriere * SCMI Clock Protocol 44*7c4b6f22SEtienne Carriere */ 45*7c4b6f22SEtienne Carriere 46*7c4b6f22SEtienne Carriere enum scmi_clock_message_id { 47*7c4b6f22SEtienne Carriere SCMI_CLOCK_RATE_SET = 0x5, 48*7c4b6f22SEtienne Carriere SCMI_CLOCK_RATE_GET = 0x6, 49*7c4b6f22SEtienne Carriere SCMI_CLOCK_CONFIG_SET = 0x7, 50*7c4b6f22SEtienne Carriere }; 51*7c4b6f22SEtienne Carriere 52*7c4b6f22SEtienne Carriere #define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0) 53*7c4b6f22SEtienne Carriere #define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1)) 54*7c4b6f22SEtienne Carriere #define SCMI_CLK_RATE_ROUND_DOWN 0 55*7c4b6f22SEtienne Carriere #define SCMI_CLK_RATE_ROUND_UP BIT(2) 56*7c4b6f22SEtienne Carriere #define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3) 57*7c4b6f22SEtienne Carriere 58*7c4b6f22SEtienne Carriere /** 59*7c4b6f22SEtienne Carriere * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command 60*7c4b6f22SEtienne Carriere * @clock_id: SCMI clock ID 61*7c4b6f22SEtienne Carriere * @attributes: Attributes of the targets clock state 62*7c4b6f22SEtienne Carriere */ 63*7c4b6f22SEtienne Carriere struct scmi_clk_state_in { 64*7c4b6f22SEtienne Carriere u32 clock_id; 65*7c4b6f22SEtienne Carriere u32 attributes; 66*7c4b6f22SEtienne Carriere }; 67*7c4b6f22SEtienne Carriere 68*7c4b6f22SEtienne Carriere /** 69*7c4b6f22SEtienne Carriere * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command 70*7c4b6f22SEtienne Carriere * @status: SCMI command status 71*7c4b6f22SEtienne Carriere */ 72*7c4b6f22SEtienne Carriere struct scmi_clk_state_out { 73*7c4b6f22SEtienne Carriere s32 status; 74*7c4b6f22SEtienne Carriere }; 75*7c4b6f22SEtienne Carriere 76*7c4b6f22SEtienne Carriere /** 77*7c4b6f22SEtienne Carriere * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command 78*7c4b6f22SEtienne Carriere * @clock_id: SCMI clock ID 79*7c4b6f22SEtienne Carriere * @attributes: Attributes of the targets clock state 80*7c4b6f22SEtienne Carriere */ 81*7c4b6f22SEtienne Carriere struct scmi_clk_rate_get_in { 82*7c4b6f22SEtienne Carriere u32 clock_id; 83*7c4b6f22SEtienne Carriere }; 84*7c4b6f22SEtienne Carriere 85*7c4b6f22SEtienne Carriere /** 86*7c4b6f22SEtienne Carriere * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command 87*7c4b6f22SEtienne Carriere * @status: SCMI command status 88*7c4b6f22SEtienne Carriere * @rate_lsb: 32bit LSB of the clock rate in Hertz 89*7c4b6f22SEtienne Carriere * @rate_msb: 32bit MSB of the clock rate in Hertz 90*7c4b6f22SEtienne Carriere */ 91*7c4b6f22SEtienne Carriere struct scmi_clk_rate_get_out { 92*7c4b6f22SEtienne Carriere s32 status; 93*7c4b6f22SEtienne Carriere u32 rate_lsb; 94*7c4b6f22SEtienne Carriere u32 rate_msb; 95*7c4b6f22SEtienne Carriere }; 96*7c4b6f22SEtienne Carriere 97*7c4b6f22SEtienne Carriere /** 98*7c4b6f22SEtienne Carriere * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command 99*7c4b6f22SEtienne Carriere * @clock_id: SCMI clock ID 100*7c4b6f22SEtienne Carriere * @flags: Flags for the clock rate set request 101*7c4b6f22SEtienne Carriere * @rate_lsb: 32bit LSB of the clock rate in Hertz 102*7c4b6f22SEtienne Carriere * @rate_msb: 32bit MSB of the clock rate in Hertz 103*7c4b6f22SEtienne Carriere */ 104*7c4b6f22SEtienne Carriere struct scmi_clk_rate_set_in { 105*7c4b6f22SEtienne Carriere u32 clock_id; 106*7c4b6f22SEtienne Carriere u32 flags; 107*7c4b6f22SEtienne Carriere u32 rate_lsb; 108*7c4b6f22SEtienne Carriere u32 rate_msb; 109*7c4b6f22SEtienne Carriere }; 110*7c4b6f22SEtienne Carriere 111*7c4b6f22SEtienne Carriere /** 112*7c4b6f22SEtienne Carriere * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command 113*7c4b6f22SEtienne Carriere * @status: SCMI command status 114*7c4b6f22SEtienne Carriere */ 115*7c4b6f22SEtienne Carriere struct scmi_clk_rate_set_out { 116*7c4b6f22SEtienne Carriere s32 status; 117*7c4b6f22SEtienne Carriere }; 118*7c4b6f22SEtienne Carriere 1191afcdfc6SEtienne Carriere #endif /* _SCMI_PROTOCOLS_H */ 120