From patchwork Thu Apr 21 20:36:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 12822400 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 067B4C433F5 for ; Thu, 21 Apr 2022 20:39:02 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z4V/AN75nOeSZlxCLGyptpVadQo1anlxMqYQJck3FJU=; b=m2XNtoQ/dGYc7b l1wZquyIz4FLmo4VLBvxeGmkMpwB6ITWzD4YNN5MzbJ867IHeqC4HIZGiK5W98wAQCETbEIEgWEai 4l2MxoUPgA6PFTGf0vG6O79UGWiXYefgb6GuNKZKxv2XWS+3a06iY0/D2JVMYK6Q6kYimcWcYJMd6 RBUnyINdcobegsrUppJ6oablXR8xipYQQ6DjZzNVGjwAEsCt7J9dvhNKSo9MQJNUcIk3VNGCLMAY6 FEuseSVcdm7OXjWhFzi4TvLu5NNt9LvQyzcPLUZDGO3DfT6o7Y9MazcqT6dTHhGJzi+e5dRZwSQjf afr4F+zCYhbLPLbho7qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdYq-00Euuu-W7; Thu, 21 Apr 2022 20:37:57 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdYn-00EutU-9T for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 20:37:54 +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 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 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-20220421_133753_503313_9D4A6B95 X-CRM114-Status: GOOD ( 11.98 ) 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 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/Documentation/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 + 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.yaml + $ref: /schemas/types.yaml#/definitions/string + ti,system-reboot-controller: description: Determines If system reboot can be triggered by SoC reboot type: boolean From patchwork Thu Apr 21 20:36:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 12822406 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 A0D80C433EF for ; Thu, 21 Apr 2022 20:40:13 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kc3aEjYToYGUKKX+jicI5N2dfSFFvFGUmRrnQMYd4bk=; b=wUcnZAXAAt0Rnx kYQh8pgvxRe6bR+Eob7O5ulCY2H7vTUg0WLWqWszpdGCtLzGD/USmM7exjjNtPMxR/dKsefNQq55o aQstuReBbhZDLfvZ1p5F53kLPV1V+F7irTlHeQBQQ4B0cTmVnvvd/So3anPwyLnw0GjLnn81Emg1A JfFnSBycM/WLVdzXVrBgQCjjBHmjLfPGgto3650KqUwxwPbzuZBjZXPX1n8ur2RL+2wxpkqQDHbj7 oEIaMmApLbf33qi9G+dBvBWHyv9csh/vU8zktHms2Veywtn6OCNJJvLvd02I185bMYwGsbPk3jAXU /jYc1oIszgtRRqEaL0hA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhda7-00EvTX-4J; Thu, 21 Apr 2022 20:39:15 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdYr-00EuvU-GA for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 20:37:59 +0000 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 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-20220421_133757_675561_9A3CADE8 X-CRM114-Status: GOOD ( 12.75 ) 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 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/Documentation/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 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 reg: + items: + - description: | + Specifies the debug messages memory mapped region that is optionally + made available from TI-SCI controller. + - description: | + Specifies the lpm memory mapped region where the FS Stub low power + firmware is to be loaded. minItems: 1 mbox-names: @@ -92,6 +99,12 @@ properties: type: object $ref: /schemas/reset/ti,sci-reset.yaml# + 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 From patchwork Thu Apr 21 20:36:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 12822402 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 062DAC433F5 for ; Thu, 21 Apr 2022 20:39: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fiUcF2Z+biOw9ywJMwAjIqUXXXfi3jlW1LhkLdl0C88=; b=ooj64xKWmTXqHQ wl04vfv261s0zUeKUNhkJ1SXT6hswxfpZHU4sghmNSYqHmHxA8qs3zX5yDAXgzB+ifuArW85VSMw7 cFkU75yNKo0Bci4OswgA8L6QhqNgWd5/B/PP7dv9gQBwcRxDPpBS/NOojFm4tNv3njucs9DDl5Ph/ M1wpSepE/l9EQGaQ3D7amEitsnCz578u6Fr29rZkMUla3xpScPBRbwQuZNxs0RwRSJt3vIXOXxbzO OjU/JERiNCCLhxszI416xIEiHmS/Y73HbgDcWxIcJ3wGuxTKzJgse3ps4td66k/uuME85ATL5UknW 92Esjo4ss/2lHf+R1Hug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdZA-00Ev1w-4K; Thu, 21 Apr 2022 20:38:16 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdYn-00EutT-IQ for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 20:37:56 +0000 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 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-20220421_133753_739133_FC82D4E1 X-CRM114-Status: GOOD ( 21.96 ) 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 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_sci_handle *handle, return ret; } +/** + * 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 = 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_PREPARE_SLEEP, + TI_SCI_FLAG_REQ_ACK_ON_PROCESSED, + sizeof(*req), sizeof(*resp)); + if (IS_ERR(xfer)) { + ret = PTR_ERR(xfer); + dev_err(dev, "Message alloc failed(%d)\n", ret); + return ret; + } + + req = (struct ti_sci_msg_req_prepare_sleep *)xfer->xfer_buf; + req->mode = mode; + req->ctx_lo = ctx_lo; + req->ctx_hi = ctx_hi; + req->debug_flags = debug_flags; + + 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_hdr *)xfer->xfer_buf; + + ret = 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 = &ops->core_ops; struct ti_sci_dev_ops *dops = &ops->dev_ops; struct ti_sci_clk_ops *cops = &ops->clk_ops; + struct ti_sci_pm_ops *pmops = &ops->pm_ops; struct ti_sci_rm_core_ops *rm_core_ops = &ops->rm_core_ops; struct ti_sci_rm_irq_ops *iops = &ops->rm_irq_ops; struct ti_sci_rm_ringacc_ops *rops = &ops->rm_ring_ops; @@ -2847,6 +2907,8 @@ static void ti_sci_setup_ops(struct ti_sci_info *info) cops->set_freq = ti_sci_cmd_clk_set_freq; cops->get_freq = ti_sci_cmd_clk_get_freq; + pmops->prepare_sleep = ti_sci_cmd_prepare_sleep; + rm_core_ops->get_range = ti_sci_cmd_get_resource_range; rm_core_ops->get_range_from_shost = 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.ti.com/ + * Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.ti.com/ */ #ifndef __TI_SCI_H @@ -35,6 +35,9 @@ #define TI_SCI_MSG_QUERY_CLOCK_FREQ 0x010d #define TI_SCI_MSG_GET_CLOCK_FREQ 0x010e +/* Low Power Mode Requests */ +#define TI_SCI_MSG_PREPARE_SLEEP 0x0300 + /* Resource Management Requests */ #define TI_SCI_MSG_GET_RESOURCE_RANGE 0x1500 @@ -545,6 +548,33 @@ struct ti_sci_msg_resp_get_clock_freq { u64 freq_hz; } __packed; +#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_SLEEP. + * + * @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 context save. + * @debug_flags Flags that can be set to halt the sequence during suspend 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 /** 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); }; +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 range. * @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; From patchwork Thu Apr 21 20:36:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 12822401 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 CC9EFC433F5 for ; Thu, 21 Apr 2022 20:39:13 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2rkMBKQCvHHFmJzcNynJztoQV6zgNx2A1ydEM3CXl1A=; b=tz93ffNRCaKxx6 Ahzf78tY82NCI6Web55iJOSy0FbpLgVH0GopUR70K4EhOphPqfNImh7Jb2r91fu0an5RQ/XXuONNa s0i4sBVObIQk65aK5Kw6TDKBNUqVqXnRFPcfY5lRc4tXo2ax3WbbrgIIPwTi3ozecN7ONa0tyMJ3Q gqRyKzadLalnscDVKT2KAhlvkTsrKsWT6cr1cEY0eHlJWMLxyqro3jtDFXkKPJHrQ3iB4YSm4wl7i Ht+dz9tU3J3vXA4HhO3MY4bAupzOlKEOB3p88AJAHc/NyRjbMTEJqIR5FdLnun0rzW9jmbfoiv4Tm 84FffwVrzHrzYp2CVZPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdYz-00Euy9-Sj; Thu, 21 Apr 2022 20:38:05 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdYn-00EutS-8W for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 20:37:54 +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 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 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-20220421_133753_506185_DA4D5EFF X-CRM114-Status: GOOD ( 21.76 ) 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 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) static DEFINE_SIMPLE_DEV_PM_OPS(ti_sci_pm_ops, ti_sci_suspend, ti_sci_resume); +static int ti_sci_init_suspend(struct platform_device *pdev, struct ti_sci_info *info) +{ + struct device *dev = &pdev->dev; + struct device_node *rmem_np; + struct reserved_mem *rmem; + + rmem_np = 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 provided.\n"); + return -EINVAL; + } + + rmem = of_reserved_mem_lookup(rmem_np); + of_node_put(rmem_np); + if (!rmem) + return -EINVAL; + + info->mem_ctx_lo = (rmem->base & 0xFFFFFFFF); + info->mem_ctx_hi = (rmem->base >> 32); + + return 0; +} + /* Description for K2G */ static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = { .default_host_id = 2, @@ -3526,6 +3554,23 @@ static int ti_sci_probe(struct platform_device *pdev) } } + /* + * 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 = ti_sci_cmd_prepare_sleep(&info->handle, 0, info->mem_ctx_lo, + info->mem_ctx_hi, 0); + if (!ret) { + ret = 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 = 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, From patchwork Thu Apr 21 20:36:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 12822405 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 E01B1C433F5 for ; Thu, 21 Apr 2022 20:40:06 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1n9ddpOKm+wgsVDPeQUUyRXk0kChC2bAzxjc1iFYNfQ=; b=rfl/nKcN3VZG8i V3C3zdJ7CRATI3gjaCfYZg11G0UkBZAWs/3gMQVwkymdBIWCM1mO9g4gVIWqQZNc+lBoETFN7QyZu 7VhWFvmDzuhERli4lb91PvI2BqVy/qOH2AHxpH7d5P+f9U8YsTiRnwxW/JBlXywrDX6B+b5z4Gq60 k8+eEDuP6/0rvyseimVZZ7z4/eqh4vy3IIepBpxVcbXhKUTAx2C7pA8/IyaXIlNyGrxZdd+D37N6Y B9vltPMEY6VZeLpuq01cDaYghhSBeDpB4q6mbLq7H3EGvTxAgV36iKMn9wC3rWAOB6J6+4SHjrx4K Ksnw7iTQcfjMHGlHrKzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdZs-00EvMK-IL; Thu, 21 Apr 2022 20:39:00 +0000 Received: from fllv0016.ext.ti.com ([198.47.19.142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdYr-00Euuv-7u for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 20:37:59 +0000 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 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-20220421_133757_443213_B500D3EF X-CRM114-Status: GOOD ( 26.27 ) 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 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; }; #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_block *nb, unsigned long mode, return NOTIFY_BAD; } +static int ti_sci_load_lpm_firmware(struct device *dev, struct ti_sci_info *info) +{ + const struct firmware *firmware; + int ret = 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_suspending) { info->is_suspending = is_suspending; @@ -3358,6 +3391,8 @@ static void ti_sci_set_is_suspending(struct ti_sci_info *info, bool is_suspendin static int ti_sci_suspend(struct device *dev) { struct ti_sci_info *info = dev_get_drvdata(dev); + int ret = 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); - return 0; + if (!info->lpm_firmware_loaded) { + ret = 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 = -ENODEV; + } else { + info->lpm_firmware_loaded = true; + } + } + + return ret; } 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 = &pdev->dev; struct device_node *rmem_np; struct reserved_mem *rmem; + struct resource *res; rmem_np = 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_device *pdev, struct ti_sci_info info->mem_ctx_lo = (rmem->base & 0xFFFFFFFF); info->mem_ctx_hi = (rmem->base >> 32); + res = 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 = devm_ioremap_resource(dev, res); + if (IS_ERR(info->lpm_region)) + return PTR_ERR(info->lpm_region); + info->lpm_region_size = 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; } From patchwork Thu Apr 21 20:36:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gerlach X-Patchwork-Id: 12822404 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 7BD4EC433EF for ; Thu, 21 Apr 2022 20:39:44 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gN8QzqSlXDA080xADZ+yoj77UnkZO5BKaetORWlkGxs=; b=r2hFPCNRUH3gm6 BLwa3j+1b9gh80McjgFzCqebN3s0ZzPi94w/K8ITEfd08Jkjufkvsojr4BIZaxeSXbu7cnugzdCp9 U+PxoOhe7UaQN5sVU0sVtbSEN7ucswjGgPm63VQMgz4VqjOVr/lMQV1Eur5KampzsN86fXGBmtBzy Mrirt7+x5gZjdc6S0BE4ArtpqbmB1+tLX9KsEJ3oOvjr1fkCenxrlp6Fs7Z3fEqDZDrjA+rIxnW3o OhJ8nSh8iKm+A4T7Fadbb+Qg/oYzP2JGfhmKym4pClNPb3jt079HVsiN/WSj9JSlOQd0fPdtEqvx4 gNocPCTyuZctNiYgGtsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdZa-00EvDv-KX; Thu, 21 Apr 2022 20:38:42 +0000 Received: from fllv0016.ext.ti.com ([198.47.19.142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhdYr-00Euut-7u for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 20:37:59 +0000 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 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-20220421_133757_469382_E46C94E1 X-CRM114-Status: GOOD ( 16.67 ) 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 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 #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 = is_suspending; } +static int ti_sci_prepare_system_suspend(struct ti_sci_info *info) +{ + int ret = 0; + int mode; + + switch (pm_suspend_target_state) { + case PM_SUSPEND_MEM: + mode = TISCI_MSG_VALUE_SLEEP_MODE_DEEP_SLEEP; + break; + default: + ret = -EINVAL; + } + + /* + * Do not fail if we don't have action to take for a + * specific suspend mode. + */ + if (ret) + return 0; + + ret = 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 = dev_get_drvdata(dev); int ret = 0; + ret = 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