1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
7 #ifndef __RPM_INTERNAL_H__
8 #define __RPM_INTERNAL_H__
10 #include <linux/bitmap.h>
11 #include <soc/qcom/tcs.h>
14 #define MAX_CMDS_PER_TCS 16
15 #define MAX_TCS_PER_TYPE 3
16 #define MAX_TCS_NR (MAX_TCS_PER_TYPE * TCS_TYPE_NR)
17 #define MAX_TCS_SLOTS (MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE)
22 * struct tcs_group: group of Trigger Command Sets (TCS) to send state requests
25 * @drv: the controller
26 * @type: type of the TCS in this group - active, sleep, wake
27 * @mask: mask of the TCSes relative to all the TCSes in the RSC
28 * @offset: start of the TCS group relative to the TCSes in the RSC
29 * @num_tcs: number of TCSes in this type
30 * @ncpt: number of commands in each TCS
31 * @lock: lock for synchronizing this TCS writes
32 * @req: requests that are sent from the TCS
33 * @cmd_cache: flattened cache of cmds in sleep/wake TCS
34 * @slots: indicates which of @cmd_addr are occupied
44 const struct tcs_request
*req
[MAX_TCS_PER_TYPE
];
46 DECLARE_BITMAP(slots
, MAX_TCS_SLOTS
);
50 * struct rpmh_request: the message to be sent to rpmh-rsc
53 * @cmd: the payload that will be part of the @msg
54 * @completion: triggered when request is done
55 * @dev: the device making the request
56 * @err: err return from the controller
57 * @needs_free: check to free dynamically allocated request object
60 struct tcs_request msg
;
61 struct tcs_cmd cmd
[MAX_RPMH_PAYLOAD
];
62 struct completion
*completion
;
63 const struct device
*dev
;
69 * struct rpmh_ctrlr: our representation of the controller
71 * @cache: the list of cached requests
72 * @cache_lock: synchronize access to the cache data
73 * @dirty: was the cache updated since flush
74 * @batch_cache: Cache sleep and wake requests sent as batch
77 struct list_head cache
;
78 spinlock_t cache_lock
;
80 struct list_head batch_cache
;
84 * struct rsc_drv: the Direct Resource Voter (DRV) of the
85 * Resource State Coordinator controller (RSC)
87 * @name: controller identifier
88 * @tcs_base: start address of the TCS registers in this controller
89 * @id: instance id in the controller (Direct Resource Voter)
90 * @num_tcs: number of TCSes in this DRV
92 * @tcs_in_use: s/w state of the TCS
93 * @lock: synchronize state of the controller
94 * @client: handle to the DRV's client.
98 void __iomem
*tcs_base
;
101 struct tcs_group tcs
[TCS_TYPE_NR
];
102 DECLARE_BITMAP(tcs_in_use
, MAX_TCS_NR
);
104 struct rpmh_ctrlr client
;
107 int rpmh_rsc_send_data(struct rsc_drv
*drv
, const struct tcs_request
*msg
);
108 int rpmh_rsc_write_ctrl_data(struct rsc_drv
*drv
,
109 const struct tcs_request
*msg
);
110 int rpmh_rsc_invalidate(struct rsc_drv
*drv
);
112 void rpmh_tx_done(const struct tcs_request
*msg
, int r
);
114 #endif /* __RPM_INTERNAL_H__ */