/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.3*/45#ifndef __SOC_QCOM_TCS_H__6#define __SOC_QCOM_TCS_H__78#include <linux/bitfield.h>9#include <linux/bits.h>1011#define MAX_RPMH_PAYLOAD 161213/**14* rpmh_state: state for the request15*16* RPMH_SLEEP_STATE: State of the resource when the processor subsystem17* is powered down. There is no client using the18* resource actively.19* RPMH_WAKE_ONLY_STATE: Resume resource state to the value previously20* requested before the processor was powered down.21* RPMH_ACTIVE_ONLY_STATE: Active or AMC mode requests. Resource state22* is aggregated immediately.23*/24enum rpmh_state {25RPMH_SLEEP_STATE,26RPMH_WAKE_ONLY_STATE,27RPMH_ACTIVE_ONLY_STATE,28};2930/**31* struct tcs_cmd: an individual request to RPMH.32*33* @addr: the address of the resource slv_id:18:16 | offset:0:1534* @data: the resource state request35* @wait: ensure that this command is complete before returning.36* Setting "wait" here only makes sense during rpmh_write_batch() for37* active-only transfers, this is because:38* rpmh_write() - Always waits.39* (DEFINE_RPMH_MSG_ONSTACK will set .wait_for_compl)40* rpmh_write_async() - Never waits.41* (There's no request completion callback)42*/43struct tcs_cmd {44u32 addr;45u32 data;46u32 wait;47};4849/**50* struct tcs_request: A set of tcs_cmds sent together in a TCS51*52* @state: state for the request.53* @wait_for_compl: wait until we get a response from the h/w accelerator54* (same as setting cmd->wait for all commands in the request)55* @num_cmds: the number of @cmds in this request56* @cmds: an array of tcs_cmds57*/58struct tcs_request {59enum rpmh_state state;60u32 wait_for_compl;61u32 num_cmds;62struct tcs_cmd *cmds;63};6465#define BCM_TCS_CMD_COMMIT_MASK BIT(30)66#define BCM_TCS_CMD_VALID_MASK BIT(29)67#define BCM_TCS_CMD_VOTE_MASK GENMASK(13, 0)68#define BCM_TCS_CMD_VOTE_Y_MASK GENMASK(13, 0)69#define BCM_TCS_CMD_VOTE_X_MASK GENMASK(27, 14)7071/* Construct a Bus Clock Manager (BCM) specific TCS command */72#define BCM_TCS_CMD(commit, valid, vote_x, vote_y) \73(u32_encode_bits(commit, BCM_TCS_CMD_COMMIT_MASK) | \74u32_encode_bits(valid, BCM_TCS_CMD_VALID_MASK) | \75u32_encode_bits(vote_x, BCM_TCS_CMD_VOTE_X_MASK) | \76u32_encode_bits(vote_y, BCM_TCS_CMD_VOTE_Y_MASK))7778#endif /* __SOC_QCOM_TCS_H__ */798081