xref: /linux/include/soc/qcom/tcs.h (revision 6311b6521bcc804e4d2fd45a5640562a7b8b5241)
1658628e7SLina Iyer /* SPDX-License-Identifier: GPL-2.0 */
2658628e7SLina Iyer /*
3*6311b652SJordan 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
33658628e7SLina Iyer  * @wait: wait for this request to be complete before sending the next
34658628e7SLina Iyer  */
35658628e7SLina Iyer struct tcs_cmd {
36658628e7SLina Iyer 	u32 addr;
37658628e7SLina Iyer 	u32 data;
38658628e7SLina Iyer 	u32 wait;
39658628e7SLina Iyer };
40658628e7SLina Iyer 
41658628e7SLina Iyer /**
42658628e7SLina Iyer  * struct tcs_request: A set of tcs_cmds sent together in a TCS
43658628e7SLina Iyer  *
44658628e7SLina Iyer  * @state:          state for the request.
45658628e7SLina Iyer  * @wait_for_compl: wait until we get a response from the h/w accelerator
46658628e7SLina Iyer  * @num_cmds:       the number of @cmds in this request
47658628e7SLina Iyer  * @cmds:           an array of tcs_cmds
48658628e7SLina Iyer  */
49658628e7SLina Iyer struct tcs_request {
50658628e7SLina Iyer 	enum rpmh_state state;
51658628e7SLina Iyer 	u32 wait_for_compl;
52658628e7SLina Iyer 	u32 num_cmds;
53658628e7SLina Iyer 	struct tcs_cmd *cmds;
54658628e7SLina Iyer };
55658628e7SLina Iyer 
56*6311b652SJordan Crouse #define BCM_TCS_CMD_COMMIT_SHFT		30
57*6311b652SJordan Crouse #define BCM_TCS_CMD_COMMIT_MASK		0x40000000
58*6311b652SJordan Crouse #define BCM_TCS_CMD_VALID_SHFT		29
59*6311b652SJordan Crouse #define BCM_TCS_CMD_VALID_MASK		0x20000000
60*6311b652SJordan Crouse #define BCM_TCS_CMD_VOTE_X_SHFT		14
61*6311b652SJordan Crouse #define BCM_TCS_CMD_VOTE_MASK		0x3fff
62*6311b652SJordan Crouse #define BCM_TCS_CMD_VOTE_Y_SHFT		0
63*6311b652SJordan Crouse #define BCM_TCS_CMD_VOTE_Y_MASK		0xfffc000
64*6311b652SJordan Crouse 
65*6311b652SJordan Crouse /* Construct a Bus Clock Manager (BCM) specific TCS command */
66*6311b652SJordan Crouse #define BCM_TCS_CMD(commit, valid, vote_x, vote_y)		\
67*6311b652SJordan Crouse 	(((commit) << BCM_TCS_CMD_COMMIT_SHFT) |		\
68*6311b652SJordan Crouse 	((valid) << BCM_TCS_CMD_VALID_SHFT) |			\
69*6311b652SJordan Crouse 	((cpu_to_le32(vote_x) &					\
70*6311b652SJordan Crouse 	BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_X_SHFT) |	\
71*6311b652SJordan Crouse 	((cpu_to_le32(vote_y) &					\
72*6311b652SJordan Crouse 	BCM_TCS_CMD_VOTE_MASK) << BCM_TCS_CMD_VOTE_Y_SHFT))
73*6311b652SJordan Crouse 
74658628e7SLina Iyer #endif /* __SOC_QCOM_TCS_H__ */
75