From patchwork Wed Aug 9 13:50:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Hu X-Patchwork-Id: 133293 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2864476vqr; Wed, 9 Aug 2023 08:10:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8OfPadK2y2jAeym59w6Bjwh0kiF07LEQlyDUN//rV57HNYAb35FQX0t+NG32stBRyxnVN X-Received: by 2002:a05:6a00:24c9:b0:687:f4eb:feb0 with SMTP id d9-20020a056a0024c900b00687f4ebfeb0mr2119677pfv.11.1691593835348; Wed, 09 Aug 2023 08:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691593835; cv=none; d=google.com; s=arc-20160816; b=mn1FKmP4UTRL86Gj8+BKz48Wp50fsv7JnBuRpy42IEV8kaNrYYOksqYVwSPnG+j4En cJd513GKczH+TG6ure5bQe0QN4pqQkTTNoOOYlaKa70DV9M2Zua5euT2KbGbEjeJxJA5 uNduF7GCM/OywNrzQSw5iGFFDF/pZcrEbJLI98Q/RzHeSkBsr79u/rTYLve93P7yqabX t/d8Q+ts/tzNc1IN/bdBubXbOkcEKH60p2OUMytkd3TGSX+OiC9jo1fFBIcQMYd/vzqG qz83DCYua9FhsT54Ln38vEZYWM6znVMQRlXDTorGfdcqysDUWu34xg+DwCJFcFEyWkiy BuNg== 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=s8zD96bw4rkncguyqlSPtv0gB2rgXdSIasM/kJ2Pb24=; fh=Rh6HoUsLduznJ0CVztCKN7xrzTKc1QihDW5l2uysiPw=; b=ueQwl4hYv9L3SqBVJv1MJtIsYcsudeD4eg7kNLh8yGDR0pckNw6qsHjyfkYQZk1YKn ItDfGAD54PWsJ+aHu7EbY173yDb+by4bQmTg9bw/IQM6OY5vHv3eW9W6bt1qbz4io9gL 1HbPGTc4VMvmk9BAGD4xoZj0PMMME3Er9B/Xo11bksIJ/FJyeCa/qbWQYcOyjUuDqBSC dzIex2nI+p18aAoIXIP0HoKM3AoxGyYeUFqNs5dadMUdXIDUX6nW9KRVR5tpuhkAHCjc M5/cIUltIQ/hsNo8nDeaIO0XydmCgfc/GV6PXdSK20dJDSF43Tfp7/QBQ9/Bh2rZ5Guf IKGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Dxbp2YMn; 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=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 139-20020a630091000000b00563dde13952si9251747pga.720.2023.08.09.08.10.21; Wed, 09 Aug 2023 08:10:35 -0700 (PDT) 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=@sifive.com header.s=google header.b=Dxbp2YMn; 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=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbjHINvU (ORCPT + 99 others); Wed, 9 Aug 2023 09:51:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231164AbjHINvT (ORCPT ); Wed, 9 Aug 2023 09:51:19 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B98712106 for ; Wed, 9 Aug 2023 06:51:18 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-268299d5d9fso3604600a91.1 for ; Wed, 09 Aug 2023 06:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1691589078; x=1692193878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s8zD96bw4rkncguyqlSPtv0gB2rgXdSIasM/kJ2Pb24=; b=Dxbp2YMn7sEEInQkq3Tx3bNagvXpt51+BczEsYwWdT4h8B5cSftkC0XtHfDYAH0/ND jBpYPBHSCCAoV2bu3BiweHCvfH+Mc514Dwc1B0vXXbVboRfRmYsawGlJi9eECwZAgF2e aV9POh06RhXEIm3jLfHDBpXKeM0Jy8s8LpwNDAYdTWkxYYh3sNy/ycHvABG0AoE6WiuM 5qWH32aJERfsumUVzLLBTManicMF7gHyJ+LMEOBi+mWokJ0/EnGJUFnaaSQvEURCPfpY rKFHLOyAZFZkr/xpM2sYkmBte/3qwLrhgZgltS+0voR81ELbQBfSrd1CE/rFOY3FHCTY QHUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691589078; x=1692193878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s8zD96bw4rkncguyqlSPtv0gB2rgXdSIasM/kJ2Pb24=; b=kIMXJ1Rshhes1fZ7oNjtMbx7VGMjQXqITTZDH4rqMW3Q+EHx9fI9ZL/5LzqugqmcCJ XtYE63wCv3SQoKFKChPTH1jW4RqGE7UZaKW6Ekv5TwVF0f9p4fedwZhouzxKwl73xE6I vvkfDmmpm+p0syzny6f+ynftqJC3q6H9UZmQiN5AdBjUvVUDmDXWcQuE46DWpwC2FMlv NhCtzqJmseQeXiZvXL1DU7kufi4bQ+WYvLj7A4gykwS5LvCHC6dgTuZWWJmZteCleji/ PDWWR5Y4o2drsHSmA166WQm1JgU5bFMSb7fkYjBzA4yVql6zM7TEYJKwE5MA0525qQ5J j07A== X-Gm-Message-State: AOJu0Yw+QmsjRaORljPmB/OcEnSlVbmPJBfWPXfdt/S+WVPeRcQBeslc FjHvh2BPsaOalJdt9jtbOSB5QQ== X-Received: by 2002:a17:90b:3444:b0:268:c569:f2af with SMTP id lj4-20020a17090b344400b00268c569f2afmr2005669pjb.7.1691589078233; Wed, 09 Aug 2023 06:51:18 -0700 (PDT) Received: from work.. (1-161-169-231.dynamic-ip.hinet.net. [1.161.169.231]) by smtp.gmail.com with ESMTPSA id p12-20020a17090a284c00b00262ca945cecsm1542677pjf.54.2023.08.09.06.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 06:51:17 -0700 (PDT) From: Nick Hu To: nick.hu@sifive.com, zong.li@sifive.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Ben Dooks Subject: [PATCH v2 1/1] serial: sifive: Add suspend and resume operations Date: Wed, 9 Aug 2023 21:50:42 +0800 Message-Id: <20230809135042.2443350-2-nick.hu@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809135042.2443350-1-nick.hu@sifive.com> References: <20230809135042.2443350-1-nick.hu@sifive.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773764697140222908 X-GMAIL-MSGID: 1773764697140222908 If the Sifive Uart is not used as the wake up source, suspend the uart before the system enter the suspend state to prevent it woken up by unexpected uart interrupt. Resume the uart once the system woken up. Signed-off-by: Nick Hu Reviewed-by: Ben Dooks --- drivers/tty/serial/sifive.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c index a19db49327e2..939dd351a058 100644 --- a/drivers/tty/serial/sifive.c +++ b/drivers/tty/serial/sifive.c @@ -1022,6 +1022,23 @@ static int sifive_serial_remove(struct platform_device *dev) return 0; } +static int sifive_serial_suspend(struct device *dev) +{ + struct sifive_serial_port *ssp = dev_get_drvdata(dev); + + return uart_suspend_port(&sifive_serial_uart_driver, &ssp->port); +} + +static int sifive_serial_resume(struct device *dev) +{ + struct sifive_serial_port *ssp = dev_get_drvdata(dev); + + return uart_resume_port(&sifive_serial_uart_driver, &ssp->port); +} + +DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend, + sifive_serial_resume); + static const struct of_device_id sifive_serial_of_match[] = { { .compatible = "sifive,fu540-c000-uart0" }, { .compatible = "sifive,uart0" }, @@ -1034,6 +1051,7 @@ static struct platform_driver sifive_serial_platform_driver = { .remove = sifive_serial_remove, .driver = { .name = SIFIVE_SERIAL_NAME, + .pm = pm_sleep_ptr(&sifive_uart_pm_ops), .of_match_table = of_match_ptr(sifive_serial_of_match), }, };