From patchwork Tue May 19 18:21:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 213976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57AA9C433E1 for ; Tue, 19 May 2020 18:21:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41124207C4 for ; Tue, 19 May 2020 18:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729492AbgESSV6 (ORCPT ); Tue, 19 May 2020 14:21:58 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:40412 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbgESSV6 (ORCPT ); Tue, 19 May 2020 14:21:58 -0400 Received: from zenbar.fritz.box (pd95ef292.dip0.t-ipconnect.de [217.94.242.146]) by mail.bugwerft.de (Postfix) with ESMTPSA id 9A13E40AEC5; Tue, 19 May 2020 18:18:59 +0000 (UTC) From: Daniel Mack To: devicetree@vger.kernel.org, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, jslaby@suse.com, jringle@gridpoint.com, m.brock@vanmierlo.com, pascal.huerst@gmail.com Subject: [PATCH v2 2/6] sc16is7xx: Add flag to activate IrDA mode Date: Tue, 19 May 2020 20:21:43 +0200 Message-Id: <20200519182147.218713-3-daniel@zonque.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519182147.218713-1-daniel@zonque.org> References: <20200519182147.218713-1-daniel@zonque.org> MIME-Version: 1.0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Pascal Huerst This series of uart controllers is able to work in IrDA mode. Add per-port flag to the device-tree to enable that feature if needed. Signed-off-by: Pascal Huerst --- drivers/tty/serial/sc16is7xx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 7d3ae31cc720..cf9cf59bb04e 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -315,6 +315,7 @@ struct sc16is7xx_one { struct kthread_work tx_work; struct kthread_work reg_work; struct sc16is7xx_one_config config; + bool irda_mode; }; struct sc16is7xx_port { @@ -994,6 +995,7 @@ static int sc16is7xx_config_rs485(struct uart_port *port, static int sc16is7xx_startup(struct uart_port *port) { + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); struct sc16is7xx_port *s = dev_get_drvdata(port->dev); unsigned int val; @@ -1032,6 +1034,13 @@ static int sc16is7xx_startup(struct uart_port *port) /* Now, initialize the UART */ sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_WORD_LEN_8); + /* Enable IrDA mode if requested in DT */ + /* This bit must be written with LCR[7] = 0 */ + sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, + SC16IS7XX_MCR_IRDA_BIT, + one->irda_mode ? + SC16IS7XX_MCR_IRDA_BIT : 0); + /* Enable the Rx and Tx FIFO */ sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, SC16IS7XX_EFCR_RXDISABLE_BIT | @@ -1302,6 +1311,17 @@ static int sc16is7xx_probe(struct device *dev, sc16is7xx_power(&s->p[i].port, 0); } + if (dev->of_node) { + struct property *prop; + const __be32 *p; + u32 u; + + of_property_for_each_u32(dev->of_node, "linux,irda-mode-ports", + prop, p, u) + if (u < devtype->nr_uart) + s->p[u].irda_mode = true; + } + /* Setup interrupt */ ret = devm_request_irq(dev, irq, sc16is7xx_irq, flags, dev_name(dev), s); From patchwork Tue May 19 18:21:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 213975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6769C433E5 for ; Tue, 19 May 2020 18:22:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C05202084C for ; Tue, 19 May 2020 18:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbgESSWB (ORCPT ); Tue, 19 May 2020 14:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729244AbgESSWA (ORCPT ); Tue, 19 May 2020 14:22:00 -0400 Received: from mail.bugwerft.de (mail.bugwerft.de [IPv6:2a03:6000:1011::59]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 77369C08C5C1; Tue, 19 May 2020 11:22:00 -0700 (PDT) Received: from zenbar.fritz.box (pd95ef292.dip0.t-ipconnect.de [217.94.242.146]) by mail.bugwerft.de (Postfix) with ESMTPSA id 8631340AEC3; Tue, 19 May 2020 18:19:03 +0000 (UTC) From: Daniel Mack To: devicetree@vger.kernel.org, linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, jslaby@suse.com, jringle@gridpoint.com, m.brock@vanmierlo.com, pascal.huerst@gmail.com, Daniel Mack Subject: [PATCH v2 5/6] sc16is7xx: Allow sharing the IRQ line Date: Tue, 19 May 2020 20:21:46 +0200 Message-Id: <20200519182147.218713-6-daniel@zonque.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519182147.218713-1-daniel@zonque.org> References: <20200519182147.218713-1-daniel@zonque.org> MIME-Version: 1.0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org When the interrupt line is shared with other devices, the IRQ must be level-triggered, as only one device can trigger a falling edge. To support this, try to acquire the IRQ with IRQF_TRIGGER_LOW|IRQF_SHARED first. Interrupt controllers that lack support for level-triggers will return an error, in which case the driver will now retry the acqusition with IRQF_TRIGGER_FALLING, which was also the default before. Signed-off-by: Daniel Mack --- drivers/tty/serial/sc16is7xx.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index cebc0cf9c30e..7e2360f8e393 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1313,7 +1313,19 @@ static int sc16is7xx_probe(struct device *dev, s->p[u].irda_mode = true; } - /* Setup interrupt */ + /* + * Setup interrupt. We first try to acquire the IRQ line as level IRQ. + * If that succeeds, we can allow sharing the interrupt as well. + * In case the interrupt controller doesn't support that, we fall + * back to a non-shared falling-edge trigger. + */ + ret = devm_request_threaded_irq(dev, irq, NULL, sc16is7xx_irq, + IRQF_TRIGGER_LOW | IRQF_SHARED | + IRQF_ONESHOT, + dev_name(dev), s); + if (!ret) + return 0; + ret = devm_request_threaded_irq(dev, irq, NULL, sc16is7xx_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, dev_name(dev), s);