162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef __SOC_QCOM_TCS_H__ 762306a36Sopenharmony_ci#define __SOC_QCOM_TCS_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define MAX_RPMH_PAYLOAD 16 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/** 1262306a36Sopenharmony_ci * rpmh_state: state for the request 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * RPMH_SLEEP_STATE: State of the resource when the processor subsystem 1562306a36Sopenharmony_ci * is powered down. There is no client using the 1662306a36Sopenharmony_ci * resource actively. 1762306a36Sopenharmony_ci * RPMH_WAKE_ONLY_STATE: Resume resource state to the value previously 1862306a36Sopenharmony_ci * requested before the processor was powered down. 1962306a36Sopenharmony_ci * RPMH_ACTIVE_ONLY_STATE: Active or AMC mode requests. Resource state 2062306a36Sopenharmony_ci * is aggregated immediately. 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_cienum rpmh_state { 2362306a36Sopenharmony_ci RPMH_SLEEP_STATE, 2462306a36Sopenharmony_ci RPMH_WAKE_ONLY_STATE, 2562306a36Sopenharmony_ci RPMH_ACTIVE_ONLY_STATE, 2662306a36Sopenharmony_ci}; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci/** 2962306a36Sopenharmony_ci * struct tcs_cmd: an individual request to RPMH. 3062306a36Sopenharmony_ci * 3162306a36Sopenharmony_ci * @addr: the address of the resource slv_id:18:16 | offset:0:15 3262306a36Sopenharmony_ci * @data: the resource state request 3362306a36Sopenharmony_ci * @wait: ensure that this command is complete before returning. 3462306a36Sopenharmony_ci * Setting "wait" here only makes sense during rpmh_write_batch() for 3562306a36Sopenharmony_ci * active-only transfers, this is because: 3662306a36Sopenharmony_ci * rpmh_write() - Always waits. 3762306a36Sopenharmony_ci * (DEFINE_RPMH_MSG_ONSTACK will set .wait_for_compl) 3862306a36Sopenharmony_ci * rpmh_write_async() - Never waits. 3962306a36Sopenharmony_ci * (There's no request completion callback) 4062306a36Sopenharmony_ci */ 4162306a36Sopenharmony_cistruct tcs_cmd { 4262306a36Sopenharmony_ci u32 addr; 4362306a36Sopenharmony_ci u32 data; 4462306a36Sopenharmony_ci u32 wait; 4562306a36Sopenharmony_ci}; 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci/** 4862306a36Sopenharmony_ci * struct tcs_request: A set of tcs_cmds sent together in a TCS 4962306a36Sopenharmony_ci * 5062306a36Sopenharmony_ci * @state: state for the request. 5162306a36Sopenharmony_ci * @wait_for_compl: wait until we get a response from the h/w accelerator 5262306a36Sopenharmony_ci * (same as setting cmd->wait for all commands in the request) 5362306a36Sopenharmony_ci * @num_cmds: the number of @cmds in this request 5462306a36Sopenharmony_ci * @cmds: an array of tcs_cmds 5562306a36Sopenharmony_ci */ 5662306a36Sopenharmony_cistruct tcs_request { 5762306a36Sopenharmony_ci enum rpmh_state state; 5862306a36Sopenharmony_ci u32 wait_for_compl; 5962306a36Sopenharmony_ci u32 num_cmds; 6062306a36Sopenharmony_ci struct tcs_cmd *cmds; 6162306a36Sopenharmony_ci}; 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci#define BCM_TCS_CMD_COMMIT_SHFT 30 6462306a36Sopenharmony_ci#define BCM_TCS_CMD_COMMIT_MASK 0x40000000 6562306a36Sopenharmony_ci#define BCM_TCS_CMD_VALID_SHFT 29 6662306a36Sopenharmony_ci#define BCM_TCS_CMD_VALID_MASK 0x20000000 6762306a36Sopenharmony_ci#define BCM_TCS_CMD_VOTE_X_SHFT 14 6862306a36Sopenharmony_ci#define BCM_TCS_CMD_VOTE_MASK 0x3fff 6962306a36Sopenharmony_ci#define BCM_TCS_CMD_VOTE_Y_SHFT 0 7062306a36Sopenharmony_ci#define BCM_TCS_CMD_VOTE_Y_MASK 0xfffc000 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* Construct a Bus Clock Manager (BCM) specific TCS command */ 7362306a36Sopenharmony_ci#define BCM_TCS_CMD(commit, valid, vote_x, vote_y) \ 7462306a36Sopenharmony_ci (((commit) << BCM_TCS_CMD_COMMIT_SHFT) | \ 7562306a36Sopenharmony_ci ((valid) << BCM_TCS_CMD_VALID_SHFT) | \ 7662306a36Sopenharmony_ci ((cpu_to_le32(vote_x) & \ 7762306a36Sopenharmony_ci BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_X_SHFT) | \ 7862306a36Sopenharmony_ci ((cpu_to_le32(vote_y) & \ 7962306a36Sopenharmony_ci BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_Y_SHFT)) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#endif /* __SOC_QCOM_TCS_H__ */ 82