From patchwork Tue Oct 15 06:11:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akash Asthana X-Patchwork-Id: 11189717 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 706291390 for ; Tue, 15 Oct 2019 06:11:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B5D620854 for ; Tue, 15 Oct 2019 06:11:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="iKT3tdEd"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="LDEUVV9+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726648AbfJOGLg (ORCPT ); Tue, 15 Oct 2019 02:11:36 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38164 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfJOGLg (ORCPT ); Tue, 15 Oct 2019 02:11:36 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2847060B7A; Tue, 15 Oct 2019 06:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1571119895; bh=CL5p7UDYzcCYK5CH6ddtzm9DcIuN04km1NLtYfXgE4M=; h=From:To:Cc:Subject:Date:From; b=iKT3tdEdCufXlR1O33WHeI6u6ch0XEgyzMMr+fPcf/CkfQbNra2Hu3lI5W1EzDdN+ 0+755bejGci9/pMh5Net3um6sPRHKDRfQVr+Fd64Czg+HHdqja7mFpqfVfkkeGm74s d8xXd9OZ77eplEumfZIWQaKsT2v4gndfZqLjje4w= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from akashast-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: akashast@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 64ECE60A23; Tue, 15 Oct 2019 06:11:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1571119894; bh=CL5p7UDYzcCYK5CH6ddtzm9DcIuN04km1NLtYfXgE4M=; h=From:To:Cc:Subject:Date:From; b=LDEUVV9+9TWYGJBmkz/gus0R18+pTHSvp7fMOFauZcRNxMC8WjTr8eMVcfnDbA8YH HxHNy+SPoY2ANL3CHJjVVWUbWZuMMdaryzV+5WDsODVOPMzmbQGjSNaCEvF8sGuQ50 KZvO8PuKtzxRlXm2ZYwEtUA3b3viXvltyCYuVx74= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 64ECE60A23 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=akashast@codeaurora.org From: Akash Asthana To: gregkh@linuxfoundation.org Cc: linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, mgautam@codeaurora.org, bjorn.andersson@linaro.org, swboyd@chromium.org, msavaliy@codeaurora.org, Akash Asthana Subject: [PATCH v3 1/2] tty: serial: qcom_geni_serial: IRQ cleanup Date: Tue, 15 Oct 2019 11:41:03 +0530 Message-Id: <1571119863-14105-1-git-send-email-akashast@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Move ISR registration from startup to probe function to avoid registering it everytime when the port open is called for driver. Signed-off-by: Akash Asthana --- Changes in v3: - Address review comments on v2 patch. - Using devm_kasprintf instead of scnprintf API. drivers/tty/serial/qcom_geni_serial.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 14c6306..12dc007 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -101,7 +102,7 @@ struct qcom_geni_serial_port { struct uart_port uport; struct geni_se se; - char name[20]; + const char *name; u32 tx_fifo_depth; u32 tx_fifo_width; u32 rx_fifo_depth; @@ -830,7 +831,7 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport) if (uart_console(uport)) console_stop(uport->cons); - free_irq(uport->irq, uport); + disable_irq(uport->irq); spin_lock_irqsave(&uport->lock, flags); qcom_geni_serial_stop_tx(uport); qcom_geni_serial_stop_rx(uport); @@ -890,21 +891,14 @@ static int qcom_geni_serial_startup(struct uart_port *uport) int ret; struct qcom_geni_serial_port *port = to_dev_port(uport, uport); - scnprintf(port->name, sizeof(port->name), - "qcom_serial_%s%d", - (uart_console(uport) ? "console" : "uart"), uport->line); - if (!port->setup) { ret = qcom_geni_serial_port_setup(uport); if (ret) return ret; } + enable_irq(uport->irq); - ret = request_irq(uport->irq, qcom_geni_serial_isr, IRQF_TRIGGER_HIGH, - port->name, uport); - if (ret) - dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret); - return ret; + return 0; } static unsigned long get_clk_cfg(unsigned long clk_freq) @@ -1297,11 +1291,25 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS; port->tx_fifo_width = DEF_FIFO_WIDTH_BITS; + port->name = devm_kasprintf(uport->dev, GFP_KERNEL, + "qcom_geni_serial_%s%d", + uart_console(uport) ? "console" : "uart", uport->line); + if (!port->name) + return ERR_PTR(-ENOMEM); + irq = platform_get_irq(pdev, 0); if (irq < 0) return irq; uport->irq = irq; + irq_set_status_flags(uport->irq, IRQ_NOAUTOEN); + ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr, + IRQF_TRIGGER_HIGH, port->name, uport); + if (ret) { + dev_err(uport->dev, "Failed to get IRQ ret %d\n", ret); + return ret; + } + uport->private_data = drv; platform_set_drvdata(pdev, port); port->handle_rx = console ? handle_rx_console : handle_rx_uart; From patchwork Tue Oct 15 06:11:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akash Asthana X-Patchwork-Id: 11189719 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF6331390 for ; Tue, 15 Oct 2019 06:12:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F62D21835 for ; Tue, 15 Oct 2019 06:12:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="GAWQEMMd"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="I70IZCx+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbfJOGMD (ORCPT ); Tue, 15 Oct 2019 02:12:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38380 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfJOGMD (ORCPT ); Tue, 15 Oct 2019 02:12:03 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7C04160B7A; Tue, 15 Oct 2019 06:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1571119921; bh=AmviZLY1yO1BoNAicdI+IEyxLpIEuPt8OV83BGe+L6I=; h=From:To:Cc:Subject:Date:From; b=GAWQEMMdimtV9dsi3uYiJg0tNffz07Mz+nEZX+H1VxUyCpiVeaFNcyyXh6TjEatfa 8KAVOSwi4Gael+xRSxvI6dF7/qpbBu9r6hsPedZaxPMNAuPTpSGWOw78VaMv+JnXrv r+CuJTbnI4L6dfvU2nwoiR2lTRFuxhCQF+ws+gS8= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from akashast-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: akashast@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A225D607EF; Tue, 15 Oct 2019 06:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1571119920; bh=AmviZLY1yO1BoNAicdI+IEyxLpIEuPt8OV83BGe+L6I=; h=From:To:Cc:Subject:Date:From; b=I70IZCx+ehUk5nsiRkkOwFO8YoOOYkMOvpLdtUaO+U5ghHNXclcnvGCcdPwaFiS99 NRxT70CQoYZFtEB9cmf/s1Kg+9IXiUXfYi4BAYiK5zmr428vki7jof8E+opV61WMKQ F8H0WgB4kgU6tW9rISuLCEgFqlOY4eczmBWShZ9I= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A225D607EF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=akashast@codeaurora.org From: Akash Asthana To: gregkh@linuxfoundation.org Cc: linux-arm-msm@vger.kernel.org, linux-serial@vger.kernel.org, mgautam@codeaurora.org, bjorn.andersson@linaro.org, swboyd@chromium.org, msavaliy@codeaurora.org, Akash Asthana Subject: [PATCH v3 2/2] tty: serial: qcom_geni_serial: Wakeup over UART RX Date: Tue, 15 Oct 2019 11:41:42 +0530 Message-Id: <1571119902-14169-1-git-send-email-akashast@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add system wakeup capability over UART RX line for wakeup capable UART. When system is suspended, RX line act as an interrupt to wakeup system for any communication requests from peer. Signed-off-by: Akash Asthana --- Changes in V3: - Address review comments on v2 patch. drivers/tty/serial/qcom_geni_serial.c | 44 ++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 12dc007..bc828e49 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -116,6 +117,7 @@ struct qcom_geni_serial_port { bool brk; unsigned int tx_remaining; + int wakeup_irq; }; static const struct uart_ops qcom_geni_console_pops; @@ -755,6 +757,15 @@ static void qcom_geni_serial_handle_tx(struct uart_port *uport, bool done, uart_write_wakeup(uport); } +static irqreturn_t qcom_geni_serial_wakeup_isr(int isr, void *dev) +{ + struct uart_port *uport = dev; + + pm_wakeup_event(uport->dev, 2000); + + return IRQ_HANDLED; +} + static irqreturn_t qcom_geni_serial_isr(int isr, void *dev) { u32 m_irq_en; @@ -1310,6 +1321,29 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) return ret; } + if (!console) { + port->wakeup_irq = platform_get_irq_optional(pdev, 1); + if (port->wakeup_irq < 0) { + dev_err(&pdev->dev, "Failed to get wakeup IRQ %d\n", + port->wakeup_irq); + } else { + irq_set_status_flags(port->wakeup_irq, IRQ_NOAUTOEN); + ret = devm_request_irq(uport->dev, port->wakeup_irq, + qcom_geni_serial_wakeup_isr, + IRQF_TRIGGER_FALLING, "uart_wakeup", uport); + if (ret) { + dev_err(uport->dev, "Failed to register wakeup IRQ ret %d\n", + ret); + return ret; + } + + device_init_wakeup(&pdev->dev, true); + ret = dev_pm_set_wake_irq(&pdev->dev, port->wakeup_irq); + if (unlikely(ret)) + dev_err(uport->dev, "%s:Failed to set IRQ wake:%d\n", + __func__, ret); + } + } uport->private_data = drv; platform_set_drvdata(pdev, port); port->handle_rx = console ? handle_rx_console : handle_rx_uart; @@ -1332,7 +1366,12 @@ static int __maybe_unused qcom_geni_serial_sys_suspend(struct device *dev) struct qcom_geni_serial_port *port = dev_get_drvdata(dev); struct uart_port *uport = &port->uport; - return uart_suspend_port(uport->private_data, uport); + uart_suspend_port(uport->private_data, uport); + + if (port->wakeup_irq > 0) + enable_irq(port->wakeup_irq); + + return 0; } static int __maybe_unused qcom_geni_serial_sys_resume(struct device *dev) @@ -1340,6 +1379,9 @@ static int __maybe_unused qcom_geni_serial_sys_resume(struct device *dev) struct qcom_geni_serial_port *port = dev_get_drvdata(dev); struct uart_port *uport = &port->uport; + if (port->wakeup_irq > 0) + disable_irq(port->wakeup_irq); + return uart_resume_port(uport->private_data, uport); }