Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14989399rwb; Mon, 28 Nov 2022 06:59:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf41m2LjBkEjlsAsmsiz4tmJMleucD4Y91GJl3EQqu1oGoyIV905Tg+dvBFZzXFrqM4vvJjh X-Received: by 2002:aa7:cad9:0:b0:461:60e8:7ac1 with SMTP id l25-20020aa7cad9000000b0046160e87ac1mr840793edt.45.1669647586187; Mon, 28 Nov 2022 06:59:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669647586; cv=none; d=google.com; s=arc-20160816; b=l5gXF+VZYbRxdHvHsA+Vf03TEAv/wmkM5kkN3RBlkXSNdFPtPWgj+SCm3VZGqK0U/z 4XwaCICTfkMm4gYzGeXA3R+gP6KCCg65owrKLcU5a0Hj1YVPlWccW1oxiMjM0PXcHPhs QsBmFxbIgvv/ZIU8VKjsKe5y+gZl11gQ2+wxjEuwhTvz+afbOvLdsAB2uD0FdXNud6b2 MCpWs6knnJKd3IepPCQk2+rmvgzBJQVh6coQW3SkzRrQaZHIVpjdQ+EAHGyvfCkN04hZ ceTOLJIJuINF70AXn7giBtvjB5wIYUUyQSaYpCCKmmQEhlaXie85cErUPKfFBydW2hF4 ZLYg== 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=7jkAENbaGQCGj8274ocsGwp0BivC0m9EFpVsZaWJ+lw=; b=f9FW4fwHvadKCD1BCZRK7TTmyZ5nR6epnWkTaAG4yuq5Z7+oUk0FAZ25FAco0KjjAo IBfGU4x4wL0Z8yG5aSyQPZiKDOTqxp5QBTp4LBKt2SrcoAH5aZ8Jf0vGGYkIwdXSjAmK pbHgKTSefR5C4XyPIgLD3c5d18behnK8nD2Bqfj86gwWagGykVeT0iExxYVRYQW/bLvB GwWrUwOGKTUQH75xgav0BdIFnQ8JGXo/PBOSx+xkUFcHUl3bZ/fzgEukDsDORE2XmH1/ Aoy2jg0Ln0XRE998ahQxbP72JgXaVvkvY4KdXXCeooq9bTl+MHADZd86Ey2tupcddMBW jwDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HWxYgAwn; 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 z6-20020a50eb46000000b00461c9bb5205si8712096edp.152.2022.11.28.06.59.25; Mon, 28 Nov 2022 06:59:46 -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=HWxYgAwn; 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 S232305AbiK1OGV (ORCPT + 84 others); Mon, 28 Nov 2022 09:06:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232314AbiK1OGG (ORCPT ); Mon, 28 Nov 2022 09:06:06 -0500 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 471EF20BDC; Mon, 28 Nov 2022 06:06:05 -0800 (PST) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2ASE5wFB044432; Mon, 28 Nov 2022 08:05:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1669644358; bh=7jkAENbaGQCGj8274ocsGwp0BivC0m9EFpVsZaWJ+lw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HWxYgAwnlxvn6a2iqF74VwkwYDzy2xLuiVXxA+LvdYu24l6xb0vGGgvPNZPZsE+Nk jEwF4dTIj12E76fxi3d5T8G9GsTBB1hlbV+9t5U4M6KoY7xd/5OEQvci6iNS/AzX+6 tug/oix7YFyuHrfHxvZ2SV/o6sDP7DUr12f9ugfg= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2ASE5wYp023854 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Nov 2022 08:05:58 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Mon, 28 Nov 2022 08:05:58 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Mon, 28 Nov 2022 08:05:57 -0600 Received: from jti.ent.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2ASE5NQd125815; Mon, 28 Nov 2022 08:05:52 -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 v5 4/6] firmware: ti_sci: Allocate memory for the LPM modes Date: Mon, 28 Nov 2022 16:05:20 +0200 Message-ID: <20221128140522.49474-5-g-vlaev@ti.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221128140522.49474-1-g-vlaev@ti.com> References: <20221128140522.49474-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 A region of memory in DDR must be used during Deep Sleep for saving of some system context when using the ti_sci firmware. From DM's point of view, this can be any contiguous region in the DDR, so can allocate 512KB of DMA reserved memory in probe(), instead of another carveout. Also send a TISCI_MSG_QUERY_FW_CAPS message to the firmware during probe to determine if any low power modes are supported and if ti_sci_init_suspend should be called based on the response received. Signed-off-by: Dave Gerlach Signed-off-by: Vibhore Vardhan Signed-off-by: Georgi Vlaev Tested-by: Roger Quadros --- drivers/firmware/ti_sci.c | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index caa7b9d2bd48..b49d81527e29 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,9 @@ #include "ti_sci.h" +/* Low power mode memory context size */ +#define LPM_CTX_MEM_SIZE 0x80000 + /* List of all TI SCI devices active in system */ static LIST_HEAD(ti_sci_list); /* Protection for the entire list */ @@ -96,6 +100,9 @@ struct ti_sci_desc { * @minfo: Message info * @node: list head * @host_id: Host ID + * @ctx_mem_addr: Low power context memory phys address + * @ctx_mem_buf: Low power context memory buffer + * @fw_caps: FW/SoC low power capabilities * @users: Number of users of this instance * @is_suspending: Flag set to indicate in suspend path. */ @@ -114,6 +121,9 @@ struct ti_sci_info { struct ti_sci_xfers_info minfo; struct list_head node; u8 host_id; + dma_addr_t ctx_mem_addr; + void *ctx_mem_buf; + u64 fw_caps; /* protected by ti_sci_list_mutex */ int users; bool is_suspending; @@ -3543,6 +3553,23 @@ 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; + + dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); + info->ctx_mem_buf = dma_alloc_coherent(info->dev, LPM_CTX_MEM_SIZE, + &info->ctx_mem_addr, + GFP_KERNEL); + if (!info->ctx_mem_buf) { + dev_err(info->dev, "Failed to allocate LPM context memory\n"); + return -ENOMEM; + } + + return 0; +} + /* Description for K2G */ static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = { .default_host_id = 2, @@ -3695,6 +3722,15 @@ static int ti_sci_probe(struct platform_device *pdev) } } + /* + * Check if the firmware supports any optional low power modes + * and initialize them if present. Old revisions of TIFS (< 08.04) + * will NACK the request. + */ + ret = ti_sci_msg_cmd_query_fw_caps(&info->handle, &info->fw_caps); + if (!ret && (info->fw_caps & MSG_MASK_CAPS_LPM)) + ti_sci_init_suspend(pdev, info); + 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, @@ -3742,6 +3778,10 @@ static int ti_sci_remove(struct platform_device *pdev) mbox_free_channel(info->chan_rx); } + if (info->ctx_mem_buf) + dma_free_coherent(info->dev, LPM_CTX_MEM_SIZE, + info->ctx_mem_buf, + info->ctx_mem_addr); return ret; } -- 2.30.2