From patchwork Fri Nov 11 17:17:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Vlaev X-Patchwork-Id: 18925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp874038wru; Fri, 11 Nov 2022 09:30:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ntkcujoTRMlnv1qFia4fJV2WyDDhTpowrd6oy3PtQbaVA+AWL5OP/rnC0fAA+boGCuAQB X-Received: by 2002:a17:907:c007:b0:78d:99a0:7cf6 with SMTP id ss7-20020a170907c00700b0078d99a07cf6mr2656190ejc.56.1668187848034; Fri, 11 Nov 2022 09:30:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668187848; cv=none; d=google.com; s=arc-20160816; b=EtvPVbNnSx3EgpHRiWro7SvRWzp4DuhXvA/fv1NQygaUiMlLUI+HcX+J3lL/2Y+tKT 18ZN+PEKxb8Lrk7pOHSEqPCY01Wwwcp1u44JUh0/daYCbfujPVGaiLtGTVZUbwWu7vyi uqYKeXV+jVsBQj+q2Brc9LcldOPth+HD9mAb1kVyJmirUQn2/qoThCVhOEPSTgzOenwf PavhKxWHvFrVP4U5mRXVFVHKikySyV/unwQE7orOitW4eoSZnWbSHtjBWVgd+01mN9q+ d46/S4obeasY5yosKWQQTDyKODoGsfDVHYIhq5p5xrvrMqZsFbC/CSq2USUmE8mRd9o3 Rkzw== 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=we6ZlnfS7ikI24BywLqmCBRSZGV/DSCDVpj0SvODauo=; b=MReMiRszRyFOx6LdNuI19D3XCMgQqP4Oumlj5YzFFhWO4xe9wx8HsRwe9pwRh3X0og fSfBUq8bXXXeTKjqrPFUeyy5XVNQ6M+uGnZnvEX3MPLBngPrtuNAOQLyK3XCsEdcAeFB ZoMOnoSceZpcrQuQKUx5wfn8h25gbQ1M+jhqxcxxxn9YhA/Q8E9r3u6TXJ235S/Hlbyq 2rUsZLIIFcSct7IPnvuRYFwg+s9o/yyJcUH3bdWm3RxUWy/f/Vf1Sa2e1En3Yqz2uvQl BTaB7BDaqYkxAWh7ppKltnaxOyHtjziGybNbYP73ZkRGYCgm9Jrg5OHzL4xvduTwCbft C8SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=I9xxV8Sd; 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 o22-20020a170906975600b007ae8b1704b9si2662840ejy.406.2022.11.11.09.30.23; Fri, 11 Nov 2022 09:30:48 -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=I9xxV8Sd; 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 S234415AbiKKRTI (ORCPT + 99 others); Fri, 11 Nov 2022 12:19:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234222AbiKKRSx (ORCPT ); Fri, 11 Nov 2022 12:18:53 -0500 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D8EE5B5A2; Fri, 11 Nov 2022 09:18:43 -0800 (PST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2ABHIYmd081079; Fri, 11 Nov 2022 11:18:34 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1668187114; bh=we6ZlnfS7ikI24BywLqmCBRSZGV/DSCDVpj0SvODauo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=I9xxV8SdRswF8va6wbWk2j4xHlIVfGZK7uecRHOJoF9YwfIZqTepdItlm+zdoMS7u scDNg697SV4jD4HKCYymxYqrnOJcC98gxvpDlOhadHoiNTJ1p4D1fZJiZT3wcttKsc AjNqaDhz6dkgVwsADV4c9v40c2TjIZiqhLZL+lFg= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2ABHIYgS057177 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 11 Nov 2022 11:18:34 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.6; Fri, 11 Nov 2022 11:18:34 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE114.ent.ti.com (10.64.6.35) 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; Fri, 11 Nov 2022 11:18:34 -0600 Received: from jti.ent.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2ABHHewc028454; Fri, 11 Nov 2022 11:18:26 -0600 From: Georgi Vlaev To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski CC: , , , Vibhore Vardhan , Vignesh Raghavendra , Roger Quadros , Georgi Vlaev Subject: [PATCH v3 5/5] firmware: ti_sci: Introduce prepare system suspend call Date: Fri, 11 Nov 2022 19:17:39 +0200 Message-ID: <20221111171739.160693-6-g-vlaev@ti.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221111171739.160693-1-g-vlaev@ti.com> References: <20221111171739.160693-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?1749221741014882514?= X-GMAIL-MSGID: =?utf-8?q?1749221741014882514?= 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 Tested-by: Roger Quadros --- 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 a961506dbbc4..18734b506e72 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)((u64)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