From nobody Thu Oct 31 02:16:23 2024 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9617E1465A0 for ; Mon, 7 Oct 2024 06:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728281390; cv=none; b=WMhwOaDNFLpTqzTpyQ5o6YafUQOp+DnuG+D7TuXByKeSjeVEB8W2fGYYgzabLR0RdbrsQv5BfOPdWF5hqvsCl8Dbm14qttofODWySPyJDsHUMTWtnhkz5CZdlDiSiZ0r+iZrczLV68s30AMBL5BrkIVwe9LbWph80C6MtZDp0I8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728281390; c=relaxed/simple; bh=EGwzc5Owsx+/bhXk0PXhY0C7yU90OavS7hMS3djDrBI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rcZD61MgzatcSgXmcMdU7bfQ6L957f1kb8cJ+f8PhuYKLD1HQ1PBWIte+rLnct2x2UoAnHVN8y5DNy3/TCgkVDIvGuM8Vwww7AJo2idXE0pZBUTR0UuH6jl/L5nrlZTeQCLCdpX0teNiHBM1mWC+g7xj7ct2jcpA+rW3PQPQiLQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=DST6YJZs; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="DST6YJZs" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5c40aea5c40so7880069a12.0 for ; Sun, 06 Oct 2024 23:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1728281387; x=1728886187; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DbLe30orUJnLewx69pgAOzw2IbndS0py8yVdX7I2BLo=; b=DST6YJZs7e8+7B93cxQCiBp5FXjss64Imke+MKIXbUT08fNH8anMB9LsjRgW2wJIli tSurcSfYycmx5zQm0n/NbUjKOWgawoJjiDl+h2w4InpEnh7kSjZASZnk6A3gB1tfUN9k V3hN5yvgF3UZ1HnqbXxJ9ST+lq9MLBXKJENeGHrsSHNzdLPJth+jw5kh1gDmCwfEduPs P1RGVXzmdbHEVDQwrS6btOcvYgEHs0atx9xjvNIm5rAkyXwvq8bhVaYRG4E4amgE6lgs nXST7F/YDLC4To2uzee+e2gBRnZISOP2MNtKkobP1e6JF4N9FQNf9lmq3MllunifXyxF eL+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728281387; x=1728886187; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DbLe30orUJnLewx69pgAOzw2IbndS0py8yVdX7I2BLo=; b=OBw6vMIaGB4oTCMq/hScNqK95fVrqV45BebzXUWOpZFT1Uzn7LtBjjr6D14Hry/Vfr YrqBOZAWTTGl3Dy18hlvlzUeCyh5nkSJctVOQhxQjGrFowDPcmtrqZXAqlTxuJZqAk2X ojIs//B8T/EOl7JRTF6EEfXsbmJR9NvIuESONVbpAPZ1GpoJpB9p7ZUl//iay0cWrR57 kzNCjSPgZD44PonTfwOQurs1mnG7xIWeswpqfLaHEChjKFWEjoXT3ZnHtTTIRTqH/uQr rM8W1Sw6QFwoROLyANCkNGdd/kO5l1c5UWpI9IxsT4CIZ5j3eT0XJUEt1yXr2e/cQsv3 /6VA== X-Forwarded-Encrypted: i=1; AJvYcCXTqM+nvquEnBc6sELAwpkRzPu0aZR+0KIXnQQ0DcEONpml8U6smb2cq5HyKPK0n366R3gVzowlwHK7H6Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3tCgPyNeWHLAGv12nx48LX4o40aJtWr2FDAC/exttn/95pY7s GYFK7pBDf0D2g6TRoVxNgaE3+tbFExymMXY4N+2a0Kt70pLeXjQfKs0T57CQ/bA= X-Google-Smtp-Source: AGHT+IEN+KwoLOFHpFSpg/JH01HwsgZgHyg31disEZr/iuiHpcFj3zR3tdPPH2bqouBr2wcVZllMZg== X-Received: by 2002:a05:6402:90b:b0:5c5:bda7:c839 with SMTP id 4fb4d7f45d1cf-5c8c0a83ef5mr17222386a12.17.1728281386737; Sun, 06 Oct 2024 23:09:46 -0700 (PDT) Received: from localhost ([2001:4090:a244:83ae:2517:2666:43c9:d0d3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e05f3b8bsm2784431a12.89.2024.10.06.23.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 23:09:46 -0700 (PDT) From: Markus Schneider-Pargmann Date: Mon, 07 Oct 2024 08:08:55 +0200 Subject: [PATCH v13 2/5] firmware: ti_sci: Add support for querying the firmware caps Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241007-tisci-syssuspendresume-v13-2-ed54cd659a49@baylibre.com> References: <20241007-tisci-syssuspendresume-v13-0-ed54cd659a49@baylibre.com> In-Reply-To: <20241007-tisci-syssuspendresume-v13-0-ed54cd659a49@baylibre.com> To: "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , Nishanth Menon , Tero Kristo , Santosh Shilimkar Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kamlesh Gurudasani , Kevin Hilman , Dhruva Gole , Vishal Mahaveer , Markus Schneider-Pargmann X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6798; i=msp@baylibre.com; h=from:subject:message-id; bh=vd+yKE3a6fH3kGb9+/6lAhLX5D8QyxAs3GjZFq/gpzA=; b=owGbwMvMwCGm0rPl0RXRdfaMp9WSGNKZq4WKHzRt5y6IuT0r3XZJ1+32ZRPi9s4sevl2wkWhL RJVZYc+dpSyMIhxMMiKKbLc/bDwXZ3c9QUR6x45wsxhZQIZwsDFKQATuabOyPDXu8J+09Temaon hCeY/cw89Gyj3/fFsyWuLWZL2/ffdp08wy9mma/H3Avvxp55oF5ve/PyynpTje8L+Fr3Nf3ZvFv +XggTAA== X-Developer-Key: i=msp@baylibre.com; a=openpgp; fpr=BADD88DB889FDC3E8A3D5FE612FA6A01E0A45B41 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 >=3D 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.h= tml [2] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/general/core.h= tml#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 | 73 +++++++++++++++++++++++++++++++++++++++++++= +++- drivers/firmware/ti_sci.h | 22 ++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 160968301b1fbc4142c18a10048aaa933e4b9c91..d53192607709c1a4773c6210a23= 8505e5849f775 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -2,7 +2,7 @@ /* * 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 */ =20 @@ -24,6 +24,7 @@ #include #include #include +#include #include =20 #include "ti_sci.h" @@ -98,6 +99,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 +116,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 +1654,67 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_s= ci_handle *handle, return ret; } =20 +/** + * 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 =3D 0; + + if (IS_ERR(handle)) + return PTR_ERR(handle); + if (!handle) + return -EINVAL; + + info =3D handle_to_ti_sci_info(handle); + dev =3D info->dev; + + xfer =3D 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 =3D PTR_ERR(xfer); + dev_err(dev, "Message alloc failed(%d)\n", ret); + return ret; + } + + ret =3D ti_sci_do_xfer(info, xfer); + if (ret) { + dev_err(dev, "Mbox send fail %d\n", ret); + goto fail; + } + + resp =3D (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 =3D -ENODEV; + goto fail; + } + + if (fw_caps) + *fw_caps =3D 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 +3454,13 @@ static int ti_sci_probe(struct platform_device *pdev) goto out; } =20 + 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); =20 ret =3D devm_register_restart_handler(dev, tisci_reboot_handler, info); diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h index 5846c60220f50c82a66ba268bb44e6d0e76382b1..73ca9503606b345c08b9b543f2d= 3474ad1d5f698 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 =20 /* 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; =20 +/** + * 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 d= evice * @hdr: Generic header --=20 2.45.2