Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2472408rwb; Fri, 11 Nov 2022 09:44:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf4+9Zl1RSgl5ALCwNcuaXUlTjHVLyhRzOmmOQ3EI64+YykBTILqhlm8i6FES+SfBwxPixbJ X-Received: by 2002:aa7:cb48:0:b0:461:d2ab:3e05 with SMTP id w8-20020aa7cb48000000b00461d2ab3e05mr2362802edt.286.1668188677563; Fri, 11 Nov 2022 09:44:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668188677; cv=none; d=google.com; s=arc-20160816; b=ydv5og6koNvKkVB2Wianr6Z1Ew7EigD+tZHzaLqDW6Y5eXO6/To6zZkhBF/Tmfgzbn 9SBrT0EtK/REK8xlGTU5Utsag+eulW+n3DGsXr2aMzTQnVF0UaGlvNnH9XfxZbzzfM5n tY/2Daz5jnZt9aviigybBYEOD7KK/mIAC6MUrsyDBgFN7gByjbeOxLz6Ibz6BYuHb5zL DdDiVrxXBMy3LUKE29b4c16ePVJVC9tdKJnMDca0uM3gkhM4YzWeaHB1iDb5qpTsb0Av zWjQ5fqwEtErolI6DQTCFNMmO2jd0nKEnmhYo1aW1QJNgI1qsLdMZBZKlkAI5bNo7h/h y3Og== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fg3-20020a056402548300b00447d567a77dsi2591135edb.207.2022.11.11.09.44.14; Fri, 11 Nov 2022 09:44:37 -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 + 92 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 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 -- 2.30.2