From nobody Sun May 10 22:40:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2C01C433FE for ; Thu, 21 Apr 2022 20:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392483AbiDUUk5 (ORCPT ); Thu, 21 Apr 2022 16:40:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344664AbiDUUkt (ORCPT ); Thu, 21 Apr 2022 16:40:49 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA1F4DF76; Thu, 21 Apr 2022 13:37:55 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbk7R026792; Thu, 21 Apr 2022 15:37:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650573467; bh=7mnJvrp490Lo0N7o19GCy4p70pRbdpLKgPu8bMwwMXA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gLdWwpNS5urCNE/bvBFaLNAN1OEmg3tlLkpXBBxeqFbUM7k0X2GENuIzEqjn4fhYA T6RAwfssZo9xrgs88L/Vqscid1We58fTIeI5bp3LkIJBvK2pOD+CkXLQjZnFr27mjY 7eRhpl1Z/TdC9jg3El/CYTo3Fl8PLOmlOc1el9Hg= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23LKbkGe084672 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Apr 2022 15:37:46 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Apr 2022 15:37:46 -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.2308.14 via Frontend Transport; Thu, 21 Apr 2022 15:37:46 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbkwe026868; Thu, 21 Apr 2022 15:37:46 -0500 From: Dave Gerlach To: Rob Herring , Santosh Shilimkar , Krzysztof Kozlowski , Tero Kristo , Nishanth Menon CC: , , , Vignesh Raghavendra , Dave Gerlach Subject: [PATCH 1/6] dt-bindings: ti,sci: Add ti,ctx-memory-region property Date: Thu, 21 Apr 2022 15:36:54 -0500 Message-ID: <20220421203659.27853-2-d-gerlach@ti.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220421203659.27853-1-d-gerlach@ti.com> References: <20220421203659.27853-1-d-gerlach@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add documentation for the ti,ctx-memory-region property which is a phandle to a reserved-memory carveout to be used by the ti_sci driver storage of low power mode memory context. This is optional for normal system operation but required to enabled suspend-to-mem usage of Deep Sleep state. Signed-off-by: Dave Gerlach --- .../devicetree/bindings/arm/keystone/ti,sci.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml b/D= ocumentation/devicetree/bindings/arm/keystone/ti,sci.yaml index 34f5f877d444..ec88aa88a2a0 100644 --- a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +++ b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml @@ -61,6 +61,15 @@ properties: mboxes: minItems: 2 =20 + ti,ctx-memory-region: + description: + Phandle to the reserved memory node to be associated with the + ti-sci device, to be used for saving low power context. The + reserved memory node should be a carveout node, and should + be defined as per the bindings in + Documentation/devicetree/bindings/reserved-memory/reserved-memory.ya= ml + $ref: /schemas/types.yaml#/definitions/string + ti,system-reboot-controller: description: Determines If system reboot can be triggered by SoC reboot type: boolean --=20 2.35.0 From nobody Sun May 10 22:40:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 677F4C433EF for ; Thu, 21 Apr 2022 20:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392507AbiDUUlK (ORCPT ); Thu, 21 Apr 2022 16:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392467AbiDUUkw (ORCPT ); Thu, 21 Apr 2022 16:40:52 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF37A4DF7D; Thu, 21 Apr 2022 13:37:59 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbkMs086287; Thu, 21 Apr 2022 15:37:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650573466; bh=00iQh3PHih6BL9yI7/x5tx/QTRchJ9JW0+LhCl/5cb4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=NYrvuAMFe6KPer6ZEYJZm4K8VfQy2d1XQ/VsNJvC3bzqLZaJnvT4lXzm8bp4IS/XL CH73Um6I009N5rSMGalfZ8++EdW1HpdzmkJlnGkAxrHONxdONS+gS0fMh0tTCccRGu yE33ViBxX7n9IBevfIjJSZKKe3rikSoTbb3WYWv0= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23LKbkjx001098 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Apr 2022 15:37:46 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Apr 2022 15:37:46 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 21 Apr 2022 15:37:46 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbkOD122041; Thu, 21 Apr 2022 15:37:46 -0500 From: Dave Gerlach To: Rob Herring , Santosh Shilimkar , Krzysztof Kozlowski , Tero Kristo , Nishanth Menon CC: , , , Vignesh Raghavendra , Dave Gerlach Subject: [PATCH 2/6] dt-bindings: ti,sci: Add lpm region and ti,lpm-firmware-name Date: Thu, 21 Apr 2022 15:36:55 -0500 Message-ID: <20220421203659.27853-3-d-gerlach@ti.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220421203659.27853-1-d-gerlach@ti.com> References: <20220421203659.27853-1-d-gerlach@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add documentation for the lpm region which tells the ti-sci driver where to load the FS Stub low power mode firmware and also the ti,lpm-firmware-name which tells the driver which binary to load. Both of these are optional for normal system operation but required to enabled suspend-to-mem usage of Deep Sleep state. Signed-off-by: Dave Gerlach --- .../bindings/arm/keystone/ti,sci.yaml | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml b/D= ocumentation/devicetree/bindings/arm/keystone/ti,sci.yaml index ec88aa88a2a0..31c783507cd0 100644 --- a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +++ b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml @@ -42,12 +42,19 @@ properties: - const: ti,am654-sci =20 reg-names: - description: | - Specifies the debug messages memory mapped region that is optionally - made available from TI-SCI controller. - const: debug_messages + items: + - const: debug_messages + - const: lpm + minItems: 1 =20 reg: + items: + - description: | + Specifies the debug messages memory mapped region that is option= ally + made available from TI-SCI controller. + - description: | + Specifies the lpm memory mapped region where the FS Stub low pow= er + firmware is to be loaded. minItems: 1 =20 mbox-names: @@ -92,6 +99,12 @@ properties: type: object $ref: /schemas/reset/ti,sci-reset.yaml# =20 + ti,lpm-firmware-name: + description: | + Name of binary of FS Stub low power firmware located on the + firmware search path. + $ref: /schemas/types.yaml#/definitions/string + required: - compatible - mbox-names --=20 2.35.0 From nobody Sun May 10 22:40:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D380FC433F5 for ; Thu, 21 Apr 2022 20:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392492AbiDUUlC (ORCPT ); Thu, 21 Apr 2022 16:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392453AbiDUUkv (ORCPT ); Thu, 21 Apr 2022 16:40:51 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10D614DF79; Thu, 21 Apr 2022 13:37:57 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23LKblx6026796; Thu, 21 Apr 2022 15:37:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650573467; bh=Bs281pt4KCHr6rUTlVaV6G8reVFizb1CW2M33XZd3g0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ooBhe7opNdN6O4qfSyk+LzL3EKlrVKI1SJWVymQVCWwlQ4My7YvUpYhSqOvrVRgXP hjLMq9Y02dXSbDKhd7ZqKZtxESmyDigCwEWYMExYSVzambGgI8TBVvChaYZzGU14nM 0IaxxxkVnx99PAbJ7O4wWTs1PKMeZbDIKqljzwLA= Received: from DLEE111.ent.ti.com (dlee111.ent.ti.com [157.170.170.22]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23LKbkUu087003 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Apr 2022 15:37:47 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Apr 2022 15:37:46 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 21 Apr 2022 15:37:46 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbkSL093975; Thu, 21 Apr 2022 15:37:46 -0500 From: Dave Gerlach To: Rob Herring , Santosh Shilimkar , Krzysztof Kozlowski , Tero Kristo , Nishanth Menon CC: , , , Vignesh Raghavendra , Dave Gerlach Subject: [PATCH 3/6] firmware: ti_sci: Introduce Power Management Ops Date: Thu, 21 Apr 2022 15:36:56 -0500 Message-ID: <20220421203659.27853-4-d-gerlach@ti.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220421203659.27853-1-d-gerlach@ti.com> References: <20220421203659.27853-1-d-gerlach@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce power management ops to the ti_sci driver and add a single prepare_sleep op that is used by the kernel suspend layer to provide details to firmware about the state being entered. Signed-off-by: Dave Gerlach --- drivers/firmware/ti_sci.c | 62 ++++++++++++++++++++++++++ drivers/firmware/ti_sci.h | 32 ++++++++++++- include/linux/soc/ti/ti_sci_protocol.h | 6 +++ 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index ebc32bbd9b83..4b0f747251c8 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -1667,6 +1667,65 @@ static int ti_sci_cmd_clk_get_freq(const struct ti_s= ci_handle *handle, return ret; } =20 +/** + * ti_sci_cmd_prepare_sleep() - Prepare system for system suspend + * @handle: pointer to TI SCI handle + * @mode: Device identifier + * @ctx_lo: Low part of address for context save + * @ctx_hi: High part of address for context save + * @debug_flags: Debug flags to pass to firmware + * + * Return: 0 if all went well, else returns appropriate error value. + */ +static int ti_sci_cmd_prepare_sleep(const struct ti_sci_handle *handle, u8= mode, + u32 ctx_lo, u32 ctx_hi, u32 debug_flags) +{ + struct ti_sci_info *info; + struct ti_sci_msg_req_prepare_sleep *req; + struct ti_sci_msg_hdr *resp; + struct ti_sci_xfer *xfer; + 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_PREPARE_SLEEP, + TI_SCI_FLAG_REQ_ACK_ON_PROCESSED, + sizeof(*req), sizeof(*resp)); + if (IS_ERR(xfer)) { + ret =3D PTR_ERR(xfer); + dev_err(dev, "Message alloc failed(%d)\n", ret); + return ret; + } + + req =3D (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf; + req->mode =3D mode; + req->ctx_lo =3D ctx_lo; + req->ctx_hi =3D ctx_hi; + req->debug_flags =3D debug_flags; + + 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_hdr *)xfer->xfer_buf; + + ret =3D ti_sci_is_response_ack(resp) ? 0 : -ENODEV; + +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; @@ -2808,6 +2867,7 @@ static void ti_sci_setup_ops(struct ti_sci_info *info) struct ti_sci_core_ops *core_ops =3D &ops->core_ops; struct ti_sci_dev_ops *dops =3D &ops->dev_ops; struct ti_sci_clk_ops *cops =3D &ops->clk_ops; + struct ti_sci_pm_ops *pmops =3D &ops->pm_ops; struct ti_sci_rm_core_ops *rm_core_ops =3D &ops->rm_core_ops; struct ti_sci_rm_irq_ops *iops =3D &ops->rm_irq_ops; struct ti_sci_rm_ringacc_ops *rops =3D &ops->rm_ring_ops; @@ -2847,6 +2907,8 @@ static void ti_sci_setup_ops(struct ti_sci_info *info) cops->set_freq =3D ti_sci_cmd_clk_set_freq; cops->get_freq =3D ti_sci_cmd_clk_get_freq; =20 + pmops->prepare_sleep =3D ti_sci_cmd_prepare_sleep; + rm_core_ops->get_range =3D ti_sci_cmd_get_resource_range; rm_core_ops->get_range_from_shost =3D ti_sci_cmd_get_resource_range_from_shost; diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h index ef3a8214d002..439e15ec54db 100644 --- a/drivers/firmware/ti_sci.h +++ b/drivers/firmware/ti_sci.h @@ -6,7 +6,7 @@ * The system works in a message response protocol * See: http://processors.wiki.ti.com/index.php/TISCI for details * - * Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.t= i.com/ + * Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.t= i.com/ */ =20 #ifndef __TI_SCI_H @@ -35,6 +35,9 @@ #define TI_SCI_MSG_QUERY_CLOCK_FREQ 0x010d #define TI_SCI_MSG_GET_CLOCK_FREQ 0x010e =20 +/* Low Power Mode Requests */ +#define TI_SCI_MSG_PREPARE_SLEEP 0x0300 + /* Resource Management Requests */ #define TI_SCI_MSG_GET_RESOURCE_RANGE 0x1500 =20 @@ -545,6 +548,33 @@ struct ti_sci_msg_resp_get_clock_freq { u64 freq_hz; } __packed; =20 +#define TISCI_MSG_VALUE_SLEEP_MODE_DEEP_SLEEP 0x0 +#define TISCI_MSG_VALUE_SLEEP_MODE_MCU_ONLY 0x1 +#define TISCI_MSG_VALUE_SLEEP_MODE_STANDBY 0x2 + +/** + * struct tisci_msg_prepare_sleep_req - Request for TISCI_MSG_PREPARE_SLEE= P. + * + * @hdr TISCI header to provide ACK/NAK flags to the host. + * @mode Low power mode to enter. + * @ctx_lo Low 32-bits of physical pointer to address to use for context= save. + * @ctx_hi High 32-bits of physical pointer to address to use for contex= t save. + * @debug_flags Flags that can be set to halt the sequence during suspen= d or + * resume to allow JTAG connection and debug. + * + * This message is used as the first step of entering a low power mode. It + * allows configurable information, including which state to enter to be + * easily shared from the application, as this is a non-secure message and + * therefore can be sent by anyone. + */ +struct ti_sci_msg_req_prepare_sleep { + struct ti_sci_msg_hdr hdr; + u8 mode; + u32 ctx_lo; + u32 ctx_hi; + u32 debug_flags; +} __packed; + #define TI_SCI_IRQ_SECONDARY_HOST_INVALID 0xff =20 /** diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/= ti_sci_protocol.h index bd0d11af76c5..8adcb45d4b5c 100644 --- a/include/linux/soc/ti/ti_sci_protocol.h +++ b/include/linux/soc/ti/ti_sci_protocol.h @@ -195,6 +195,11 @@ struct ti_sci_clk_ops { u64 *current_freq); }; =20 +struct ti_sci_pm_ops { + int (*prepare_sleep)(const struct ti_sci_handle *handle, u8 mode, + u32 ctx_lo, u32 ctx_hi, u32 flags); +}; + /** * struct ti_sci_resource_desc - Description of TI SCI resource instance r= ange. * @start: Start index of the first resource range. @@ -539,6 +544,7 @@ struct ti_sci_ops { struct ti_sci_core_ops core_ops; struct ti_sci_dev_ops dev_ops; struct ti_sci_clk_ops clk_ops; + struct ti_sci_pm_ops pm_ops; struct ti_sci_rm_core_ops rm_core_ops; struct ti_sci_rm_irq_ops rm_irq_ops; struct ti_sci_rm_ringacc_ops rm_ring_ops; --=20 2.35.0 From nobody Sun May 10 22:40:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 484CAC433EF for ; Thu, 21 Apr 2022 20:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392469AbiDUUkw (ORCPT ); Thu, 21 Apr 2022 16:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347666AbiDUUkt (ORCPT ); Thu, 21 Apr 2022 16:40:49 -0400 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EA6B4DF77; Thu, 21 Apr 2022 13:37:55 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbluq026800; Thu, 21 Apr 2022 15:37:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650573467; bh=Buk4/Q/Knf7GPVo3lVclQIHMgwwIxKgFs+8J/u0XktY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kvg8JTnVdaKyaD+Un6CrCT6k/LrvaseU+4s8Ynr2H4OY7YdUaYsU/CUNYujbbGqda Ho7CvZST0L/bxbB51FHdDfiHzHVa6AjD3ZN1V3nID2l9qzoCUZRRYsqIgAu6Bxq1NS K+a6rr7N5sKAyDfcuUEFaQ//shevxb7NaZTGa5Sg= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23LKblN1084675 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Apr 2022 15:37:47 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Apr 2022 15:37:46 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 21 Apr 2022 15:37:46 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbkcQ012880; Thu, 21 Apr 2022 15:37:46 -0500 From: Dave Gerlach To: Rob Herring , Santosh Shilimkar , Krzysztof Kozlowski , Tero Kristo , Nishanth Menon CC: , , , Vignesh Raghavendra , Dave Gerlach Subject: [PATCH 4/6] firmware: ti_sci: Introduce ti,ctx-memory-region for reserved LPM memory Date: Thu, 21 Apr 2022 15:36:57 -0500 Message-ID: <20220421203659.27853-5-d-gerlach@ti.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220421203659.27853-1-d-gerlach@ti.com> References: <20220421203659.27853-1-d-gerlach@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" A reserved memory region in DDR must be used during low power modes for saving of some system context when using the ti_sci firmware, so introduce a property to allow providing this in the device tree so that it can be read and shared with the firmware. Also send a TISCI_MSG_PREPARE_SUSPEND message to the firmware during probe to determine if system suspend is supported and if ti_sci_init_suspend should be called based on the response received. Signed-off-by: Dave Gerlach --- drivers/firmware/ti_sci.c | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 4b0f747251c8..1c2000b40e8f 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -96,6 +97,8 @@ struct ti_sci_desc { * @minfo: Message info * @node: list head * @host_id: Host ID + * @mem_ctx_lo: Low word of address used for low power context memory + * @mem_ctx_hi: High word of address used for low power context memory * @users: Number of users of this instance * @is_suspending: Flag set to indicate in suspend path. */ @@ -114,6 +117,8 @@ struct ti_sci_info { struct ti_sci_xfers_info minfo; struct list_head node; u8 host_id; + u32 mem_ctx_lo; + u32 mem_ctx_hi; /* protected by ti_sci_list_mutex */ int users; bool is_suspending; @@ -3374,6 +3379,29 @@ static int ti_sci_resume(struct device *dev) =20 static DEFINE_SIMPLE_DEV_PM_OPS(ti_sci_pm_ops, ti_sci_suspend, ti_sci_resu= me); =20 +static int ti_sci_init_suspend(struct platform_device *pdev, struct ti_sci= _info *info) +{ + struct device *dev =3D &pdev->dev; + struct device_node *rmem_np; + struct reserved_mem *rmem; + + rmem_np =3D of_parse_phandle(dev->of_node, "ti,ctx-memory-region", 0); + if (!rmem_np) { + dev_warn(dev, "ti,ctx-memory-region is required for suspend but not prov= ided.\n"); + return -EINVAL; + } + + rmem =3D of_reserved_mem_lookup(rmem_np); + of_node_put(rmem_np); + if (!rmem) + return -EINVAL; + + info->mem_ctx_lo =3D (rmem->base & 0xFFFFFFFF); + info->mem_ctx_hi =3D (rmem->base >> 32); + + return 0; +} + /* Description for K2G */ static const struct ti_sci_desc ti_sci_pmmc_k2g_desc =3D { .default_host_id =3D 2, @@ -3526,6 +3554,23 @@ static int ti_sci_probe(struct platform_device *pdev) } } =20 + /* + * Attempt to call prepare_sleep, this will be NAK'd if suspend is not + * supported by firmware in use, in which case we will not attempt to + * init suspend. + */ + ret =3D ti_sci_cmd_prepare_sleep(&info->handle, 0, info->mem_ctx_lo, + info->mem_ctx_hi, 0); + if (!ret) { + ret =3D ti_sci_init_suspend(pdev, info); + if (ret) + dev_warn(dev, + "ti_sci_init_suspend failed, mem suspend will be non-functional.\n"); + } + + /* Suspend is an optional feature, reset return value and continue. */ + ret =3D 0; + dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n", info->handle.version.abi_major, info->handle.version.abi_minor, info->handle.version.firmware_revision, --=20 2.35.0 From nobody Sun May 10 22:40:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 923D4C433EF for ; Thu, 21 Apr 2022 20:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392517AbiDUUlL (ORCPT ); Thu, 21 Apr 2022 16:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392470AbiDUUkw (ORCPT ); Thu, 21 Apr 2022 16:40:52 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03284DF77; Thu, 21 Apr 2022 13:37:59 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23LKblZC090011; Thu, 21 Apr 2022 15:37:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650573467; bh=ktVjKFfmp76XHoh+/NFYL5nAOCW3wIUrCAuJVOklyFU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kDy6QbLvbw16yc3ulRnLHoLhpKNsDz+BA6ck8+iW4l2CH0vjoxvQ0SXvk6CziC58Y PDCTrOwwHKBhw7ZtF+/1NfHTIiVIEY3GakG09n0EX/eAaO9Et3RWKMFUQtIUuMevqr iDEWDtmE5iABSYJw0mf41YAq6gl22tZ8tKYJ5vm4= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23LKblAQ084678 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Apr 2022 15:37:47 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Apr 2022 15:37:46 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 21 Apr 2022 15:37:46 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbkq2122044; Thu, 21 Apr 2022 15:37:46 -0500 From: Dave Gerlach To: Rob Herring , Santosh Shilimkar , Krzysztof Kozlowski , Tero Kristo , Nishanth Menon CC: , , , Vignesh Raghavendra , Dave Gerlach Subject: [PATCH 5/6] firmware: ti_sci: Use dt provided fw name and address to load at suspend time Date: Thu, 21 Apr 2022 15:36:58 -0500 Message-ID: <20220421203659.27853-6-d-gerlach@ti.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220421203659.27853-1-d-gerlach@ti.com> References: <20220421203659.27853-1-d-gerlach@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use request_firmware_direct to load the fs stub LPM firmware to a provided lpm memory region. The filename for the firmware is provided in the device tree as "ti,lpm-firmware-name" Also, add support for "lazy loading" of this firmware during the suspend callback for the driver so that it is loaded at first suspend. It is possible in the future for this firmware to require reload, so add a check to indicate that the firmware is currently loaded so it is only loaded once at this time. Signed-off-by: Dave Gerlach --- drivers/firmware/ti_sci.c | 69 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 1c2000b40e8f..772643cb940c 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,8 @@ struct ti_sci_desc { * @debug_region: Memory region where the debug message are available * @debug_region_size: Debug region size * @debug_buffer: Buffer allocated to copy debug messages. + * @lpm_region: Memory region where the FS Stub LPM Firmware will be stored + * @lpm_region_size: LPM region size * @handle: Instance of TI SCI handle to send to clients. * @cl: Mailbox Client * @chan_tx: Transmit mailbox channel @@ -101,6 +104,8 @@ struct ti_sci_desc { * @mem_ctx_hi: High word of address used for low power context memory * @users: Number of users of this instance * @is_suspending: Flag set to indicate in suspend path. + * @lpm_firmware_loaded: Flag to indicate if LPM firmware has been loaded + * @lpm_firmware_name: Name of firmware binary to load from fw search path */ struct ti_sci_info { struct device *dev; @@ -110,6 +115,8 @@ struct ti_sci_info { void __iomem *debug_region; char *debug_buffer; size_t debug_region_size; + void __iomem *lpm_region; + size_t lpm_region_size; struct ti_sci_handle handle; struct mbox_client cl; struct mbox_chan *chan_tx; @@ -122,6 +129,8 @@ struct ti_sci_info { /* protected by ti_sci_list_mutex */ int users; bool is_suspending; + bool lpm_firmware_loaded; + const char *lpm_firmware_name; }; =20 #define cl_to_ti_sci_info(c) container_of(c, struct ti_sci_info, cl) @@ -3350,6 +3359,30 @@ static int tisci_reboot_handler(struct notifier_bloc= k *nb, unsigned long mode, return NOTIFY_BAD; } =20 +static int ti_sci_load_lpm_firmware(struct device *dev, struct ti_sci_info= *info) +{ + const struct firmware *firmware; + int ret =3D 0; + + /* If no firmware name is set, do not attempt to load. */ + if (!info->lpm_firmware_name) + return 0; + + if (request_firmware_direct(&firmware, info->lpm_firmware_name, dev)) { + dev_warn(dev, "Cannot load %s\n", info->lpm_firmware_name); + return -ENODEV; + } + + if (firmware->size > info->lpm_region_size) + return -ENOMEM; + + memcpy_toio(info->lpm_region, firmware->data, firmware->size); + + release_firmware(firmware); + + return ret; +} + static void ti_sci_set_is_suspending(struct ti_sci_info *info, bool is_sus= pending) { info->is_suspending =3D is_suspending; @@ -3358,6 +3391,8 @@ static void ti_sci_set_is_suspending(struct ti_sci_in= fo *info, bool is_suspendin static int ti_sci_suspend(struct device *dev) { struct ti_sci_info *info =3D dev_get_drvdata(dev); + int ret =3D 0; + /* * We must switch operation to polled mode now as drivers and the genpd * layer may make late TI SCI calls to change clock and device states @@ -3365,7 +3400,19 @@ static int ti_sci_suspend(struct device *dev) */ ti_sci_set_is_suspending(info, true); =20 - return 0; + if (!info->lpm_firmware_loaded) { + ret =3D ti_sci_load_lpm_firmware(dev, info); + if (ret) { + dev_err(dev, + "Failed to load low power mode firmware, suspend is non functional (%d= )\n", + ret); + ret =3D -ENODEV; + } else { + info->lpm_firmware_loaded =3D true; + } + } + + return ret; } =20 static int ti_sci_resume(struct device *dev) @@ -3384,6 +3431,7 @@ static int ti_sci_init_suspend(struct platform_device= *pdev, struct ti_sci_info struct device *dev =3D &pdev->dev; struct device_node *rmem_np; struct reserved_mem *rmem; + struct resource *res; =20 rmem_np =3D of_parse_phandle(dev->of_node, "ti,ctx-memory-region", 0); if (!rmem_np) { @@ -3399,6 +3447,25 @@ static int ti_sci_init_suspend(struct platform_devic= e *pdev, struct ti_sci_info info->mem_ctx_lo =3D (rmem->base & 0xFFFFFFFF); info->mem_ctx_hi =3D (rmem->base >> 32); =20 + res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpm"); + if (!res) { + dev_warn(dev, + "lpm region is required for suspend but not provided.\n"); + return -EINVAL; + } + + info->lpm_region =3D devm_ioremap_resource(dev, res); + if (IS_ERR(info->lpm_region)) + return PTR_ERR(info->lpm_region); + info->lpm_region_size =3D resource_size(res); + + if (of_property_read_string(dev->of_node, "ti,lpm-firmware-name", + &info->lpm_firmware_name)) { + dev_warn(dev, + "ti,lpm-firmware-name is required for suspend but not provided.\n"); + return -EINVAL; + } + return 0; } =20 --=20 2.35.0 From nobody Sun May 10 22:40:51 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5087C433F5 for ; Thu, 21 Apr 2022 20:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392505AbiDUUlP (ORCPT ); Thu, 21 Apr 2022 16:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392468AbiDUUkw (ORCPT ); Thu, 21 Apr 2022 16:40:52 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C2424DF76; Thu, 21 Apr 2022 13:37:59 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbl8p090016; Thu, 21 Apr 2022 15:37:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1650573467; bh=0d5eQnd+UR9U9jPUjFIONA+8xaxiU9xXTiPVUnEhXc4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Vc5jk9sV9XyEevpIGBybWpxJH2n/iCl6PeAJw/y73wgs4/bIuOCyWGw0A8Tyb2m5w 1Dz9Ro2EbsU+abZ0ZUaDw2+UdvQ4987Pk4+MezAXNp+CtZoeR9PwI2JXqODv8sI2iS qbBu73f9jgb7jr3aJgGmUsu33dVAyS6WQ7mXZbXM= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 23LKbll4001174 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Apr 2022 15:37:47 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Apr 2022 15:37:46 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 21 Apr 2022 15:37:47 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 23LKbkZm093984; Thu, 21 Apr 2022 15:37:46 -0500 From: Dave Gerlach To: Rob Herring , Santosh Shilimkar , Krzysztof Kozlowski , Tero Kristo , Nishanth Menon CC: , , , Vignesh Raghavendra , Dave Gerlach Subject: [PATCH 6/6] firmware: ti_sci: Introduce prepare system suspend call Date: Thu, 21 Apr 2022 15:36:59 -0500 Message-ID: <20220421203659.27853-7-d-gerlach@ti.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220421203659.27853-1-d-gerlach@ti.com> References: <20220421203659.27853-1-d-gerlach@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce a ti_sci_prepare_system_suspend call to be used in the driver suspend handler to allow the system to identify the low power mode being entered and if nevessary, send TI_SCI_MSG_BEGIN_SLEEP with information about the mode is being entered and the address for DDR memory carveout. Signed-off-by: Dave Gerlach --- drivers/firmware/ti_sci.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 772643cb940c..07b6fa98bb45 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -23,6 +23,7 @@ #include #include #include +#include #include =20 #include "ti_sci.h" @@ -3388,11 +3389,41 @@ static void ti_sci_set_is_suspending(struct ti_sci_= info *info, bool is_suspendin info->is_suspending =3D is_suspending; } =20 +static int ti_sci_prepare_system_suspend(struct ti_sci_info *info) +{ + int ret =3D 0; + int mode; + + switch (pm_suspend_target_state) { + case PM_SUSPEND_MEM: + mode =3D TISCI_MSG_VALUE_SLEEP_MODE_DEEP_SLEEP; + break; + default: + ret =3D -EINVAL; + } + + /* + * Do not fail if we don't have action to take for a + * specific suspend mode. + */ + if (ret) + return 0; + + ret =3D ti_sci_cmd_prepare_sleep(&info->handle, mode, info->mem_ctx_lo, + info->mem_ctx_hi, 0); + + return ret; +} + static int ti_sci_suspend(struct device *dev) { struct ti_sci_info *info =3D dev_get_drvdata(dev); int ret =3D 0; =20 + ret =3D ti_sci_prepare_system_suspend(info); + if (ret) + return ret; + /* * We must switch operation to polled mode now as drivers and the genpd * layer may make late TI SCI calls to change clock and device states --=20 2.35.0