From patchwork Tue Nov 8 22:45:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Vlaev X-Patchwork-Id: 17261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp17978wru; Tue, 8 Nov 2022 14:48:43 -0800 (PST) X-Google-Smtp-Source: AMsMyM7gWqUPuwEWFhdpoOXmcoY7o90/lGI9G7nkvPieiX4vHiFvx9di3VC8GyxF9yqACa0m/O4E X-Received: by 2002:a17:90b:4c06:b0:214:199c:7512 with SMTP id na6-20020a17090b4c0600b00214199c7512mr40438600pjb.201.1667947723058; Tue, 08 Nov 2022 14:48:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667947723; cv=none; d=google.com; s=arc-20160816; b=ck1U2vfSxX44UEFmEDtTYjvDSikqR3CB6l3uaGCQC5LVGViPbKJJ2Cjipk15y4Goef Mo9YLaThHjO8DMLDhXbAbqXNOjALqyp7jAv14eJnANw8/M+1N8g40Rvzyp+JHvZZI3MC O2keg/S7A5eTDF1zBcbeWwSSHFVs86QFuUZYKgK9zhhP8MUDftfYceFGZjwScegItp8w CEE2JbAKeMnsT/gPGI1w+49KIYJOr8PG/X6/z+LXLXTdnn+Gnzt8nD7wHXTTgoh1loTZ HJVyTGqOKRrn7acvvyLJc81tmwJvWxn/+inS9iLSDbgZaEANrHqu8lTbNyY/n0qvyme3 huhw== 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=irLruPItPKZSOBhSNcqEgmj1Wp8qBzvia9j9Am2wPIk=; b=JT6cxhuVqFWYUAM7VHhD4KUQboKIDBYNPPT0lnvD1tvhx5nkUDheY/kU+lYunrs19s NcSGUcystASbzSm3ImNu8EqcHV5nZ9x6v+vGB9JzgfPnOcYiCcs2kkpTfBVFNL7P1249 nee2NYgzs6BWB5wIegYohVUarsTJj7DWTyqUFqeUDUOz/josOb6AbHTrVIq985zfSHaN btaI2AYebzHRWDpwAXu/5Ou679o0UkUo4m8n8Vr0OkNckzVCKNoh7L6akCr7/C69vLT3 q5vclQqO2VHuq1ZwRVP1rivmBsrkvB1unrocG4vh3RCOnQSMe0YTLl6nBswBazbW8MNZ xF/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fx0E8Aav; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q202-20020a632ad3000000b004708e8db2b4si3165552pgq.796.2022.11.08.14.48.29; Tue, 08 Nov 2022 14:48:43 -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=fx0E8Aav; 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 S229973AbiKHWqp (ORCPT + 99 others); Tue, 8 Nov 2022 17:46:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbiKHWq3 (ORCPT ); Tue, 8 Nov 2022 17:46:29 -0500 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDB2C60691; Tue, 8 Nov 2022 14:46:28 -0800 (PST) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2A8MkNt9123857; Tue, 8 Nov 2022 16:46:23 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1667947583; bh=irLruPItPKZSOBhSNcqEgmj1Wp8qBzvia9j9Am2wPIk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fx0E8AavhyiUkG9lhmBvcw42Ap0HLQu8i1LOYt5Jkza/9r3nBBVUGNY+P/Oy/JlVm MxNEuUwctkK4aavk+ZoQJ9QZAq3KlxoQ+Joiqqz7dQmIH+B2uK8PlVG7qVTZwlxmXD 7RDCSDp2BHb8DNZ6JwmXQl3oFGkt5rd4qqr+PHv8= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2A8MkN27119415 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Nov 2022 16:46:23 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.6; Tue, 8 Nov 2022 16:46:23 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.6 via Frontend Transport; Tue, 8 Nov 2022 16:46:23 -0600 Received: from jti.ent.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2A8MjSp1071038; Tue, 8 Nov 2022 16:46:15 -0600 From: Georgi Vlaev To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski CC: , , , Vibhore Vardhan , Vignesh Raghavendra , Georgi Vlaev Subject: [PATCH v2 5/5] firmware: ti_sci: Introduce prepare system suspend call Date: Wed, 9 Nov 2022 00:45:27 +0200 Message-ID: <20221108224527.137179-6-g-vlaev@ti.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221108224527.137179-1-g-vlaev@ti.com> References: <20221108224527.137179-1-g-vlaev@ti.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748969951645714148?= X-GMAIL-MSGID: =?utf-8?q?1748969951645714148?= From: Dave Gerlach 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 necessary, send TI_SCI_MSG_BEGIN_SLEEP with information about the mode is being entered and the address for allocated memory for storing the context during Deep Sleep. Signed-off-by: Dave Gerlach Signed-off-by: Vibhore Vardhan Signed-off-by: Georgi Vlaev --- drivers/firmware/ti_sci.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 4986df1b8570..a6d982685aca 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -3509,9 +3509,39 @@ 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; + + return ti_sci_cmd_prepare_sleep(&info->handle, mode, + (u32)(info->ctx_mem_addr & 0xffffffff), + (u32)(info->ctx_mem_addr >> 32), 0); +} + static int ti_sci_suspend(struct device *dev) { struct ti_sci_info *info = dev_get_drvdata(dev); + int ret; + + 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