linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] serial: sh-sci: modify sci_break_ctl()
@ 2012-04-06  0:59 Shimoda, Yoshihiro
  2012-04-06  1:57 ` Simon Horman
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Shimoda, Yoshihiro @ 2012-04-06  0:59 UTC (permalink / raw)
  To: linux-sh

SCIF modules which have SCSPTR can output the break signal.
This patch supports it.

This patch tested on sh7757lcr.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 about v2:
  - add serial_sci.h
  - change sci_in/sci_out to serial_port_in/serial_port_out

 drivers/tty/serial/sh-sci.c |   30 ++++++++++++++++++++++++++----
 include/linux/serial_sci.h  |    2 ++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 3158e17..3e471fc 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1564,10 +1564,32 @@ static void sci_enable_ms(struct uart_port *port)

 static void sci_break_ctl(struct uart_port *port, int break_state)
 {
-	/*
-	 * Not supported by hardware. Most parts couple break and rx
-	 * interrupts together, with break detection always enabled.
-	 */
+	struct sci_port *s = to_sci_port(port);
+	unsigned short scscr, scsptr;
+
+	switch (s->cfg->regtype) {
+	case SCIx_SH4_SCIF_REGTYPE:
+		scsptr = serial_port_in(port, SCSPTR);
+		scscr = serial_port_in(port, SCSCR);
+
+		if (break_state = -1) {
+			scsptr = (scsptr | SCSPTR_SPB2IO) & ~SCSPTR_SPB2DT;
+			scscr &= ~SCSCR_TE;
+		} else {
+			scsptr = (scsptr | SCSPTR_SPB2DT) & ~SCSPTR_SPB2IO;
+			scscr |= SCSCR_TE;
+		}
+
+		serial_port_out(port, SCSPTR, scsptr);
+		serial_port_out(port, SCSCR, scscr);
+		break;
+	default:
+		/*
+		 * Not supported by hardware. Most parts couple break and rx
+		 * interrupts together, with break detection always enabled.
+		 */
+		break;
+	}
 }

 #ifdef CONFIG_SERIAL_SH_SCI_DMA
diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h
index 7877907..eb763ad 100644
--- a/include/linux/serial_sci.h
+++ b/include/linux/serial_sci.h
@@ -52,6 +52,8 @@ enum {
 /* SCSPTR, optional */
 #define SCSPTR_RTSIO	(1 << 7)
 #define SCSPTR_CTSIO	(1 << 5)
+#define SCSPTR_SPB2IO	(1 << 1)
+#define SCSPTR_SPB2DT	(1 << 0)

 /* Offsets into the sci_port->irqs array */
 enum {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
@ 2012-04-06  1:57 ` Simon Horman
  2012-04-06  2:13 ` Shimoda, Yoshihiro
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Simon Horman @ 2012-04-06  1:57 UTC (permalink / raw)
  To: linux-sh

On Fri, Apr 06, 2012 at 09:59:14AM +0900, Shimoda, Yoshihiro wrote:
> SCIF modules which have SCSPTR can output the break signal.
> This patch supports it.
> 
> This patch tested on sh7757lcr.

Hi Shimoda-san,

I have checked that this change boots on the sh7757lcr
and that the serial console seems to work. I am curious to
know if there is anything else that can be tested.

> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  about v2:
>   - add serial_sci.h
>   - change sci_in/sci_out to serial_port_in/serial_port_out
> 
>  drivers/tty/serial/sh-sci.c |   30 ++++++++++++++++++++++++++----
>  include/linux/serial_sci.h  |    2 ++
>  2 files changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 3158e17..3e471fc 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1564,10 +1564,32 @@ static void sci_enable_ms(struct uart_port *port)
> 
>  static void sci_break_ctl(struct uart_port *port, int break_state)
>  {
> -	/*
> -	 * Not supported by hardware. Most parts couple break and rx
> -	 * interrupts together, with break detection always enabled.
> -	 */
> +	struct sci_port *s = to_sci_port(port);
> +	unsigned short scscr, scsptr;
> +
> +	switch (s->cfg->regtype) {
> +	case SCIx_SH4_SCIF_REGTYPE:
> +		scsptr = serial_port_in(port, SCSPTR);
> +		scscr = serial_port_in(port, SCSCR);
> +
> +		if (break_state = -1) {
> +			scsptr = (scsptr | SCSPTR_SPB2IO) & ~SCSPTR_SPB2DT;
> +			scscr &= ~SCSCR_TE;
> +		} else {
> +			scsptr = (scsptr | SCSPTR_SPB2DT) & ~SCSPTR_SPB2IO;
> +			scscr |= SCSCR_TE;
> +		}
> +
> +		serial_port_out(port, SCSPTR, scsptr);
> +		serial_port_out(port, SCSCR, scscr);
> +		break;
> +	default:
> +		/*
> +		 * Not supported by hardware. Most parts couple break and rx
> +		 * interrupts together, with break detection always enabled.
> +		 */
> +		break;
> +	}
>  }
> 
>  #ifdef CONFIG_SERIAL_SH_SCI_DMA
> diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h
> index 7877907..eb763ad 100644
> --- a/include/linux/serial_sci.h
> +++ b/include/linux/serial_sci.h
> @@ -52,6 +52,8 @@ enum {
>  /* SCSPTR, optional */
>  #define SCSPTR_RTSIO	(1 << 7)
>  #define SCSPTR_CTSIO	(1 << 5)
> +#define SCSPTR_SPB2IO	(1 << 1)
> +#define SCSPTR_SPB2DT	(1 << 0)
> 
>  /* Offsets into the sci_port->irqs array */
>  enum {
> -- 
> 1.7.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
  2012-04-06  1:57 ` Simon Horman
@ 2012-04-06  2:13 ` Shimoda, Yoshihiro
  2012-04-06  2:44 ` Simon Horman
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Shimoda, Yoshihiro @ 2012-04-06  2:13 UTC (permalink / raw)
  To: linux-sh

Hi Simon-san,

2012/04/06 10:57, Simon Horman wrote:
> On Fri, Apr 06, 2012 at 09:59:14AM +0900, Shimoda, Yoshihiro wrote:
>> SCIF modules which have SCSPTR can output the break signal.
>> This patch supports it.
>>
>> This patch tested on sh7757lcr.
> 
> Hi Shimoda-san,
> 
> I have checked that this change boots on the sh7757lcr
> and that the serial console seems to work. I am curious to
> know if there is anything else that can be tested.

Thank you for the check.
setup-xxxx.c which have "PORT_SCIF" can be tested:
 - SH7724, SH7785, R8A7779, etc.

Best regards,
Yoshihiro Shimoda

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
  2012-04-06  1:57 ` Simon Horman
  2012-04-06  2:13 ` Shimoda, Yoshihiro
@ 2012-04-06  2:44 ` Simon Horman
  2012-04-06  3:50 ` Shimoda, Yoshihiro
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Simon Horman @ 2012-04-06  2:44 UTC (permalink / raw)
  To: linux-sh

On Fri, Apr 06, 2012 at 11:13:24AM +0900, Shimoda, Yoshihiro wrote:
> Hi Simon-san,
> 
> 2012/04/06 10:57, Simon Horman wrote:
> > On Fri, Apr 06, 2012 at 09:59:14AM +0900, Shimoda, Yoshihiro wrote:
> >> SCIF modules which have SCSPTR can output the break signal.
> >> This patch supports it.
> >>
> >> This patch tested on sh7757lcr.
> > 
> > Hi Shimoda-san,
> > 
> > I have checked that this change boots on the sh7757lcr
> > and that the serial console seems to work. I am curious to
> > know if there is anything else that can be tested.
> 
> Thank you for the check.
> setup-xxxx.c which have "PORT_SCIF" can be tested:
>  - SH7724, SH7785, R8A7779, etc.

Thanks, I will try and test on ecovec which I believe has SH7724.
Do you have any information on how I should test the code,
other than booting it

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
                   ` (2 preceding siblings ...)
  2012-04-06  2:44 ` Simon Horman
@ 2012-04-06  3:50 ` Shimoda, Yoshihiro
  2012-04-06  5:11 ` Simon Horman
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Shimoda, Yoshihiro @ 2012-04-06  3:50 UTC (permalink / raw)
  To: linux-sh

2012/04/06 11:44, Simon Horman wrote:
> On Fri, Apr 06, 2012 at 11:13:24AM +0900, Shimoda, Yoshihiro wrote:
>>
>> Thank you for the check.
>> setup-xxxx.c which have "PORT_SCIF" can be tested:
>>  - SH7724, SH7785, R8A7779, etc.
> 
> Thanks, I will try and test on ecovec which I believe has SH7724.

Yes, ecovec has SH7724.

> Do you have any information on how I should test the code,
> other than booting it

If userland calls ioctl with TIOCSBRK/TIOCCBRK, the sci_break_ctl
is called. After TIOCSBRK we cannot send data from SCIF.
After TIOCCBRK, we can send data from SCIF.

Best regards,
Yoshihiro Shimoda

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
                   ` (3 preceding siblings ...)
  2012-04-06  3:50 ` Shimoda, Yoshihiro
@ 2012-04-06  5:11 ` Simon Horman
  2012-04-06  5:39 ` Shimoda, Yoshihiro
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Simon Horman @ 2012-04-06  5:11 UTC (permalink / raw)
  To: linux-sh

On Fri, Apr 06, 2012 at 12:50:00PM +0900, Shimoda, Yoshihiro wrote:
> 2012/04/06 11:44, Simon Horman wrote:
> > On Fri, Apr 06, 2012 at 11:13:24AM +0900, Shimoda, Yoshihiro wrote:
> >>
> >> Thank you for the check.
> >> setup-xxxx.c which have "PORT_SCIF" can be tested:
> >>  - SH7724, SH7785, R8A7779, etc.
> > 
> > Thanks, I will try and test on ecovec which I believe has SH7724.
> 
> Yes, ecovec has SH7724.
> 
> > Do you have any information on how I should test the code,
> > other than booting it
> 
> If userland calls ioctl with TIOCSBRK/TIOCCBRK, the sci_break_ctl
> is called. After TIOCSBRK we cannot send data from SCIF.
> After TIOCCBRK, we can send data from SCIF.

Thanks, that make a lot of sense.

Unfortunately the ecovec doesn't exercise the new code
as the regtype of its scif is SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE
but your code only operates on SCIx_SH4_SCIF_REGTYPE.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
                   ` (4 preceding siblings ...)
  2012-04-06  5:11 ` Simon Horman
@ 2012-04-06  5:39 ` Shimoda, Yoshihiro
  2012-04-06 11:13 ` Simon Horman
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Shimoda, Yoshihiro @ 2012-04-06  5:39 UTC (permalink / raw)
  To: linux-sh

2012/04/06 14:11, Simon Horman wrote:
> On Fri, Apr 06, 2012 at 12:50:00PM +0900, Shimoda, Yoshihiro wrote:
>>
>> If userland calls ioctl with TIOCSBRK/TIOCCBRK, the sci_break_ctl
>> is called. After TIOCSBRK we cannot send data from SCIF.
>> After TIOCCBRK, we can send data from SCIF.
> 
> Thanks, that make a lot of sense.
> 
> Unfortunately the ecovec doesn't exercise the new code
> as the regtype of its scif is SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE
> but your code only operates on SCIx_SH4_SCIF_REGTYPE.

Sorry I forgot that the SH7724 has SCIF and SCIFA.
The ecovec uses SCIF, and it doesn't have SCSPTR.
I checked the ecovec schematics, but it cannot use SCIFA because
other functions use the multiplex pins.

Best regards,
Yoshihiro Shimoda

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
                   ` (5 preceding siblings ...)
  2012-04-06  5:39 ` Shimoda, Yoshihiro
@ 2012-04-06 11:13 ` Simon Horman
  2012-04-09  7:59 ` Paul Mundt
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Simon Horman @ 2012-04-06 11:13 UTC (permalink / raw)
  To: linux-sh

On Fri, Apr 06, 2012 at 02:39:00PM +0900, Shimoda, Yoshihiro wrote:
> 2012/04/06 14:11, Simon Horman wrote:
> > On Fri, Apr 06, 2012 at 12:50:00PM +0900, Shimoda, Yoshihiro wrote:
> >>
> >> If userland calls ioctl with TIOCSBRK/TIOCCBRK, the sci_break_ctl
> >> is called. After TIOCSBRK we cannot send data from SCIF.
> >> After TIOCCBRK, we can send data from SCIF.
> > 
> > Thanks, that make a lot of sense.
> > 
> > Unfortunately the ecovec doesn't exercise the new code
> > as the regtype of its scif is SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE
> > but your code only operates on SCIx_SH4_SCIF_REGTYPE.
> 
> Sorry I forgot that the SH7724 has SCIF and SCIFA.
> The ecovec uses SCIF, and it doesn't have SCSPTR.
> I checked the ecovec schematics, but it cannot use SCIFA because
> other functions use the multiplex pins.

No problem.

In any case, Reviewed-by: Simon Horman <horms@verge.net.au>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
                   ` (6 preceding siblings ...)
  2012-04-06 11:13 ` Simon Horman
@ 2012-04-09  7:59 ` Paul Mundt
  2012-04-11  4:28 ` Paul Mundt
  2012-04-11  9:36 ` Shimoda, Yoshihiro
  9 siblings, 0 replies; 11+ messages in thread
From: Paul Mundt @ 2012-04-09  7:59 UTC (permalink / raw)
  To: linux-sh

On Fri, Apr 06, 2012 at 09:59:14AM +0900, Shimoda, Yoshihiro wrote:
> SCIF modules which have SCSPTR can output the break signal.
> This patch supports it.
> 
> This patch tested on sh7757lcr.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  about v2:
>   - add serial_sci.h
>   - change sci_in/sci_out to serial_port_in/serial_port_out
> 
Looks good to me, I'll queue it up, thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
                   ` (7 preceding siblings ...)
  2012-04-09  7:59 ` Paul Mundt
@ 2012-04-11  4:28 ` Paul Mundt
  2012-04-11  9:36 ` Shimoda, Yoshihiro
  9 siblings, 0 replies; 11+ messages in thread
From: Paul Mundt @ 2012-04-11  4:28 UTC (permalink / raw)
  To: linux-sh

On Fri, Apr 06, 2012 at 02:39:00PM +0900, Shimoda, Yoshihiro wrote:
> 2012/04/06 14:11, Simon Horman wrote:
> > On Fri, Apr 06, 2012 at 12:50:00PM +0900, Shimoda, Yoshihiro wrote:
> >>
> >> If userland calls ioctl with TIOCSBRK/TIOCCBRK, the sci_break_ctl
> >> is called. After TIOCSBRK we cannot send data from SCIF.
> >> After TIOCCBRK, we can send data from SCIF.
> > 
> > Thanks, that make a lot of sense.
> > 
> > Unfortunately the ecovec doesn't exercise the new code
> > as the regtype of its scif is SCIx_SH4_SCIF_NO_SCSPTR_REGTYPE
> > but your code only operates on SCIx_SH4_SCIF_REGTYPE.
> 
> Sorry I forgot that the SH7724 has SCIF and SCIFA.
> The ecovec uses SCIF, and it doesn't have SCSPTR.

Well, one thing that you can do is test for the SCSPTR existence and
simply not care about the port type. This is roughly what the generic
sci_init_pins() does for example.

You would have to ensure that the bits you are twiddling also exist for
the SCIx_SH2_SCIF_FIFODATA_REGTYPE, SCIx_SH2_SCIF_FIFODATA_REGTYPE, and
SCIx_SH4_SCIF_FIFODATA_REGTYPE, though.

> I checked the ecovec schematics, but it cannot use SCIFA because
> other functions use the multiplex pins.
> 
You should be able to plug them in for the port and let the sh-sci driver
try to grab the port. The port will simply be skipped if pin demux fails.
Take a look at 50f0959ad4f9ac1c5ee208bb820de299a1b3730b for an idea of
how to wire it up.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] serial: sh-sci: modify sci_break_ctl()
  2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
                   ` (8 preceding siblings ...)
  2012-04-11  4:28 ` Paul Mundt
@ 2012-04-11  9:36 ` Shimoda, Yoshihiro
  9 siblings, 0 replies; 11+ messages in thread
From: Shimoda, Yoshihiro @ 2012-04-11  9:36 UTC (permalink / raw)
  To: linux-sh

2012/04/11 13:28, Paul Mundt wrote:
> On Fri, Apr 06, 2012 at 02:39:00PM +0900, Shimoda, Yoshihiro wrote:
>>
>> Sorry I forgot that the SH7724 has SCIF and SCIFA.
>> The ecovec uses SCIF, and it doesn't have SCSPTR.
> 
> Well, one thing that you can do is test for the SCSPTR existence and
> simply not care about the port type. This is roughly what the generic
> sci_init_pins() does for example.
> 
> You would have to ensure that the bits you are twiddling also exist for
> the SCIx_SH2_SCIF_FIFODATA_REGTYPE, SCIx_SH2_SCIF_FIFODATA_REGTYPE, and
> SCIx_SH4_SCIF_FIFODATA_REGTYPE, though.

Thank you for the suggestion. I will modify the code.

>> I checked the ecovec schematics, but it cannot use SCIFA because
>> other functions use the multiplex pins.
>>
> You should be able to plug them in for the port and let the sh-sci driver
> try to grab the port. The port will simply be skipped if pin demux fails.
> Take a look at 50f0959ad4f9ac1c5ee208bb820de299a1b3730b for an idea of
> how to wire it up.
> 

I'm sorry, I don't understand this comment.
I think that if the sh-sci driver grab the port, other driver cannot
work correctly when other driver is working.

Best regards,
Yoshihiro Shimoda

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-04-11  9:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-06  0:59 [PATCH v2] serial: sh-sci: modify sci_break_ctl() Shimoda, Yoshihiro
2012-04-06  1:57 ` Simon Horman
2012-04-06  2:13 ` Shimoda, Yoshihiro
2012-04-06  2:44 ` Simon Horman
2012-04-06  3:50 ` Shimoda, Yoshihiro
2012-04-06  5:11 ` Simon Horman
2012-04-06  5:39 ` Shimoda, Yoshihiro
2012-04-06 11:13 ` Simon Horman
2012-04-09  7:59 ` Paul Mundt
2012-04-11  4:28 ` Paul Mundt
2012-04-11  9:36 ` Shimoda, Yoshihiro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).