From patchwork Wed Nov 9 10:45:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sherry Sun X-Patchwork-Id: 623299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23C56C433FE for ; Wed, 9 Nov 2022 10:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231247AbiKIKrP (ORCPT ); Wed, 9 Nov 2022 05:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231199AbiKIKrM (ORCPT ); Wed, 9 Nov 2022 05:47:12 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80052.outbound.protection.outlook.com [40.107.8.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0785824099; Wed, 9 Nov 2022 02:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b4t67VVuRFeUDY6FfzVJo/OgFiNerdcMxbmqyRsBEI/ixBQeuvrDMlEYB2OEQ6NmOIbrxufCtzDSl0TF6zEkcC/4fWpNaWGM3hGM1pUXO9oCGJxGnwOqc/tACdHXmvGeUIIq/brtMNuS5Io6rr7yErNGzVdMA1SFtqqZtln4XmhXWHBISIeuxHK9VQ8y/GFtMz5FOwTi7G66qwjT11w4qls6KYaxOclYsvn2aSaF6K1QJFu5usWx47zp6rHlpp0hJKsJSRdqTkQdZXOZOysKA2Ppd6Qk+5v82GqjCc+zzQCEIVO1rawenctJuwaimG/xYaCNE42YMqIMJ4ANT1kPrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a75+bEwNy1nTGQmnjrn2PlnFepRP7Rt9WT0OsQZt+ew=; b=P7FqeI46gnncWKlKFu3c7nS7bqBGIWrQJKZzYRm9Ded5otfL3NDOUL/bGqwYpb/wwIBCq5p2SfMKL3AC6RyBkn4w5Luz7kZXoRrVbbi47cvjxbwZBDrTbzMmH/2Lst/8fdPK+h5UCJq3zIyfd1tKzVIasPvlGNrqLnFHNpBRoCzsyezDJLjrrFg30+nGV/DBQoZCveD5RtISylCPGJ183bbznucbWs/ns/jvD9Gy6l8Mr38aiPVuZDImtXwpI0tfqIlMIs5ohrhGaRCi83gA4PtelVf08X5okyofBmTwpM7C1w9tuOYBWaBWOaT74eX7dw6gYAH4eaPKxx492QuDxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a75+bEwNy1nTGQmnjrn2PlnFepRP7Rt9WT0OsQZt+ew=; b=FuZSmpGk9cwA4FImuRzygFKpgH3ZCNzhO4yQBk+HyORfv/vjanNi3sDsOZqGu6FgAtCzD0iDAmVK91NSk/XKRCWXb+qA0uclAL8zYIMEwglbYzMFmBtUt2FykZTiZMuY2KQ3ENNAQkj3MMYJDMrwTFV0O3wWU+RtmlT7lJ8i7i0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) by PAXPR04MB8974.eurprd04.prod.outlook.com (2603:10a6:102:20d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Wed, 9 Nov 2022 10:47:03 +0000 Received: from AS8PR04MB8404.eurprd04.prod.outlook.com ([fe80::71f1:f7bb:5039:e55d]) by AS8PR04MB8404.eurprd04.prod.outlook.com ([fe80::71f1:f7bb:5039:e55d%3]) with mapi id 15.20.5791.027; Wed, 9 Nov 2022 10:47:03 +0000 From: Sherry Sun To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH 1/2] tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma case Date: Wed, 9 Nov 2022 18:45:14 +0800 Message-Id: <20221109104515.17266-2-sherry.sun@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221109104515.17266-1-sherry.sun@nxp.com> References: <20221109104515.17266-1-sherry.sun@nxp.com> X-ClientProxiedBy: SI2PR02CA0009.apcprd02.prod.outlook.com (2603:1096:4:194::11) To AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8404:EE_|PAXPR04MB8974:EE_ X-MS-Office365-Filtering-Correlation-Id: 16cd4161-2c8a-402a-e928-08dac23fbd08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7BuzLHnUEDzxnhBAweJhsVGHabn7Naje3smdaxfnh2f0oUYwxjn39tuvWajx8pAslzynUMcnwLv7H+XccrDURlrLv73NYd69nbzu4nRJrsgAiZAw3hcOPvZmg9q+przrd7j4g0szcjGAKNAyXmRRG35pXYwk0t/fbokE1nFwtR8WmcCn3caWc/jweElrmVUaIjN/DAetby6rxhOHM8n74daimjiyXr52U5v87cq4qS79hCwByMXVy5W83H+PbyYmVi//wlWb8YjzeIkUSWveHptYO4JFB0j0XGVmhAFobf4BsHq45TQwZm3lbzyxFhgb2gdU8Rg2yRjiPyO37VWvTd6fwlOC7ZF9h1lqfn3EF+BaIWlWe2QgFhsW2AOR9ZNsDlgxkRSRfRU+vT2Z2+n3Tn5Q1181tv+rx1mSVAiNOtTTXB4ru6faoQ7vsCXHfKshVvv8j5XZBllyD3GUkP+eoJba40c5Gq5h+0F2XHHbQlRWKXjO0ur5JoeIpvqfU9iuM4GS1hwmJRMVtUFc7ys37JqOrUuYxIBr38v3mrqqv2MPejPdKoWsVLZxFW6my1tzKgzCY6UkBES05MOQ+jmz42wI+439RF/xvmVYEVeKRkMaTa5r9mwExqJYEdXbTbF6c17ZKFycYJmzrQ14QafvcAgMTYeOQ6MkkpdV/qMYX16WDxPQujOsWXTZdQiad9MvHDwSTb5s+GEgtmHmr/Vg8g5QpjEpc7OQHGSukPvMsthOk3WcKNbyVRVnCVSs9S+mWnruKJujHl3++Lpx7R9QYQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8404.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(346002)(396003)(376002)(136003)(39860400002)(451199015)(186003)(86362001)(38100700002)(38350700002)(316002)(66476007)(66556008)(66946007)(8936002)(8676002)(2906002)(44832011)(41300700001)(6666004)(4326008)(26005)(52116002)(1076003)(2616005)(6506007)(83380400001)(5660300002)(6512007)(6486002)(478600001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IIqyeZr7oQ6qIgZUUf9NEbEw10rElc2AZWeJnUPy6/KYg0C10usMs2is/vSaIaVef5E6zgIOQGjpyGGJOKa7NKdsv2DVPk1JLHkh15ZjpHhkv1vaY5lZPxzGGz/LAa4SMVbflxcJjmsj/3NxaGf+oTZGL5afsJopm1YpyoUUhX4umoGcRfZoLJ5ZIZV3z67hrMAjsOpCrK5skNMwpxymj8CD4IDDcjIksNSutZzPGEgA4DyyZvfyQqxzmFMsVUklXtibjZlABhIQ2IstHJzgyZUaAVyttQr5l1P6LjECnsqMx7y1epAmDuc2Yl68z1KPoJhb+0gEOibnM/kiwEZG+hsUqdbpiorwkAQMN+oG2uWkLuIP//J5qltzPla6zGcKW5GxXtI0pAgFk3KpeOWZruZmMxFCPOjFH+hG+u8JtDVGHssOhlR4KUB5LhgkauuMeKZCLjzUKT4AN37MwOubHMZnAC/fgRYYVcCaYmYPoEOZGd3+6sS+YUIYPcwnLunzS7htCfoG2K7vI+7HDdqEfvMqnpzxcKTx0aPqh6GSF8H9cLswX31KKr4+1DmHUavPj1Lt+gnOsm2333CNIBG34FCFH7acsb6dmongXZJOdjkGptYuf2800nRadszRbENTKdS+hRVmqtMPmhaGE1cPSa0lkRki3K/wZHGTCZ4dZi3JfEohX+DE0r5IKmNAww23RY7VP18SG++DCQV/58Hn1UsdKsZgRNium3J8z020lw448uSmM0ST+jUftcrRRPELpw4Boe66d+wxyfdVOHEe2YVhfO7WDZ/VCAgsuCc5G0sU2ZC0giAps5O32aFqCE/E/KaE1MsAt4SCbi/BqbJiZ2oHyaYac9Mb2dx9Ph91RouYL3i3dJ/45LF+/5cUxhGk5MAaCsJyA+aODO3K4GIw3M/VVh2lppIBNsQQZ5Gk2mwaf8qQVtwZ1Y2lE+aUYzACkoaMAub7SU2rxX9lG4+9aTgbajPCU4xgeMmk64Hrb2pWr8YE10Ck7CsryjawnNLmJ0wBvUkbHuPhdiCFvfW1/ThcVA0Q0xN1t2EePlRPkes41j7RhFsv/r8wDSGA8czrRqiG5gVFHYmHcjCd2+d/SKSWt5fqOeEa8xZtlJxgOZL4znfMKPjeFQX3E9zD6g2ofFORbDrHY06OIiBTRjRGdP6TJVkEVD2uDqkYMO/+CGheEVoqQjf9Z4J/DhjatzeiJaSJgwpGMgvdwRz3ms0iIPkoVBk+3nmObyO1xkFg8LgU+KN+Sd63Hz1+YsIX10JMtvCVQ4wfDniNkhF29ARAhDak23zi0jQdiyfYj2SApmmDD/vw2KTOGnEPQL44DcfdXjnCEK3J/X8ovATFXaOqZ385D47T1EZ6lzMjzRzDDCJ5zs6+9rmnDv29yRkRsKmyTPH/hZ8CQXv8oNA0+JQjeQRejEJm2T9ha98CyO0NpH/6TpwvgAukkyd+ZFRokehvuKdrRFeDPiz73DIKl9MzjBHfxoyRngrq+WKFqcaris3/jdeIVMh3NXcaIjU5pjssjieklSP86GCqsc4Qcq+/dfqH/D0s4iDFoFK3C5JAYPVfVKx7TxV6OXYy2fWUiLBM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16cd4161-2c8a-402a-e928-08dac23fbd08 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8404.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:47:03.8583 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XSH5PoonnVg4wWEg6mNs+ALfSm+dUCtJwWLIS4D9ilSEwBjRKhOgeiKfNgGc0LF+5KAEDY2z/9yczNSz/AdVIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8974 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org For the lpuart driver, the Idle Line Interrupt Enable now is only needed for the CPU mode, so enable the UARTCTRL_ILIE at the correct place, and clear it when shutdown. Also need to configure the suitable UARTCTRL_IDLECFG, now the value is 0x7, represent 128 idle characters will trigger the Idle Line Interrupt. Signed-off-by: Sherry Sun --- drivers/tty/serial/fsl_lpuart.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index bd685491eead..f5a0a14fa366 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -179,7 +179,7 @@ #define UARTCTRL_SBK 0x00010000 #define UARTCTRL_MA1IE 0x00008000 #define UARTCTRL_MA2IE 0x00004000 -#define UARTCTRL_IDLECFG 0x00000100 +#define UARTCTRL_IDLECFG_OFF 8 #define UARTCTRL_LOOPS 0x00000080 #define UARTCTRL_DOZEEN 0x00000040 #define UARTCTRL_RSRC 0x00000020 @@ -230,6 +230,8 @@ #define GLOBAL_RST_MIN_US 20 #define GLOBAL_RST_MAX_US 40 +#define UARTCTRL_IDLECFG 0x7 + /* Rx DMA timeout in ms, which is used to calculate Rx ring buffer size */ #define DMA_RX_TIMEOUT (10) @@ -1506,7 +1508,7 @@ static void lpuart32_setup_watermark(struct lpuart_port *sport) ctrl = lpuart32_read(&sport->port, UARTCTRL); ctrl_saved = ctrl; ctrl &= ~(UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_TE | - UARTCTRL_RIE | UARTCTRL_RE); + UARTCTRL_RIE | UARTCTRL_RE | UARTCTRL_ILIE); lpuart32_write(&sport->port, ctrl, UARTCTRL); /* enable FIFO mode */ @@ -1530,7 +1532,8 @@ static void lpuart32_setup_watermark_enable(struct lpuart_port *sport) lpuart32_setup_watermark(sport); temp = lpuart32_read(&sport->port, UARTCTRL); - temp |= UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE; + temp |= UARTCTRL_RE | UARTCTRL_TE; + temp |= UARTCTRL_IDLECFG << UARTCTRL_IDLECFG_OFF; lpuart32_write(&sport->port, temp, UARTCTRL); } @@ -1669,7 +1672,7 @@ static void lpuart32_configure(struct lpuart_port *sport) } temp = lpuart32_read(&sport->port, UARTCTRL); if (!sport->lpuart_dma_rx_use) - temp |= UARTCTRL_RIE; + temp |= UARTCTRL_RIE | UARTCTRL_ILIE; if (!sport->lpuart_dma_tx_use) temp |= UARTCTRL_TIE; lpuart32_write(&sport->port, temp, UARTCTRL); @@ -1770,7 +1773,7 @@ static void lpuart32_shutdown(struct uart_port *port) /* disable Rx/Tx and interrupts */ temp = lpuart32_read(port, UARTCTRL); - temp &= ~(UARTCTRL_TE | UARTCTRL_RE | + temp &= ~(UARTCTRL_TE | UARTCTRL_RE | UARTCTRL_ILIE | UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE); lpuart32_write(port, temp, UARTCTRL); From patchwork Wed Nov 9 10:56:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sherry Sun X-Patchwork-Id: 623297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3512AC4332F for ; Wed, 9 Nov 2022 10:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbiKIK7T (ORCPT ); Wed, 9 Nov 2022 05:59:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbiKIK7R (ORCPT ); Wed, 9 Nov 2022 05:59:17 -0500 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20629.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 331A913CDB; Wed, 9 Nov 2022 02:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CB+C9TOI08OuRXFkSdBER1gtcV5nSorVFg9cgoawJagcoinuXyrko51ZvDDF19DOtaU2WQ2fAdG2LoIci8SSfbUtTqRXzRHsBACo0dO+YfMbFKAhflOiRBu367lcro8uNilQcgTAjwMajCPV0NHtIclvHotK7h+sd1SjOJ+MVPkekgImgCuOioBoaX0ieZv3LUKSitqE3pPvgFPabBXuXXc/Zi+TSMmmIqBbRIBc/79P8XPSDXA6FfPJr7G9gP3p2swDMCyKgcAcl8sUA0+cshNIZwCqUnMKffPq3jR4kPJRn/yU300Jh7Jg4dgVaLfuUDc2ahMFMG5dE+yg0tPTjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XBqbLX6EUudZPxFb4ReckpPzBhyyGwwhFdF3x9HCgv0=; b=HprgEXzYZmtmbOo/DMXF1ToMGPyiqumVOHLRnACTIXMsHklNl8Kvj8lKeR0KJiR1sZuU7m64PybBQFFfpg0lf41IoDNLal/D0Ka6ZcDLUsqTEqzFqB3i4JB5/Z0+PEjONQlXZG3SmPu2MHzfraUHz5OWNEvfXyadIoVP0RkI5lR4b/zaFcDUPeC/jtM91eP4fMdtV0ftIC/maBYbx/zPaAKHyJB2DFcwEkEBX0ZepKZ6jOaWbHBxe9qlZSyKKhV1+fLsEU2OxVJ2jnqV1WfcIKZPsQuglizxDb/HTrqYMWqBlPzpTZEhTOzwRtkxd36M/WImhaWc2xSIFCOUQ/6ERA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XBqbLX6EUudZPxFb4ReckpPzBhyyGwwhFdF3x9HCgv0=; b=UApWVHySOGYZWxVz/+g8CMFL0Mufb5YGZF7KV0ufZTnJKMzezAUQjvMU5ZEJa9Kn9j4CJGSwA81FbFhWWYFgbkWeXo3f67bA4mxLbhyxBOuotBUFgBeakQL5jJRt4DdAEI/imKekAmZT9YfQ29UQt1KeuuLrIJu2ZMPJuqCnFYI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) by AS8PR04MB8515.eurprd04.prod.outlook.com (2603:10a6:20b:342::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.20; Wed, 9 Nov 2022 10:59:08 +0000 Received: from AS8PR04MB8404.eurprd04.prod.outlook.com ([fe80::71f1:f7bb:5039:e55d]) by AS8PR04MB8404.eurprd04.prod.outlook.com ([fe80::71f1:f7bb:5039:e55d%3]) with mapi id 15.20.5791.027; Wed, 9 Nov 2022 10:59:08 +0000 From: Sherry Sun To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH 2/2] tty: serial: fsl_lpuart: Add runtime pm support Date: Wed, 9 Nov 2022 18:56:59 +0800 Message-Id: <20221109105659.17381-3-sherry.sun@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221109105659.17381-1-sherry.sun@nxp.com> References: <20221109105659.17381-1-sherry.sun@nxp.com> X-ClientProxiedBy: SI2PR01CA0034.apcprd01.prod.exchangelabs.com (2603:1096:4:192::9) To AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8404:EE_|AS8PR04MB8515:EE_ X-MS-Office365-Filtering-Correlation-Id: b2b64579-2ea2-4092-c54a-08dac2416cb0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pL93gJFQLRXhFXyq9y//cYTiJYu67W6JQQKuetB3PzmU+iWVdNcqQqtcejtk8ru7fHHAtOxQ+h9BVJ/NTStG0wYHJZvpyVKwtS1zg4vZ06LJdnKwI8RZapaUeNud3vjmPn/l8c7bv9TwAWJbn2U2jYxWPmDOx4BG5rO4doi3qND4kk1Mbrrn/emeKr+0PlzTagOXbTG81liggTDer67sM25LaL/aXxxYo5TEA3ris3jeapplkLR6xtXuS5CYM8/Yx5iQKvXWCu9SctoRE17n1+TeiAWtlUC6rAaypLgfXyVfaxaRV3vNeswNSt2uB86GjzDp9edYHHOHHj8J9LlAzWIQqW1ZXjKAUWWPT5q0nvgB0pv4R+wBdHD0dP8YuTyR6Alg96aHvNtL6NPIQaeZ3BG9/jPk2gVHDKfILXGBeTS1C9P5qJuF6IwJTe5rh9z8ysrB2JpoUq+BRVLrUWxNYnQrPkcaSAFEFxGmMcsR0g6E/xkV5mT7JsXu7jb8GMETQ0e53htyWcpxryuuJ5DRXK8uWcdgX3ynThxoPH976y4HAO9fEla5aIwr+j9UsI1ZRSiSfu3GGuIRnVKST0puLssnZhZ3bkQvNyxv23wdlfHEEaqdxWX4OB7q/mULYtxmJU7LawZbuwF4c7PIkHx8p4p/aoxnBSMqmvvDMp/qzG14SwkGHMGsDgQJjRE2AbX6kunqIlBbCB/oJ1BClXEJBo/nnbxedQaNq8xC8AkQIGFcHjXJcaZmiuATCYs+/L6UblPxEsHfczk55jH2pqb/uA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8404.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(346002)(39860400002)(366004)(376002)(396003)(136003)(451199015)(36756003)(86362001)(44832011)(5660300002)(52116002)(2906002)(26005)(6512007)(83380400001)(38350700002)(38100700002)(1076003)(2616005)(6506007)(186003)(66946007)(66556008)(66476007)(316002)(478600001)(41300700001)(4326008)(8936002)(6666004)(6486002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i5P802hhpmtrHxL6oITDZgr1ogiE4rrh8JFV5PFmBRTx3kr0cK4Hhxng5J0rN0T0J7i+/ZvwyOVAcBezOPluAERpQRc5569E6YKi/D5gh55kdWm9pI0YqwYb0mHiw2YoyPmGLaERqGUrOWLxuLBIfHbg1xOF04FEVBgbpkY6YzomuzM5CejBWEj/fXnbBEhjxz3BdeThDGRb4rbp5j8QQaY1UeECPCt/NiRNV2G5sISVOp+/KSGFL7wO/Uy4dC/APjAYpu7m4xP/wzELYOJdsWVZn3f+z9/ekjvmUH+BrN8jf6Ec63VfuT4oUVCksqDPxWxOG2sjITUEOC3hSelLhSyn7GVXyE8Yzg17E1A33AzjuIX3x3Dszp6XsIfXs9ZezHQ8jmoOH9XPjmHcRyHbpTIynURW6OH01L8Wlxa4SOj01dlMRHBrRGEL7DqbujTFQZYSLrt6/6Ed/lmZXSFjWe9n/YMfIb12JxlRUZLCkQ72iTVQNncQiix6s9nMG3li+LAQ/dbb53CsJssFdO+QClQYojROf85ApAIdQZRRjHldJrTd+Y7fHF+dpx71c/J6k2pNPVHZjJ9v/MHOLp5fVdOeZ6pukFH9O/onQKlV+SN4U3Uvfg5Qx/9a7D/zYT5pDX5HymHV3W1w9GLEt0wSdpqiMjqZ4brYDe2zNSyPGxPD9t2BnLJ8cPrAMukzlXwIyNshkEgyhJ70t+bg1uPKalIs7H2Tpe3/E2QEX4+qWa5LBc+V+YkhlqWoQxWLKSOxg9lIn5Hlxhv8IsRsEnVBmBzmEbW5zxT+tTwgEozAYa4sEtLjduRBYFRAD2rgIW+2tkvnDG6Xs6w78ymJzNXb1X5jzKTn076a5krHw3XXy/Wv7wTsAMajjRDlcQOrecbexbTQRgu6/F0f7Vj1kX+mDpXKggIH1StRxJNmTuAnNWu4dySoCVHY4QzjFWkp1PJyy7T/iuTa+dbOf0gGwpb4hgdThg8ti0URFySVSgbFrWcMDHalcpD6yNfnmXaFYlhE2f4FL+d5RwTlEpP9lfJhjVYoIHItMO2E+7byTnqaiScFEgCaEf0kg0mt44RuSa9L2sE3JDHZFH9gyySduYDKs/ICbPVOtxn6VWlZGJxXMLCmA79QrJ2Yj8u4H1a7Kgf90wKjaD+LWxIrkAr4w2VQ66gJFTPgUUnalYBd76+n/WpLS9/Md+NO78qA7MZ85fGqmIrWSexlI9bvU9WanjkPGhKGEuWZgxy9ddonF9XpCNwJXDhcKuVGkyFGXsqgxvoyMEeQZ/jJGmIM4UC13k8kP7aK6FDWJCcXZiBEvB/a4HrDi98BFhJS0XU5PyXnIRmjfbG7wz9n1hvGcM3aCOM2gN/3oCsFLlJaIhdFkRJgwbRkBZzT1u7WeU/RCw21Pve2uBxrZCDFnWsxWFSVRoU3xccKWJl5y/a1Gb0kD5sFFhUR+5uTjET1XFNpHeX2nkLXEwl/pZNdp9cJowy8Nj8aBJxXF1YTfFG3nmBri+Ip+5548B9eIpxHjz2cUcWLIuORP/U38cTAwDvAdSMI1OCNfs5c+dyE7+48FKArXKz/6msKPf0pFjx8eCV6dbIS1ZTY X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2b64579-2ea2-4092-c54a-08dac2416cb0 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8404.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 10:59:08.0720 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cCRtx/uO/1ZD7zjzAzX0lyLav2fW2mzeAJOWCX1PtpvGCvDEDxMUvij2uaDcOymYxL7pnpXAcm9/deUjZaHuZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8515 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add runtime pm support to manage the lpuart clock. Signed-off-by: Sherry Sun --- drivers/tty/serial/fsl_lpuart.c | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 474943cb06b2..e678a7aaf7e4 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -235,6 +236,7 @@ /* Rx DMA timeout in ms, which is used to calculate Rx ring buffer size */ #define DMA_RX_TIMEOUT (10) +#define UART_AUTOSUSPEND_TIMEOUT 3000 #define DRIVER_NAME "fsl-lpuart" #define DEV_NAME "ttyLP" @@ -795,6 +797,20 @@ static void lpuart32_start_tx(struct uart_port *port) } } +static void +lpuart_uart_pm(struct uart_port *port, unsigned int state, unsigned int oldstate) +{ + switch (state) { + case UART_PM_STATE_OFF: + pm_runtime_mark_last_busy(port->dev); + pm_runtime_put_autosuspend(port->dev); + break; + default: + pm_runtime_get_sync(port->dev); + break; + } +} + /* return TIOCSER_TEMT when transmitter is not busy */ static unsigned int lpuart_tx_empty(struct uart_port *port) { @@ -2243,6 +2259,7 @@ static const struct uart_ops lpuart_pops = { .startup = lpuart_startup, .shutdown = lpuart_shutdown, .set_termios = lpuart_set_termios, + .pm = lpuart_uart_pm, .type = lpuart_type, .request_port = lpuart_request_port, .release_port = lpuart_release_port, @@ -2267,6 +2284,7 @@ static const struct uart_ops lpuart32_pops = { .startup = lpuart32_startup, .shutdown = lpuart32_shutdown, .set_termios = lpuart32_set_termios, + .pm = lpuart_uart_pm, .type = lpuart_type, .request_port = lpuart_request_port, .release_port = lpuart_release_port, @@ -2747,6 +2765,11 @@ static int lpuart_probe(struct platform_device *pdev) handler = lpuart_int; } + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, UART_AUTOSUSPEND_TIMEOUT); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + ret = lpuart_global_reset(sport); if (ret) goto failed_reset; @@ -2771,6 +2794,9 @@ static int lpuart_probe(struct platform_device *pdev) failed_attach_port: failed_get_rs485: failed_reset: + pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); lpuart_disable_clks(sport); return ret; } @@ -2789,9 +2815,30 @@ static int lpuart_remove(struct platform_device *pdev) if (sport->dma_rx_chan) dma_release_channel(sport->dma_rx_chan); + pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); return 0; } +static int __maybe_unused lpuart_runtime_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct lpuart_port *sport = platform_get_drvdata(pdev); + + lpuart_disable_clks(sport); + + return 0; +}; + +static int __maybe_unused lpuart_runtime_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct lpuart_port *sport = platform_get_drvdata(pdev); + + return lpuart_enable_clks(sport); +}; + static void serial_lpuart_enable_wakeup(struct lpuart_port *sport, bool on) { unsigned int val, baud; @@ -2937,6 +2984,10 @@ static int __maybe_unused lpuart_suspend(struct device *dev) sport->dma_tx_in_progress = false; dmaengine_terminate_all(sport->dma_tx_chan); } + } else if (pm_runtime_active(sport->port.dev)) { + lpuart_disable_clks(sport); + pm_runtime_disable(sport->port.dev); + pm_runtime_set_suspended(sport->port.dev); } return 0; @@ -2971,12 +3022,19 @@ static void lpuart_console_fixup(struct lpuart_port *sport) static int __maybe_unused lpuart_resume(struct device *dev) { struct lpuart_port *sport = dev_get_drvdata(dev); + int ret; if (lpuart_uport_is_active(sport)) { if (lpuart_is_32(sport)) lpuart32_hw_setup(sport); else lpuart_hw_setup(sport); + } else if (pm_runtime_active(sport->port.dev)) { + ret = lpuart_enable_clks(sport); + if (ret) + return ret; + pm_runtime_set_active(sport->port.dev); + pm_runtime_enable(sport->port.dev); } lpuart_console_fixup(sport); @@ -2986,6 +3044,8 @@ static int __maybe_unused lpuart_resume(struct device *dev) } static const struct dev_pm_ops lpuart_pm_ops = { + SET_RUNTIME_PM_OPS(lpuart_runtime_suspend, + lpuart_runtime_resume, NULL) SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(lpuart_suspend_noirq, lpuart_resume_noirq) SET_SYSTEM_SLEEP_PM_OPS(lpuart_suspend, lpuart_resume)