Skip to content

Commit 055b6cf

Browse files
gvlaevnmenon
authored andcommitted
firmware: ti_sci: Add support for querying the firmware caps
Add support for the TISCI_MSG_QUERY_FW_CAPS message, used to retrieve the firmware capabilities of the currently running system firmware. The message belongs to the TISCI general core message API [1] and is available in SysFW version 08.04.03 and above. Currently, the message is supported on devices with split architecture of the system firmware (DM + TIFS) like AM62x. Old revisions or not yet supported platforms will NACK this request. We're using this message locally in ti_sci.c to get the low power features of the FW/SoC. As there's no other kernel consumers yet, this is not added to struct ti_sci_core_ops. Sysfw version >= 10.00.04 support LPM_DM_MANAGED capability [2], where Device Mgr firmware now manages which low power mode is chosen. Going forward, this is the default configuration supported for TI AM62 family of devices. The state chosen by the DM can be influenced by sending constraints using the new LPM constraint APIs. [1] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/general/core.html [2] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/general/core.html#tisci-msg-query-fw-caps Signed-off-by: Georgi Vlaev <[email protected]> [[email protected]: Support for LPM_DM_MANAGED mode] Signed-off-by: Vibhore Vardhan <[email protected]> Signed-off-by: Kevin Hilman <[email protected]> Tested-by: Dhruva Gole <[email protected]> Signed-off-by: Markus Schneider-Pargmann <[email protected]> Tested-by: Kevin Hilman <[email protected]> Tested-by: Roger Quadros <[email protected]> Acked-by: Dhruva Gole <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Nishanth Menon <[email protected]>
1 parent 3e36070 commit 055b6cf

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

drivers/firmware/ti_sci.c

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Texas Instruments System Control Interface Protocol Driver
44
*
5-
* Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.ti.com/
5+
* Copyright (C) 2015-2024 Texas Instruments Incorporated - https://www.ti.com/
66
* Nishanth Menon
77
*/
88

@@ -24,6 +24,7 @@
2424
#include <linux/slab.h>
2525
#include <linux/soc/ti/ti-msgmgr.h>
2626
#include <linux/soc/ti/ti_sci_protocol.h>
27+
#include <linux/sys_soc.h>
2728
#include <linux/reboot.h>
2829

2930
#include "ti_sci.h"
@@ -98,6 +99,7 @@ struct ti_sci_desc {
9899
* @minfo: Message info
99100
* @node: list head
100101
* @host_id: Host ID
102+
* @fw_caps: FW/SoC low power capabilities
101103
* @users: Number of users of this instance
102104
*/
103105
struct ti_sci_info {
@@ -114,6 +116,7 @@ struct ti_sci_info {
114116
struct ti_sci_xfers_info minfo;
115117
struct list_head node;
116118
u8 host_id;
119+
u64 fw_caps;
117120
/* protected by ti_sci_list_mutex */
118121
int users;
119122
};
@@ -1651,6 +1654,67 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle,
16511654
return ret;
16521655
}
16531656

1657+
/**
1658+
* ti_sci_msg_cmd_query_fw_caps() - Get the FW/SoC capabilities
1659+
* @handle: Pointer to TI SCI handle
1660+
* @fw_caps: Each bit in fw_caps indicating one FW/SOC capability
1661+
*
1662+
* Check if the firmware supports any optional low power modes.
1663+
* Old revisions of TIFS (< 08.04) will NACK the request which results in
1664+
* -ENODEV being returned.
1665+
*
1666+
* Return: 0 if all went well, else returns appropriate error value.
1667+
*/
1668+
static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle,
1669+
u64 *fw_caps)
1670+
{
1671+
struct ti_sci_info *info;
1672+
struct ti_sci_xfer *xfer;
1673+
struct ti_sci_msg_resp_query_fw_caps *resp;
1674+
struct device *dev;
1675+
int ret = 0;
1676+
1677+
if (IS_ERR(handle))
1678+
return PTR_ERR(handle);
1679+
if (!handle)
1680+
return -EINVAL;
1681+
1682+
info = handle_to_ti_sci_info(handle);
1683+
dev = info->dev;
1684+
1685+
xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_QUERY_FW_CAPS,
1686+
TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
1687+
sizeof(struct ti_sci_msg_hdr),
1688+
sizeof(*resp));
1689+
if (IS_ERR(xfer)) {
1690+
ret = PTR_ERR(xfer);
1691+
dev_err(dev, "Message alloc failed(%d)\n", ret);
1692+
return ret;
1693+
}
1694+
1695+
ret = ti_sci_do_xfer(info, xfer);
1696+
if (ret) {
1697+
dev_err(dev, "Mbox send fail %d\n", ret);
1698+
goto fail;
1699+
}
1700+
1701+
resp = (struct ti_sci_msg_resp_query_fw_caps *)xfer->xfer_buf;
1702+
1703+
if (!ti_sci_is_response_ack(resp)) {
1704+
dev_err(dev, "Failed to get capabilities\n");
1705+
ret = -ENODEV;
1706+
goto fail;
1707+
}
1708+
1709+
if (fw_caps)
1710+
*fw_caps = resp->fw_caps;
1711+
1712+
fail:
1713+
ti_sci_put_one_xfer(&info->minfo, xfer);
1714+
1715+
return ret;
1716+
}
1717+
16541718
static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle)
16551719
{
16561720
struct ti_sci_info *info;
@@ -3390,6 +3454,13 @@ static int ti_sci_probe(struct platform_device *pdev)
33903454
goto out;
33913455
}
33923456

3457+
ti_sci_msg_cmd_query_fw_caps(&info->handle, &info->fw_caps);
3458+
dev_dbg(dev, "Detected firmware capabilities: %s%s%s\n",
3459+
info->fw_caps & MSG_FLAG_CAPS_GENERIC ? "Generic" : "",
3460+
info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO ? " Partial-IO" : "",
3461+
info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED ? " DM-Managed" : ""
3462+
);
3463+
33933464
ti_sci_setup_ops(info);
33943465

33953466
ret = devm_register_restart_handler(dev, tisci_reboot_handler, info);

drivers/firmware/ti_sci.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define TI_SCI_MSG_WAKE_REASON 0x0003
2020
#define TI_SCI_MSG_GOODBYE 0x0004
2121
#define TI_SCI_MSG_SYS_RESET 0x0005
22+
#define TI_SCI_MSG_QUERY_FW_CAPS 0x0022
2223

2324
/* Device requests */
2425
#define TI_SCI_MSG_SET_DEVICE_STATE 0x0200
@@ -132,6 +133,27 @@ struct ti_sci_msg_req_reboot {
132133
struct ti_sci_msg_hdr hdr;
133134
} __packed;
134135

136+
/**
137+
* struct ti_sci_msg_resp_query_fw_caps - Response for query firmware caps
138+
* @hdr: Generic header
139+
* @fw_caps: Each bit in fw_caps indicating one FW/SOC capability
140+
* MSG_FLAG_CAPS_GENERIC: Generic capability (LPM not supported)
141+
* MSG_FLAG_CAPS_LPM_PARTIAL_IO: Partial IO in LPM
142+
* MSG_FLAG_CAPS_LPM_DM_MANAGED: LPM can be managed by DM
143+
*
144+
* Response to a generic message with message type TI_SCI_MSG_QUERY_FW_CAPS
145+
* providing currently available SOC/firmware capabilities. SoC that don't
146+
* support low power modes return only MSG_FLAG_CAPS_GENERIC capability.
147+
*/
148+
struct ti_sci_msg_resp_query_fw_caps {
149+
struct ti_sci_msg_hdr hdr;
150+
#define MSG_FLAG_CAPS_GENERIC TI_SCI_MSG_FLAG(0)
151+
#define MSG_FLAG_CAPS_LPM_PARTIAL_IO TI_SCI_MSG_FLAG(4)
152+
#define MSG_FLAG_CAPS_LPM_DM_MANAGED TI_SCI_MSG_FLAG(5)
153+
#define MSG_MASK_CAPS_LPM GENMASK_ULL(4, 1)
154+
u64 fw_caps;
155+
} __packed;
156+
135157
/**
136158
* struct ti_sci_msg_req_set_device_state - Set the desired state of the device
137159
* @hdr: Generic header

0 commit comments

Comments
 (0)