Lines Matching defs:tcs
25 #include <soc/qcom/tcs.h>
62 #define RSC_DRV_STATUS 0x18 /* zero if tcs is busy */
95 * specified in the device tree by "qcom,tcs-offset" and used to
98 * specified by the device tree as "qcom,tcs-config".
227 struct tcs_group *tcs = &drv->tcs[type];
230 if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS))
233 for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
237 bitmap_zero(tcs->slots, MAX_TCS_SLOTS);
268 struct tcs_group *tcs;
291 tcs = &drv->tcs[type];
292 if (msg->state == RPMH_ACTIVE_ONLY_STATE && !tcs->num_tcs)
293 tcs = &drv->tcs[WAKE_TCS];
295 return tcs;
317 struct tcs_group *tcs;
321 tcs = &drv->tcs[i];
322 if (tcs->mask & BIT(tcs_id))
323 return tcs->req[tcs_id - tcs->offset];
436 * If wake tcs was re-purposed for sending active
440 if (!drv->tcs[ACTIVE_TCS].num_tcs)
454 if (!drv->tcs[ACTIVE_TCS].num_tcs)
511 * @tcs: A pointer to the tcs_group used for ACTIVE_ONLY transfers.
528 static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs,
534 int tcs_id = tcs->offset;
536 for (i = 0; i < tcs->num_tcs; i++, tcs_id++) {
555 * find_free_tcs() - Find free tcs in the given tcs_group; only for active.
556 * @tcs: A pointer to the active-only tcs_group (or the wake tcs_group if
561 * Return: The first tcs that's free.
563 static int find_free_tcs(struct tcs_group *tcs)
567 for (i = 0; i < tcs->num_tcs; i++) {
568 if (tcs_is_free(tcs->drv, tcs->offset + i))
569 return tcs->offset + i;
576 * claim_tcs_for_req() - Claim a tcs in the given tcs_group; only for active.
578 * @tcs: The tcs_group used for ACTIVE_ONLY transfers.
581 * Claims a tcs in the given tcs_group while making sure that no existing cmd
587 * Return: The id of the claimed tcs or -EBUSY if a matching msg is in flight
590 static int claim_tcs_for_req(struct rsc_drv *drv, struct tcs_group *tcs,
599 ret = check_for_req_inflight(drv, tcs, msg);
603 return find_free_tcs(tcs);
630 struct tcs_group *tcs;
634 tcs = get_tcs_for_msg(drv, msg);
635 if (IS_ERR(tcs))
636 return PTR_ERR(tcs);
640 /* Wait forever for a free tcs. It better be there eventually! */
642 (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0,
645 tcs->req[tcs_id - tcs->offset] = msg;
647 if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS) {
650 * repurposed TCS to avoid triggering them. tcs->slots will be
675 * @tcs: The tcs group to search.
684 * tcs->slots for.
688 static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg,
696 slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS,
698 if (slot >= tcs->num_tcs * tcs->ncpt)
700 i += tcs->ncpt;
703 bitmap_set(tcs->slots, slot, msg->num_cmds);
705 offset = slot / tcs->ncpt;
706 *tcs_id = offset + tcs->offset;
707 *cmd_id = slot % tcs->ncpt;
727 struct tcs_group *tcs;
731 tcs = get_tcs_for_msg(drv, msg);
732 if (IS_ERR(tcs))
733 return PTR_ERR(tcs);
736 ret = find_slots(tcs, msg, &tcs_id, &cmd_id);
761 struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS];
769 if (!tcs->num_tcs)
770 tcs = &drv->tcs[WAKE_TCS];
772 for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
871 struct tcs_group *tcs;
873 ret = of_property_read_u32(dn, "qcom,tcs-offset", &offset);
887 n = of_property_count_u32_elems(dn, "qcom,tcs-config");
892 ret = of_property_read_u32_index(dn, "qcom,tcs-config",
899 ret = of_property_read_u32_index(dn, "qcom,tcs-config",
908 tcs = &drv->tcs[tcs_cfg[i].type];
909 if (tcs->drv)
911 tcs->drv = drv;
912 tcs->type = tcs_cfg[i].type;
913 tcs->num_tcs = tcs_cfg[i].n;
914 tcs->ncpt = ncpt;
916 if (!tcs->num_tcs || tcs->type == CONTROL_TCS)
919 if (st + tcs->num_tcs > max_tcs ||
920 st + tcs->num_tcs >= BITS_PER_BYTE * sizeof(tcs->mask))
923 tcs->mask = ((1 << tcs->num_tcs) - 1) << st;
924 tcs->offset = st;
925 st += tcs->num_tcs;
1005 writel_relaxed(drv->tcs[ACTIVE_TCS].mask,