Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <g-vlaev@ti.com>
[vibhore@ti.com: Support for LPM_DM_MANAGED mode]
Signed-off-by: Vibhore Vardhan <vibhore@ti.com>
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Tested-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Tested-by: Kevin Hilman <khilman@baylibre.com>
Tested-by: Roger Quadros <rogerq@kernel.org>
Acked-by: Dhruva Gole <d-gole@ti.com>
Link: https://lore.kernel.org/r/20241007-tisci-syssuspendresume-v13-2-ed54cd659a49@baylibre.com
Signed-off-by: Nishanth Menon <nm@ti.com>

authored by

Georgi Vlaev and committed by
Nishanth Menon
055b6cfb 3e360703

+94 -1
+72 -1
drivers/firmware/ti_sci.c
··· 2 2 /* 3 3 * Texas Instruments System Control Interface Protocol Driver 4 4 * 5 - * Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.ti.com/ 5 + * Copyright (C) 2015-2024 Texas Instruments Incorporated - https://www.ti.com/ 6 6 * Nishanth Menon 7 7 */ 8 8 ··· 24 24 #include <linux/slab.h> 25 25 #include <linux/soc/ti/ti-msgmgr.h> 26 26 #include <linux/soc/ti/ti_sci_protocol.h> 27 + #include <linux/sys_soc.h> 27 28 #include <linux/reboot.h> 28 29 29 30 #include "ti_sci.h" ··· 99 98 * @minfo: Message info 100 99 * @node: list head 101 100 * @host_id: Host ID 101 + * @fw_caps: FW/SoC low power capabilities 102 102 * @users: Number of users of this instance 103 103 */ 104 104 struct ti_sci_info { ··· 116 114 struct ti_sci_xfers_info minfo; 117 115 struct list_head node; 118 116 u8 host_id; 117 + u64 fw_caps; 119 118 /* protected by ti_sci_list_mutex */ 120 119 int users; 121 120 }; ··· 1647 1644 ret = -ENODEV; 1648 1645 else 1649 1646 *freq = resp->freq_hz; 1647 + 1648 + fail: 1649 + ti_sci_put_one_xfer(&info->minfo, xfer); 1650 + 1651 + return ret; 1652 + } 1653 + 1654 + /** 1655 + * ti_sci_msg_cmd_query_fw_caps() - Get the FW/SoC capabilities 1656 + * @handle: Pointer to TI SCI handle 1657 + * @fw_caps: Each bit in fw_caps indicating one FW/SOC capability 1658 + * 1659 + * Check if the firmware supports any optional low power modes. 1660 + * Old revisions of TIFS (< 08.04) will NACK the request which results in 1661 + * -ENODEV being returned. 1662 + * 1663 + * Return: 0 if all went well, else returns appropriate error value. 1664 + */ 1665 + static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle, 1666 + u64 *fw_caps) 1667 + { 1668 + struct ti_sci_info *info; 1669 + struct ti_sci_xfer *xfer; 1670 + struct ti_sci_msg_resp_query_fw_caps *resp; 1671 + struct device *dev; 1672 + int ret = 0; 1673 + 1674 + if (IS_ERR(handle)) 1675 + return PTR_ERR(handle); 1676 + if (!handle) 1677 + return -EINVAL; 1678 + 1679 + info = handle_to_ti_sci_info(handle); 1680 + dev = info->dev; 1681 + 1682 + xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_QUERY_FW_CAPS, 1683 + TI_SCI_FLAG_REQ_ACK_ON_PROCESSED, 1684 + sizeof(struct ti_sci_msg_hdr), 1685 + sizeof(*resp)); 1686 + if (IS_ERR(xfer)) { 1687 + ret = PTR_ERR(xfer); 1688 + dev_err(dev, "Message alloc failed(%d)\n", ret); 1689 + return ret; 1690 + } 1691 + 1692 + ret = ti_sci_do_xfer(info, xfer); 1693 + if (ret) { 1694 + dev_err(dev, "Mbox send fail %d\n", ret); 1695 + goto fail; 1696 + } 1697 + 1698 + resp = (struct ti_sci_msg_resp_query_fw_caps *)xfer->xfer_buf; 1699 + 1700 + if (!ti_sci_is_response_ack(resp)) { 1701 + dev_err(dev, "Failed to get capabilities\n"); 1702 + ret = -ENODEV; 1703 + goto fail; 1704 + } 1705 + 1706 + if (fw_caps) 1707 + *fw_caps = resp->fw_caps; 1650 1708 1651 1709 fail: 1652 1710 ti_sci_put_one_xfer(&info->minfo, xfer); ··· 3453 3389 dev_err(dev, "Unable to communicate with TISCI(%d)\n", ret); 3454 3390 goto out; 3455 3391 } 3392 + 3393 + ti_sci_msg_cmd_query_fw_caps(&info->handle, &info->fw_caps); 3394 + dev_dbg(dev, "Detected firmware capabilities: %s%s%s\n", 3395 + info->fw_caps & MSG_FLAG_CAPS_GENERIC ? "Generic" : "", 3396 + info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO ? " Partial-IO" : "", 3397 + info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED ? " DM-Managed" : "" 3398 + ); 3456 3399 3457 3400 ti_sci_setup_ops(info); 3458 3401
+22
drivers/firmware/ti_sci.h
··· 19 19 #define TI_SCI_MSG_WAKE_REASON 0x0003 20 20 #define TI_SCI_MSG_GOODBYE 0x0004 21 21 #define TI_SCI_MSG_SYS_RESET 0x0005 22 + #define TI_SCI_MSG_QUERY_FW_CAPS 0x0022 22 23 23 24 /* Device requests */ 24 25 #define TI_SCI_MSG_SET_DEVICE_STATE 0x0200 ··· 131 130 */ 132 131 struct ti_sci_msg_req_reboot { 133 132 struct ti_sci_msg_hdr hdr; 133 + } __packed; 134 + 135 + /** 136 + * struct ti_sci_msg_resp_query_fw_caps - Response for query firmware caps 137 + * @hdr: Generic header 138 + * @fw_caps: Each bit in fw_caps indicating one FW/SOC capability 139 + * MSG_FLAG_CAPS_GENERIC: Generic capability (LPM not supported) 140 + * MSG_FLAG_CAPS_LPM_PARTIAL_IO: Partial IO in LPM 141 + * MSG_FLAG_CAPS_LPM_DM_MANAGED: LPM can be managed by DM 142 + * 143 + * Response to a generic message with message type TI_SCI_MSG_QUERY_FW_CAPS 144 + * providing currently available SOC/firmware capabilities. SoC that don't 145 + * support low power modes return only MSG_FLAG_CAPS_GENERIC capability. 146 + */ 147 + struct ti_sci_msg_resp_query_fw_caps { 148 + struct ti_sci_msg_hdr hdr; 149 + #define MSG_FLAG_CAPS_GENERIC TI_SCI_MSG_FLAG(0) 150 + #define MSG_FLAG_CAPS_LPM_PARTIAL_IO TI_SCI_MSG_FLAG(4) 151 + #define MSG_FLAG_CAPS_LPM_DM_MANAGED TI_SCI_MSG_FLAG(5) 152 + #define MSG_MASK_CAPS_LPM GENMASK_ULL(4, 1) 153 + u64 fw_caps; 134 154 } __packed; 135 155 136 156 /**