Lines Matching defs:voter
16 #include "bcm-voter.h"
23 * struct bcm_voter - Bus Clock Manager voter
26 * @lock: mutex to protect commit and wake/sleep lists in the voter
138 static void tcs_list_gen(struct bcm_voter *voter, int bucket,
142 struct list_head *bcm_list = &voter->commit_list;
158 wait = commit && (voter->tcs_wait & BIT(bucket));
181 * of_bcm_voter_get - gets a bcm voter handle from DT node
183 * @name: name for the bcm voter device
189 * when matching bcm voter is yet to be found.
193 struct bcm_voter *voter = ERR_PTR(-EPROBE_DEFER);
204 idx = of_property_match_string(np, "qcom,bcm-voter-names", name);
214 voter = temp;
221 return voter;
227 * @voter: voter that the bcms are being added to
230 void qcom_icc_bcm_voter_add(struct bcm_voter *voter, struct qcom_icc_bcm *bcm)
232 if (!voter)
235 mutex_lock(&voter->lock);
237 list_add_tail(&bcm->list, &voter->commit_list);
240 list_add_tail(&bcm->ws_list, &voter->ws_list);
242 mutex_unlock(&voter->lock);
248 * @voter: voter that needs flushing
251 * associated with the voter. It conditionally generate WAKE and SLEEP commands
258 int qcom_icc_bcm_voter_commit(struct bcm_voter *voter)
266 if (!voter)
269 mutex_lock(&voter->lock);
270 list_for_each_entry(bcm, &voter->commit_list, list)
281 list_sort(NULL, &voter->commit_list, cmp_vcd);
287 tcs_list_gen(voter, QCOM_ICC_BUCKET_AMC, cmds, commit_idx);
291 rpmh_invalidate(voter->dev);
293 ret = rpmh_write_batch(voter->dev, RPMH_ACTIVE_ONLY_STATE,
300 list_for_each_entry_safe(bcm, bcm_tmp, &voter->commit_list, list)
303 list_for_each_entry_safe(bcm, bcm_tmp, &voter->ws_list, ws_list) {
313 list_add_tail(&bcm->list, &voter->commit_list);
318 if (list_empty(&voter->commit_list))
321 list_sort(NULL, &voter->commit_list, cmp_vcd);
323 tcs_list_gen(voter, QCOM_ICC_BUCKET_WAKE, cmds, commit_idx);
325 ret = rpmh_write_batch(voter->dev, RPMH_WAKE_ONLY_STATE, cmds, commit_idx);
331 tcs_list_gen(voter, QCOM_ICC_BUCKET_SLEEP, cmds, commit_idx);
333 ret = rpmh_write_batch(voter->dev, RPMH_SLEEP_STATE, cmds, commit_idx);
340 list_for_each_entry_safe(bcm, bcm_tmp, &voter->commit_list, list)
343 mutex_unlock(&voter->lock);
351 struct bcm_voter *voter;
353 voter = devm_kzalloc(&pdev->dev, sizeof(*voter), GFP_KERNEL);
354 if (!voter)
357 voter->dev = &pdev->dev;
358 voter->np = np;
360 if (of_property_read_u32(np, "qcom,tcs-wait", &voter->tcs_wait))
361 voter->tcs_wait = QCOM_ICC_TAG_ACTIVE_ONLY;
363 mutex_init(&voter->lock);
364 INIT_LIST_HEAD(&voter->commit_list);
365 INIT_LIST_HEAD(&voter->ws_list);
368 list_add_tail(&voter->voter_node, &bcm_voters);
375 { .compatible = "qcom,bcm-voter" },