^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __SOC_QCOM_TCS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __SOC_QCOM_TCS_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define MAX_RPMH_PAYLOAD 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * rpmh_state: state for the request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * RPMH_SLEEP_STATE: State of the resource when the processor subsystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * is powered down. There is no client using the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * resource actively.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * RPMH_WAKE_ONLY_STATE: Resume resource state to the value previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * requested before the processor was powered down.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * RPMH_ACTIVE_ONLY_STATE: Active or AMC mode requests. Resource state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * is aggregated immediately.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) enum rpmh_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) RPMH_SLEEP_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) RPMH_WAKE_ONLY_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) RPMH_ACTIVE_ONLY_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * struct tcs_cmd: an individual request to RPMH.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * @addr: the address of the resource slv_id:18:16 | offset:0:15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * @data: the resource state request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * @wait: wait for this request to be complete before sending the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct tcs_cmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u32 addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) u32 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) u32 wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * struct tcs_request: A set of tcs_cmds sent together in a TCS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @state: state for the request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * @wait_for_compl: wait until we get a response from the h/w accelerator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @num_cmds: the number of @cmds in this request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @cmds: an array of tcs_cmds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct tcs_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) enum rpmh_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) u32 wait_for_compl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) u32 num_cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct tcs_cmd *cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define BCM_TCS_CMD_COMMIT_SHFT 30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define BCM_TCS_CMD_COMMIT_MASK 0x40000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define BCM_TCS_CMD_VALID_SHFT 29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define BCM_TCS_CMD_VALID_MASK 0x20000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define BCM_TCS_CMD_VOTE_X_SHFT 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define BCM_TCS_CMD_VOTE_MASK 0x3fff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define BCM_TCS_CMD_VOTE_Y_SHFT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define BCM_TCS_CMD_VOTE_Y_MASK 0xfffc000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* Construct a Bus Clock Manager (BCM) specific TCS command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define BCM_TCS_CMD(commit, valid, vote_x, vote_y) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) (((commit) << BCM_TCS_CMD_COMMIT_SHFT) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) ((valid) << BCM_TCS_CMD_VALID_SHFT) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) ((cpu_to_le32(vote_x) & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_X_SHFT) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) ((cpu_to_le32(vote_y) & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_Y_SHFT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #endif /* __SOC_QCOM_TCS_H__ */