| .. | .. |
|---|
| 8 | 8 | #define __RPM_INTERNAL_H__ |
|---|
| 9 | 9 | |
|---|
| 10 | 10 | #include <linux/bitmap.h> |
|---|
| 11 | +#include <linux/wait.h> |
|---|
| 11 | 12 | #include <soc/qcom/tcs.h> |
|---|
| 12 | 13 | |
|---|
| 13 | 14 | #define TCS_TYPE_NR 4 |
|---|
| .. | .. |
|---|
| 22 | 23 | * struct tcs_group: group of Trigger Command Sets (TCS) to send state requests |
|---|
| 23 | 24 | * to the controller |
|---|
| 24 | 25 | * |
|---|
| 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 |
|---|
| 26 | + * @drv: The controller. |
|---|
| 27 | + * @type: Type of the TCS in this group - active, sleep, wake. |
|---|
| 28 | + * @mask: Mask of the TCSes relative to all the TCSes in the RSC. |
|---|
| 29 | + * @offset: Start of the TCS group relative to the TCSes in the RSC. |
|---|
| 30 | + * @num_tcs: Number of TCSes in this type. |
|---|
| 31 | + * @ncpt: Number of commands in each TCS. |
|---|
| 32 | + * @req: Requests that are sent from the TCS; only used for ACTIVE_ONLY |
|---|
| 33 | + * transfers (could be on a wake/sleep TCS if we are borrowing for |
|---|
| 34 | + * an ACTIVE_ONLY transfer). |
|---|
| 35 | + * Start: grab drv->lock, set req, set tcs_in_use, drop drv->lock, |
|---|
| 36 | + * trigger |
|---|
| 37 | + * End: get irq, access req, |
|---|
| 38 | + * grab drv->lock, clear tcs_in_use, drop drv->lock |
|---|
| 39 | + * @slots: Indicates which of @cmd_addr are occupied; only used for |
|---|
| 40 | + * SLEEP / WAKE TCSs. Things are tightly packed in the |
|---|
| 41 | + * case that (ncpt < MAX_CMDS_PER_TCS). That is if ncpt = 2 and |
|---|
| 42 | + * MAX_CMDS_PER_TCS = 16 then bit[2] = the first bit in 2nd TCS. |
|---|
| 35 | 43 | */ |
|---|
| 36 | 44 | struct tcs_group { |
|---|
| 37 | 45 | struct rsc_drv *drv; |
|---|
| .. | .. |
|---|
| 40 | 48 | u32 offset; |
|---|
| 41 | 49 | int num_tcs; |
|---|
| 42 | 50 | int ncpt; |
|---|
| 43 | | - spinlock_t lock; |
|---|
| 44 | 51 | const struct tcs_request *req[MAX_TCS_PER_TYPE]; |
|---|
| 45 | | - u32 *cmd_cache; |
|---|
| 46 | 52 | DECLARE_BITMAP(slots, MAX_TCS_SLOTS); |
|---|
| 47 | 53 | }; |
|---|
| 48 | 54 | |
|---|
| .. | .. |
|---|
| 84 | 90 | * struct rsc_drv: the Direct Resource Voter (DRV) of the |
|---|
| 85 | 91 | * Resource State Coordinator controller (RSC) |
|---|
| 86 | 92 | * |
|---|
| 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 |
|---|
| 91 | | - * @tcs: TCS groups |
|---|
| 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. |
|---|
| 93 | + * @name: Controller identifier. |
|---|
| 94 | + * @tcs_base: Start address of the TCS registers in this controller. |
|---|
| 95 | + * @id: Instance id in the controller (Direct Resource Voter). |
|---|
| 96 | + * @num_tcs: Number of TCSes in this DRV. |
|---|
| 97 | + * @rsc_pm: CPU PM notifier for controller. |
|---|
| 98 | + * Used when solver mode is not present. |
|---|
| 99 | + * @cpus_in_pm: Number of CPUs not in idle power collapse. |
|---|
| 100 | + * Used when solver mode is not present. |
|---|
| 101 | + * @tcs: TCS groups. |
|---|
| 102 | + * @tcs_in_use: S/W state of the TCS; only set for ACTIVE_ONLY |
|---|
| 103 | + * transfers, but might show a sleep/wake TCS in use if |
|---|
| 104 | + * it was borrowed for an active_only transfer. You |
|---|
| 105 | + * must hold the lock in this struct (AKA drv->lock) in |
|---|
| 106 | + * order to update this. |
|---|
| 107 | + * @lock: Synchronize state of the controller. If RPMH's cache |
|---|
| 108 | + * lock will also be held, the order is: drv->lock then |
|---|
| 109 | + * cache_lock. |
|---|
| 110 | + * @tcs_wait: Wait queue used to wait for @tcs_in_use to free up a |
|---|
| 111 | + * slot |
|---|
| 112 | + * @client: Handle to the DRV's client. |
|---|
| 95 | 113 | */ |
|---|
| 96 | 114 | struct rsc_drv { |
|---|
| 97 | 115 | const char *name; |
|---|
| 98 | 116 | void __iomem *tcs_base; |
|---|
| 99 | 117 | int id; |
|---|
| 100 | 118 | int num_tcs; |
|---|
| 119 | + struct notifier_block rsc_pm; |
|---|
| 120 | + atomic_t cpus_in_pm; |
|---|
| 101 | 121 | struct tcs_group tcs[TCS_TYPE_NR]; |
|---|
| 102 | 122 | DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR); |
|---|
| 103 | 123 | spinlock_t lock; |
|---|
| 124 | + wait_queue_head_t tcs_wait; |
|---|
| 104 | 125 | struct rpmh_ctrlr client; |
|---|
| 105 | 126 | }; |
|---|
| 106 | 127 | |
|---|
| 107 | 128 | int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg); |
|---|
| 108 | 129 | int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, |
|---|
| 109 | 130 | const struct tcs_request *msg); |
|---|
| 110 | | -int rpmh_rsc_invalidate(struct rsc_drv *drv); |
|---|
| 131 | +void rpmh_rsc_invalidate(struct rsc_drv *drv); |
|---|
| 111 | 132 | |
|---|
| 112 | 133 | void rpmh_tx_done(const struct tcs_request *msg, int r); |
|---|
| 134 | +int rpmh_flush(struct rpmh_ctrlr *ctrlr); |
|---|
| 113 | 135 | |
|---|
| 114 | 136 | #endif /* __RPM_INTERNAL_H__ */ |
|---|