From patchwork Thu Aug 29 20:16:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13783797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D987AC87FD2 for ; Thu, 29 Aug 2024 20:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XGlk+6RhKnBgzhvhm0ocxM8uELwMTtl2eqHYRSP1FzQ=; b=MaZK8O+nwyqPlap2pMiH3L/H4t zNXDSdYCrp/qbnv4uX0aRWVZ65WNCZBtJkip+PBgQzGmK6NiHWyPy/MGq73KMRb2Dgg11+ELSl5Hy qBWbuR0eK1rPOP1OUVUwk3cQ8vgmIcUxKk+uWv/H5QdD//2v5zdgx7J5/yQepGUsh3ktKPjghqrDt WQCiv0v6ZB/Zy9i9f6BPA6y8Q8kVsQSETfougQ/t7Zf+d3sIorTlh6U2+Vuk+fvI7VvNQl+Ou/Heu hVSfHvRSPGGsy29avTBU7QrIi9WYbuLfKf0z8/Gv4AhYl1uoGBsrjoeK8jGrqg6sTjmMMCHyF0xUQ v5f8WSEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjlZw-00000003Vle-2mJx; Thu, 29 Aug 2024 20:17:12 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjlZ3-00000003VWK-2Mhz for linux-arm-kernel@lists.infradead.org; Thu, 29 Aug 2024 20:16:19 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42bb9d719d4so2865195e9.3 for ; Thu, 29 Aug 2024 13:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1724962576; x=1725567376; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XGlk+6RhKnBgzhvhm0ocxM8uELwMTtl2eqHYRSP1FzQ=; b=Ae+hBqs4eBtJcqTL4DuttkuOYHmgbEEUqsoXiUM9zJSEda6022Hp5SXxwe7wOPbnMX NfQNrK4VcX3AtAmY+oVZLj2iNDSGMMR6cQnE95JCBX8p3aPr4ePRqnED24ikjtPornx6 ZOWEfdpfqBWPY8SxVy24EMyN9Ci8IgIRCqnntVFD/Pu4cuPepfJO+714kpWBiN3hG+bS VsIoVwdTr8mZI+0/UkzrymfR+ns2F1xh78Soknyzvkv8x4V3d2ah8c+VgO1akM/4aa4a dfuntvGTBqg6Zb4SZifsO6MUwLlTYs2q6b56d3eb5xQDIQC72m2v7AQdEONaBSxymXH+ vbDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724962576; x=1725567376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XGlk+6RhKnBgzhvhm0ocxM8uELwMTtl2eqHYRSP1FzQ=; b=YjZ3z6exOzWQYoELwz4XZ9HpvBz13ROC8Kkf95K2cPTdlxkSsNec8ItW9X1nxCjIIE Kul70hz+R0WmkYe59DccNBXjXrms84ssYISTvuv/Mi1vhQzQQMqM/dkAktOR/AC1xM9t Ku/9b4P1dw+SKTMozdhgA/FlFLEWZ6mbJKpFP5rcffVQn2r00mf06NHbM/p2a+KgnZ6W b1R/300DcGJcFqVRBYLAi3kU3PtGSncKoMG72+x4iR524LOXoN4AHSvx+tfVqyNTLUWD WjQIh6vkDWlbsjAPXPJ0JRxZV6v429ZvrI0bos5HoFd3l1QIHclpYePt4GNMHY2MwOsc 3V+w== X-Forwarded-Encrypted: i=1; AJvYcCU97NW+lN+yzQsxxH0WHIliPaoopRyprV+zSmkepIUfFCo7OcDtO5Ayw8rwfC+107lhtx8bK0qN2uhDobDgUa3C@lists.infradead.org X-Gm-Message-State: AOJu0YwCJHjVxffNCgx9aPbLaDlj3ovj7UE3zf2U0XvhvegZY5/mDxh2 +m6CgC8BIYJoQK8Ijlay2IB/Kx0Uu/LxObIaQYuVQosdFPdfTRr9F2NyqcyP9Wk= X-Google-Smtp-Source: AGHT+IEX9BEL/aSSY4fkZb4HqB4p1WoEr4eolcIacJOSg8a9+g4vDR3ZPBbzPuaUQ5RK8ohKWgpiWQ== X-Received: by 2002:a05:600c:4fcd:b0:426:58ca:5a3 with SMTP id 5b1f17b1804b1-42bb032caf5mr26615175e9.30.1724962575865; Thu, 29 Aug 2024 13:16:15 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:802f:3a47:b29:5530:28a2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6deb303sm26681385e9.9.2024.08.29.13.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 13:16:15 -0700 (PDT) From: Markus Schneider-Pargmann To: Nishanth Menon , Tero Kristo , Santosh Shilimkar Cc: Vibhore Vardhan , Kevin Hilman , Dhruva Gole , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Georgi Vlaev , Markus Schneider-Pargmann Subject: [PATCH v11 1/4] firmware: ti_sci: Add support for querying the firmware caps Date: Thu, 29 Aug 2024 22:16:02 +0200 Message-ID: <20240829201606.1407773-2-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240829201606.1407773-1-msp@baylibre.com> References: <20240829201606.1407773-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_131617_636542_7A2B7872 X-CRM114-Status: GOOD ( 24.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Georgi Vlaev 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 [vibhore@ti.com: Support for LPM_DM_MANAGED mode] Signed-off-by: Vibhore Vardhan Signed-off-by: Kevin Hilman Tested-by: Dhruva Gole Signed-off-by: Markus Schneider-Pargmann Acked-by: Dhruva Gole --- drivers/firmware/ti_sci.c | 74 ++++++++++++++++++++++++++++++++++++++- drivers/firmware/ti_sci.h | 22 ++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 160968301b1f..bed7c8892341 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -2,10 +2,11 @@ /* * Texas Instruments System Control Interface Protocol Driver * - * Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.ti.com/ + * Copyright (C) 2015-2024 Texas Instruments Incorporated - https://www.ti.com/ * Nishanth Menon */ +#include "linux/dev_printk.h" #define pr_fmt(fmt) "%s: " fmt, __func__ #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include "ti_sci.h" @@ -98,6 +100,7 @@ struct ti_sci_desc { * @minfo: Message info * @node: list head * @host_id: Host ID + * @fw_caps: FW/SoC low power capabilities * @users: Number of users of this instance */ struct ti_sci_info { @@ -114,6 +117,7 @@ struct ti_sci_info { struct ti_sci_xfers_info minfo; struct list_head node; u8 host_id; + u64 fw_caps; /* protected by ti_sci_list_mutex */ int users; }; @@ -1651,6 +1655,67 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_sci_handle *handle, return ret; } +/** + * ti_sci_msg_cmd_query_fw_caps() - Get the FW/SoC capabilities + * @handle: Pointer to TI SCI handle + * @fw_caps: Each bit in fw_caps indicating one FW/SOC capability + * + * Check if the firmware supports any optional low power modes. + * Old revisions of TIFS (< 08.04) will NACK the request which results in + * -ENODEV being returned. + * + * Return: 0 if all went well, else returns appropriate error value. + */ +static int ti_sci_msg_cmd_query_fw_caps(const struct ti_sci_handle *handle, + u64 *fw_caps) +{ + struct ti_sci_info *info; + struct ti_sci_xfer *xfer; + struct ti_sci_msg_resp_query_fw_caps *resp; + struct device *dev; + int ret = 0; + + if (IS_ERR(handle)) + return PTR_ERR(handle); + if (!handle) + return -EINVAL; + + info = handle_to_ti_sci_info(handle); + dev = info->dev; + + xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_QUERY_FW_CAPS, + TI_SCI_FLAG_REQ_ACK_ON_PROCESSED, + sizeof(struct ti_sci_msg_hdr), + sizeof(*resp)); + if (IS_ERR(xfer)) { + ret = PTR_ERR(xfer); + dev_err(dev, "Message alloc failed(%d)\n", ret); + return ret; + } + + ret = ti_sci_do_xfer(info, xfer); + if (ret) { + dev_err(dev, "Mbox send fail %d\n", ret); + goto fail; + } + + resp = (struct ti_sci_msg_resp_query_fw_caps *)xfer->xfer_buf; + + if (!ti_sci_is_response_ack(resp)) { + dev_err(dev, "Failed to get capabilities\n"); + ret = -ENODEV; + goto fail; + } + + if (fw_caps) + *fw_caps = resp->fw_caps; + +fail: + ti_sci_put_one_xfer(&info->minfo, xfer); + + return ret; +} + static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) { struct ti_sci_info *info; @@ -3390,6 +3455,13 @@ static int ti_sci_probe(struct platform_device *pdev) goto out; } + ti_sci_msg_cmd_query_fw_caps(&info->handle, &info->fw_caps); + dev_dbg(dev, "Detected firmware capabilities: %s%s%s\n", + info->fw_caps & MSG_FLAG_CAPS_GENERIC ? "Generic" : "", + info->fw_caps & MSG_FLAG_CAPS_LPM_PARTIAL_IO ? " Partial-IO" : "", + info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED ? " DM-Managed" : "" + ); + ti_sci_setup_ops(info); ret = devm_register_restart_handler(dev, tisci_reboot_handler, info); diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h index 5846c60220f5..73ca9503606b 100644 --- a/drivers/firmware/ti_sci.h +++ b/drivers/firmware/ti_sci.h @@ -19,6 +19,7 @@ #define TI_SCI_MSG_WAKE_REASON 0x0003 #define TI_SCI_MSG_GOODBYE 0x0004 #define TI_SCI_MSG_SYS_RESET 0x0005 +#define TI_SCI_MSG_QUERY_FW_CAPS 0x0022 /* Device requests */ #define TI_SCI_MSG_SET_DEVICE_STATE 0x0200 @@ -132,6 +133,27 @@ struct ti_sci_msg_req_reboot { struct ti_sci_msg_hdr hdr; } __packed; +/** + * struct ti_sci_msg_resp_query_fw_caps - Response for query firmware caps + * @hdr: Generic header + * @fw_caps: Each bit in fw_caps indicating one FW/SOC capability + * MSG_FLAG_CAPS_GENERIC: Generic capability (LPM not supported) + * MSG_FLAG_CAPS_LPM_PARTIAL_IO: Partial IO in LPM + * MSG_FLAG_CAPS_LPM_DM_MANAGED: LPM can be managed by DM + * + * Response to a generic message with message type TI_SCI_MSG_QUERY_FW_CAPS + * providing currently available SOC/firmware capabilities. SoC that don't + * support low power modes return only MSG_FLAG_CAPS_GENERIC capability. + */ +struct ti_sci_msg_resp_query_fw_caps { + struct ti_sci_msg_hdr hdr; +#define MSG_FLAG_CAPS_GENERIC TI_SCI_MSG_FLAG(0) +#define MSG_FLAG_CAPS_LPM_PARTIAL_IO TI_SCI_MSG_FLAG(4) +#define MSG_FLAG_CAPS_LPM_DM_MANAGED TI_SCI_MSG_FLAG(5) +#define MSG_MASK_CAPS_LPM GENMASK_ULL(4, 1) + u64 fw_caps; +} __packed; + /** * struct ti_sci_msg_req_set_device_state - Set the desired state of the device * @hdr: Generic header