From patchwork Wed Dec 2 11:39:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 337465 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=-17.0 required=3.0 tests=BAYES_00, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 BF616C8301D for ; Wed, 2 Dec 2020 11:40:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E83822206 for ; Wed, 2 Dec 2020 11:40:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729604AbgLBLkh (ORCPT ); Wed, 2 Dec 2020 06:40:37 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36566 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728381AbgLBLkh (ORCPT ); Wed, 2 Dec 2020 06:40:37 -0500 Received: by mail-lf1-f67.google.com with SMTP id v14so4164867lfo.3; Wed, 02 Dec 2020 03:40:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qh172KviYxa9zp9+o3L4Po4UyIe5hNPQfMlxTZlddTg=; b=cFD3bSXVoBcOe3UDCQEXB9HMMyzavhkudtAmLKt+4TDbFstwHuuUXHxwtPn0O3lpxA K3A/KH/PdU8leRWYhEE7YKg8/ELpuSsHgx7bVJVZ7OyGIhUglziW2Mfexqo4fRm3bMLC vSg7v8KRE20V52ftKcMY4TkB+37qphVX8JM+6lDJOF8oSSY9s7FxxEe991jOYMDHz3Ur J4a5QeN6lJ5GavvQW3xXjAaVHpmQkLRus5zkLBxOk9W8wEAY7D9WrpVmsug/6v53S3qa cJjwKpwIz0HDT1+b6oM6DnK3pBC/zC9v5kcHc+ap293/WwbhN8oxmeeojTLdnT9MXgBq 9uTw== X-Gm-Message-State: AOAM532F/AZEX2eCm2ncO0LyRH5wfUAYp95gVTOHuoLAKIv8sPcoKsT0 rY5UDHZNEI6ZSFIgee34Zms= X-Google-Smtp-Source: ABdhPJwoVdp8m2G7eivVLWdlKmMT+Mkq9450XQZv3A0x9keCOk8Do2wAIMeotyIiIlPfZDcI8vM4Mg== X-Received: by 2002:ac2:5087:: with SMTP id f7mr1174426lfm.369.1606909188621; Wed, 02 Dec 2020 03:39:48 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id r66sm379960lff.265.2020.12.02.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:39:47 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kkQUc-00072n-LD; Wed, 02 Dec 2020 12:40:18 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , "Mychaela N . Falconia" , linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 1/7] tty: use assign_bit() in port-flag accessors Date: Wed, 2 Dec 2020 12:39:36 +0100 Message-Id: <20201202113942.27024-2-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202113942.27024-1-johan@kernel.org> References: <20201202113942.27024-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Use the new assign_bit() wrapper in the port-flag accessors instead of open coding. Suggested-by: Jiri Slaby Signed-off-by: Johan Hovold --- include/linux/tty.h | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/include/linux/tty.h b/include/linux/tty.h index a99e9b8e4e31..eca7fd5e9fd0 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -612,10 +612,7 @@ static inline bool tty_port_cts_enabled(struct tty_port *port) static inline void tty_port_set_cts_flow(struct tty_port *port, bool val) { - if (val) - set_bit(TTY_PORT_CTS_FLOW, &port->iflags); - else - clear_bit(TTY_PORT_CTS_FLOW, &port->iflags); + assign_bit(TTY_PORT_CTS_FLOW, &port->iflags, val); } static inline bool tty_port_active(struct tty_port *port) @@ -625,10 +622,7 @@ static inline bool tty_port_active(struct tty_port *port) static inline void tty_port_set_active(struct tty_port *port, bool val) { - if (val) - set_bit(TTY_PORT_ACTIVE, &port->iflags); - else - clear_bit(TTY_PORT_ACTIVE, &port->iflags); + assign_bit(TTY_PORT_ACTIVE, &port->iflags, val); } static inline bool tty_port_check_carrier(struct tty_port *port) @@ -638,10 +632,7 @@ static inline bool tty_port_check_carrier(struct tty_port *port) static inline void tty_port_set_check_carrier(struct tty_port *port, bool val) { - if (val) - set_bit(TTY_PORT_CHECK_CD, &port->iflags); - else - clear_bit(TTY_PORT_CHECK_CD, &port->iflags); + assign_bit(TTY_PORT_CHECK_CD, &port->iflags, val); } static inline bool tty_port_suspended(struct tty_port *port) @@ -651,10 +642,7 @@ static inline bool tty_port_suspended(struct tty_port *port) static inline void tty_port_set_suspended(struct tty_port *port, bool val) { - if (val) - set_bit(TTY_PORT_SUSPENDED, &port->iflags); - else - clear_bit(TTY_PORT_SUSPENDED, &port->iflags); + assign_bit(TTY_PORT_SUSPENDED, &port->iflags, val); } static inline bool tty_port_initialized(struct tty_port *port) @@ -664,10 +652,7 @@ static inline bool tty_port_initialized(struct tty_port *port) static inline void tty_port_set_initialized(struct tty_port *port, bool val) { - if (val) - set_bit(TTY_PORT_INITIALIZED, &port->iflags); - else - clear_bit(TTY_PORT_INITIALIZED, &port->iflags); + assign_bit(TTY_PORT_INITIALIZED, &port->iflags, val); } static inline bool tty_port_kopened(struct tty_port *port) @@ -677,10 +662,7 @@ static inline bool tty_port_kopened(struct tty_port *port) static inline void tty_port_set_kopened(struct tty_port *port, bool val) { - if (val) - set_bit(TTY_PORT_KOPENED, &port->iflags); - else - clear_bit(TTY_PORT_KOPENED, &port->iflags); + assign_bit(TTY_PORT_KOPENED, &port->iflags, val); } extern struct tty_struct *tty_port_tty_get(struct tty_port *port); From patchwork Wed Dec 2 11:39:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 336472 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=-17.0 required=3.0 tests=BAYES_00, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 16035C64E90 for ; Wed, 2 Dec 2020 11:40:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5BD722249 for ; Wed, 2 Dec 2020 11:40:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbgLBLke (ORCPT ); Wed, 2 Dec 2020 06:40:34 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34231 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbgLBLkc (ORCPT ); Wed, 2 Dec 2020 06:40:32 -0500 Received: by mail-lj1-f196.google.com with SMTP id y16so3247160ljk.1; Wed, 02 Dec 2020 03:40:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=01vHtzx/5aEVlHEVhq/PMF1AoVHq8PWDJZfl0akHsik=; b=KEpQBNlPZ/0JC6t0QmcsaXPH4Vh8x77zoMbnpzOQLBVpfYWSkjtXTS9IV8UiBNfbdo uEkMJjBHkZ9qRb7WXvBwdxlKlbcyUWuogbglBysSEXRwhsuY1zX1l47hsmuBAf0aUy6e 92dRUA03f/uj04NZH21Yuk7sDkQaw4/MDjgVhXsl+BfXZg4piAYWE/JNCIm9w9ED93xZ K/OSM3WHWVP56Wo5yTJIiX2vj6ZxAHyvi1sObve1Vv7Pk7TBexK0lq8s9N5FE6zy6aHh 4RU4fGHC5EUaFcgevTol/HNgQYerLOagi6bbzZhkz20bDRP+dBIJfF+KV2Em2nU3Fsin 4Ffw== X-Gm-Message-State: AOAM531UUR8uOn3tOK2uaZuK2BznwbJn4+BkGT+u2J2c4wYgck4t0T0x PqrNGwj9eTINOLR0wkkQAsOCRblauzEjbw== X-Google-Smtp-Source: ABdhPJxOqwspvf/MmAVckgjGG6+2wsOWl7R7BrdrJxygrukymZb8YLK6+3N4jhC7EqalwUGrJGESWQ== X-Received: by 2002:a2e:3518:: with SMTP id z24mr1019450ljz.310.1606909189303; Wed, 02 Dec 2020 03:39:49 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id x11sm379239lfe.96.2020.12.02.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:39:47 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kkQUc-00072t-Or; Wed, 02 Dec 2020 12:40:18 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , "Mychaela N . Falconia" , linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 2/7] tty: use const parameters in port-flag accessors Date: Wed, 2 Dec 2020 12:39:37 +0100 Message-Id: <20201202113942.27024-3-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202113942.27024-1-johan@kernel.org> References: <20201202113942.27024-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Declare the port parameter to the flag-test accessors as const. This is currently mostly cosmetic as the accessors are already inlined. Suggested-by: Jiri Slaby Signed-off-by: Johan Hovold --- include/linux/tty.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/tty.h b/include/linux/tty.h index eca7fd5e9fd0..3ebeb7fbe332 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -605,7 +605,7 @@ static inline struct tty_port *tty_port_get(struct tty_port *port) } /* If the cts flow control is enabled, return true. */ -static inline bool tty_port_cts_enabled(struct tty_port *port) +static inline bool tty_port_cts_enabled(const struct tty_port *port) { return test_bit(TTY_PORT_CTS_FLOW, &port->iflags); } @@ -615,7 +615,7 @@ static inline void tty_port_set_cts_flow(struct tty_port *port, bool val) assign_bit(TTY_PORT_CTS_FLOW, &port->iflags, val); } -static inline bool tty_port_active(struct tty_port *port) +static inline bool tty_port_active(const struct tty_port *port) { return test_bit(TTY_PORT_ACTIVE, &port->iflags); } @@ -625,7 +625,7 @@ static inline void tty_port_set_active(struct tty_port *port, bool val) assign_bit(TTY_PORT_ACTIVE, &port->iflags, val); } -static inline bool tty_port_check_carrier(struct tty_port *port) +static inline bool tty_port_check_carrier(const struct tty_port *port) { return test_bit(TTY_PORT_CHECK_CD, &port->iflags); } @@ -635,7 +635,7 @@ static inline void tty_port_set_check_carrier(struct tty_port *port, bool val) assign_bit(TTY_PORT_CHECK_CD, &port->iflags, val); } -static inline bool tty_port_suspended(struct tty_port *port) +static inline bool tty_port_suspended(const struct tty_port *port) { return test_bit(TTY_PORT_SUSPENDED, &port->iflags); } @@ -645,7 +645,7 @@ static inline void tty_port_set_suspended(struct tty_port *port, bool val) assign_bit(TTY_PORT_SUSPENDED, &port->iflags, val); } -static inline bool tty_port_initialized(struct tty_port *port) +static inline bool tty_port_initialized(const struct tty_port *port) { return test_bit(TTY_PORT_INITIALIZED, &port->iflags); } @@ -655,7 +655,7 @@ static inline void tty_port_set_initialized(struct tty_port *port, bool val) assign_bit(TTY_PORT_INITIALIZED, &port->iflags, val); } -static inline bool tty_port_kopened(struct tty_port *port) +static inline bool tty_port_kopened(const struct tty_port *port) { return test_bit(TTY_PORT_KOPENED, &port->iflags); } From patchwork Wed Dec 2 11:39:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 337464 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=-17.0 required=3.0 tests=BAYES_00, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 D43BFC64E7C for ; Wed, 2 Dec 2020 11:41:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 814CC20709 for ; Wed, 2 Dec 2020 11:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729698AbgLBLkt (ORCPT ); Wed, 2 Dec 2020 06:40:49 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38673 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgLBLkc (ORCPT ); Wed, 2 Dec 2020 06:40:32 -0500 Received: by mail-lj1-f193.google.com with SMTP id j10so3215626lja.5; Wed, 02 Dec 2020 03:40:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fraB3Wh6hPdE3o2D/kX730gDe4KdALMn6rjz8MjFR5Y=; b=kuSrcro6hA/CdMYb9NHG/rq68skl4PEM8q2C9EFL+Dx8NRXtzTCemsqRNDruvl6sWs vMhegOj1pZbHULJvAKv1q+mt2zolC3H9+pnW+eAVyHfgr5P8JVuWqnHi6TgR8DS2yHao 8QdCKiOlj+NIC5R7k5y2VzMMjvu8D07Qbutc1Rv1bjYdLfAuQ1mlLM/GQrEEL1IpAVN2 MLlANNxARA/gsj1Iy4jhQ2WRwwolcpzw7YT3RdyKc1BBnxRmlY8Ge166Wp5/yCG0ibws g7tTXH73l6B1l7wzB2kFV/P5feZvE8iZ4XHlgzaeCevlnB3fPmgsoVvDu++Xui4Lzwae D6lA== X-Gm-Message-State: AOAM533usAVaxiYjbazTWk2NlaM2lo3pamiEYOpfVrnlT/+AYZUlK2VR mY3btDf3fsboKk60XR+rnbA= X-Google-Smtp-Source: ABdhPJzFuHZC0BBruoFMX/bNpSx/Oa1Q4cpNr2kFh2u5qgBIcDBgDESdWMu+lIpVAMOj6C2u3LOENw== X-Received: by 2002:a2e:86da:: with SMTP id n26mr981641ljj.124.1606909189958; Wed, 02 Dec 2020 03:39:49 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id s23sm401265ljs.75.2020.12.02.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:39:48 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kkQUc-00072y-SU; Wed, 02 Dec 2020 12:40:18 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , "Mychaela N . Falconia" , linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 3/7] tty: add port flag to suppress ready signalling on open Date: Wed, 2 Dec 2020 12:39:38 +0100 Message-Id: <20201202113942.27024-4-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202113942.27024-1-johan@kernel.org> References: <20201202113942.27024-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add a NORDY port flag to suppress raising the modem-control lines on open to signal DTE readiness. This can be used to implement a NORDY termios control flag to complement HUPCL, which controls lowering of the modem-control lines on final close. Initially drivers can export the flag through sysfs, which also allows control over the lines on first open. This can be used to prevent undesirable side-effects on open for applications where the DTR and RTS lines are used for non-standard purposes such as generating power-on and reset pulses. Reviewed-by: Mychaela N. Falconia Signed-off-by: Johan Hovold --- drivers/tty/tty_port.c | 2 +- include/linux/tty.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c index ea80bf872f54..2613debc1d06 100644 --- a/drivers/tty/tty_port.c +++ b/drivers/tty/tty_port.c @@ -415,7 +415,7 @@ EXPORT_SYMBOL(tty_port_carrier_raised); */ void tty_port_raise_dtr_rts(struct tty_port *port) { - if (port->ops->dtr_rts) + if (port->ops->dtr_rts && !tty_port_nordy(port)) port->ops->dtr_rts(port, 1); } EXPORT_SYMBOL(tty_port_raise_dtr_rts); diff --git a/include/linux/tty.h b/include/linux/tty.h index 3ebeb7fbe332..05bec5837b51 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -267,6 +267,7 @@ struct tty_port { #define TTY_PORT_CHECK_CD 4 /* carrier detect enabled */ #define TTY_PORT_KOPENED 5 /* device exclusively opened by kernel */ +#define TTY_PORT_NORDY 6 /* do not raise DTR/RTS on open */ /* * Where all of the state associated with a tty is kept while the tty @@ -665,6 +666,16 @@ static inline void tty_port_set_kopened(struct tty_port *port, bool val) assign_bit(TTY_PORT_KOPENED, &port->iflags, val); } +static inline bool tty_port_nordy(const struct tty_port *port) +{ + return test_bit(TTY_PORT_NORDY, &port->iflags); +} + +static inline void tty_port_set_nordy(struct tty_port *port, bool val) +{ + assign_bit(TTY_PORT_NORDY, &port->iflags, val); +} + extern struct tty_struct *tty_port_tty_get(struct tty_port *port); extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); extern int tty_port_carrier_raised(struct tty_port *port); From patchwork Wed Dec 2 11:39:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 336471 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=-17.0 required=3.0 tests=BAYES_00, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 7B998C83018 for ; Wed, 2 Dec 2020 11:40:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A19722203 for ; Wed, 2 Dec 2020 11:40:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729686AbgLBLkk (ORCPT ); Wed, 2 Dec 2020 06:40:40 -0500 Received: from mail-lf1-f44.google.com ([209.85.167.44]:36387 "EHLO mail-lf1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726179AbgLBLkj (ORCPT ); Wed, 2 Dec 2020 06:40:39 -0500 Received: by mail-lf1-f44.google.com with SMTP id v14so4165031lfo.3; Wed, 02 Dec 2020 03:40:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wpl3GUF0Lna+9aQ+M4y15hfBavFW+GP9gpBC+7GpH5Y=; b=D0t+JDpDGdYf2jOcYQV738Dd1nEa7yQK/hjNkEj1X5/NsBNPh53C9FAOwB1/JSwVAJ srCHFBnriqPxnpdZjsmnhUvTC1U+ealhXUQNxStn1Pp7FFy+OenFpoqgq8mt6NwdxuKX nMrvqsW8A49alLdn/XYVWGCwn4OFL4PwC+QJKVMc8OhqTNbpYo/mk5+V2P9ui/zUdDeh QDX1JMz5hOVOXtNnwXjGYZm3ZfBwwuhcpzFuuzcM4aKkzDri6AVb5MCG0x5/5P6pDmrH 5HcS3IhmYvclU4HCeaewN/ICk6NC85Vsvy6oW421mCtfzLlvMih3+7V29S7zRFNVyzLm zRIA== X-Gm-Message-State: AOAM530hMWDvbTW/4xB3jZAGKhNizzr0UtDebi1V8aWidI3oUkluUYmO jgSqMy6P/pZpwtdY6OWHkm0= X-Google-Smtp-Source: ABdhPJwyUJNCE0J39vsIAzAyLSqtGSgb7f96Lf3Wll5DzpTzhWzBGG7xh1QqFM8hjsN1W7HbJXOZmg== X-Received: by 2002:a05:6512:2151:: with SMTP id s17mr1074253lfr.287.1606909190549; Wed, 02 Dec 2020 03:39:50 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id 136sm384688lfn.193.2020.12.02.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:39:48 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kkQUc-000733-VU; Wed, 02 Dec 2020 12:40:19 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , "Mychaela N . Falconia" , linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 4/7] serial: core: add sysfs attribute to suppress ready signalling on open Date: Wed, 2 Dec 2020 12:39:39 +0100 Message-Id: <20201202113942.27024-5-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202113942.27024-1-johan@kernel.org> References: <20201202113942.27024-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add a nordy sysfs attribute to suppress raising the modem-control lines on open to signal DTE readiness. This can be used to prevent undesirable side-effects on open for applications where the DTR and RTS lines are used for non-standard purposes such as generating power-on and reset pulses. Signed-off-by: Johan Hovold --- Documentation/ABI/testing/sysfs-tty | 7 +++++++ drivers/tty/serial/serial_core.c | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty index e157130a6792..2634b4bf9c7f 100644 --- a/Documentation/ABI/testing/sysfs-tty +++ b/Documentation/ABI/testing/sysfs-tty @@ -161,3 +161,10 @@ Contact: Andy Shevchenko Description: Allows user to detach or attach back the given device as kernel console. It shows and accepts a boolean variable. + +What: /sys/class/tty/ttyS0/nordy +Date: November 2020 +Contact: Johan Hovold +Description: + Show and store the port NORDY flag which suppresses raising + the modem-control lines on open to signal DTE readiness. diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f41cba10b86b..7db1814b9d99 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2805,6 +2805,30 @@ static ssize_t console_store(struct device *dev, return ret < 0 ? ret : count; } +static ssize_t nordy_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct tty_port *port = dev_get_drvdata(dev); + + return sprintf(buf, "%d\n", tty_port_nordy(port)); +} + +static ssize_t nordy_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct tty_port *port = dev_get_drvdata(dev); + bool val; + int ret; + + ret = kstrtobool(buf, &val); + if (ret) + return ret; + + tty_port_set_nordy(port, val); + + return count; +} + static DEVICE_ATTR_RO(uartclk); static DEVICE_ATTR_RO(type); static DEVICE_ATTR_RO(line); @@ -2819,6 +2843,7 @@ static DEVICE_ATTR_RO(io_type); static DEVICE_ATTR_RO(iomem_base); static DEVICE_ATTR_RO(iomem_reg_shift); static DEVICE_ATTR_RW(console); +static DEVICE_ATTR_RW(nordy); static struct attribute *tty_dev_attrs[] = { &dev_attr_uartclk.attr, @@ -2835,6 +2860,7 @@ static struct attribute *tty_dev_attrs[] = { &dev_attr_iomem_base.attr, &dev_attr_iomem_reg_shift.attr, &dev_attr_console.attr, + &dev_attr_nordy.attr, NULL }; From patchwork Wed Dec 2 11:39:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 336469 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=-17.0 required=3.0 tests=BAYES_00, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 4F24CC83016 for ; Wed, 2 Dec 2020 11:41:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1953620709 for ; Wed, 2 Dec 2020 11:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbgLBLks (ORCPT ); Wed, 2 Dec 2020 06:40:48 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:33337 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgLBLkd (ORCPT ); Wed, 2 Dec 2020 06:40:33 -0500 Received: by mail-lf1-f67.google.com with SMTP id l11so4202208lfg.0; Wed, 02 Dec 2020 03:40:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tP2HvplWRaMXdOrLEwAbMpgsLuB/LtE2K3OBH4UE6QM=; b=nBu7trBqYxRQlQbVfl9XsOSIEbGXmMrOXpSe718JzeiaJrprDBQDqo37xRRZl1CfPT V+0iltwTcp/2arRJQyw7K+/sLWajsm4gUUuYKOXqUllDR0NcvIQd/OIa9BO+YwyI1sWu ABtvH2PhT3fJ+ZEgZJH1Kjy0+dPZh/jdH3pIEgIa/Qohsgg3BmSUHAFy7ica2Jb/iqpA e5h04/5yoCPCqudWbhRLQkR+XYfc0VmFK7RiLA+4WNyY3xOiLIrEyL2vAtSwKb7FmtZ3 owQdGkIbTa0JUjCmJaYsQeiMpMdVbpL084nQeMx1rhr4qd1eip7Vvu6yInG+2t4isS9c 62pg== X-Gm-Message-State: AOAM5314Y+K4C64lm/goOvkRFZR22R2n4F8PLBoo3Ugep2wqLfOH3/8R pwJusy3bRKctKXf2b7uszJs= X-Google-Smtp-Source: ABdhPJwF4T7Ii6Rs+7XME3BIDjgfwitUBpk4MgYq1TJ2v9pWqbFWzDGtOvHDm3kXv6watTkD+U55tA== X-Received: by 2002:ac2:5a47:: with SMTP id r7mr974435lfn.525.1606909191191; Wed, 02 Dec 2020 03:39:51 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id t20sm385034lff.153.2020.12.02.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:39:49 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kkQUd-000738-27; Wed, 02 Dec 2020 12:40:19 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , "Mychaela N . Falconia" , linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 5/7] USB: serial: add sysfs attribute to suppress ready signalling on open Date: Wed, 2 Dec 2020 12:39:40 +0100 Message-Id: <20201202113942.27024-6-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202113942.27024-1-johan@kernel.org> References: <20201202113942.27024-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add a nordy sysfs attribute to suppress raising the modem-control lines on open to signal DTE readiness. This can be used to prevent undesirable side-effects on open for applications where the DTR and RTS lines are used for non-standard purposes such as generating power-on and reset pulses. Signed-off-by: Johan Hovold --- drivers/usb/serial/bus.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index eb0195cf37dd..db75cc5c3dfb 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c @@ -35,6 +35,37 @@ static int usb_serial_device_match(struct device *dev, return 0; } +static ssize_t nordy_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct usb_serial_port *port = dev_get_drvdata(dev); + + return sprintf(buf, "%d\n", tty_port_nordy(&port->port)); +} + +static ssize_t nordy_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct usb_serial_port *port = dev_get_drvdata(dev); + bool val; + int ret; + + ret = kstrtobool(buf, &val); + if (ret) + return ret; + + tty_port_set_nordy(&port->port, val); + + return count; +} +static DEVICE_ATTR_RW(nordy); + +static struct attribute *tty_attrs[] = { + &dev_attr_nordy.attr, + NULL +}; +ATTRIBUTE_GROUPS(tty); + static int usb_serial_device_probe(struct device *dev) { struct usb_serial_driver *driver; @@ -60,8 +91,8 @@ static int usb_serial_device_probe(struct device *dev) } minor = port->minor; - tty_dev = tty_port_register_device(&port->port, usb_serial_tty_driver, - minor, dev); + tty_dev = tty_port_register_device_attr(&port->port, + usb_serial_tty_driver, minor, dev, port, tty_groups); if (IS_ERR(tty_dev)) { retval = PTR_ERR(tty_dev); goto err_port_remove; From patchwork Wed Dec 2 11:39:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 337466 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=-17.0 required=3.0 tests=BAYES_00, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 BF810C83016 for ; Wed, 2 Dec 2020 11:40:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EC6220709 for ; Wed, 2 Dec 2020 11:40:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729654AbgLBLki (ORCPT ); Wed, 2 Dec 2020 06:40:38 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40703 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727650AbgLBLke (ORCPT ); Wed, 2 Dec 2020 06:40:34 -0500 Received: by mail-lj1-f195.google.com with SMTP id y10so3201837ljc.7; Wed, 02 Dec 2020 03:40:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eioTLuh9qMD02dGo7kd70kPRax33tNEMYOnayXuoEQw=; b=JEsJTJ7HgMwoalHv+9t1mJQEvFR4miRs3ZN18+Nw6D6dtop7N9eADkj7H4yBmAUVKM x0beFwZF+eWhmPkM6F1SV46Xy6Yw0pRx743I2VdztlMYeyj5icGuDsnNUSSciwjvV+CU 6dxT1schanz48ryV1YZ+8hksR13hJcwLOp33tuAcLdgnuP7vfXeHOtgs1blVjKxpQmKT fL6NBKO15XO/TgcCLFuiZR7NS4MkCWkR6xYCwJ6aUotcogaZjMTN9smBMbpyBDqRHNUM 4sgDV/hPL6A9/C9OVaMyZFx53EeFz3sS+1AMjkeKuieKulck/aAVN2ucMwQBiyUgqDzn WdXA== X-Gm-Message-State: AOAM533bZtshmcVRQCqC9IEn4Li+og7BO2AMJgdaIV3zBcvxQ8FLZCjF DegyYPB8sXL4TxvCO/uOaW9FRbju0ApjAg== X-Google-Smtp-Source: ABdhPJz5D+PQ6DzPdL9r9JsL4vg/TaoTkfaha5it7UuZ/g1kY3PSanEghj7QtwQsdePnLdQX45iFlw== X-Received: by 2002:a05:651c:3cf:: with SMTP id f15mr980595ljp.118.1606909191641; Wed, 02 Dec 2020 03:39:51 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id a11sm403184ljp.21.2020.12.02.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:39:49 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kkQUd-00073D-52; Wed, 02 Dec 2020 12:40:19 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , "Mychaela N . Falconia" , linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 6/7] USB: serial: ftdi_sio: pass port to quirk port_probe functions Date: Wed, 2 Dec 2020 12:39:41 +0100 Message-Id: <20201202113942.27024-7-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202113942.27024-1-johan@kernel.org> References: <20201202113942.27024-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: "Mychaela N. Falconia" The original code passed only the pointer to the ftdi_private struct to quirk port_probe functions. However, some quirks may need to be applied conditionally only to some channels of a multichannel FT2232x or FT4232H device, and if a given quirk's port_probe function needs to figure out which channel of a multichannel device is currently being considered, it needs access to the port pointer passed to the ftdi_sio_port_probe() function, so it can traverse USB data structures from there. Signed-off-by: Mychaela N. Falconia Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index e0f4c3d9649c..b69032c9ec2b 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -88,15 +88,15 @@ struct ftdi_private { struct ftdi_sio_quirk { int (*probe)(struct usb_serial *); /* Special settings for probed ports. */ - void (*port_probe)(struct ftdi_private *); + void (*port_probe)(struct usb_serial_port *); }; static int ftdi_jtag_probe(struct usb_serial *serial); static int ftdi_NDI_device_setup(struct usb_serial *serial); static int ftdi_stmclite_probe(struct usb_serial *serial); static int ftdi_8u2232c_probe(struct usb_serial *serial); -static void ftdi_USB_UIRT_setup(struct ftdi_private *priv); -static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv); +static void ftdi_USB_UIRT_setup(struct usb_serial_port *port); +static void ftdi_HE_TIRA1_setup(struct usb_serial_port *port); static const struct ftdi_sio_quirk ftdi_jtag_quirk = { .probe = ftdi_jtag_probe, @@ -2252,11 +2252,11 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) mutex_init(&priv->cfg_lock); - if (quirk && quirk->port_probe) - quirk->port_probe(priv); - usb_set_serial_port_data(port, priv); + if (quirk && quirk->port_probe) + quirk->port_probe(port); + ftdi_determine_type(port); ftdi_set_max_packet_size(port); if (read_latency_timer(port) < 0) @@ -2277,8 +2277,10 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) /* Setup for the USB-UIRT device, which requires hardwired * baudrate (38400 gets mapped to 312500) */ /* Called from usbserial:serial_probe */ -static void ftdi_USB_UIRT_setup(struct ftdi_private *priv) +static void ftdi_USB_UIRT_setup(struct usb_serial_port *port) { + struct ftdi_private *priv = usb_get_serial_port_data(port); + priv->flags |= ASYNC_SPD_CUST; priv->custom_divisor = 77; priv->force_baud = 38400; @@ -2287,8 +2289,10 @@ static void ftdi_USB_UIRT_setup(struct ftdi_private *priv) /* Setup for the HE-TIRA1 device, which requires hardwired * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */ -static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv) +static void ftdi_HE_TIRA1_setup(struct usb_serial_port *port) { + struct ftdi_private *priv = usb_get_serial_port_data(port); + priv->flags |= ASYNC_SPD_CUST; priv->custom_divisor = 240; priv->force_baud = 38400; From patchwork Wed Dec 2 11:39:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 336470 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=-17.0 required=3.0 tests=BAYES_00, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 B475CC64E7C for ; Wed, 2 Dec 2020 11:40:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5318522203 for ; Wed, 2 Dec 2020 11:40:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729630AbgLBLki (ORCPT ); Wed, 2 Dec 2020 06:40:38 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39033 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727664AbgLBLke (ORCPT ); Wed, 2 Dec 2020 06:40:34 -0500 Received: by mail-lj1-f193.google.com with SMTP id o24so3201811ljj.6; Wed, 02 Dec 2020 03:40:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F2ypKkOamjttQVwgv5mmaq3G5mJZylZwjPDQAwTLqx0=; b=OCqyoGj3zOuaMij0txoIVDfogxzH8fw5l7ZbDy27UgjQAsmwTRhA6pBVNg/ZyD0ttq db4t1Ap0Ie+/2Tb+JxCDEDVqmgT9zVmXCqt0+Hsfe04FOoYC97Z9mkwAuuChB1vHSc/D Xfizjo22JAFp6KppEqqgvuNkETQJyUtaPQ7Q8GkeMK6nGt9aNoy45bjH6MVZtXsB3Oe9 6W8PRmPqzsQIUTMGOiP5DPhwWIY25fzAs+7DsmMfXvo8SAyfUBIsTkmRD+Axt9mtf9Wc E0CR4la9HimMMP0//pN0FLXiCzKD+VRw2ZCdkSg5+HDMS7tfBtkfzmUsQoEN26JVo6Rb NEEA== X-Gm-Message-State: AOAM530fOOCLSkaN0eZ/3kTf319Jpu21PkRsLUi86lf83U9HmdKIfCgR rOKAcIxWLT706xI7L7dxAEEGqcMCmXBj+Q== X-Google-Smtp-Source: ABdhPJyplTPn0nJsn80Zygl/EROVP3j8GB/CsH5P3t3301AG3y96QvioJWYVnT0U2BVwCRI4+l60RA== X-Received: by 2002:a2e:99d7:: with SMTP id l23mr973603ljj.303.1606909192214; Wed, 02 Dec 2020 03:39:52 -0800 (PST) Received: from xi.terra (c-beaee455.07-184-6d6c6d4.bbcust.telenor.se. [85.228.174.190]) by smtp.gmail.com with ESMTPSA id s20sm401932ljg.15.2020.12.02.03.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:39:49 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.93.0.4) (envelope-from ) id 1kkQUd-00073I-8a; Wed, 02 Dec 2020 12:40:19 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Jiri Slaby , "Mychaela N . Falconia" , linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 7/7] USB: serial: ftdi_sio: add support for FreeCalypso DUART28C adapter Date: Wed, 2 Dec 2020 12:39:42 +0100 Message-Id: <20201202113942.27024-8-johan@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202113942.27024-1-johan@kernel.org> References: <20201202113942.27024-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: "Mychaela N. Falconia" FreeCalypso DUART28C is an FT2232D-based USB to dual UART adapter with a special quirk: Channel B RTS and DTR outputs (BDBUS2 and BDBUS4 on the chip) have been repurposed to drive PWON and RESET controls on Calypso targets. The circuit is wired such that BDBUS[24] high (RTS/DTR inactive) is the normal state with Iota VRPC controls NOT activated, whereas BDBUS[24] low (RTS or DTR active) turn ON the corresponding open drain control signal drivers. A special ftdi_sio driver quirk is needed in order to suppress automatic assertion of DTR & RTS on device open: this device's special PWON and RESET control drivers MUST NOT be activated when the port is ordinarily opened for plain serial communication, instead they must only be activated when a special userspace application explicitly requests such activation with a TIOCMBIS ioctl. These special userspace applications are responsible for making the needed pulse with a TIOCMBIS, delay, TIOCMBIC sequence. The special quirk is conditionalized on the DUART28C adapter's custom USB ID, and is further limited to FT2232D Channel B only: Channel A is wired normally, with the chip's ADBUS2 and ADBUS4 outputs actually being RTS and DTR rather than something else. Signed-off-by: Mychaela N. Falconia [johan: reimplement using new NORDY flag, trim quirk comment] Signed-off-by: Johan Hovold --- drivers/usb/serial/ftdi_sio.c | 22 ++++++++++++++++++++++ drivers/usb/serial/ftdi_sio_ids.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index b69032c9ec2b..1ba34ffe3a25 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -97,6 +97,7 @@ static int ftdi_stmclite_probe(struct usb_serial *serial); static int ftdi_8u2232c_probe(struct usb_serial *serial); static void ftdi_USB_UIRT_setup(struct usb_serial_port *port); static void ftdi_HE_TIRA1_setup(struct usb_serial_port *port); +static void ftdi_duart28c_setup(struct usb_serial_port *port); static const struct ftdi_sio_quirk ftdi_jtag_quirk = { .probe = ftdi_jtag_probe, @@ -122,6 +123,10 @@ static const struct ftdi_sio_quirk ftdi_8u2232c_quirk = { .probe = ftdi_8u2232c_probe, }; +static const struct ftdi_sio_quirk ftdi_duart28c_quirk = { + .port_probe = ftdi_duart28c_setup, +}; + /* * The 8U232AM has the same API as the sio except for: * - it can support MUCH higher baudrates; up to: @@ -1042,6 +1047,8 @@ static const struct usb_device_id id_table_combined[] = { .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, { USB_DEVICE(FTDI_VID, FTDI_FALCONIA_JTAG_UNBUF_PID), .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, + { USB_DEVICE(FTDI_VID, FTDI_FALCONIA_DUART28C_PID), + .driver_info = (kernel_ulong_t)&ftdi_duart28c_quirk }, { } /* Terminating entry */ }; @@ -2386,6 +2393,21 @@ static int ftdi_stmclite_probe(struct usb_serial *serial) return 0; } +/* + * FreeCalypso DUART28C is an FT2232D-based USB to dual UART adapter + * with a special quirk: Channel B RTS and DTR outputs (BDBUS2 and BDBUS4 + * on the chip) have been repurposed to drive PWON and RESET controls. + */ +static void ftdi_duart28c_setup(struct usb_serial_port *port) +{ + struct usb_serial *serial = port->serial; + struct usb_interface *intf = serial->interface; + int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; + + if (ifnum == 1) + tty_port_set_nordy(&port->port, true); +} + static int ftdi_sio_port_remove(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index 3d47c6d72256..3081b8916a0a 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h @@ -45,6 +45,7 @@ */ #define FTDI_FALCONIA_JTAG_BUF_PID 0x7150 #define FTDI_FALCONIA_JTAG_UNBUF_PID 0x7151 +#define FTDI_FALCONIA_DUART28C_PID 0x7152 /* Sienna Serial Interface by Secyourit GmbH */ #define FTDI_SIENNA_PID 0x8348