1658628e7SLina Iyer /* SPDX-License-Identifier: GPL-2.0 */ 2658628e7SLina Iyer /* 36311b652SJordan Crouse * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. 4658628e7SLina Iyer */ 5658628e7SLina Iyer 6658628e7SLina Iyer #ifndef __SOC_QCOM_TCS_H__ 7658628e7SLina Iyer #define __SOC_QCOM_TCS_H__ 8658628e7SLina Iyer 9658628e7SLina Iyer #define MAX_RPMH_PAYLOAD 16 10658628e7SLina Iyer 11658628e7SLina Iyer /** 12658628e7SLina Iyer * rpmh_state: state for the request 13658628e7SLina Iyer * 14658628e7SLina Iyer * RPMH_SLEEP_STATE: State of the resource when the processor subsystem 15658628e7SLina Iyer * is powered down. There is no client using the 16658628e7SLina Iyer * resource actively. 17658628e7SLina Iyer * RPMH_WAKE_ONLY_STATE: Resume resource state to the value previously 18658628e7SLina Iyer * requested before the processor was powered down. 19658628e7SLina Iyer * RPMH_ACTIVE_ONLY_STATE: Active or AMC mode requests. Resource state 20658628e7SLina Iyer * is aggregated immediately. 21658628e7SLina Iyer */ 22658628e7SLina Iyer enum rpmh_state { 23658628e7SLina Iyer RPMH_SLEEP_STATE, 24658628e7SLina Iyer RPMH_WAKE_ONLY_STATE, 25658628e7SLina Iyer RPMH_ACTIVE_ONLY_STATE, 26658628e7SLina Iyer }; 27658628e7SLina Iyer 28658628e7SLina Iyer /** 29658628e7SLina Iyer * struct tcs_cmd: an individual request to RPMH. 30658628e7SLina Iyer * 31658628e7SLina Iyer * @addr: the address of the resource slv_id:18:16 | offset:0:15 32658628e7SLina Iyer * @data: the resource state request 33*fef419c4SLina Iyer * @wait: ensure that this command is complete before returning. 34*fef419c4SLina Iyer * Setting "wait" here only makes sense during rpmh_write_batch() for 35*fef419c4SLina Iyer * active-only transfers, this is because: 36*fef419c4SLina Iyer * rpmh_write() - Always waits. 37*fef419c4SLina Iyer * (DEFINE_RPMH_MSG_ONSTACK will set .wait_for_compl) 38*fef419c4SLina Iyer * rpmh_write_async() - Never waits. 39*fef419c4SLina Iyer * (There's no request completion callback) 40658628e7SLina Iyer */ 41658628e7SLina Iyer struct tcs_cmd { 42658628e7SLina Iyer u32 addr; 43658628e7SLina Iyer u32 data; 44658628e7SLina Iyer u32 wait; 45658628e7SLina Iyer }; 46658628e7SLina Iyer 47658628e7SLina Iyer /** 48658628e7SLina Iyer * struct tcs_request: A set of tcs_cmds sent together in a TCS 49658628e7SLina Iyer * 50658628e7SLina Iyer * @state: state for the request. 51658628e7SLina Iyer * @wait_for_compl: wait until we get a response from the h/w accelerator 52*fef419c4SLina Iyer * (same as setting cmd->wait for all commands in the request) 53658628e7SLina Iyer * @num_cmds: the number of @cmds in this request 54658628e7SLina Iyer * @cmds: an array of tcs_cmds 55658628e7SLina Iyer */ 56658628e7SLina Iyer struct tcs_request { 57658628e7SLina Iyer enum rpmh_state state; 58658628e7SLina Iyer u32 wait_for_compl; 59658628e7SLina Iyer u32 num_cmds; 60658628e7SLina Iyer struct tcs_cmd *cmds; 61658628e7SLina Iyer }; 62658628e7SLina Iyer 636311b652SJordan Crouse #define BCM_TCS_CMD_COMMIT_SHFT 30 646311b652SJordan Crouse #define BCM_TCS_CMD_COMMIT_MASK 0x40000000 656311b652SJordan Crouse #define BCM_TCS_CMD_VALID_SHFT 29 666311b652SJordan Crouse #define BCM_TCS_CMD_VALID_MASK 0x20000000 676311b652SJordan Crouse #define BCM_TCS_CMD_VOTE_X_SHFT 14 686311b652SJordan Crouse #define BCM_TCS_CMD_VOTE_MASK 0x3fff 696311b652SJordan Crouse #define BCM_TCS_CMD_VOTE_Y_SHFT 0 706311b652SJordan Crouse #define BCM_TCS_CMD_VOTE_Y_MASK 0xfffc000 716311b652SJordan Crouse 726311b652SJordan Crouse /* Construct a Bus Clock Manager (BCM) specific TCS command */ 736311b652SJordan Crouse #define BCM_TCS_CMD(commit, valid, vote_x, vote_y) \ 746311b652SJordan Crouse (((commit) << BCM_TCS_CMD_COMMIT_SHFT) | \ 756311b652SJordan Crouse ((valid) << BCM_TCS_CMD_VALID_SHFT) | \ 766311b652SJordan Crouse ((cpu_to_le32(vote_x) & \ 776311b652SJordan Crouse BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_X_SHFT) | \ 786311b652SJordan Crouse ((cpu_to_le32(vote_y) & \ 796311b652SJordan Crouse BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_Y_SHFT)) 806311b652SJordan Crouse 81658628e7SLina Iyer #endif /* __SOC_QCOM_TCS_H__ */ 82