From patchwork Sun Sep 11 14:02:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 605258 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 8B5EEC6FA86 for ; Sun, 11 Sep 2022 14:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230404AbiIKODW (ORCPT ); Sun, 11 Sep 2022 10:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230352AbiIKODN (ORCPT ); Sun, 11 Sep 2022 10:03:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80EC433A23; Sun, 11 Sep 2022 07:03:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C5202B80B57; Sun, 11 Sep 2022 14:03:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50897C4347C; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=PEHzzoH9IF5H8guB1gj3gMHXET+ye+3uJaMUPxbg1us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kIdFj89bb+WtZNYc1l8Ki70QoDiqYBv1ldKR5Tj9ljvCrSfWpCMa1d07wM4byN/aZ leM8U+iZO8t/DYh7HZR4GZ7aFPr2z8k1FgK8IRi4ZK6b10X8gky6bB3NitYcybHP3m 2DmYtHrYXsex6NbqltKRYPqE/vzkTF8RFgKA0wO/1F7oVKnW8haiH6ffoJlxP+1EDy cjOFUzIGH1WQXbtK2Pj9kds99NBTnBd5T5kHho79Y3QV4/DpEwbt4BtBHHtBDfpnSz NufXRoC0dZg5Y67EMFChMZbtR57I5R8ja9GWLWEPsNqnjTr9Z4L03ED5jq8fm4xgtC 9fdYLaC57gAEQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYL-0007wY-HQ; Sun, 11 Sep 2022 16:03:17 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/12] USB: serial: ftdi_sio: clean up chip type enum Date: Sun, 11 Sep 2022 16:02:05 +0200 Message-Id: <20220911140216.30481-2-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Clean up the chip type enum by dropping the explicit values and moving the definition to the implementation to make it easier to add further types. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 11 +++++++++++ drivers/usb/serial/ftdi_sio.h | 12 ------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 52d59be92034..3757931284cb 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -47,6 +47,17 @@ #define DRIVER_AUTHOR "Greg Kroah-Hartman , Bill Ryder , Kuba Ober , Andreas Mohr, Johan Hovold " #define DRIVER_DESC "USB FTDI Serial Converters Driver" +enum ftdi_chip_type { + SIO, + FT8U232AM, + FT232BM, + FT2232C, + FT232RL, + FT2232H, + FT4232H, + FT232H, + FTX, +}; struct ftdi_private { enum ftdi_chip_type chip_type; diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index be1641e0408b..12bc3a82ac2c 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -153,18 +153,6 @@ * not supported by the FT8U232AM). */ -enum ftdi_chip_type { - SIO = 1, - FT8U232AM = 2, - FT232BM = 3, - FT2232C = 4, - FT232RL = 5, - FT2232H = 6, - FT4232H = 7, - FT232H = 8, - FTX = 9, -}; - enum ftdi_sio_baudrate { ftdi_sio_b300 = 0, ftdi_sio_b600 = 1, From patchwork Sun Sep 11 14:02:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 604971 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 B5CBAC6FA86 for ; Sun, 11 Sep 2022 14:03:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230446AbiIKOD1 (ORCPT ); Sun, 11 Sep 2022 10:03:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbiIKODO (ORCPT ); Sun, 11 Sep 2022 10:03:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 807CE3340C; Sun, 11 Sep 2022 07:03:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B58C9B80B55; Sun, 11 Sep 2022 14:03:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 405ABC433B5; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=k9SpcPU5DzUUP01/cKJ1szMTaQhD2tLr4OvnVCKvrMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vtz1d4VXTN2xj+RhI0AYuygL6SK2bDDdtZnl1cBkoOvq27mb+kWuldMXDpzjjLqtN LmSqSXOBOB5L1TpdByMSGBrCZ6tKvi7nZZZtDr5r0PvBtVv8ip53DdYlQOJeMJSpmk dsbYKBbyhqYrcCXSKF0K7s7Vh+gYN20DcYSmgyhHTfzCFWah3rGc7amcO6VHK7dzms hZdzeRb9G5l5NlQ9oSVZ8Au8bGtu6CoZlo70/DCx8ZfSn5TxOS1lGsjIqN80OqSieZ 68GIKbFcKfzPBNLCFNpx6cMJpBqEQDtuxGlH6NnGtqi0aPITfuBvxGaXRixZPzd+bn McxYuTmTj+WdQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYL-0007wa-JZ; Sun, 11 Sep 2022 16:03:17 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/12] USB: serial: ftdi_sio: drop redundant chip type comments Date: Sun, 11 Sep 2022 16:02:06 +0200 Message-Id: <20220911140216.30481-3-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Drop redundant chip type comments. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 3757931284cb..4b432707d75b 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -61,7 +61,6 @@ enum ftdi_chip_type { struct ftdi_private { enum ftdi_chip_type chip_type; - /* type of device, either SIO or FT8U232AM */ int baud_base; /* baud base clock for divisor setting */ int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the @@ -1318,7 +1317,7 @@ static u32 get_ftdi_divisor(struct tty_struct *tty, if (!baud) baud = 9600; switch (priv->chip_type) { - case SIO: /* SIO chip */ + case SIO: switch (baud) { case 300: div_value = ftdi_sio_b300; break; case 600: div_value = ftdi_sio_b600; break; @@ -1339,7 +1338,7 @@ static u32 get_ftdi_divisor(struct tty_struct *tty, div_okay = 0; } break; - case FT8U232AM: /* 8U232AM chip */ + case FT8U232AM: if (baud <= 3000000) { div_value = ftdi_232am_baud_to_divisor(baud); } else { @@ -1349,10 +1348,10 @@ static u32 get_ftdi_divisor(struct tty_struct *tty, div_okay = 0; } break; - case FT232BM: /* FT232BM chip */ - case FT2232C: /* FT2232C chip */ - case FT232RL: /* FT232RL chip */ - case FTX: /* FT-X series */ + case FT232BM: + case FT2232C: + case FT232RL: + case FTX: if (baud <= 3000000) { u16 product_id = le16_to_cpu( port->serial->dev->descriptor.idProduct); @@ -1372,9 +1371,9 @@ static u32 get_ftdi_divisor(struct tty_struct *tty, baud = 9600; } break; - case FT2232H: /* FT2232H chip */ - case FT4232H: /* FT4232H chip */ - case FT232H: /* FT232H chip */ + case FT2232H: + case FT4232H: + case FT232H: if ((baud <= 12000000) && (baud >= 1200)) { div_value = ftdi_2232h_baud_to_divisor(baud); } else if (baud < 1200) { @@ -1386,7 +1385,7 @@ static u32 get_ftdi_divisor(struct tty_struct *tty, baud = 9600; } break; - } /* priv->chip_type */ + } if (div_okay) { dev_dbg(dev, "%s - Baud rate set to %d (divisor 0x%lX) on chip %s\n", From patchwork Sun Sep 11 14:02:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 605256 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 E6B20C54EE9 for ; Sun, 11 Sep 2022 14:03:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230406AbiIKOD2 (ORCPT ); Sun, 11 Sep 2022 10:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbiIKODO (ORCPT ); Sun, 11 Sep 2022 10:03:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80FE633A2B; Sun, 11 Sep 2022 07:03:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9DB38B80B51; Sun, 11 Sep 2022 14:03:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DB8DC433D7; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=RTXkeeZEPPGrbwaO0YHvnaYqk5ERJAmf6ulr4Fnc6bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XmlT3cNY+Tpzh16FVIYbWWWVIrbmsYVzHcLiSlVTVCkB7wfNK5U5moNQlNUk8W0xx Sryxm/UfWUcTqLM7vNXATSKKaNThWjJmyoUWNAOLkBD9NIRVUKSw0+mD4Tc2tZ5nU4 eXPxoTBDV4O1zT1cQ++FpYVdUI1kU1dhUBq0uIAsbAFnNZfuUkYeMjgLhY5DD5oZZ3 PkMDqTYp/v32MgsoHWolQa4IMaaNmAuF49/Wb/G/Zn2oV76/2fETfKzpFbcFwj1K74 veebpUpK/s5vpsMvGdlWvDe8CkPkqSM+d9UjEIFimVf/gWhAQjw4w5F8/JARutb6Lj ZS1pGxPbE5iPg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYL-0007wc-MT; Sun, 11 Sep 2022 16:03:17 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/12] USB: serial: ftdi_sio: rename chip types Date: Sun, 11 Sep 2022 16:02:07 +0200 Message-Id: <20220911140216.30481-4-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Shorten the chip type enum and string representation for A, B and R chip types so that they don't include the IC package type in the name. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 60 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 4b432707d75b..b4db6a4ea223 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -49,13 +49,13 @@ enum ftdi_chip_type { SIO, - FT8U232AM, - FT232BM, + FT232A, + FT232B, FT2232C, - FT232RL, + FT232R, + FT232H, FT2232H, FT4232H, - FT232H, FTX, }; @@ -1071,15 +1071,15 @@ static const struct usb_device_id id_table_combined[] = { MODULE_DEVICE_TABLE(usb, id_table_combined); static const char *ftdi_chip_name[] = { - [SIO] = "SIO", /* the serial part of FT8U100AX */ - [FT8U232AM] = "FT8U232AM", - [FT232BM] = "FT232BM", - [FT2232C] = "FT2232C", - [FT232RL] = "FT232RL", - [FT2232H] = "FT2232H", - [FT4232H] = "FT4232H", - [FT232H] = "FT232H", - [FTX] = "FT-X" + [SIO] = "SIO", /* the serial part of FT8U100AX */ + [FT232A] = "FT232A", + [FT232B] = "FT232B", + [FT2232C] = "FT2232C", + [FT232R] = "FT232R", + [FT232H] = "FT232H", + [FT2232H] = "FT2232H", + [FT4232H] = "FT4232H", + [FTX] = "FT-X", }; @@ -1338,7 +1338,7 @@ static u32 get_ftdi_divisor(struct tty_struct *tty, div_okay = 0; } break; - case FT8U232AM: + case FT232A: if (baud <= 3000000) { div_value = ftdi_232am_baud_to_divisor(baud); } else { @@ -1348,9 +1348,9 @@ static u32 get_ftdi_divisor(struct tty_struct *tty, div_okay = 0; } break; - case FT232BM: + case FT232B: case FT2232C: - case FT232RL: + case FT232R: case FTX: if (baud <= 3000000) { u16 product_id = le16_to_cpu( @@ -1432,7 +1432,7 @@ static int write_latency_timer(struct usb_serial_port *port) int rv; int l = priv->latency; - if (priv->chip_type == SIO || priv->chip_type == FT8U232AM) + if (priv->chip_type == SIO || priv->chip_type == FT232A) return -EINVAL; if (priv->flags & ASYNC_LOW_LATENCY) @@ -1473,7 +1473,7 @@ static int read_latency_timer(struct usb_serial_port *port) struct ftdi_private *priv = usb_get_serial_port_data(port); int rv; - if (priv->chip_type == SIO || priv->chip_type == FT8U232AM) + if (priv->chip_type == SIO || priv->chip_type == FT232A) return -EINVAL; rv = _read_latency_timer(port); @@ -1604,7 +1604,7 @@ static void ftdi_determine_type(struct usb_serial_port *port) priv->baud_base = 12000000 / 16; } else if (version < 0x400) { /* Assume it's an FT8U232AM (or FT8U245AM) */ - priv->chip_type = FT8U232AM; + priv->chip_type = FT232A; /* * It might be a BM type because of the iSerialNumber bug. * If iSerialNumber==0 and the latency timer is readable, @@ -1615,14 +1615,14 @@ static void ftdi_determine_type(struct usb_serial_port *port) dev_dbg(&port->dev, "%s: has latency timer so not an AM type\n", __func__); - priv->chip_type = FT232BM; + priv->chip_type = FT232B; } } else if (version < 0x600) { /* Assume it's an FT232BM (or FT245BM) */ - priv->chip_type = FT232BM; + priv->chip_type = FT232B; } else if (version < 0x900) { /* Assume it's an FT232RL */ - priv->chip_type = FT232RL; + priv->chip_type = FT232R; } else if (version < 0x1000) { /* Assume it's an FT232H */ priv->chip_type = FT232H; @@ -1752,9 +1752,9 @@ static int create_sysfs_attrs(struct usb_serial_port *port) dev_dbg(&port->dev, "sysfs attributes for %s\n", ftdi_chip_name[priv->chip_type]); retval = device_create_file(&port->dev, &dev_attr_event_char); if ((!retval) && - (priv->chip_type == FT232BM || + (priv->chip_type == FT232B || priv->chip_type == FT2232C || - priv->chip_type == FT232RL || + priv->chip_type == FT232R || priv->chip_type == FT2232H || priv->chip_type == FT4232H || priv->chip_type == FT232H || @@ -1773,9 +1773,9 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) /* XXX see create_sysfs_attrs */ if (priv->chip_type != SIO) { device_remove_file(&port->dev, &dev_attr_event_char); - if (priv->chip_type == FT232BM || + if (priv->chip_type == FT232B || priv->chip_type == FT2232C || - priv->chip_type == FT232RL || + priv->chip_type == FT232R || priv->chip_type == FT2232H || priv->chip_type == FT4232H || priv->chip_type == FT232H || @@ -2153,7 +2153,7 @@ static int ftdi_gpio_init(struct usb_serial_port *port) case FT232H: result = ftdi_gpio_init_ft232h(port); break; - case FT232RL: + case FT232R: result = ftdi_gpio_init_ft232r(port); break; case FTX: @@ -2838,10 +2838,10 @@ static int ftdi_get_modem_status(struct usb_serial_port *port, case SIO: len = 1; break; - case FT8U232AM: - case FT232BM: + case FT232A: + case FT232B: case FT2232C: - case FT232RL: + case FT232R: case FT2232H: case FT4232H: case FT232H: From patchwork Sun Sep 11 14:02:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 605257 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 8CBE4C54EE9 for ; Sun, 11 Sep 2022 14:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbiIKODZ (ORCPT ); Sun, 11 Sep 2022 10:03:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230358AbiIKODO (ORCPT ); Sun, 11 Sep 2022 10:03:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99E0533A19; Sun, 11 Sep 2022 07:03:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4D6F7B80B50; Sun, 11 Sep 2022 14:03:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64F70C43141; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=WWx3AJlX6Slk7wqDxJ03BK7fBMO8+hLbvGw5qltzu88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S2ME8UJtIiwFMdofFqm+rWwVReu7wqvU+NEaE0uj6TTATHVsdwpTF7LaNltA7HXqL yP65rwTzpl4J8+mn521HOqNiC+92Qq3yj805zqr24ntUo+vT6B+PKamYzmkNbmU2Ji QzpBzF5IBTeR7fU8gSqt8o2A+2Y3hNvh7MMbay/CqaO7uST9kjM5sFkBC13BjutfEf vxzZHMVRtXZ0Ok4XxrA9+aieFlouWcl+yjEX+2vUKZXpsUK5oG85lKcyeWRvF5swBD /3hc8iremlwoQs4/4oYXFb2PUy0MvQUYz4C4yB0oCw74aItvvCm3Do5IhNlXPMFc/B 5aGjSTroV8fUA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYL-0007wg-Pg; Sun, 11 Sep 2022 16:03:17 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/12] USB: serial: ftdi_sio: include FT2232D in type string Date: Sun, 11 Sep 2022 16:02:08 +0200 Message-Id: <20220911140216.30481-5-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Include the updated D-version in the type string for the FT2232C type. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index b4db6a4ea223..cd3cdecc5f90 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1074,7 +1074,7 @@ static const char *ftdi_chip_name[] = { [SIO] = "SIO", /* the serial part of FT8U100AX */ [FT232A] = "FT232A", [FT232B] = "FT232B", - [FT2232C] = "FT2232C", + [FT2232C] = "FT2232C/D", [FT232R] = "FT232R", [FT232H] = "FT232H", [FT2232H] = "FT2232H", From patchwork Sun Sep 11 14:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 604974 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 F1368ECAAD3 for ; Sun, 11 Sep 2022 14:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbiIKODQ (ORCPT ); Sun, 11 Sep 2022 10:03:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbiIKODL (ORCPT ); Sun, 11 Sep 2022 10:03:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 005363340C; Sun, 11 Sep 2022 07:03:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 91EC56102D; Sun, 11 Sep 2022 14:03:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BE7CC43142; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=w/Ksdq4EdREphK9IhIE14j5zncHoLhHSvs29UcJrW5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XmoXeV2wK8f7EFdzxWlFv9h1l8cULEcRSt04zuf7O6OwjddT/gdBisRCzJqZsiomk wcKY40jsFt1mlJLbcUtYq42oLmd0mTjdvQ4EFBaujlQGessWcq2wKLarlvF36y41sc Fuf8drXYzvZ/K/CR5DO+mc5KtnV2K4oNxvcj92ZggodajWH0+mR/kwdq6bOyExn11E 3nW4K/yHZeuIbLcubCfyB8DoYqqpkPTVOEpmvzJWvjbtvUxVzBEG8zZ2uFopy8ojvW v+wAHVK7cY9mLr/rwko6ltUDoONOj1b8H71c/KKwLeZhjyX02h49VPEfpf8bbVJamA nE5jNpTQ3YIYw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYL-0007wj-Sb; Sun, 11 Sep 2022 16:03:17 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/12] USB: serial: ftdi_sio: rename channel index Date: Sun, 11 Sep 2022 16:02:09 +0200 Message-Id: <20220911140216.30481-6-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Multi-channel devices require a channel selector to be included in control requests. Replace "interface" with the less ambiguous "channel", which is the terminology used for newer devices, in the corresponding defines and variables. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 40 +++++++++++++++++------------------ drivers/usb/serial/ftdi_sio.h | 10 ++++----- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index cd3cdecc5f90..707dc3d67a19 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -72,8 +72,7 @@ struct ftdi_private { unsigned long last_dtr_rts; /* saved modem control outputs */ char prev_status; /* Used for TIOCMIWAIT */ char transmit_empty; /* If transmitter is empty or not */ - u16 interface; /* FT2232C, FT2232H or FT4232H port interface - (0 for FT232/245) */ + u16 channel; /* channel index, or 0 for legacy types */ speed_t force_baud; /* if non-zero, force the baud rate to this value */ @@ -1271,7 +1270,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, usb_sndctrlpipe(port->serial->dev, 0), FTDI_SIO_SET_MODEM_CTRL_REQUEST, FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, - value, priv->interface, + value, priv->channel, NULL, 0, WDR_TIMEOUT); if (rv < 0) { dev_dbg(dev, "%s Error from MODEM_CTRL urb: DTR %s, RTS %s\n", @@ -1413,7 +1412,7 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) priv->chip_type == FTX) { /* Probably the BM type needs the MSB of the encoded fractional * divider also moved like for the chips above. Any infos? */ - index = (u16)((index << 8) | priv->interface); + index = (u16)((index << 8) | priv->channel); } rv = usb_control_msg(port->serial->dev, @@ -1444,7 +1443,7 @@ static int write_latency_timer(struct usb_serial_port *port) usb_sndctrlpipe(udev, 0), FTDI_SIO_SET_LATENCY_TIMER_REQUEST, FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, - l, priv->interface, + l, priv->channel, NULL, 0, WDR_TIMEOUT); if (rv < 0) dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); @@ -1460,7 +1459,7 @@ static int _read_latency_timer(struct usb_serial_port *port) rv = usb_control_msg_recv(udev, 0, FTDI_SIO_GET_LATENCY_TIMER_REQUEST, FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 0, - priv->interface, &buf, 1, WDR_TIMEOUT, + priv->channel, &buf, 1, WDR_TIMEOUT, GFP_KERNEL); if (rv == 0) rv = buf; @@ -1581,15 +1580,14 @@ static void ftdi_determine_type(struct usb_serial_port *port) } else priv->chip_type = FT2232C; - /* Determine interface code. */ if (ifnum == 0) - priv->interface = INTERFACE_A; + priv->channel = CHANNEL_A; else if (ifnum == 1) - priv->interface = INTERFACE_B; + priv->channel = CHANNEL_B; else if (ifnum == 2) - priv->interface = INTERFACE_C; + priv->channel = CHANNEL_C; else if (ifnum == 3) - priv->interface = INTERFACE_D; + priv->channel = CHANNEL_D; /* BM-type devices have a bug where bcdDevice gets set * to 0x200 when iSerialNumber is 0. */ @@ -1730,7 +1728,7 @@ static ssize_t event_char_store(struct device *dev, usb_sndctrlpipe(udev, 0), FTDI_SIO_SET_EVENT_CHAR_REQUEST, FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, - v, priv->interface, + v, priv->channel, NULL, 0, WDR_TIMEOUT); if (rv < 0) { dev_dbg(&port->dev, "Unable to write event character: %i\n", rv); @@ -1804,7 +1802,7 @@ static int ftdi_set_bitmode(struct usb_serial_port *port, u8 mode) usb_sndctrlpipe(serial->dev, 0), FTDI_SIO_SET_BITMODE_REQUEST, FTDI_SIO_SET_BITMODE_REQUEST_TYPE, val, - priv->interface, NULL, 0, WDR_TIMEOUT); + priv->channel, NULL, 0, WDR_TIMEOUT); if (result < 0) { dev_err(&serial->interface->dev, "bitmode request failed for value 0x%04x: %d\n", @@ -1868,7 +1866,7 @@ static int ftdi_read_cbus_pins(struct usb_serial_port *port) result = usb_control_msg_recv(serial->dev, 0, FTDI_SIO_READ_PINS_REQUEST, FTDI_SIO_READ_PINS_REQUEST_TYPE, 0, - priv->interface, &buf, 1, WDR_TIMEOUT, + priv->channel, &buf, 1, WDR_TIMEOUT, GFP_KERNEL); if (result == 0) result = buf; @@ -2404,7 +2402,7 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port) usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, FTDI_SIO_RESET_SIO, - priv->interface, NULL, 0, WDR_TIMEOUT); + priv->channel, NULL, 0, WDR_TIMEOUT); /* Termios defaults are set by usb_serial_init. We don't change port->tty->termios - this would lose speed settings, etc. @@ -2427,7 +2425,7 @@ static void ftdi_dtr_rts(struct usb_serial_port *port, int on) usb_sndctrlpipe(port->serial->dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, - 0, priv->interface, NULL, 0, + 0, priv->channel, NULL, 0, WDR_TIMEOUT) < 0) { dev_err(&port->dev, "error from flowcontrol urb\n"); } @@ -2620,7 +2618,7 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state) usb_sndctrlpipe(port->serial->dev, 0), FTDI_SIO_SET_DATA_REQUEST, FTDI_SIO_SET_DATA_REQUEST_TYPE, - value , priv->interface, + value, priv->channel, NULL, 0, WDR_TIMEOUT) < 0) { dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n", __func__, break_state); @@ -2756,7 +2754,7 @@ static void ftdi_set_termios(struct tty_struct *tty, if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_DATA_REQUEST, FTDI_SIO_SET_DATA_REQUEST_TYPE, - value , priv->interface, + value, priv->channel, NULL, 0, WDR_SHORT_TIMEOUT) < 0) { dev_err(ddev, "%s FAILED to set databits/stopbits/parity\n", __func__); @@ -2769,7 +2767,7 @@ static void ftdi_set_termios(struct tty_struct *tty, if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, - 0, priv->interface, + 0, priv->channel, NULL, 0, WDR_TIMEOUT) < 0) { dev_err(ddev, "%s error from disable flowcontrol urb\n", __func__); @@ -2803,7 +2801,7 @@ static void ftdi_set_termios(struct tty_struct *tty, index = FTDI_SIO_DISABLE_FLOW_CTRL; } - index |= priv->interface; + index |= priv->channel; ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, @@ -2857,7 +2855,7 @@ static int ftdi_get_modem_status(struct usb_serial_port *port, usb_rcvctrlpipe(port->serial->dev, 0), FTDI_SIO_GET_MODEM_STATUS_REQUEST, FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, - 0, priv->interface, + 0, priv->channel, buf, len, WDR_TIMEOUT); /* NOTE: We allow short responses and handle that below. */ diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 12bc3a82ac2c..55ea61264f91 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -40,11 +40,11 @@ #define FTDI_SIO_READ_PINS 0x0c /* Read immediate value of pins */ #define FTDI_SIO_READ_EEPROM 0x90 /* Read EEPROM */ -/* Interface indices for FT2232, FT2232H and FT4232H devices */ -#define INTERFACE_A 1 -#define INTERFACE_B 2 -#define INTERFACE_C 3 -#define INTERFACE_D 4 +/* Channel indices for FT2232, FT2232H and FT4232H devices */ +#define CHANNEL_A 1 +#define CHANNEL_B 2 +#define CHANNEL_C 3 +#define CHANNEL_D 4 /* From patchwork Sun Sep 11 14:02:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 604975 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 14135C54EE9 for ; Sun, 11 Sep 2022 14:03:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbiIKODM (ORCPT ); Sun, 11 Sep 2022 10:03:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbiIKODL (ORCPT ); Sun, 11 Sep 2022 10:03:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A4E0326C0; Sun, 11 Sep 2022 07:03:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 00E9561012; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56045C43470; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=nhRqD/sx9Bg9OQB7wlx22Zh4neB2ClHMeK+G19F5nZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHl+UYFDyc9hgxyCCqbEbyuAycVDgCkpId92WnzHynB8lZHCpMwv7dh4tN+Bgyz9k 9ldSpyf3QSX0ySTmJFxO+cisPeLzzrW0lOj9i25m70wMrVm+l30tEBEt0U0t7jql7M 184ypNApHU8+6NQ8u2Arek4WxdBGRJLmlRWlw7B75SaReZs5UfbpqXmCxU0/XQaSyZ oFn3xLn4hOlF6ZZxbO/FUd6NbcWMypTQ0lNyMfW+1FvjKQOdoxuqsZojxEu/aFDFbT RrcqoK43aEf6Jy53yxbbe+NC/mvkA+aA9DFHkRC/AoHelNxOW2devG9ESuipiJVrPN pNEY9KpifMlgA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYL-0007wm-Vr; Sun, 11 Sep 2022 16:03:18 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/12] USB: serial: ftdi_sio: tighten device-type detection Date: Sun, 11 Sep 2022 16:02:10 +0200 Message-Id: <20220911140216.30481-7-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Clean up and tighten the device-type detection, which is based on bcdDevice. Don't make assumptions about unknown (future) types (currently assumed to be either FT2232C or FT-X depending on bNumInterfaces) and instead log an error and refuse to bind so that we can add proper support when needed. Note that the bcdDevice values have been provided by FTDI. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 118 ++++++++++++++++------------------ 1 file changed, 55 insertions(+), 63 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 707dc3d67a19..f372f55a1bdf 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1547,89 +1547,73 @@ static int get_lsr_info(struct usb_serial_port *port, return 0; } - -/* Determine type of FTDI chip based on USB config and descriptor. */ -static void ftdi_determine_type(struct usb_serial_port *port) +static int ftdi_determine_type(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; struct usb_device *udev = serial->dev; - unsigned version; - unsigned interfaces; + unsigned int version, ifnum; + + version = le16_to_cpu(udev->descriptor.bcdDevice); + ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; - /* Assume it is not the original SIO device for now. */ priv->baud_base = 48000000 / 2; + priv->channel = 0; - version = le16_to_cpu(udev->descriptor.bcdDevice); - interfaces = udev->actconfig->desc.bNumInterfaces; - dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__, - version, interfaces); - if (interfaces > 1) { - struct usb_interface *intf = serial->interface; - int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; - - /* Multiple interfaces.*/ - if (version == 0x0800) { - priv->chip_type = FT4232H; - /* Hi-speed - baud clock runs at 120MHz */ - priv->baud_base = 120000000 / 2; - } else if (version == 0x0700) { - priv->chip_type = FT2232H; - /* Hi-speed - baud clock runs at 120MHz */ - priv->baud_base = 120000000 / 2; - } else - priv->chip_type = FT2232C; - - if (ifnum == 0) - priv->channel = CHANNEL_A; - else if (ifnum == 1) - priv->channel = CHANNEL_B; - else if (ifnum == 2) - priv->channel = CHANNEL_C; - else if (ifnum == 3) - priv->channel = CHANNEL_D; - - /* BM-type devices have a bug where bcdDevice gets set - * to 0x200 when iSerialNumber is 0. */ - if (version < 0x500) { - dev_dbg(&port->dev, - "%s: something fishy - bcdDevice too low for multi-interface device\n", - __func__); - } - } else if (version < 0x200) { - /* Old device. Assume it's the original SIO. */ - priv->chip_type = SIO; - priv->baud_base = 12000000 / 16; - } else if (version < 0x400) { - /* Assume it's an FT8U232AM (or FT8U245AM) */ + switch (version) { + case 0x200: priv->chip_type = FT232A; + /* - * It might be a BM type because of the iSerialNumber bug. - * If iSerialNumber==0 and the latency timer is readable, - * assume it is BM type. + * FT232B devices have a bug where bcdDevice gets set to 0x200 + * when iSerialNumber is 0. Assume it is an FT232B in case the + * latency timer is readable. */ if (udev->descriptor.iSerialNumber == 0 && _read_latency_timer(port) >= 0) { - dev_dbg(&port->dev, - "%s: has latency timer so not an AM type\n", - __func__); priv->chip_type = FT232B; } - } else if (version < 0x600) { - /* Assume it's an FT232BM (or FT245BM) */ + break; + case 0x400: priv->chip_type = FT232B; - } else if (version < 0x900) { - /* Assume it's an FT232RL */ + break; + case 0x500: + priv->chip_type = FT2232C; + priv->channel = CHANNEL_A + ifnum; + break; + case 0x600: priv->chip_type = FT232R; - } else if (version < 0x1000) { - /* Assume it's an FT232H */ + break; + case 0x700: + priv->chip_type = FT2232H; + priv->channel = CHANNEL_A + ifnum; + priv->baud_base = 120000000 / 2; + break; + case 0x800: + priv->chip_type = FT4232H; + priv->channel = CHANNEL_A + ifnum; + priv->baud_base = 120000000 / 2; + break; + case 0x900: priv->chip_type = FT232H; - } else { - /* Assume it's an FT-X series device */ + priv->baud_base = 120000000 / 2; + break; + case 0x1000: priv->chip_type = FTX; + break; + default: + if (version < 0x200) { + priv->chip_type = SIO; + priv->baud_base = 12000000 / 16; + } else { + dev_err(&port->dev, "unknown device type: 0x%02x\n", version); + return -ENODEV; + } } dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); + + return 0; } @@ -2256,7 +2240,10 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) usb_set_serial_port_data(port, priv); - ftdi_determine_type(port); + result = ftdi_determine_type(port); + if (result) + goto err_free; + ftdi_set_max_packet_size(port); if (read_latency_timer(port) < 0) priv->latency = 16; @@ -2271,6 +2258,11 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) } return 0; + +err_free: + kfree(priv); + + return result; } /* Setup for the USB-UIRT device, which requires hardwired From patchwork Sun Sep 11 14:02:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 604970 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 5A0A4C54EE9 for ; Sun, 11 Sep 2022 14:03:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230427AbiIKODb (ORCPT ); Sun, 11 Sep 2022 10:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbiIKODQ (ORCPT ); Sun, 11 Sep 2022 10:03:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6713C33A3B; Sun, 11 Sep 2022 07:03:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C8DA0B80B3B; Sun, 11 Sep 2022 14:03:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F68EC43149; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=37cnzMM3fHj4HuHjrrjP7jTiSZuXJ1j1atdznt3e8Hc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pepUIK7+4MCU4bGUVs4WRJUA0mEgHALyh3xx8GjxAj7Rb86mJnGkxBX0GgjHKBAGP 0jemwS3p6nE6gC4g+3kKUgo8hY1jQjPdYDRwaWODTGnb2P8s1ma3Fw7xnnKag1tW70 Gr8Y/6v4ReELfhaBfzGaYpkhMgggyWP6PA31yLZui1iWlQIQrVbKVnsJvEuA7xNaFh 41xwZebw6XtD1Ay0FxsHIRLnAIPXELfzTQG9dCh98TKc3/u8wuoCoRJpz5PGyFPuza 5IYOI0slfL6D6nO5QLp/jscmhiE3X+JBrv7CK4ly+k/PUvKrfPrH60e5GdNkYpcian hwlH40e72dGuA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYM-0007wp-2p; Sun, 11 Sep 2022 16:03:18 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/12] USB: serial: ftdi_sio: clean up modem-status handling Date: Sun, 11 Sep 2022 16:02:11 +0200 Message-Id: <20220911140216.30481-8-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org All chip types but the original SIO (FT8U100AX) return a two-byte modem status and there's no need to explicitly list every other type in the handler. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index f372f55a1bdf..58e0acb211df 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2821,27 +2821,13 @@ static int ftdi_get_modem_status(struct usb_serial_port *port, if (!buf) return -ENOMEM; /* - * The 8U232AM returns a two byte value (the SIO a 1 byte value) in - * the same format as the data returned from the in point. + * The device returns a two byte value (the SIO a 1 byte value) in the + * same format as the data returned from the IN endpoint. */ - switch (priv->chip_type) { - case SIO: + if (priv->chip_type == SIO) len = 1; - break; - case FT232A: - case FT232B: - case FT2232C: - case FT232R: - case FT2232H: - case FT4232H: - case FT232H: - case FTX: + else len = 2; - break; - default: - ret = -EFAULT; - goto out; - } ret = usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), From patchwork Sun Sep 11 14:02:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 605260 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 0F7D2C54EE9 for ; Sun, 11 Sep 2022 14:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230355AbiIKODN (ORCPT ); Sun, 11 Sep 2022 10:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbiIKODL (ORCPT ); Sun, 11 Sep 2022 10:03:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3681E33419; Sun, 11 Sep 2022 07:03:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C06CC60F5B; Sun, 11 Sep 2022 14:03:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87AF2C43146; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=AEuQN1qN6g4lPNcGSyMgkuEVA8PP453BV0ADwWgFgQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=usPjSiPoWKN/+cbGghdmZOsmNK8WmSkn2z0waF9Doxij9MQM9jGqUSQcCAgQBP4QP MSQX7lFNP3knTEpkm96ktvS7fqMqQpZ+CAevgb5iLlEpEBdZfe/1cJTpczQRnTm7OG p6qad5mI9g8yUDdl1QOpkGnYi72nNkeyxgTQwFW7CjvSwYb01VsIMydjhHk2MWjdku UoLVBREBCsjTwNWpnTTOhfAgHUZqqce+Bp8XkR1U5PXddR9/RFYT6FPsRLfIXgvH4S BK9yM6yV7yIC2i2AyblhFEhTi0p9NogBs9iQTlpg4mrM9WO73m0M8RcjOiG2CYPP+X 357X7OT9pwulA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYM-0007ws-5j; Sun, 11 Sep 2022 16:03:18 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/12] USB: serial: ftdi_sio: clean up attribute handling Date: Sun, 11 Sep 2022 16:02:12 +0200 Message-Id: <20220911140216.30481-9-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The driver exposes two attributes for all chip types but FT232A, which doesn't have a configurable latency timer, and SIO, which (probably) doesn't support the event-char mechanism either. Explicitly test for the exceptions rather than list each and every supported device type in the attribute helpers. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 47 ++++++++++++----------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 58e0acb211df..835e12fc971a 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1726,46 +1726,31 @@ static DEVICE_ATTR_WO(event_char); static int create_sysfs_attrs(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); - int retval = 0; - - /* XXX I've no idea if the original SIO supports the event_char - * sysfs parameter, so I'm playing it safe. */ - if (priv->chip_type != SIO) { - dev_dbg(&port->dev, "sysfs attributes for %s\n", ftdi_chip_name[priv->chip_type]); - retval = device_create_file(&port->dev, &dev_attr_event_char); - if ((!retval) && - (priv->chip_type == FT232B || - priv->chip_type == FT2232C || - priv->chip_type == FT232R || - priv->chip_type == FT2232H || - priv->chip_type == FT4232H || - priv->chip_type == FT232H || - priv->chip_type == FTX)) { - retval = device_create_file(&port->dev, - &dev_attr_latency_timer); - } + enum ftdi_chip_type type = priv->chip_type; + int ret = 0; + + if (type != SIO) { + ret = device_create_file(&port->dev, &dev_attr_event_char); + if (ret) + return ret; } - return retval; + + if (type != SIO && type != FT232A) + ret = device_create_file(&port->dev, &dev_attr_latency_timer); + + return ret; } static void remove_sysfs_attrs(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); + enum ftdi_chip_type type = priv->chip_type; - /* XXX see create_sysfs_attrs */ - if (priv->chip_type != SIO) { + if (type != SIO) device_remove_file(&port->dev, &dev_attr_event_char); - if (priv->chip_type == FT232B || - priv->chip_type == FT2232C || - priv->chip_type == FT232R || - priv->chip_type == FT2232H || - priv->chip_type == FT4232H || - priv->chip_type == FT232H || - priv->chip_type == FTX) { - device_remove_file(&port->dev, &dev_attr_latency_timer); - } - } + if (type != SIO && type != FT232A) + device_remove_file(&port->dev, &dev_attr_latency_timer); } #ifdef CONFIG_GPIOLIB From patchwork Sun Sep 11 14:02:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 604973 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 B4428C54EE9 for ; Sun, 11 Sep 2022 14:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230393AbiIKODU (ORCPT ); Sun, 11 Sep 2022 10:03:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbiIKODM (ORCPT ); Sun, 11 Sep 2022 10:03:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE0C5326C0; Sun, 11 Sep 2022 07:03:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 59BBE61048; Sun, 11 Sep 2022 14:03:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F047C4314B; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=8hzbbHrrGmUOdQqlSJTWWGTPUH/13Z+G4m3ZYEOgNvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=enVnn68zg9k4o1V/OCt/4mezo8NKe/wT8/lv9XAirYMcn+T5zICCv0Q8rehhW3u4S XbDkZ/y0/Qzu/dDDQqOZMMHEkzI0DBWNrNqSfq3dkft3g+vTpX4nX7lfz87tkBfERz XtZNPEu5K4xjDfnJQs+Yv2pBkTa9UpsECnlBhA8SrY6iFtyn4nDTHi4XyRdfuKuUKh 6nP1xAgq2GO2qqreas4J8dm2f/ILk9LWSIw8WOeAL2e3c/d6wfE11bjrKi4O9ofZ6v VFL8yvtd5nb8aw2YfhYUWIaQNA9E2gbFMx2N4P/KtgtLrpPwy6d0FilT8sC7vwcHO4 oGsu1FlAj0Ojw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYM-0007wv-8b; Sun, 11 Sep 2022 16:03:18 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/12] USB: serial: ftdi_sio: clean up baudrate request Date: Sun, 11 Sep 2022 16:02:13 +0200 Message-Id: <20220911140216.30481-10-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Multi-channel devices need to encode the channel selector in their control requests and newer single-channel chip types use the same request format. Set the channel index also for these single-channel types so that the index can be used to determine the baudrate request format instead of listing types explicitly. Note that FT232H and FTX accept either 0 or 1 as selector for their single channel, presumably for backward compatibility reasons. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 835e12fc971a..e772aacae562 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1407,13 +1407,8 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) index_value = get_ftdi_divisor(tty, port); value = (u16)index_value; index = (u16)(index_value >> 16); - if (priv->chip_type == FT2232C || priv->chip_type == FT2232H || - priv->chip_type == FT4232H || priv->chip_type == FT232H || - priv->chip_type == FTX) { - /* Probably the BM type needs the MSB of the encoded fractional - * divider also moved like for the chips above. Any infos? */ + if (priv->channel) index = (u16)((index << 8) | priv->channel); - } rv = usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), @@ -1596,10 +1591,12 @@ static int ftdi_determine_type(struct usb_serial_port *port) break; case 0x900: priv->chip_type = FT232H; + priv->channel = CHANNEL_A + ifnum; priv->baud_base = 120000000 / 2; break; case 0x1000: priv->chip_type = FTX; + priv->channel = CHANNEL_A + ifnum; break; default: if (version < 0x200) { From patchwork Sun Sep 11 14:02:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 605255 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 F3CBBC54EE9 for ; Sun, 11 Sep 2022 14:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbiIKODd (ORCPT ); Sun, 11 Sep 2022 10:03:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbiIKODQ (ORCPT ); Sun, 11 Sep 2022 10:03:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6125333A3A; Sun, 11 Sep 2022 07:03:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 13C83B80B52; Sun, 11 Sep 2022 14:03:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C02B8C43150; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=SAqqcP5lBP9yri+H9v6GzRI9aDJ/79pe958bAhnOMkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vI+EiDCpbWLRRhLV5ZS31hyuSwJCqJLEM9sc0cJeJXnKvIQ+94kHhn4jVlcvE9j5d VYcvotOyucCGqVHzLw7fFVu+isOpTq/sOmk5DgO0CnivCAuGAEd04ziDnDtnUCh5B/ gcX3CEVs0RxSgZKjHo3QNFaM1HZQx/iO1AadP7Zrx0s+0WItfXoGUuT4qo8QnLOb+X xnHQtSSgp7KSD9/hr4XTUpdqMcST1EylREk5+Mb8E9IGGn8H4+YT/UPpStkU9eYff6 GyfO82AfaZk6jxhBvdDIkbJQmbx/yiEqr2RcpEO0/OUhGqK8hm+D19PUl0W+YuYC8T BwQjRn+DQxHqQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYM-0007wy-BC; Sun, 11 Sep 2022 16:03:18 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/12] USB: serial: ftdi_sio: assume hi-speed type Date: Sun, 11 Sep 2022 16:02:14 +0200 Message-Id: <20220911140216.30481-11-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org In preparation for adding further Hi-Speed types, assume a 120 MHz clock and set the channel index by default and instead override these values as needed for legacy types. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index e772aacae562..a43101000ee3 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1552,13 +1552,15 @@ static int ftdi_determine_type(struct usb_serial_port *port) version = le16_to_cpu(udev->descriptor.bcdDevice); ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; - priv->baud_base = 48000000 / 2; - priv->channel = 0; + /* Assume Hi-Speed type */ + priv->baud_base = 120000000 / 2; + priv->channel = CHANNEL_A + ifnum; switch (version) { case 0x200: priv->chip_type = FT232A; - + priv->baud_base = 48000000 / 2; + priv->channel = 0; /* * FT232B devices have a bug where bcdDevice gets set to 0x200 * when iSerialNumber is 0. Assume it is an FT232B in case the @@ -1571,37 +1573,36 @@ static int ftdi_determine_type(struct usb_serial_port *port) break; case 0x400: priv->chip_type = FT232B; + priv->baud_base = 48000000 / 2; + priv->channel = 0; break; case 0x500: priv->chip_type = FT2232C; - priv->channel = CHANNEL_A + ifnum; + priv->baud_base = 48000000 / 2; break; case 0x600: priv->chip_type = FT232R; + priv->baud_base = 48000000 / 2; + priv->channel = 0; break; case 0x700: priv->chip_type = FT2232H; - priv->channel = CHANNEL_A + ifnum; - priv->baud_base = 120000000 / 2; break; case 0x800: priv->chip_type = FT4232H; - priv->channel = CHANNEL_A + ifnum; - priv->baud_base = 120000000 / 2; break; case 0x900: priv->chip_type = FT232H; - priv->channel = CHANNEL_A + ifnum; - priv->baud_base = 120000000 / 2; break; case 0x1000: priv->chip_type = FTX; - priv->channel = CHANNEL_A + ifnum; + priv->baud_base = 48000000 / 2; break; default: if (version < 0x200) { priv->chip_type = SIO; priv->baud_base = 12000000 / 16; + priv->channel = 0; } else { dev_err(&port->dev, "unknown device type: 0x%02x\n", version); return -ENODEV; From patchwork Sun Sep 11 14:02:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 605259 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 7CE59ECAAD3 for ; Sun, 11 Sep 2022 14:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbiIKODS (ORCPT ); Sun, 11 Sep 2022 10:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbiIKODM (ORCPT ); Sun, 11 Sep 2022 10:03:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 660D433A19; Sun, 11 Sep 2022 07:03:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ED68D61041; Sun, 11 Sep 2022 14:03:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF5CCC4314F; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904989; bh=4VDAeDrDE5XmmwiLBFA5Z5Gow6FH/LGJWnAEFdy77bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e6qh9CEkMZATgzZDsl0E9mTtdXTFCNPVt7FW55dI5eLClbbr0C65y6TBy1gjk68ei Z9A6aEDtz+spf/X/dO69TZ88Xol4XrLAJ6yLsf/A4qKObqGehX8i/A9z+n5z5d3bdh T8FkQf72RWqDLYzcnRlFxungHLJfni6qPYuC++Brtiqa+FowZWuwXqhLXhKS7b5I/M TOwFwSc6ICsLNuuxu8d7q5mw3T3oMHX2mLYA3uZ3gt8hyFZfIq0mX6ev6f2sV5cQ24 VN2aFwKzxYFtMrYMPFqDZmzdUjoZ6vCYg22Q9YjglNXvlwCauOAa9yRIVxOCrjUvNg dZb4L3zG9sbaA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYM-0007x1-Dh; Sun, 11 Sep 2022 16:03:18 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/12] USB: serial: ftdi_sio: simplify divisor handling Date: Sun, 11 Sep 2022 16:02:15 +0200 Message-Id: <20220911140216.30481-12-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org In preparation for adding further Hi-Speed types, assume the device type is Hi-Speed unless it's an explicitly listed legacy type when determining divisors. Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index a43101000ee3..e9f508e31876 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1370,9 +1370,7 @@ static u32 get_ftdi_divisor(struct tty_struct *tty, baud = 9600; } break; - case FT2232H: - case FT4232H: - case FT232H: + default: if ((baud <= 12000000) && (baud >= 1200)) { div_value = ftdi_2232h_baud_to_divisor(baud); } else if (baud < 1200) { From patchwork Sun Sep 11 14:02:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 604969 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 D018BC6FA86 for ; Sun, 11 Sep 2022 14:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbiIKODg (ORCPT ); Sun, 11 Sep 2022 10:03:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230374AbiIKODQ (ORCPT ); Sun, 11 Sep 2022 10:03:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 577C733A38; Sun, 11 Sep 2022 07:03:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 06FB0B80B4B; Sun, 11 Sep 2022 14:03:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F20EBC43153; Sun, 11 Sep 2022 14:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662904990; bh=IKrZDRYxuBggOVlSeyt3KrXHgAe9Y/gZ2LAGYJArBlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UO8Qs6nYuHLExz8QkzQXGuoMXIEqTPb4+p4Mc8IxaTDEVW+nPC8VCTNI+LJl2epUk znWs2BExVS5rrIck3KlMiw8LHeNTDch/cU6JA8rcuGSl6BTFhMm47XvR/vH5/k+GjQ +lBdNhTUwEDfoo0KyhAIDvgbtNk47j4i40P6mfgUs6itfLqzCOyogd+Q9m7Ok9iRFn XzcMkfweHU9HTze42XQcAlJaDHA/b2mTh/N67/fg+HmqjrEwy6fCCGdcGMSJCtGQ85 5WlZxSzFX14tJGY7dSW7O87si7+YiGobnJQTIecDs4i9lnMyxreHH0VWNNPUzd7Qwc iZacRyw6W66TA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oXNYM-0007x4-Gd; Sun, 11 Sep 2022 16:03:18 +0200 From: Johan Hovold To: Johan Hovold Cc: Amireddy mallikarjuna reddy , arun.pappan@ftdichip.com, sowjanya.reddy@ftdichip.com, malliamireddy009@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/12] USB: serial: ftdi_sio: add support for HP and HA devices Date: Sun, 11 Sep 2022 16:02:16 +0200 Message-Id: <20220911140216.30481-13-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911140216.30481-1-johan@kernel.org> References: <20220911140216.30481-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Amireddy mallikarjuna reddy Add the product IDs for the USB-to-Serial devices FT2233HP, FT2232HP, FT4233HP, FT4232HP, FT233HP, FT232HP, and FT4232HA. Also include BCD values so that the chip type can be determined. Signed-off-by: Amireddy mallikarjuna reddy Link: https://lore.kernel.org/r/ac28f2c5eba23a645b3b9299c224f2755a233eef.1658385786.git.mallikarjuna.reddy@ftdichip.com [ johan: rebase on type-handling rework, drop "Q" from automotive type name ] Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 42 +++++++++++++++++++++++++++++++ drivers/usb/serial/ftdi_sio_ids.h | 7 ++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index e9f508e31876..c1e707555fe0 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -56,6 +56,13 @@ enum ftdi_chip_type { FT232H, FT2232H, FT4232H, + FT4232HA, + FT232HP, + FT233HP, + FT2232HP, + FT2233HP, + FT4232HP, + FT4233HP, FTX, }; @@ -189,6 +196,13 @@ static const struct usb_device_id id_table_combined[] = { { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) }, { USB_DEVICE(FTDI_VID, FTDI_232H_PID) }, { USB_DEVICE(FTDI_VID, FTDI_FTX_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_FT2233HP_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_FT4233HP_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_FT2232HP_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_FT4232HP_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_FT233HP_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_FT232HP_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_FT4232HA_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, @@ -1078,6 +1092,13 @@ static const char *ftdi_chip_name[] = { [FT232H] = "FT232H", [FT2232H] = "FT2232H", [FT4232H] = "FT4232H", + [FT4232HA] = "FT4232HA", + [FT232HP] = "FT232HP", + [FT233HP] = "FT233HP", + [FT2232HP] = "FT2232HP", + [FT2233HP] = "FT2233HP", + [FT4232HP] = "FT4232HP", + [FT4233HP] = "FT4233HP", [FTX] = "FT-X", }; @@ -1596,6 +1617,27 @@ static int ftdi_determine_type(struct usb_serial_port *port) priv->chip_type = FTX; priv->baud_base = 48000000 / 2; break; + case 0x2800: + priv->chip_type = FT2233HP; + break; + case 0x2900: + priv->chip_type = FT4233HP; + break; + case 0x3000: + priv->chip_type = FT2232HP; + break; + case 0x3100: + priv->chip_type = FT4232HP; + break; + case 0x3200: + priv->chip_type = FT233HP; + break; + case 0x3300: + priv->chip_type = FT232HP; + break; + case 0x3600: + priv->chip_type = FT4232HA; + break; default: if (version < 0x200) { priv->chip_type = SIO; diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index 31c8ccabbbb7..e2099445db70 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h @@ -25,6 +25,13 @@ #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ #define FTDI_232H_PID 0x6014 /* Single channel hi-speed device */ #define FTDI_FTX_PID 0x6015 /* FT-X series (FT201X, FT230X, FT231X, etc) */ +#define FTDI_FT2233HP_PID 0x6040 /* Dual channel hi-speed device with PD */ +#define FTDI_FT4233HP_PID 0x6041 /* Quad channel hi-speed device with PD */ +#define FTDI_FT2232HP_PID 0x6042 /* Dual channel hi-speed device with PD */ +#define FTDI_FT4232HP_PID 0x6043 /* Quad channel hi-speed device with PD */ +#define FTDI_FT233HP_PID 0x6044 /* Dual channel hi-speed device with PD */ +#define FTDI_FT232HP_PID 0x6045 /* Dual channel hi-speed device with PD */ +#define FTDI_FT4232HA_PID 0x6048 /* Quad channel automotive grade hi-speed device */ #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */