mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-21 12:25:27 +00:00
soc: qcom: rpmh: U-Boot API changes
Fix build errors, add some debug logging. Acked-by: Sumit Garg <sumit.garg@linaro.org> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
This commit is contained in:
parent
a726ea1140
commit
c6112dd247
2 changed files with 22 additions and 35 deletions
|
@ -16,25 +16,28 @@
|
||||||
|
|
||||||
#define RPMH_TIMEOUT_MS msecs_to_jiffies(10000)
|
#define RPMH_TIMEOUT_MS msecs_to_jiffies(10000)
|
||||||
|
|
||||||
#define DEFINE_RPMH_MSG_ONSTACK(device, s, q, name) \
|
#define DEFINE_RPMH_MSG_ONSTACK(device, s, name) \
|
||||||
struct rpmh_request name = { \
|
struct rpmh_request name = { \
|
||||||
.msg = { \
|
.msg = { \
|
||||||
.state = s, \
|
.state = s, \
|
||||||
.cmds = name.cmd, \
|
.cmds = name.cmd, \
|
||||||
.num_cmds = 0, \
|
.num_cmds = 0, \
|
||||||
.wait_for_compl = true, \
|
|
||||||
}, \
|
}, \
|
||||||
.cmd = { { 0 } }, \
|
.cmd = { { 0 } }, \
|
||||||
.completion = q, \
|
|
||||||
.dev = device, \
|
.dev = device, \
|
||||||
.needs_free = false, \
|
.needs_free = false, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ctrlr_to_drv(ctrlr) container_of(ctrlr, struct rsc_drv, client)
|
#define ctrlr_to_drv(ctrlr) container_of(ctrlr, struct rsc_drv, client)
|
||||||
|
|
||||||
static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev)
|
static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct rsc_drv *drv = dev_get_drvdata(dev->parent);
|
struct rsc_drv *drv = (struct rsc_drv *)dev_get_priv(dev->parent);
|
||||||
|
|
||||||
|
if (!drv) {
|
||||||
|
log_err("BUG: no RPMh driver for %s (parent %s)\n", dev->name, dev->parent->name);
|
||||||
|
BUG();
|
||||||
|
}
|
||||||
|
|
||||||
return &drv->client;
|
return &drv->client;
|
||||||
}
|
}
|
||||||
|
@ -50,34 +53,21 @@ static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev)
|
||||||
* SLEEP/WAKE_ONLY requests are not sent to the controller at
|
* SLEEP/WAKE_ONLY requests are not sent to the controller at
|
||||||
* this time. Use rpmh_flush() to send them to the controller.
|
* this time. Use rpmh_flush() to send them to the controller.
|
||||||
*/
|
*/
|
||||||
static int __rpmh_write(const struct device *dev, enum rpmh_state state,
|
static int __rpmh_write(const struct udevice *dev, enum rpmh_state state,
|
||||||
struct rpmh_request *rpm_msg)
|
struct rpmh_request *rpm_msg)
|
||||||
{
|
{
|
||||||
struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
|
struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
|
||||||
int ret = -EINVAL;
|
|
||||||
struct cache_req *req;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Cache the request in our store and link the payload */
|
if (state != RPMH_ACTIVE_ONLY_STATE) {
|
||||||
for (i = 0; i < rpm_msg->msg.num_cmds; i++) {
|
log_err("only ACTIVE_ONLY state supported\n");
|
||||||
req = cache_rpm_request(ctrlr, state, &rpm_msg->msg.cmds[i]);
|
return -EINVAL;
|
||||||
if (IS_ERR(req))
|
|
||||||
return PTR_ERR(req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == RPMH_ACTIVE_ONLY_STATE) {
|
return rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg);
|
||||||
ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msg->msg);
|
|
||||||
} else {
|
|
||||||
/* Clean up our call by spoofing tx_done */
|
|
||||||
ret = 0;
|
|
||||||
rpmh_tx_done(&rpm_msg->msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state,
|
static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state,
|
||||||
const struct tcs_cmd *cmd, u32 n)
|
const struct tcs_cmd *cmd, u32 n)
|
||||||
{
|
{
|
||||||
if (!cmd || !n || n > MAX_RPMH_PAYLOAD)
|
if (!cmd || !n || n > MAX_RPMH_PAYLOAD)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -88,6 +78,8 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state,
|
||||||
req->msg.cmds = req->cmd;
|
req->msg.cmds = req->cmd;
|
||||||
req->msg.num_cmds = n;
|
req->msg.num_cmds = n;
|
||||||
|
|
||||||
|
debug("rpmh_msg: %d, %d cmds [first %#x/%#x]\n", state, n, cmd->addr, cmd->data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,11 +93,10 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state,
|
||||||
*
|
*
|
||||||
* May sleep. Do not call from atomic contexts.
|
* May sleep. Do not call from atomic contexts.
|
||||||
*/
|
*/
|
||||||
int rpmh_write(const struct device *dev, enum rpmh_state state,
|
int rpmh_write(const struct udevice *dev, enum rpmh_state state,
|
||||||
const struct tcs_cmd *cmd, u32 n)
|
const struct tcs_cmd *cmd, u32 n)
|
||||||
{
|
{
|
||||||
DECLARE_COMPLETION_ONSTACK(compl);
|
DEFINE_RPMH_MSG_ONSTACK(dev, state, rpm_msg);
|
||||||
DEFINE_RPMH_MSG_ONSTACK(dev, state, &compl, rpm_msg);
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = __fill_rpmh_msg(&rpm_msg, state, cmd, n);
|
ret = __fill_rpmh_msg(&rpm_msg, state, cmd, n);
|
||||||
|
@ -113,11 +104,7 @@ int rpmh_write(const struct device *dev, enum rpmh_state state,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = __rpmh_write(dev, state, &rpm_msg);
|
ret = __rpmh_write(dev, state, &rpm_msg);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = wait_for_completion_timeout(&compl, RPMH_TIMEOUT_MS);
|
return ret;
|
||||||
WARN_ON(!ret);
|
|
||||||
return (ret > 0) ? 0 : -ETIMEDOUT;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(rpmh_write);
|
EXPORT_SYMBOL_GPL(rpmh_write);
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
#ifndef __SOC_QCOM_RPMH_H__
|
#ifndef __SOC_QCOM_RPMH_H__
|
||||||
#define __SOC_QCOM_RPMH_H__
|
#define __SOC_QCOM_RPMH_H__
|
||||||
|
|
||||||
|
#include <dm/device-internal.h>
|
||||||
#include <soc/qcom/tcs.h>
|
#include <soc/qcom/tcs.h>
|
||||||
#include <linux/platform_device.h>
|
|
||||||
|
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_QCOM_RPMH)
|
#if IS_ENABLED(CONFIG_QCOM_RPMH)
|
||||||
int rpmh_write(const struct device *dev, enum rpmh_state state,
|
int rpmh_write(const struct udevice *dev, enum rpmh_state state,
|
||||||
const struct tcs_cmd *cmd, u32 n);
|
const struct tcs_cmd *cmd, u32 n);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue