From mboxrd@z Thu Jan 1 00:00:00 1970 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 8D8DFEB64DD for ; Thu, 3 Aug 2023 15:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:CC:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1PG4uA4N4J9VfG3nnZXUe6rLVuhxjPI2cIolKL4vb4g=; b=NRrdmKWjxZUXn2 65LraHUlYr2XZwsfsFxEdp/vjyk/J7mtdvkMdRgVnhTnJleffH/oEgXspB12KO2I5aCt2bTliGo8J 2kdsXObre4c47DdxnDAqGWeFY7QOartFsCBHd1EOyf/9i9Oo7W0kShosJgeY52Nxexia0RRhW//oo xGDclVDmJJPljOa2BhDqUI51cCN2DBPnogmB/gPGOaAJqn7drYm2wUfCoMdExvOV22yMz5DnhvA7L XRf4k1SzgsvstMH2Gk2Wa0ubezbDCCS0YUueS2HhxFt/REc0eSA5uvpbMKTPu1RFR4YadWxtY2Bj4 05j++XEPwQffYpbKiUhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRa99-00ABn3-0T; Thu, 03 Aug 2023 15:21:51 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRa95-00ABlb-30 for linux-arm-kernel@lists.infradead.org; Thu, 03 Aug 2023 15:21:49 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 373FLeH9066661; Thu, 3 Aug 2023 10:21:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1691076100; bh=0oLLrcALLTvK2D0vhqA42SQmHxM6JCkudEP7Scb6TJ4=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=F+yXRBwp7akwcD6qF5ESDx4Svm1a2TxGCG34MP+gRb7rjJH0QfHFhd6o0Qwd1M223 2NOOgFF+Kve8gN8mGVRnHllh13ZU3yp4jlgnoS6+8nscAsf4/N8qI5RG750pjwzIeA c3UYEgvLLEt4Nt1yffV8Np+rTSIq8hnt/DS9GfYA= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 373FLefS074267 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 3 Aug 2023 10:21:40 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 3 Aug 2023 10:21:40 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 3 Aug 2023 10:21:40 -0500 Received: from [10.250.36.243] (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 373FLd7N128726; Thu, 3 Aug 2023 10:21:39 -0500 Message-ID: <6ac87c33-eb5a-7613-3046-c90b72a20217@ti.com> Date: Thu, 3 Aug 2023 10:21:39 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH V6 2/4] firmware: ti_sci: Add support for querying the firmware caps Content-Language: en-US To: Dhruva Gole , Nishanth Menon , Tero Kristo , Santosh Shilimkar CC: , , , Viresh Kumar , "Praneeth Bajjuri" , Tony Lindgren , Georgi Vlaev References: <20230803064247.503036-1-d-gole@ti.com> <20230803064247.503036-3-d-gole@ti.com> From: Andrew Davis In-Reply-To: <20230803064247.503036-3-d-gole@ti.com> X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230803_082148_054878_FF7AFA95 X-CRM114-Status: GOOD ( 30.72 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 8/3/23 1:42 AM, Dhruva Gole wrote: > From: Georgi Vlaev > > This patch adds 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. The API is also buggy on SYSFW 9.00 and below, maybe we should check the firmware version in this function and return "not supported" or all 0s, instead of returning known bad values. Andrew > > We're using this message locally in ti_sci.c to get the low > power featutes of the FW/SoC. As there's no other kernel > consumers yet, this is not added to struct ti_sci_core_ops. > > [1] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/general/core.html > > Signed-off-by: Georgi Vlaev > --- > drivers/firmware/ti_sci.c | 56 +++++++++++++++++++++++++++++++++++++++ > drivers/firmware/ti_sci.h | 26 ++++++++++++++++++ > 2 files changed, 82 insertions(+) > > diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c > index 31a71613ca54..3b40f9336b3f 100644 > --- a/drivers/firmware/ti_sci.c > +++ b/drivers/firmware/ti_sci.c > @@ -1723,6 +1723,62 @@ static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8 mode, > 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 > + * > + * 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)) { > + ret = -ENODEV; > + goto fail; > + } > + > + if (fw_caps) > + *fw_caps = resp->fw_caps; > + > +fail: > + ti_sci_put_one_xfer(&info->minfo, xfer); > + > + return ret; > +} > + > /** > * ti_sci_msg_cmd_lpm_wake_reason() - Get the wakeup source from LPM > * @handle: Pointer to TI SCI handle > diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h > index e4bfe146c43d..d5b23d91b9b9 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 > @@ -137,6 +138,31 @@ 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_DEEP_SLEEP: Deep Sleep LPM > + * MSG_FLAG_CAPS_LPM_MCU_ONLY: MCU only LPM > + * MSG_FLAG_CAPS_LPM_STANDBY: Standby LPM > + * MSG_FLAG_CAPS_LPM_PARTIAL_IO: Partial IO in LPM > + * > + * 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_DEEP_SLEEP TI_SCI_MSG_FLAG(1) > +#define MSG_FLAG_CAPS_LPM_MCU_ONLY TI_SCI_MSG_FLAG(2) > +#define MSG_FLAG_CAPS_LPM_STANDBY TI_SCI_MSG_FLAG(3) > +#define MSG_FLAG_CAPS_LPM_PARTIAL_IO TI_SCI_MSG_FLAG(4) > +#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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel