Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1451508 > unrolled thread

sc16is7xx: fix RTS/CTS implementation and add reading CTS

Started byPascal JEAN <epsilonrt@gmail.com>
First post2016-07-27 23:00 +0200
Last post2016-07-28 16:20 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  sc16is7xx: fix RTS/CTS implementation and add reading CTS Pascal JEAN <epsilonrt@gmail.com> - 2016-07-27 23:00 +0200
    [PATCH 1/2] sc16is7xx: fix RTS/CTS implementation Pascal JEAN <epsilonrt@gmail.com> - 2016-07-27 23:00 +0200
      Re: [PATCH 1/2] sc16is7xx: fix RTS/CTS implementation Greg KH <gregkh@linuxfoundation.org> - 2016-07-27 23:30 +0200
        Re: [PATCH 1/2] sc16is7xx: fix RTS/CTS implementation Pascal JEAN <epsilonrt@gmail.com> - 2016-07-28 09:00 +0200
        [PATCH 2/2] sc16is7xx: add reading CTS Pascal JEAN <epsilonrt@gmail.com> - 2016-07-28 09:10 +0200
          Re: [PATCH 2/2] sc16is7xx: add reading CTS Greg KH <gregkh@linuxfoundation.org> - 2016-07-28 16:20 +0200

#1451508 — sc16is7xx: fix RTS/CTS implementation and add reading CTS

FromPascal JEAN <epsilonrt@gmail.com>
Date2016-07-27 23:00 +0200
Subjectsc16is7xx: fix RTS/CTS implementation and add reading CTS
Message-ID<rZE5P-4nL-11@gated-at.bofh.it>
Hi Greg,

Here are explanations of the two patches:

0001-sc16is7xx-fix-RTS-CTS-implementation.patch:
RTS/CTS handshaking for sc16is7xx driver does not work, no character is sent 
regardless of the state of CTS.

This test was done on a raspberry pi 2:

1- sc16is7xx_set_baud() overwrites the flow control configuration bits in EFR. 
Writing in EFR has been replaced by an update.
2- As noted in the file Documentation/serial/driver, 
get_mctrl() should return an active state for unsupported entries.

0002-sc16is7xx-add-reading-CTS.patch:
This patch adds the possibility to read the actual status of the CTS input when
 RTS/CTS handshaking is not activated.

After those changes everything works.

Thank you for your hard work.
Have a nice day.
Pascal

[toc] | [next] | [standalone]


#1451509 — [PATCH 1/2] sc16is7xx: fix RTS/CTS implementation

FromPascal JEAN <epsilonrt@gmail.com>
Date2016-07-27 23:00 +0200
Subject[PATCH 1/2] sc16is7xx: fix RTS/CTS implementation
Message-ID<rZE5P-4nL-17@gated-at.bofh.it>
In reply to#1451508
Signed-off-by: Pascal JEAN <epsilonrt@gmail.com>
---
 drivers/tty/serial/sc16is7xx.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index f36e6df..3e65079 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -511,16 +511,18 @@ static int sc16is7xx_set_baud(struct uart_port *port, int baud)
 
 	/* Enable enhanced features */
 	regcache_cache_bypass(s->regmap, true);
-	sc16is7xx_port_write(port, SC16IS7XX_EFR_REG,
-			     SC16IS7XX_EFR_ENABLE_BIT);
+	sc16is7xx_port_update(port, SC16IS7XX_EFR_REG,
+			     SC16IS7XX_EFR_ENABLE_BIT,
+			     SC16IS7XX_EFR_ENABLE_BIT);
+	sc16is7xx_port_update(port, SC16IS7XX_MCR_REG,
+			      SC16IS7XX_MCR_CLKSEL_BIT,
+			      prescaler);
+	sc16is7xx_port_update(port, SC16IS7XX_EFR_REG,
+			     SC16IS7XX_EFR_ENABLE_BIT, 0);
 	regcache_cache_bypass(s->regmap, false);
 
 	/* Put LCR back to the normal mode */
 	sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr);
 
-	sc16is7xx_port_update(port, SC16IS7XX_MCR_REG,
-			      SC16IS7XX_MCR_CLKSEL_BIT,
-			      prescaler);
 
 	/* Open the LCR divisors for configuration */
 	sc16is7xx_port_write(port, SC16IS7XX_LCR_REG,
@@ -817,9 +819,9 @@ static unsigned int sc16is7xx_tx_empty(struct uart_port *port)
 static unsigned int sc16is7xx_get_mctrl(struct uart_port *port)
 {
 	/* DCD and DSR are not wired and CTS/RTS is handled automatically
-	 * so just indicate DSR and CAR asserted
+	 * so just indicate all inputs asserted
 	 */
-	return TIOCM_DSR | TIOCM_CAR;
+	return TIOCM_DSR | TIOCM_CAR | TIOCM_RI | TIOCM_CTS;
 }
 
 static void sc16is7xx_set_mctrl(struct uart_port *port, unsigned int mctrl)
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1451525 — Re: [PATCH 1/2] sc16is7xx: fix RTS/CTS implementation

FromGreg KH <gregkh@linuxfoundation.org>
Date2016-07-27 23:30 +0200
SubjectRe: [PATCH 1/2] sc16is7xx: fix RTS/CTS implementation
Message-ID<rZEyS-4Oy-9@gated-at.bofh.it>
In reply to#1451509
On Wed, Jul 27, 2016 at 10:58:42PM +0200, Pascal JEAN wrote:
> Signed-off-by: Pascal JEAN <epsilonrt@gmail.com>
> ---
>  drivers/tty/serial/sc16is7xx.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)

I can't take patches with out any changelog text, sorry, please add the
information you had in patch 0/2 to the text in these two patches, plus
any other information that might be needed.

Also, your Signed-off-by: and From: email addresses don't match, please
fix that up somehow.

thanks,

greg k-h

[toc] | [prev] | [next] | [standalone]


#1451746 — Re: [PATCH 1/2] sc16is7xx: fix RTS/CTS implementation

FromPascal JEAN <epsilonrt@gmail.com>
Date2016-07-28 09:00 +0200
SubjectRe: [PATCH 1/2] sc16is7xx: fix RTS/CTS implementation
Message-ID<rZNsu-2yr-19@gated-at.bofh.it>
In reply to#1451525
Hi Greg,

Here are changelog for this patch.
Best Regards

Le 27/07/2016 à 23:28, Greg KH a écrit :
> On Wed, Jul 27, 2016 at 10:58:42PM +0200, Pascal JEAN wrote:
>> Signed-off-by: Pascal JEAN <epsilonrt@gmail.com>
>> ---
>>  drivers/tty/serial/sc16is7xx.c | 16 +++++++++-------
>>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> I can't take patches with out any changelog text, sorry, please add the
> information you had in patch 0/2 to the text in these two patches, plus
> any other information that might be needed.
> 
> Also, your Signed-off-by: and From: email addresses don't match, please
> fix that up somehow.
> 
> thanks,
> 
> greg k-h
> 

Changelog:

sc16is7xx: fix RTS/CTS implementation

	RTS/CTS handshaking for sc16is7xx driver does not work,
	no character is sent regardless of the state of CTS.
	Fixes:
	1- sc16is7xx_set_baud() overwrites the flow control
	   configuration bits in EFR.
	   Writing in EFR has been replaced by an update.
	2- As noted in the file Documentation/serial/driver,
	   get_mctrl() should return an active state for
	   unsupported entries.
	After those changes everything works.


Signed-off-by: Pascal JEAN <epsilonrt@gmail.com>
---
 drivers/tty/serial/sc16is7xx.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index f36e6df..3e65079 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -511,16 +511,18 @@ static int sc16is7xx_set_baud(struct uart_port
*port, int baud)

 	/* Enable enhanced features */
 	regcache_cache_bypass(s->regmap, true);
-	sc16is7xx_port_write(port, SC16IS7XX_EFR_REG,
-			     SC16IS7XX_EFR_ENABLE_BIT);
+	sc16is7xx_port_update(port, SC16IS7XX_EFR_REG,
+			     SC16IS7XX_EFR_ENABLE_BIT,
+			     SC16IS7XX_EFR_ENABLE_BIT);
+	sc16is7xx_port_update(port, SC16IS7XX_MCR_REG,
+			      SC16IS7XX_MCR_CLKSEL_BIT,
+			      prescaler);
+	sc16is7xx_port_update(port, SC16IS7XX_EFR_REG,
+			     SC16IS7XX_EFR_ENABLE_BIT, 0);
 	regcache_cache_bypass(s->regmap, false);

 	/* Put LCR back to the normal mode */
 	sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr);

-	sc16is7xx_port_update(port, SC16IS7XX_MCR_REG,
-			      SC16IS7XX_MCR_CLKSEL_BIT,
-			      prescaler);

 	/* Open the LCR divisors for configuration */
 	sc16is7xx_port_write(port, SC16IS7XX_LCR_REG,
@@ -817,9 +819,9 @@ static unsigned int sc16is7xx_tx_empty(struct
uart_port *port)
 static unsigned int sc16is7xx_get_mctrl(struct uart_port *port)
 {
 	/* DCD and DSR are not wired and CTS/RTS is handled automatically
-	 * so just indicate DSR and CAR asserted
+	 * so just indicate all inputs asserted
 	 */
-	return TIOCM_DSR | TIOCM_CAR;
+	return TIOCM_DSR | TIOCM_CAR | TIOCM_RI | TIOCM_CTS;
 }

 static void sc16is7xx_set_mctrl(struct uart_port *port, unsigned int mctrl)
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1451754 — [PATCH 2/2] sc16is7xx: add reading CTS

FromPascal JEAN <epsilonrt@gmail.com>
Date2016-07-28 09:10 +0200
Subject[PATCH 2/2] sc16is7xx: add reading CTS
Message-ID<rZNC9-2Rd-23@gated-at.bofh.it>
In reply to#1451525
Hi Greg,

Here are changelog for this patch.
Best Regards

Changelog:

sc16is7xx: add reading CTS

	This patch adds the possibility to read the actual
	status of the CTS input when RTS/CTS handshaking is
	not activated (for general purposes).


Signed-off-by: Pascal JEAN <epsilonrt@gmail.com>
---
 drivers/tty/serial/sc16is7xx.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 3e65079..8833a18 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -818,10 +818,19 @@ static unsigned int sc16is7xx_tx_empty(struct
uart_port *port)

 static unsigned int sc16is7xx_get_mctrl(struct uart_port *port)
 {
-	/* DCD and DSR are not wired and CTS/RTS is handled automatically
-	 * so just indicate all inputs asserted
-	 */
-	return TIOCM_DSR | TIOCM_CAR | TIOCM_RI | TIOCM_CTS;
+	/* DCD, DSR and RI are not wired so just indicate asserted */
+	unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_RI;
+
+	if (port->status & UPSTAT_CTS_ENABLE)
+		/* CTS handled automatically, indicates that it is always
+		 * asserted, this is required for proper management of
+		 * the upper layer
+		 */
+		mctrl |= TIOCM_CTS;
+	else {
+		/* CTS is not managed automatically, returns its actual state
+		 * the upper layer
+		 */
+		u8 msr = sc16is7xx_port_read(port, SC16IS7XX_MSR_REG);
+
+		mctrl |= (msr & SC16IS7XX_MSR_CTS_BIT) ? TIOCM_CTS : 0;
+	}
+	return mctrl;
 }

 static void sc16is7xx_set_mctrl(struct uart_port *port, unsigned int mctrl)
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1451954 — Re: [PATCH 2/2] sc16is7xx: add reading CTS

FromGreg KH <gregkh@linuxfoundation.org>
Date2016-07-28 16:20 +0200
SubjectRe: [PATCH 2/2] sc16is7xx: add reading CTS
Message-ID<rZUki-7mZ-17@gated-at.bofh.it>
In reply to#1451754
On Thu, Jul 28, 2016 at 09:07:36AM +0200, Pascal JEAN wrote:
> Hi Greg,
> 
> Here are changelog for this patch.
> Best Regards
> 
> Changelog:

<snip>

Um, I can't take this, sorry.  Please re-read
Documentation/SubmittingPatches for how to properly format and send
things, I should not have to hand-edit any files in order to accept a
patch.

Please also version number your patches, with the needed information.
This would have been "v2", I'll expect to see "v3" after this.

Same goes for the other patch in this series.

thanks,

greg k-h

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web