Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14968012rwb; Mon, 28 Nov 2022 06:45:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6HNcldZkK3fAyuSgzdZp9Rk0X1ATQamgXsOL7W1ZOt7N0JBmZNtETjKfDivYmPVC0qDfM6 X-Received: by 2002:a17:903:244c:b0:189:3279:5e82 with SMTP id l12-20020a170903244c00b0018932795e82mr31919679pls.10.1669646733071; Mon, 28 Nov 2022 06:45:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669646733; cv=none; d=google.com; s=arc-20160816; b=rKm/s19mmD4Ize/Awe+AS8z30kzAMDvUDwzB4HvXwQKi9o25KUz5qk1I9ifjambcWB gsCm+MCb9meHiyuDqdUeOj6C/Exd4/5jVURx3pcvhF5AnuHiJ/pM7YQujKf1IujkzdFt 4e90iAqcHTeBQMWeJMna392FfChDd38fyuKEHQEOLTnlc46Yjt5vhf7DshJ0iJreJ5BZ UBUSud72qGKRwkahKJdnKqIF3NxjFN3JO8f8CGCqxe4EjtZV2AJGib5eBEJyrCUVJeQ9 fGWAe+271KTY2qLC3H0LMKBs9ikb/L6Oe1w1paQZ1Pwv8maepVES+KDQjK7jgnuzC+K4 aMfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yJGD9dUZPktIgmbSEnoYDWr8lwSvo0rr9GJtL7kjW6M=; b=TF3e8i3Df7At5UuBY911Bd2P0gY//s5FxdvLCNlaSC2A/KABfVIA7OkZq4X5DioiVw N/NffdthCc/+wUy470AS8TnZL+HAMjNzXd083/QVHQN+0IUkIX46D2kKDxjt2p0HT3px aRHEDNaTQRi8MwO6+ofhrhhdZVVavqkyDPxvUo84xJEaFiVHudUc4c6XMifZ4C5huuOX HGR738xcmRFbdbDk8V01NIsHaYt2jVY8BtbgMscE61ttpRPSxslcnrfM6KoVAmET52AE tCNANZZ/kEJZC+IpIUU6fptShpw76697Pg09VnvGQk6IToZdbOzZKlr1DhcNBddlBKTY CT/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HY95ibaT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a056a001a4d00b005726ac2f6b3si12901882pfv.159.2022.11.28.06.45.20; Mon, 28 Nov 2022 06:45:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HY95ibaT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231382AbiK1OGD (ORCPT + 84 others); Mon, 28 Nov 2022 09:06:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbiK1OF7 (ORCPT ); Mon, 28 Nov 2022 09:05:59 -0500 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78D8C20BD8; Mon, 28 Nov 2022 06:05:58 -0800 (PST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2ASE5pFQ080281; Mon, 28 Nov 2022 08:05:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1669644351; bh=yJGD9dUZPktIgmbSEnoYDWr8lwSvo0rr9GJtL7kjW6M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HY95ibaTlByV+u9X0bN0VJ3qnX9PtyxzeKoWOJOf+o95cCv3sYeSWiojXbKlnIBlr 3DZL5bECUXFxpMvh9XcNRkfka7HXi1b29GNWdfbAl9nwx35aO5hGbgiDclxvtTsKgO ljYg3uRvsftQEfDWNUJT4Xfw/hVqQyRCoSOeoTW0= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2ASE5pF3036300 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Nov 2022 08:05:51 -0600 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Mon, 28 Nov 2022 08:05:51 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Mon, 28 Nov 2022 08:05:51 -0600 Received: from jti.ent.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2ASE5NQc125815; Mon, 28 Nov 2022 08:05:45 -0600 From: Georgi Vlaev To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski CC: , , , Vibhore Vardhan , Vignesh Raghavendra , Roger Quadros , Georgi Vlaev Subject: [PATCH v5 3/6] firmware: ti_sci: Add support for querying the firmware caps Date: Mon, 28 Nov 2022 16:05:19 +0200 Message-ID: <20221128140522.49474-4-g-vlaev@ti.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221128140522.49474-1-g-vlaev@ti.com> References: <20221128140522.49474-1-g-vlaev@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 bace9e9cd478..caa7b9d2bd48 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -1726,6 +1726,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 -- 2.30.2