Lines Matching +full:rpmh +full:- +full:rsc
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
21 #include <soc/qcom/rpmh.h>
23 #include "rpmh-internal.h"
59 * struct batch_cache_req - An entry in our batch catch
74 struct rsc_drv *drv = dev_get_drvdata(dev->parent); in get_rpmh_ctrlr()
76 return &drv->client; in get_rpmh_ctrlr()
83 struct completion *compl = rpm_msg->completion; in rpmh_tx_done()
84 bool free = rpm_msg->needs_free; in rpmh_tx_done()
101 list_for_each_entry(p, &ctrlr->cache, list) { in __find_req()
102 if (p->addr == addr) { in __find_req()
119 spin_lock_irqsave(&ctrlr->cache_lock, flags); in cache_rpm_request()
120 req = __find_req(ctrlr, cmd->addr); in cache_rpm_request()
126 req = ERR_PTR(-ENOMEM); in cache_rpm_request()
130 req->addr = cmd->addr; in cache_rpm_request()
131 req->sleep_val = req->wake_val = UINT_MAX; in cache_rpm_request()
132 list_add_tail(&req->list, &ctrlr->cache); in cache_rpm_request()
135 old_sleep_val = req->sleep_val; in cache_rpm_request()
136 old_wake_val = req->wake_val; in cache_rpm_request()
141 req->wake_val = cmd->data; in cache_rpm_request()
144 req->sleep_val = cmd->data; in cache_rpm_request()
148 ctrlr->dirty |= (req->sleep_val != old_sleep_val || in cache_rpm_request()
149 req->wake_val != old_wake_val) && in cache_rpm_request()
150 req->sleep_val != UINT_MAX && in cache_rpm_request()
151 req->wake_val != UINT_MAX; in cache_rpm_request()
154 spin_unlock_irqrestore(&ctrlr->cache_lock, flags); in cache_rpm_request()
160 * __rpmh_write: Cache and send the RPMH request
166 * Cache the RPMH request and send if the state is ACTIVE_ONLY.
174 int ret = -EINVAL; in __rpmh_write()
179 for (i = 0; i < rpm_msg->msg.num_cmds; i++) { in __rpmh_write()
180 req = cache_rpm_request(ctrlr, state, &rpm_msg->msg.cmds[i]); in __rpmh_write()
186 ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg); in __rpmh_write()
190 rpmh_tx_done(&rpm_msg->msg); in __rpmh_write()
200 return -EINVAL; in __fill_rpmh_msg()
202 memcpy(req->cmd, cmd, n * sizeof(*cmd)); in __fill_rpmh_msg()
204 req->msg.state = state; in __fill_rpmh_msg()
205 req->msg.cmds = req->cmd; in __fill_rpmh_msg()
206 req->msg.num_cmds = n; in __fill_rpmh_msg()
212 * rpmh_write_async: Write a set of RPMH commands
219 * Write a set of RPMH commands, the order of commands is maintained
230 return -ENOMEM; in rpmh_write_async()
231 rpm_msg->needs_free = true; in rpmh_write_async()
244 * rpmh_write: Write a set of RPMH commands and block until response
270 return (ret > 0) ? 0 : -ETIMEDOUT; in rpmh_write()
278 spin_lock_irqsave(&ctrlr->cache_lock, flags); in cache_batch()
279 list_add_tail(&req->list, &ctrlr->batch_cache); in cache_batch()
280 ctrlr->dirty = true; in cache_batch()
281 spin_unlock_irqrestore(&ctrlr->cache_lock, flags); in cache_batch()
292 list_for_each_entry(req, &ctrlr->batch_cache, list) { in flush_batch()
293 for (i = 0; i < req->count; i++) { in flush_batch()
294 rpm_msg = req->rpm_msgs + i; in flush_batch()
296 &rpm_msg->msg); in flush_batch()
306 * rpmh_write_batch: Write multiple sets of RPMH commands and wait for the
314 * Write a request to the RSC controller without caching. If the request
318 * request is sent as fire-n-forget and no ack is expected.
335 return -EINVAL; in rpmh_write_batch()
340 return -EINVAL; in rpmh_write_batch()
343 count * (sizeof(req->rpm_msgs[0]) + sizeof(*compls)), in rpmh_write_batch()
346 return -ENOMEM; in rpmh_write_batch()
351 req->count = count; in rpmh_write_batch()
352 rpm_msgs = req->rpm_msgs; in rpmh_write_batch()
371 pr_err("Error(%d) sending RPMH message addr=%#x\n", in rpmh_write_batch()
378 while (i--) { in rpmh_write_batch()
387 ret = -ETIMEDOUT; in rpmh_write_batch()
401 return (req->sleep_val != UINT_MAX && in is_req_valid()
402 req->wake_val != UINT_MAX && in is_req_valid()
403 req->sleep_val != req->wake_val); in is_req_valid()
421 * rpmh_flush() - Flushes the buffered sleep and wake sets to TCSes
426 * * 0 - Success
427 * * Error code - Otherwise
441 if (!spin_trylock(&ctrlr->cache_lock)) in rpmh_flush()
442 return -EBUSY; in rpmh_flush()
444 if (!ctrlr->dirty) { in rpmh_flush()
457 list_for_each_entry(p, &ctrlr->cache, list) { in rpmh_flush()
459 pr_debug("%s: skipping RPMH req: a:%#x s:%#x w:%#x", in rpmh_flush()
460 __func__, p->addr, p->sleep_val, p->wake_val); in rpmh_flush()
463 ret = send_single(ctrlr, RPMH_SLEEP_STATE, p->addr, in rpmh_flush()
464 p->sleep_val); in rpmh_flush()
467 ret = send_single(ctrlr, RPMH_WAKE_ONLY_STATE, p->addr, in rpmh_flush()
468 p->wake_val); in rpmh_flush()
473 ctrlr->dirty = false; in rpmh_flush()
478 spin_unlock(&ctrlr->cache_lock); in rpmh_flush()
495 spin_lock_irqsave(&ctrlr->cache_lock, flags); in rpmh_invalidate()
496 list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) in rpmh_invalidate()
498 INIT_LIST_HEAD(&ctrlr->batch_cache); in rpmh_invalidate()
499 ctrlr->dirty = true; in rpmh_invalidate()
500 spin_unlock_irqrestore(&ctrlr->cache_lock, flags); in rpmh_invalidate()