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
156 static void tcs_list_gen(struct bcm_voter *voter, int bucket,
160 struct list_head *bcm_list = &voter->commit_list;
176 wait = commit && (voter->tcs_wait & BIT(bucket));
199 * of_bcm_voter_get - gets a bcm voter handle from DT node
201 * @name: name for the bcm voter device
207 * when matching bcm voter is yet to be found.
211 struct bcm_voter *voter = ERR_PTR(-EPROBE_DEFER);
222 idx = of_property_match_string(np, "qcom,bcm-voter-names", name);
232 voter = temp;
239 return voter;
245 * @voter: voter that the bcms are being added to
248 void qcom_icc_bcm_voter_add(struct bcm_voter *voter, struct qcom_icc_bcm *bcm)
250 if (!voter)
253 mutex_lock(&voter->lock);
255 list_add_tail(&bcm->list, &voter->commit_list);
258 list_add_tail(&bcm->ws_list, &voter->ws_list);
260 mutex_unlock(&voter->lock);
266 * @voter: voter that needs flushing
269 * associated with the voter. It conditionally generate WAKE and SLEEP commands
276 int qcom_icc_bcm_voter_commit(struct bcm_voter *voter)
284 if (!voter)
287 mutex_lock(&voter->lock);
288 list_for_each_entry(bcm, &voter->commit_list, list) {
303 list_sort(NULL, &voter->commit_list, cmp_vcd);
309 tcs_list_gen(voter, QCOM_ICC_BUCKET_AMC, cmds, commit_idx);
313 rpmh_invalidate(voter->dev);
315 ret = rpmh_write_batch(voter->dev, RPMH_ACTIVE_ONLY_STATE,
322 list_for_each_entry_safe(bcm, bcm_tmp, &voter->commit_list, list)
325 list_for_each_entry_safe(bcm, bcm_tmp, &voter->ws_list, ws_list) {
335 list_add_tail(&bcm->list, &voter->commit_list);
340 if (list_empty(&voter->commit_list))
343 list_sort(NULL, &voter->commit_list, cmp_vcd);
345 tcs_list_gen(voter, QCOM_ICC_BUCKET_WAKE, cmds, commit_idx);
347 ret = rpmh_write_batch(voter->dev, RPMH_WAKE_ONLY_STATE, cmds, commit_idx);
353 tcs_list_gen(voter, QCOM_ICC_BUCKET_SLEEP, cmds, commit_idx);
355 ret = rpmh_write_batch(voter->dev, RPMH_SLEEP_STATE, cmds, commit_idx);
362 list_for_each_entry_safe(bcm, bcm_tmp, &voter->commit_list, list)
365 mutex_unlock(&voter->lock);
373 struct bcm_voter *voter;
375 voter = devm_kzalloc(&pdev->dev, sizeof(*voter), GFP_KERNEL);
376 if (!voter)
379 voter->dev = &pdev->dev;
380 voter->np = np;
382 if (of_property_read_u32(np, "qcom,tcs-wait", &voter->tcs_wait))
383 voter->tcs_wait = QCOM_ICC_TAG_ACTIVE_ONLY;
385 mutex_init(&voter->lock);
386 INIT_LIST_HEAD(&voter->commit_list);
387 INIT_LIST_HEAD(&voter->ws_list);
390 list_add_tail(&voter->voter_node, &bcm_voters);
397 { .compatible = "qcom,bcm-voter" },