From patchwork Wed Nov 13 10:48:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akash Asthana X-Patchwork-Id: 11241669 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 14E211709 for ; Wed, 13 Nov 2019 10:48:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E88AE21D7F for ; Wed, 13 Nov 2019 10:48:50 +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="aPbmhKek"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="aPbmhKek" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726422AbfKMKsu (ORCPT ); Wed, 13 Nov 2019 05:48:50 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:56032 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbfKMKsu (ORCPT ); Wed, 13 Nov 2019 05:48:50 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C82756053B; Wed, 13 Nov 2019 10:48:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573642128; bh=D04D7dnFG22G8WWSbOngQnJW+3O26cXP21Q7gTbDLhw=; h=From:To:Cc:Subject:Date:From; b=aPbmhKekTc9LCM/2yryPlCvQ6f8z1bydPiULCDV9e5qMiqVtkG1ndszKbscPq1MBr SLwQoQ7wz9r0xGxyqa7mUQkmraNSK16n3E/hN2a/t/yIIbgwvigd9Fy2ICKShqAu9q fVc5TMm2beqjnZZqe08h+YmwKi8qXDtzpUd1/3s4= 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 8C5B46030B; Wed, 13 Nov 2019 10:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573642128; bh=D04D7dnFG22G8WWSbOngQnJW+3O26cXP21Q7gTbDLhw=; h=From:To:Cc:Subject:Date:From; b=aPbmhKekTc9LCM/2yryPlCvQ6f8z1bydPiULCDV9e5qMiqVtkG1ndszKbscPq1MBr SLwQoQ7wz9r0xGxyqa7mUQkmraNSK16n3E/hN2a/t/yIIbgwvigd9Fy2ICKShqAu9q fVc5TMm2beqjnZZqe08h+YmwKi8qXDtzpUd1/3s4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8C5B46030B 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, swboyd@chromium.org, msavaliy@codeaurora.org, Akash Asthana Subject: [PATCH v5 1/3] tty: serial: qcom_geni_serial: IRQ cleanup Date: Wed, 13 Nov 2019 16:18:31 +0530 Message-Id: <1573642111-17479-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 v5: - No change. Changes in v4: - As per Stephen's comment, move ISR registration(later in probe) after registering uart port with serial core. - As per Greg's comment, corrected returning of PTR value from integer type function(probe). Changes in v3: - As per Stephen's comment, using devm_kasprintf instead of scnprintf API. drivers/tty/serial/qcom_geni_serial.c | 38 ++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 14c6306..634054a 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,6 +1291,12 @@ 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 -ENOMEM; + irq = platform_get_irq(pdev, 0); if (irq < 0) return irq; @@ -1307,7 +1307,21 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) port->handle_rx = console ? handle_rx_console : handle_rx_uart; if (!console) device_create_file(uport->dev, &dev_attr_loopback); - return uart_add_one_port(drv, uport); + + ret = uart_add_one_port(drv, uport); + if (ret) + return ret; + + 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); + uart_remove_one_port(drv, uport); + return ret; + } + + return ret; } static int qcom_geni_serial_remove(struct platform_device *pdev) From patchwork Wed Nov 13 10:48:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akash Asthana X-Patchwork-Id: 11241671 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 BA57E14E5 for ; Wed, 13 Nov 2019 10:49:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AF14222BD for ; Wed, 13 Nov 2019 10:49:13 +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="CBsSAS9M"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="a8mmcVgW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727142AbfKMKtN (ORCPT ); Wed, 13 Nov 2019 05:49:13 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:56284 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726138AbfKMKtM (ORCPT ); Wed, 13 Nov 2019 05:49:12 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6C86960592; Wed, 13 Nov 2019 10:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573642151; bh=bXxQtYvurhAVLIzAS+o22RaXGTA/pMMVi2RYqvEjxcw=; h=From:To:Cc:Subject:Date:From; b=CBsSAS9MUoGFqg0z6augI8jCg/omhhM2aqoSxaKmJ8XkgzxL2CnH8VeYJ76Toi7E9 tN1PTS1358P+16q8736uVPdJZ0iq5vVMTtWgxYWSDjjMHnS/QxNcbGj4SqaQpMKEbn +yMgQbnJ8FUZgA6IqQGCjALYZ2Ts4tdM7H6K2SrU= 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 2DE1A606AC; Wed, 13 Nov 2019 10:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573642150; bh=bXxQtYvurhAVLIzAS+o22RaXGTA/pMMVi2RYqvEjxcw=; h=From:To:Cc:Subject:Date:From; b=a8mmcVgWkAvhDJ/KUdmK/4SSL5qL1qgblUolseJqTjwsZZtv/d2qhpe1RG8ijvcnO IV0Frjq7HEqQTP75/72ZkNQ8Q/7N5KeFVJ8HMe/jbxDvkXv3vqZqAtk06KC/PNGyQF EFMqH9dFhzQIgGTMcIl2EeyiobtdLWCoh2BxhY3E= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2DE1A606AC 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, swboyd@chromium.org, msavaliy@codeaurora.org, Akash Asthana Subject: [PATCH v5 2/3] tty: serial: qcom_geni_serial: Wakeup over UART RX Date: Wed, 13 Nov 2019 16:18:56 +0530 Message-Id: <1573642136-30488-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 V5: - No change. Changes in V4: - As per Greg's comment, removed extra dev_err logging. - As per Stephen's comment, using common code that manage wakeirq irqs for devices. Using dev_pm_set_dedicated_wake_irq API that will take care of requesting and attaching wakeup irqs for devices. Also, it sets wakeirq status to WAKE_IRQ_DEDICATED_ALLOCATED as a result enabling/disabling of wake irq will be managed by suspend/resume framework so, removed the code for enabling and disabling of wake irq from the driver. Changes in V3: - As per Stephen's comment, using platform_get_irq_optional API to get wakeup IRQ for device. Changes in V2: - As per Stephen's comment, splitted V1 patch into 2 seperate patch. a) Clean up of core IRQ registration b) Add wakeup feature. drivers/tty/serial/qcom_geni_serial.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 634054a..56dad67 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -116,6 +118,7 @@ struct qcom_geni_serial_port { bool brk; unsigned int tx_remaining; + int wakeup_irq; }; static const struct uart_ops qcom_geni_console_pops; @@ -1302,6 +1305,9 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) return irq; uport->irq = irq; + if (!console) + port->wakeup_irq = platform_get_irq_optional(pdev, 1); + uport->private_data = drv; platform_set_drvdata(pdev, port); port->handle_rx = console ? handle_rx_console : handle_rx_uart; @@ -1321,6 +1327,23 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) return ret; } + if (port->wakeup_irq > 0) { + /* + * Set pm_runtime status as ACTIVE so that wakeup_irq gets + * enabled/disabled from dev_pm_arm_wake_irq during system + * suspend/resume respectively. + */ + pm_runtime_set_active(&pdev->dev); + device_init_wakeup(&pdev->dev, true); + ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, + port->wakeup_irq); + if (ret) { + device_init_wakeup(&pdev->dev, false); + uart_remove_one_port(drv, uport); + return ret; + } + } + return ret; } @@ -1330,6 +1353,10 @@ static int qcom_geni_serial_remove(struct platform_device *pdev) struct uart_driver *drv = port->uport.private_data; uart_remove_one_port(drv, &port->uport); + + device_init_wakeup(&pdev->dev, false); + dev_pm_clear_wake_irq(&pdev->dev); + return 0; } From patchwork Wed Nov 13 10:49:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akash Asthana X-Patchwork-Id: 11241673 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 52B0514E5 for ; Wed, 13 Nov 2019 10:49:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31E3F2245A for ; Wed, 13 Nov 2019 10:49:36 +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="mi2TqSYx"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="mi2TqSYx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726138AbfKMKtf (ORCPT ); Wed, 13 Nov 2019 05:49:35 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:56584 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727685AbfKMKte (ORCPT ); Wed, 13 Nov 2019 05:49:34 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BD77A6076A; Wed, 13 Nov 2019 10:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573642173; bh=DPkyfJIDRwVR+l7oKURkDUeN4K8w4CWQB6yMzGzfDhw=; h=From:To:Cc:Subject:Date:From; b=mi2TqSYxnjlNmEtXP+yKAaOamZ9jckUymRv/DsgWrcNX/7QdcYDGTF+pUK2Zsexyj u988BQaLDnxWTCNyUs5Hm5Wr+EV26MUUQMKpqlGGHI3XuTnbBDEPk0WagyZXkxW1sK cfZ0mrVxiJgL8uPugZG5FiBCNpIO7rkis5bAduEg= 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 9AA396053B; Wed, 13 Nov 2019 10:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1573642173; bh=DPkyfJIDRwVR+l7oKURkDUeN4K8w4CWQB6yMzGzfDhw=; h=From:To:Cc:Subject:Date:From; b=mi2TqSYxnjlNmEtXP+yKAaOamZ9jckUymRv/DsgWrcNX/7QdcYDGTF+pUK2Zsexyj u988BQaLDnxWTCNyUs5Hm5Wr+EV26MUUQMKpqlGGHI3XuTnbBDEPk0WagyZXkxW1sK cfZ0mrVxiJgL8uPugZG5FiBCNpIO7rkis5bAduEg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 9AA396053B 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, swboyd@chromium.org, msavaliy@codeaurora.org, Akash Asthana Subject: [PATCH v5 3/3] tty: serial: qcom_geni_serial: Remove sysfs file Date: Wed, 13 Nov 2019 16:19:21 +0530 Message-Id: <1573642161-14189-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 Remove code from the driver that create and maintain loopback sysfs node. Instead use the ioctl TIOCMSET with TIOCM_LOOP argument to set HW to loopback mode. Signed-off-by: Akash Asthana --- Changes in V5: - As per Greg's and Stephen's comment on v4 patch, removed loopback sysfs file related code. drivers/tty/serial/qcom_geni_serial.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 56dad67..52f5ea2 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -165,30 +165,6 @@ static struct qcom_geni_serial_port qcom_geni_uart_ports[GENI_UART_PORTS] = { }, }; -static ssize_t loopback_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct qcom_geni_serial_port *port = dev_get_drvdata(dev); - - return snprintf(buf, sizeof(u32), "%d\n", port->loopback); -} - -static ssize_t loopback_store(struct device *dev, - struct device_attribute *attr, const char *buf, - size_t size) -{ - struct qcom_geni_serial_port *port = dev_get_drvdata(dev); - u32 loopback; - - if (kstrtoint(buf, 0, &loopback) || loopback > MAX_LOOPBACK_CFG) { - dev_err(dev, "Invalid input\n"); - return -EINVAL; - } - port->loopback = loopback; - return size; -} -static DEVICE_ATTR_RW(loopback); - static struct qcom_geni_serial_port qcom_geni_console_port = { .uport = { .iotype = UPIO_MEM, @@ -238,10 +214,14 @@ static void qcom_geni_serial_set_mctrl(struct uart_port *uport, unsigned int mctrl) { u32 uart_manual_rfr = 0; + struct qcom_geni_serial_port *port = to_dev_port(uport, uport); if (uart_console(uport)) return; + if (mctrl & TIOCM_LOOP) + port->loopback = MAX_LOOPBACK_CFG; + if (!(mctrl & TIOCM_RTS)) uart_manual_rfr = UART_MANUAL_RFR_EN | UART_RFR_NOT_READY; writel(uart_manual_rfr, uport->membase + SE_UART_MANUAL_RFR); @@ -1311,8 +1291,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev) uport->private_data = drv; platform_set_drvdata(pdev, port); port->handle_rx = console ? handle_rx_console : handle_rx_uart; - if (!console) - device_create_file(uport->dev, &dev_attr_loopback); ret = uart_add_one_port(drv, uport); if (ret)