From patchwork Wed Nov 29 15:31:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 171435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp418729vqn; Wed, 29 Nov 2023 07:31:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGT+VHTiFY2U7tufyXuePEYl+LtZ71X2UGErYhyIhPR0je3J9en5DiM4p51an4XSFI/2xJy X-Received: by 2002:a05:6870:1681:b0:1fa:1f0c:cf with SMTP id j1-20020a056870168100b001fa1f0c00cfmr18755802oae.6.1701271905607; Wed, 29 Nov 2023 07:31:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271905; cv=none; d=google.com; s=arc-20160816; b=otGaf7YhTfTMdxUy+20Tr9ym39M4PPSW+UlAFevuVjMNnOqbc/Sa1JZoOvRMYQCtTR jaoMaKW/b/mB1HW4UV2POz+MI9IcXw1pFRQQbkDxccDOsDSHAmJrRnPb5vnfFOw0iU3n Jah4IKRtPNSW9GMRmo2d25eqcmkz60dH60mrY5d2n98EdfPlRr3rp53U3rRM4yA63LYF Y2rvjpNQsGVBSlZ4m6PDKdW6cVF3cxv6xv9AWUYZY9gDy4JNn/ZSwW06SKshXshwmlIc RUDQ/rJucUyWB7WFo9i1eeloNMPehYp6Xta1CN3WXSuyuAZxzIcLh2PHrh8jS9xb2xhs VBuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=QI1TyzlXaMDB+nhKVeoMHOxLQU8QDlDCw/eJpwfHUjI=; fh=qiuiZXOuSBoCezToil2F5RBR95PkXWcuBaEpicqga+E=; b=lcSiNpzyFNK9h/AShqBsjPFEQXQxf3gPB27ajgQ3aDvGSm4dMY/J3uZutF7cGia5or p6sYAQBfJy++rvlomWTdUMT4EtiyvbrXrORBX8jJN7A+1MsgNPzyxpNBCqcusmOpkg0j Ko13sm6k1hjypCBf3SLd6W1zhZ3mXYseNafaFWnyyX2LFGhH5FpyorMLn3Y+MnTdMu8o CNXuuLDjU2/RSscAzzEUYQOVysfbqJ5ZlyC/hqnIplLIvMF+2FtXvQOu+27p2+Ihoa5L 4haMeMzJRD2pT5ImwKvZRJNLbejBf+//+6z6M0KisudONKa1tXrjDT9iDECuwRvjsfc0 iLjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=B+04Pvk3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id oy19-20020a056871781300b001fa150be386si4277336oac.285.2023.11.29.07.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:31:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=B+04Pvk3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2F5D681CCDAA; Wed, 29 Nov 2023 07:31:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234890AbjK2PbV (ORCPT + 99 others); Wed, 29 Nov 2023 10:31:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231206AbjK2PbT (ORCPT ); Wed, 29 Nov 2023 10:31:19 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99B1D48; Wed, 29 Nov 2023 07:31:25 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id C7635E0004; Wed, 29 Nov 2023 15:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701271884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QI1TyzlXaMDB+nhKVeoMHOxLQU8QDlDCw/eJpwfHUjI=; b=B+04Pvk3bWmTvMKPRwosQPKO0bPMfT8nIYKro4x6w5StmHTn4ntp35qumfbEmEr1iZUFvY h5vd2lx1Zu/KXq7I1HA6Svd1D8ClwkQzAwQqywyRs6HtxmBhOuq9HzTD+NKrs44JpoWvuw VHRg8plyHlX+LFUItkfkhsHzfg4vpwM8PfCvcrdrTsXreunjIm8cyH+AnsJW1ZwL0MK0KB r0EjUi5bX7UQ1s8CqLH9z99bs2+qnDt7eLd45H3/eLWPQ18er8GjsSPAiysHVatAko5t7V 3TbKN29vILU+zZ12cMiF7FB7eNV+Q1gav41vgI+AS112rPbwCGOV6ckr5sfFiQ== From: Thomas Richard Date: Wed, 29 Nov 2023 16:31:17 +0100 Subject: [PATCH 1/5] dt-bindings: arm: keystone: add ti,j7200-sci compatible MIME-Version: 1.0 Message-Id: <20231129-j7200-tisci-s2r-v1-1-c1d5964ed574@bootlin.com> References: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> In-Reply-To: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vignesh Raghavendra Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:31:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783912889758351237 X-GMAIL-MSGID: 1783912889758351237 On j7200, during suspend to ram the soc is powered-off. At resume requested irqs shall be restored which is a different behavior from other platforms. Signed-off-by: Thomas Richard Acked-by: Conor Dooley --- Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml index c24ad0968f3e..53d9c58dcd70 100644 --- a/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml +++ b/Documentation/devicetree/bindings/arm/keystone/ti,sci.yaml @@ -40,6 +40,8 @@ properties: - description: System controller on TI AM654 SoC items: - const: ti,am654-sci + - description: System controller on TI J7200 SOC + - const: ti,j7200-sci reg-names: description: | From patchwork Wed Nov 29 15:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 171436 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp418774vqn; Wed, 29 Nov 2023 07:31:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVTvPHEC9eg7pTFlZCpNdX+MHG193XkxzPtu44+t8P2VvumqZ3uEowPJsJrNlTuzjvXrPW X-Received: by 2002:a05:6a00:cc3:b0:6cb:db73:a6db with SMTP id b3-20020a056a000cc300b006cbdb73a6dbmr21724997pfv.21.1701271909539; Wed, 29 Nov 2023 07:31:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271909; cv=none; d=google.com; s=arc-20160816; b=OAKmjgfaaZL4rC9HxB+nHhZi5nugLhGcjIFTGNSvZD8hYEW88GA6LaEYT8LxnoNrlk iV1J/6L1P2OnRgrIS57/CaTxgjFkebBkYdVfFCl7Al/QedBSmGnlFzePZZ277BvGdl8a 60G2yAmTsfuSdn6O+0GdlBvdB8s0ZqgP60T6sEuLgv47AZlEQS+RTic2hWu2qWifTgii Fz/ywZEa4z/Q4St3YIjmCnBdJyj/14UWJrKMLjqkky4TzZ9CDq4jop5pfQbKVR6mBNBm M4dDYAfX9658U6DAJd+s2IXNDAZlEiPTYzzor9iRWset6Que053vGXaOSY0Hj9ty5yoX QiVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=+cbJLlFkfaPpJj8eq2H7GH+mfMR2CF2wpb8mSuVlsv0=; fh=qiuiZXOuSBoCezToil2F5RBR95PkXWcuBaEpicqga+E=; b=TvruU2+dRmNk4mwXysddxyOunef3cwBNZoOqA8ao9uCBS/gRAKm0QOhsfN1t9Vrjnn IjHxboEmpQvhZEufLnoRr1MJJLKGyLOC02us16EsN8RLZkPWjrGFJU4IqLPZodfX26E8 5kSZemcGjaFQzIRms/42QyT2H0GD+f0w+dr+nLoP+0fjOGVbRRqoyO/Z+6FczRSA8uJF e37Gd9R3ieflADiXUuZhyIf1eAhY/Y1ayHBVEBC1DSU7D6FA5Pm0BSJ/uKpXFGotKExs uJFR/0yI9UdYOiGJMUs42JTaWqHHeZgEe+v0BZ9xLkR3etLGvfT5lCOgTw9t6dWeihsO soWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NvRyz5oV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bw28-20020a056a02049c00b005b88dfa676esi15203252pgb.158.2023.11.29.07.31.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:31:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NvRyz5oV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 49D6081C8D92; Wed, 29 Nov 2023 07:31:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343562AbjK2Pb0 (ORCPT + 99 others); Wed, 29 Nov 2023 10:31:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234104AbjK2PbU (ORCPT ); Wed, 29 Nov 2023 10:31:20 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47225D46; Wed, 29 Nov 2023 07:31:26 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 6066EE0011; Wed, 29 Nov 2023 15:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701271884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+cbJLlFkfaPpJj8eq2H7GH+mfMR2CF2wpb8mSuVlsv0=; b=NvRyz5oV+vJAoMD+AzwVa0Pd3fnr+0xseEL8Idc6yMEkfYblEjF1tnKQk8dZ9Zsnw3tu2k MsWb8UYvtX+4Oa54PdnY5Jo7iNPLv7uDa/6nQl25VeYsqNOzLAufD6dAo1itmaYp9PXDMz wkPB5GTCnLIsRV5X9mWxzLAUCm7pLqspV9Weuu7Ltpn4OHxj+PUbYookW9YM9LcNU/VOXt Yuq1JzI9DDXHDxWMkVfim4EgxX+SBRzKGBAT0uqghV7frsfBGBsWPQT0UmetjjrtsYRUuK KW3G8peHoHsWh4AdoVeR0OqBPvurU6pCrjl4C/hZmDyfTnAA/9PFsOPv+rL2aA== From: Thomas Richard Date: Wed, 29 Nov 2023 16:31:18 +0100 Subject: [PATCH 2/5] firmware: ti_sci: add suspend/resume support for irqs MIME-Version: 1.0 Message-Id: <20231129-j7200-tisci-s2r-v1-2-c1d5964ed574@bootlin.com> References: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> In-Reply-To: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vignesh Raghavendra Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:31:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783912894037278012 X-GMAIL-MSGID: 1783912894037278012 On j7200, during suspend to ram, the SoC is powered-off. The irqs configuration is lost, so it shall be restored at resume. The ti-sci has an internal list of irqs updated at each set/free. All irqs in this list are restored at resume. Signed-off-by: Thomas Richard --- drivers/firmware/ti_sci.c | 155 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 147 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 7041befc756a..c26ec86a5ff2 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "ti_sci.h" @@ -75,12 +76,24 @@ struct ti_sci_xfers_info { * @max_msgs: Maximum number of messages that can be pending * simultaneously in the system * @max_msg_size: Maximum size of data per message that can be handled. + * @restore_irqs: Set to true if allocated irqs shall be restored at resume */ struct ti_sci_desc { u8 default_host_id; int max_rx_timeout_ms; int max_msgs; int max_msg_size; + bool restore_irqs; +}; + +/** + * struct ti_sci_irq - Description of allocated irqs + * @list: List head + * @desc: Description of the irq + */ +struct ti_sci_irq { + struct list_head list; + struct ti_sci_msg_req_manage_irq desc; }; /** @@ -97,6 +110,7 @@ struct ti_sci_desc { * @chan_tx: Transmit mailbox channel * @chan_rx: Receive mailbox channel * @minfo: Message info + * @irqs: List of allocated irqs * @node: list head * @host_id: Host ID * @users: Number of users of this instance @@ -114,6 +128,7 @@ struct ti_sci_info { struct mbox_chan *chan_tx; struct mbox_chan *chan_rx; struct ti_sci_xfers_info minfo; + struct ti_sci_irq irqs; struct list_head node; u8 host_id; /* protected by ti_sci_list_mutex */ @@ -1890,6 +1905,29 @@ static int ti_sci_manage_irq(const struct ti_sci_handle *handle, return ret; } +/** + * ti_sci_irqs_equal() - Helper API to compare two irqs (generic headers are not + * compared) + * @irq_a: IRQ A to compare + * @irq_b: IRQ B to compare + * + * Return: true if the two irqs are equal, else false. + */ +static bool ti_sci_irqs_equal(struct ti_sci_msg_req_manage_irq irq_a, + struct ti_sci_msg_req_manage_irq irq_b) +{ + return irq_a.valid_params == irq_b.valid_params && + irq_a.src_id == irq_b.src_id && + irq_a.src_index == irq_b.src_index && + irq_a.dst_id == irq_b.dst_id && + irq_a.dst_host_irq == irq_b.dst_host_irq && + irq_a.ia_id == irq_b.ia_id && + irq_a.vint == irq_b.vint && + irq_a.global_event == irq_b.global_event && + irq_a.vint_status_bit == irq_b.vint_status_bit && + irq_a.secondary_host == irq_b.secondary_host; +} + /** * ti_sci_set_irq() - Helper api to configure the irq route between the * requested source and destination @@ -1913,15 +1951,39 @@ static int ti_sci_set_irq(const struct ti_sci_handle *handle, u32 valid_params, u16 dst_host_irq, u16 ia_id, u16 vint, u16 global_event, u8 vint_status_bit, u8 s_host) { + struct ti_sci_info *info = handle_to_ti_sci_info(handle); + struct ti_sci_msg_req_manage_irq *desc; + struct ti_sci_irq *irq; + int ret; + pr_debug("%s: IRQ set with valid_params = 0x%x from src = %d, index = %d, to dst = %d, irq = %d,via ia_id = %d, vint = %d, global event = %d,status_bit = %d\n", __func__, valid_params, src_id, src_index, dst_id, dst_host_irq, ia_id, vint, global_event, vint_status_bit); - return ti_sci_manage_irq(handle, valid_params, src_id, src_index, - dst_id, dst_host_irq, ia_id, vint, - global_event, vint_status_bit, s_host, - TI_SCI_MSG_SET_IRQ); + ret = ti_sci_manage_irq(handle, valid_params, src_id, src_index, + dst_id, dst_host_irq, ia_id, vint, + global_event, vint_status_bit, s_host, + TI_SCI_MSG_SET_IRQ); + + if (ret) + return ret; + + irq = kmalloc(sizeof(*irq), GFP_KERNEL); + desc = &irq->desc; + desc->valid_params = valid_params; + desc->src_id = src_id; + desc->src_index = src_index; + desc->dst_id = dst_id; + desc->dst_host_irq = dst_host_irq; + desc->ia_id = ia_id; + desc->vint = vint; + desc->global_event = global_event; + desc->vint_status_bit = vint_status_bit; + desc->secondary_host = s_host; + list_add(&irq->list, &info->irqs.list); + + return ret; } /** @@ -1947,15 +2009,46 @@ static int ti_sci_free_irq(const struct ti_sci_handle *handle, u32 valid_params, u16 dst_host_irq, u16 ia_id, u16 vint, u16 global_event, u8 vint_status_bit, u8 s_host) { + struct ti_sci_info *info = handle_to_ti_sci_info(handle); + struct ti_sci_msg_req_manage_irq irq_desc; + struct ti_sci_irq *this_irq; + struct list_head *this; + int ret; + pr_debug("%s: IRQ release with valid_params = 0x%x from src = %d, index = %d, to dst = %d, irq = %d,via ia_id = %d, vint = %d, global event = %d,status_bit = %d\n", __func__, valid_params, src_id, src_index, dst_id, dst_host_irq, ia_id, vint, global_event, vint_status_bit); - return ti_sci_manage_irq(handle, valid_params, src_id, src_index, - dst_id, dst_host_irq, ia_id, vint, - global_event, vint_status_bit, s_host, - TI_SCI_MSG_FREE_IRQ); + ret = ti_sci_manage_irq(handle, valid_params, src_id, src_index, + dst_id, dst_host_irq, ia_id, vint, + global_event, vint_status_bit, s_host, + TI_SCI_MSG_FREE_IRQ); + + if (ret) + return ret; + + irq_desc.valid_params = valid_params; + irq_desc.src_id = src_id; + irq_desc.src_index = src_index; + irq_desc.dst_id = dst_id; + irq_desc.dst_host_irq = dst_host_irq; + irq_desc.ia_id = ia_id; + irq_desc.vint = vint; + irq_desc.global_event = global_event; + irq_desc.vint_status_bit = vint_status_bit; + irq_desc.secondary_host = s_host; + + list_for_each(this, &info->irqs.list) { + this_irq = list_entry(this, struct ti_sci_irq, list); + if (ti_sci_irqs_equal(irq_desc, this_irq->desc)) { + list_del(&this_irq->list); + kfree(this_irq); + break; + } + } + + return ret; } /** @@ -3266,6 +3359,37 @@ static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode, return NOTIFY_BAD; } +static int __maybe_unused ti_sci_resume_noirq(struct device *dev) +{ + const struct ti_sci_desc *desc = device_get_match_data(dev); + struct ti_sci_info *info = dev_get_drvdata(dev); + struct ti_sci_msg_req_manage_irq *irq_desc; + struct ti_sci_irq *irq; + struct list_head *this; + int ret = 0; + + if (!desc->restore_irqs || pm_suspend_target_state != PM_SUSPEND_MEM) + return ret; + + /* restore irqs */ + list_for_each(this, &info->irqs.list) { + irq = list_entry(this, struct ti_sci_irq, list); + irq_desc = &irq->desc; + ret |= ti_sci_manage_irq(&info->handle, irq_desc->valid_params, + irq_desc->src_id, irq_desc->src_index, + irq_desc->dst_id, irq_desc->dst_host_irq, + irq_desc->ia_id, irq_desc->vint, + irq_desc->global_event, irq_desc->vint_status_bit, + irq_desc->secondary_host, TI_SCI_MSG_SET_IRQ); + } + + return ret; +} + +static const struct dev_pm_ops ti_sci_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(NULL, ti_sci_resume_noirq) +}; + /* Description for K2G */ static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = { .default_host_id = 2, @@ -3286,9 +3410,21 @@ static const struct ti_sci_desc ti_sci_pmmc_am654_desc = { .max_msg_size = 60, }; +/* Description for J7200 */ +static const struct ti_sci_desc ti_sci_pmmc_j7200_desc = { + .default_host_id = 2, + /* Conservative duration */ + .max_rx_timeout_ms = 1000, + /* Limited by MBOX_TX_QUEUE_LEN. K2G can handle up to 128 messages! */ + .max_msgs = 20, + .max_msg_size = 64, + .restore_irqs = true, +}; + static const struct of_device_id ti_sci_of_match[] = { {.compatible = "ti,k2g-sci", .data = &ti_sci_pmmc_k2g_desc}, {.compatible = "ti,am654-sci", .data = &ti_sci_pmmc_am654_desc}, + {.compatible = "ti,j7200-sci", .data = &ti_sci_pmmc_j7200_desc}, { /* Sentinel */ }, }; MODULE_DEVICE_TABLE(of, ti_sci_of_match); @@ -3415,6 +3551,8 @@ static int ti_sci_probe(struct platform_device *pdev) info->handle.version.firmware_revision, info->handle.version.firmware_description); + INIT_LIST_HEAD(&info->irqs.list); + mutex_lock(&ti_sci_list_mutex); list_add_tail(&info->node, &ti_sci_list); mutex_unlock(&ti_sci_list_mutex); @@ -3435,6 +3573,7 @@ static struct platform_driver ti_sci_driver = { .name = "ti-sci", .of_match_table = of_match_ptr(ti_sci_of_match), .suppress_bind_attrs = true, + .pm = &ti_sci_pm_ops, }, }; module_platform_driver(ti_sci_driver); From patchwork Wed Nov 29 15:31:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 171438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp418860vqn; Wed, 29 Nov 2023 07:31:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAfa1n/MYwXQlhq3o0iYy6J/nePmkcG4WM4tNoGX76xstRuoYWsOCt10NAmERaTRlCVXYA X-Received: by 2002:a17:90b:1d12:b0:285:d96c:66c with SMTP id on18-20020a17090b1d1200b00285d96c066cmr10405089pjb.43.1701271916645; Wed, 29 Nov 2023 07:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271916; cv=none; d=google.com; s=arc-20160816; b=oPYTA1uUZ8az4MjWJdzpp/OpED8lGgEg1zVRy1YZIMeJPmZgi9noPcS1xXxJBX9MPp 0Tx5tDG2P4GRJ6o6LWWOV4C/ZAB3UKpRAUy1l+Wetw4NAEcL1l4DZyQBe3Zsby+VIZTR 5puUGeJTYq5MA053BHZOyijx6SgQVECvtvoqC8PxAZKumh3Uca97sSJrwoL0+AjHTAic iYx5jvXnML1dlF8OIL20iNCAvVx+eXURWPh+UiGO139388FYg9LyAuWWr7s28Beb9lS3 zEqEodRdAZ3g7taxhB7BmhVgmrAgYA6ZBH4hydT8tAshTgvglEoRqPKDJ10xF1rAlvU5 8lpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=1sAANN2EXeewZfaaobbe7muJTHqc8A8qnJjW9NGWcx8=; fh=qiuiZXOuSBoCezToil2F5RBR95PkXWcuBaEpicqga+E=; b=GOQBWwXeh+d1r4KUyn60UVtZrqmJItM8QSdeAIkgCf1PgrR+A2qktViGY4/Lkq498X /CUY1Bb2c2MuJ+5uzcPXWAnFi54EFf3Lh/k/g8oCrywCUjhji6uLBZ2jJviRAfrfpetD UChtQ+B+EIYzXHyEgrPKspMTYqisl2GgIHTQvOTjZREwBdhttGeIhawMdQiO7t55Us9B 8SWrpCYZEa9M72F5FtNPL7DXIdbX4wJhlJFFMCo6VxCmgzEkoY0ogEhbAS+5GIc3oMwG JPf7Es8KVfaeZcT4oLlVp2jm6fx2tQcBkSJbRCIjwgZ6y9GCiGq39axfV12fXSvMAgOM u0pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Bu0pbZEC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id bb16-20020a17090b009000b00285b7529e7asi1505740pjb.103.2023.11.29.07.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:31:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Bu0pbZEC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 57B3980BB215; Wed, 29 Nov 2023 07:31:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343638AbjK2Pb2 (ORCPT + 99 others); Wed, 29 Nov 2023 10:31:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234898AbjK2PbV (ORCPT ); Wed, 29 Nov 2023 10:31:21 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC2DD1BF; Wed, 29 Nov 2023 07:31:26 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 08D42E0013; Wed, 29 Nov 2023 15:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701271885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1sAANN2EXeewZfaaobbe7muJTHqc8A8qnJjW9NGWcx8=; b=Bu0pbZECI7sSk70SeqV6BFWJPSrmAsRp2m0uGsoD2H1yVZjphF1Z5CqBRErPyFHg6wE696 1Ul3AFqec7rPvpHTuEY+3yMu3rRr/pZvFgwnWQOfjdBbGOOQMaEqImhtUFxQoedH78DEY0 XvOuwOwIAQ6woWiV8jBoXXhOaZwJSYYiBxkH/gYRbECvdKQ+GbieTpf/S4kYl6D3uZ3iFu VgEKVCDhmbyxL8CEhdsPocoVNXCSP1QAhcVvDItFiouwZMmaWag91eRfRnDyYlxdxef5k7 Hcg52H2lyI68tqyjH3HcF2Da06v5jsqs/W4d84OeRDizSH04+hF8a2m5ys+86A== From: Thomas Richard Date: Wed, 29 Nov 2023 16:31:19 +0100 Subject: [PATCH 3/5] arm64: dts: ti: k3-j7200: use ti,j7200-sci compatible MIME-Version: 1.0 Message-Id: <20231129-j7200-tisci-s2r-v1-3-c1d5964ed574@bootlin.com> References: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> In-Reply-To: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vignesh Raghavendra Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:31:49 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783912901485204302 X-GMAIL-MSGID: 1783912901485204302 On j7200, suspend to ram poweroff the SOC. This compatible restores irqs at resume. Signed-off-by: Thomas Richard --- arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi index 467970fab3a0..d8dc1421e75e 100644 --- a/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi +++ b/arch/arm64/boot/dts/ti/k3-j7200-mcu-wakeup.dtsi @@ -7,7 +7,7 @@ &cbass_mcu_wakeup { dmsc: system-controller@44083000 { - compatible = "ti,k2g-sci"; + compatible = "ti,j7200-sci", "ti,k2g-sci"; ti,host-id = <12>; mbox-names = "rx", "tx"; From patchwork Wed Nov 29 15:31:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 171437 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp418846vqn; Wed, 29 Nov 2023 07:31:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUKj+r/jffbiyHyO1ti2oV4T44Bv/SOKBmhvOoDcCQZAmnu/WzC1IZLPSgLPhokHmkW8Ha X-Received: by 2002:a05:6808:1895:b0:3b8:42c9:dba0 with SMTP id bi21-20020a056808189500b003b842c9dba0mr23485044oib.31.1701271916200; Wed, 29 Nov 2023 07:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271916; cv=none; d=google.com; s=arc-20160816; b=ChjQCcS1U9Ogl/VfrZeKmUg6A3hmeVQs4CoGZ/ZzJvScKv5HUb22GtqHcJ+ZtWwEEU NfYGzCyI2NyVMW9/kGZPYAyT4YC/lrPOq0bw51X4nvCIxXVTw/qnODYLYBEa6TQmUvPd 5GIJboF6YwWke8JNdh7kzIDwqcgVU/4tQF3DHOEp/sNwRMhkZV/g08B05xGs9x2TL3jv AThfru0JpBoyi4anwbLp7SRiP0cyeKbbrTZWMndRuUscrkDyzitkMSsrtvqMqrvIH1kZ ckfINwWffB+iuOpDo+okeQb0c5zP+rBFNipRx/5jNJXCoZGdUHaqzqyf40UjxfT/A7Tx 3xHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ONeuGYPs2IMgsIBQkR63Bawpq/9TA/sG6QW/wej75m4=; fh=qiuiZXOuSBoCezToil2F5RBR95PkXWcuBaEpicqga+E=; b=kxNaZ03qq0W584Himspg3GTK1af4K6J7GuppEKZzyZEsQnyR4ErW82bF1/gLcz3vvJ YW97rs2DiQwiMLNMZX83NO7IKFfWkUbyGi7XA28ECr/dTPoxYwGsF4k6ng7Qox/Fxo2G vbXU52ulS6Rr7SwtHSl7Ocs59KuuMoTEwRKgMttCj460ObF5U0z3IlK59ohIUPQQjSvM M4H7/1aBv/0YLySkfvwMRObjnUTjJviRXBmUWfbXWSiYFoHwn61GywGfMIzzr1oxeSCA RIOlhCkVuOtWn0UsSBHN15woTQMFm1O8x22vV286Zo1avlbe++7dVQZAETcmuGCOAZwW BV2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="BO10/zqY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id gu17-20020a0568082f1100b003b2d98b5d4dsi5834525oib.262.2023.11.29.07.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:31:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="BO10/zqY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 45FDD81CCDB0; Wed, 29 Nov 2023 07:31:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343739AbjK2Pbb (ORCPT + 99 others); Wed, 29 Nov 2023 10:31:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234907AbjK2PbV (ORCPT ); Wed, 29 Nov 2023 10:31:21 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D02CD6E; Wed, 29 Nov 2023 07:31:27 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 980B2E0012; Wed, 29 Nov 2023 15:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701271886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ONeuGYPs2IMgsIBQkR63Bawpq/9TA/sG6QW/wej75m4=; b=BO10/zqYJKqTCTIriRT9JmPYFVTsWtcA7KqYL7K/1BHkPPd1Xn0YV9WLZVcrbte4oXJ2t5 3yPSNaxWnpuWxT/A/2D2eVv/dIWO5zasx3T0t64s3Yj6FmsKEAE9y5lN+X7hL+eZrye8NF xkapT2x0QOo5fK3O2yfX6sJo38ukCLlKiAf2Y7brH8S8iwQC2oH8hgCG4TXlO4V72aIQsd roI5ybfc38SLcyjs2xBIR2XOgXfHQtbegtMgxm+pcQNyM8DNq2Qa6Yt5psl0+3Qt7agspG vwaOIprv1oFe5JB3R6Mwc5LCySr4SG8rjNzBhjIWr1LzOig16YdDNBxyDGLmLQ== From: Thomas Richard Date: Wed, 29 Nov 2023 16:31:20 +0100 Subject: [PATCH 4/5] firmware: ti-sci: for j7200 before suspend check the reserved memory for lpm MIME-Version: 1.0 Message-Id: <20231129-j7200-tisci-s2r-v1-4-c1d5964ed574@bootlin.com> References: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> In-Reply-To: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vignesh Raghavendra Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:31:45 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783912900704337832 X-GMAIL-MSGID: 1783912900704337832 On j7200, a reserved memory region is needed for TF-A to save its context during suspend to ram. In ti-sci suspend, check if the region was defined, if not return an error. Signed-off-by: Thomas Richard --- drivers/firmware/ti_sci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index c26ec86a5ff2..deaca17322df 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -77,6 +77,8 @@ struct ti_sci_xfers_info { * simultaneously in the system * @max_msg_size: Maximum size of data per message that can be handled. * @restore_irqs: Set to true if allocated irqs shall be restored at resume + * @lpm_region: Set to true if a reserved memory region is needed for suspend to + * ram */ struct ti_sci_desc { u8 default_host_id; @@ -84,6 +86,7 @@ struct ti_sci_desc { int max_msgs; int max_msg_size; bool restore_irqs; + bool lpm_region; }; /** @@ -3359,6 +3362,32 @@ static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode, return NOTIFY_BAD; } +static bool ti_sci_check_lpm_region(void) +{ + struct device_node *parent, *node; + + parent = of_find_node_by_path("/reserved-memory"); + for_each_child_of_node(parent, node) { + if (of_node_name_eq(node, "lpm-memory")) + return true; + } + + return false; +} + +static int __maybe_unused ti_sci_suspend(struct device *dev) +{ + const struct ti_sci_desc *desc = device_get_match_data(dev); + + if (pm_suspend_target_state == PM_SUSPEND_MEM && + desc->lpm_region && !ti_sci_check_lpm_region()) { + dev_err(dev, "lpm region is required for suspend to ram but is not provided\n"); + return -EINVAL; + } + + return 0; +} + static int __maybe_unused ti_sci_resume_noirq(struct device *dev) { const struct ti_sci_desc *desc = device_get_match_data(dev); @@ -3387,6 +3416,7 @@ static int __maybe_unused ti_sci_resume_noirq(struct device *dev) } static const struct dev_pm_ops ti_sci_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(ti_sci_suspend, NULL) SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(NULL, ti_sci_resume_noirq) }; @@ -3419,6 +3449,7 @@ static const struct ti_sci_desc ti_sci_pmmc_j7200_desc = { .max_msgs = 20, .max_msg_size = 64, .restore_irqs = true, + .lpm_region = true, }; static const struct of_device_id ti_sci_of_match[] = { @@ -3546,6 +3577,11 @@ static int ti_sci_probe(struct platform_device *pdev) } } +#ifdef CONFIG_PM_SLEEP + if (desc->lpm_region && !ti_sci_check_lpm_region()) + dev_warn(dev, "lpm region is required for suspend to ram but is not provided\n"); +#endif + 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 Wed Nov 29 15:31:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 171439 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp418912vqn; Wed, 29 Nov 2023 07:32:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFDa3w7RsGcWEc903agzdcP6UBZMeuGUdu56027gRqk7hVLutV7uW3v4AYvCwntCLS67pE X-Received: by 2002:a05:6870:9e81:b0:1f9:46c8:b64a with SMTP id pu1-20020a0568709e8100b001f946c8b64amr27102911oab.24.1701271923050; Wed, 29 Nov 2023 07:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271923; cv=none; d=google.com; s=arc-20160816; b=R9Ti18B0x3uhHqk5esiYg+faB5XjvIIDfepJlsHn1n4bNSGW5OAzHGFIfE59ksKgub Aq03AkLA7LnpKZiEB3oPBTnNzOjGmHwIlhzAL0yjOJ8aYbnyj04jQXX0D/fGOUulFqaC mKmfWo4FKCn6J1pBRGAispqZ9PDvgVTN6riNF7cU+siYlil7ZdVW6yyDhuW5hxskzxc+ 5dBlNXG1RdD6M1OWqSgWhqouGY6rPFeAa8BCsirdWFzzzHgZGuwMuwDTUQcfZT8iLXkV r6BDntW8a1guA3n3n0C0xBaAJ9RD12S0fXUsMcN4aThef+OC3vhAck2iVNy6CPUV0rLP fVvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=n6Se7MgTLDlVPsmnv481wC76UKLsZL7lpNqEMlGZzy0=; fh=qiuiZXOuSBoCezToil2F5RBR95PkXWcuBaEpicqga+E=; b=n5vfrZAD4AnmPR9Vh0wgp939tpJVzmhXXWtEVKwr90U/Cjdgov82l2U00xiEJxPUln OOGG83V+JVrHW5ZtgKrjxCYzbUtUKmu0ld+vu7PgrEVlTBYwEqMQcYahwQZn9rVA7i5u tf0UvxSjttbMdHx9CMz52wVlfZ+o6bnq7UnZSslD99LdTj+r9/WA8Iww+hdEAjwCDoNc D3B/Xzhtrtv8DwhiSAzgNdz1ca6MaiHQNoY5SKZmv3ZTDM8gAzVQ571RqP1RxQDZypmi Ha049CcToCN9yNkIOi0GG01b1P5iwfxHtXKb9W4ZEGFxRVY3ubcGlZU4iXdJ/dzNZHoI ZFVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="IAr/fyUw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id cz7-20020a056870648700b001fa0c4ddd3esi4569035oab.102.2023.11.29.07.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:32:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="IAr/fyUw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 21E3D808EDFD; Wed, 29 Nov 2023 07:32:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343771AbjK2Pbd (ORCPT + 99 others); Wed, 29 Nov 2023 10:31:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234918AbjK2PbV (ORCPT ); Wed, 29 Nov 2023 10:31:21 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF4E8D6F; Wed, 29 Nov 2023 07:31:27 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 340CDE000A; Wed, 29 Nov 2023 15:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701271886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n6Se7MgTLDlVPsmnv481wC76UKLsZL7lpNqEMlGZzy0=; b=IAr/fyUww18EgY4GKsHZMYeVTdK+cveCDjQkTAmKmYQJpAQ7V63VUI9w7uU7LnDdhJ++6s dswp7Ew+Zg2jg5CZ6Spu6PDvXR+wXPIizzILSrhOIIRTH348R5T8oNbB0qw9s1hJRTqFdV 2Fy+7NThE7UTzrSf0si2wpYZf8E9T0LpEFGHklB76X5DCOqK1OrBEAMdRHaIW5bIgqCctX oWBJ5zufnZ+o9VcXTxrrzf5pGoqf2q7bRqpUHmsMx/5lsiRj2JVK0yEGnZy+kq8fjMv+Pg i45A8YVchsERATCQniJ8Nm2udPMXvwziQDnejef9/H38zCbu3qbps28oEgypgA== From: Thomas Richard Date: Wed, 29 Nov 2023 16:31:21 +0100 Subject: [PATCH 5/5] arm64: dts: ti: k3-j7200: add reserved memory regions for lpm MIME-Version: 1.0 Message-Id: <20231129-j7200-tisci-s2r-v1-5-c1d5964ed574@bootlin.com> References: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> In-Reply-To: <20231129-j7200-tisci-s2r-v1-0-c1d5964ed574@bootlin.com> To: Nishanth Menon , Tero Kristo , Santosh Shilimkar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vignesh Raghavendra Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, gregory.clement@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:32:00 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783912907947526244 X-GMAIL-MSGID: 1783912907947526244 Two memory regions are reserved for suspend to ram on j7200. One is dedicated to TF-A, it uses this region to save its context during suspend. The second region is for R5 SPL, which uses it for its stacks and to store some firmware images. These regions are reserved from the linux point of view to avoid any memory corruption. Signed-off-by: Thomas Richard --- arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi b/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi index 5a300d4c8ba0..dc8c9c3e8443 100644 --- a/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi +++ b/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi @@ -79,6 +79,16 @@ rtos_ipc_memory_region: ipc-memories@a4000000 { alignment = <0x1000>; no-map; }; + + lpm_r5_spl_ctx_ddr: lpm-memory@a5000000 { + reg = <0x00 0xa5000000 0x00 0x1000000>; + no-map; + }; + + lpm_bl31_ctx_ddr: lpm-memory@a6000000 { + reg = <0x00 0xa6000000 0x00 0x20000>; + no-map; + }; }; };