From patchwork Thu May 21 09:11:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 213967 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 0C683C433E1 for ; Thu, 21 May 2020 09:12:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D311F20759 for ; Thu, 21 May 2020 09:12:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728804AbgEUJMD (ORCPT ); Thu, 21 May 2020 05:12:03 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:59138 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728545AbgEUJMC (ORCPT ); Thu, 21 May 2020 05:12:02 -0400 Received: from zenbar.fritz.box (pd95ef28a.dip0.t-ipconnect.de [217.94.242.138]) by mail.bugwerft.de (Postfix) with ESMTPSA id BC45640BCC0; Thu, 21 May 2020 09:09:00 +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 v3 1/6] dt-bindings: sc16is7xx: Add flag to activate IrDA mode Date: Thu, 21 May 2020 11:11:47 +0200 Message-Id: <20200521091152.404404-2-daniel@zonque.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521091152.404404-1-daniel@zonque.org> References: <20200521091152.404404-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. This adds a property to the device tree to enable that feature on selected ports if needed. Signed-off-by: Pascal Huerst Signed-off-by: Daniel Mack --- Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt b/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt index c1091a923a89..4d1f55abe876 100644 --- a/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt +++ b/Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt @@ -21,6 +21,8 @@ Optional properties: the second cell is used to specify the GPIO polarity: 0 = active high, 1 = active low. +- linux,irda-mode-ports: An array that lists the indices of the port that + should operate in IrDA mode. Example: sc16is750: sc16is750@51 { @@ -55,6 +57,8 @@ Optional properties: the second cell is used to specify the GPIO polarity: 0 = active high, 1 = active low. +- linux,irda-mode-ports: An array that lists the indices of the port that + should operate in IrDA mode. Example: sc16is750: sc16is750@0 { From patchwork Thu May 21 09:11:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 213966 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=unavailable 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 B398BC433E5 for ; Thu, 21 May 2020 09:12:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8070220759 for ; Thu, 21 May 2020 09:12:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728801AbgEUJME (ORCPT ); Thu, 21 May 2020 05:12:04 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:59168 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728761AbgEUJME (ORCPT ); Thu, 21 May 2020 05:12:04 -0400 Received: from zenbar.fritz.box (pd95ef28a.dip0.t-ipconnect.de [217.94.242.138]) by mail.bugwerft.de (Postfix) with ESMTPSA id 8F4AE40BCC8; Thu, 21 May 2020 09:09: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 v3 3/6] sc16is7xx: Always use falling edge IRQ Date: Thu, 21 May 2020 11:11:49 +0200 Message-Id: <20200521091152.404404-4-daniel@zonque.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521091152.404404-1-daniel@zonque.org> References: <20200521091152.404404-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 The driver currently only uses IRQF_TRIGGER_FALLING if the probing happened without a device-tree setup. The device however will always generate falling edges on its IRQ line, so let's use that flag in all cases. Signed-off-by: Daniel Mack --- drivers/tty/serial/sc16is7xx.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index cf9cf59bb04e..fcb2551a5df2 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1185,7 +1185,7 @@ static int sc16is7xx_gpio_direction_output(struct gpio_chip *chip, static int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, - struct regmap *regmap, int irq, unsigned long flags) + struct regmap *regmap, int irq) { struct sched_param sched_param = { .sched_priority = MAX_RT_PRIO / 2 }; unsigned long freq = 0, *pfreq = dev_get_platdata(dev); @@ -1324,7 +1324,7 @@ static int sc16is7xx_probe(struct device *dev, /* Setup interrupt */ ret = devm_request_irq(dev, irq, sc16is7xx_irq, - flags, dev_name(dev), s); + IRQF_TRIGGER_FALLING, dev_name(dev), s); if (!ret) return 0; @@ -1398,7 +1398,6 @@ static struct regmap_config regcfg = { static int sc16is7xx_spi_probe(struct spi_device *spi) { const struct sc16is7xx_devtype *devtype; - unsigned long flags = 0; struct regmap *regmap; int ret; @@ -1419,14 +1418,13 @@ static int sc16is7xx_spi_probe(struct spi_device *spi) const struct spi_device_id *id_entry = spi_get_device_id(spi); devtype = (struct sc16is7xx_devtype *)id_entry->driver_data; - flags = IRQF_TRIGGER_FALLING; } regcfg.max_register = (0xf << SC16IS7XX_REG_SHIFT) | (devtype->nr_uart - 1); regmap = devm_regmap_init_spi(spi, ®cfg); - return sc16is7xx_probe(&spi->dev, devtype, regmap, spi->irq, flags); + return sc16is7xx_probe(&spi->dev, devtype, regmap, spi->irq); } static int sc16is7xx_spi_remove(struct spi_device *spi) @@ -1465,7 +1463,6 @@ static int sc16is7xx_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { const struct sc16is7xx_devtype *devtype; - unsigned long flags = 0; struct regmap *regmap; if (i2c->dev.of_node) { @@ -1474,14 +1471,13 @@ static int sc16is7xx_i2c_probe(struct i2c_client *i2c, return -ENODEV; } else { devtype = (struct sc16is7xx_devtype *)id->driver_data; - flags = IRQF_TRIGGER_FALLING; } regcfg.max_register = (0xf << SC16IS7XX_REG_SHIFT) | (devtype->nr_uart - 1); regmap = devm_regmap_init_i2c(i2c, ®cfg); - return sc16is7xx_probe(&i2c->dev, devtype, regmap, i2c->irq, flags); + return sc16is7xx_probe(&i2c->dev, devtype, regmap, i2c->irq); } static int sc16is7xx_i2c_remove(struct i2c_client *client) From patchwork Thu May 21 09:11:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 213965 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=unavailable 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 291EDC433E4 for ; Thu, 21 May 2020 09:12:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00E952070A for ; Thu, 21 May 2020 09:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728815AbgEUJMG (ORCPT ); Thu, 21 May 2020 05:12:06 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:59214 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728813AbgEUJMG (ORCPT ); Thu, 21 May 2020 05:12:06 -0400 Received: from zenbar.fritz.box (pd95ef28a.dip0.t-ipconnect.de [217.94.242.138]) by mail.bugwerft.de (Postfix) with ESMTPSA id 5E93040BCCF; Thu, 21 May 2020 09:09:06 +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 v3 6/6] sc16is7xx: Read the LSR register for basic device presence check Date: Thu, 21 May 2020 11:11:52 +0200 Message-Id: <20200521091152.404404-7-daniel@zonque.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200521091152.404404-1-daniel@zonque.org> References: <20200521091152.404404-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 Currently, the driver probes just fine and binds all its resources even if the physical device is not present. As the device lacks an identification register, let's at least read the LSR register to check whether a device at the configured address responds to the request at all. Signed-off-by: Daniel Mack --- drivers/tty/serial/sc16is7xx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 7e2360f8e393..5e84ed5938af 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -1181,6 +1181,7 @@ static int sc16is7xx_probe(struct device *dev, { struct sched_param sched_param = { .sched_priority = MAX_RT_PRIO / 2 }; unsigned long freq = 0, *pfreq = dev_get_platdata(dev); + unsigned int val; u32 uartclk = 0; int i, ret; struct sc16is7xx_port *s; @@ -1188,6 +1189,16 @@ static int sc16is7xx_probe(struct device *dev, if (IS_ERR(regmap)) return PTR_ERR(regmap); + /* + * This device does not have an identification register that would + * tell us if we are really connected to the correct device. + * The best we can do is to check if communication is at all possible. + */ + ret = regmap_read(regmap, + SC16IS7XX_LSR_REG << SC16IS7XX_REG_SHIFT, &val); + if (ret < 0) + return ret; + /* Alloc port structure */ s = devm_kzalloc(dev, struct_size(s, p, devtype->nr_uart), GFP_KERNEL); if (!s) {