All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] serial: 8250_dw: Add support for IrDA SIR mode
@ 2016-10-27 16:38 ` Ed Blake
  0 siblings, 0 replies; 7+ messages in thread
From: Ed Blake @ 2016-10-27 16:38 UTC (permalink / raw)
  To: gregkh
  Cc: jslaby, andriy.shevchenko, wangkefeng.wang, heikki.krogerus,
	noamc, annie.wang, linux-serial, linux-kernel, james.hartley,
	Ed Blake

Add a set_ldisc function to enable/disable IrDA SIR mode according to
the new line discipline.

Signed-off-by: Ed Blake <ed.blake@imgtec.com>
---
 drivers/tty/serial/8250/8250_dw.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 459d726..7dd5369 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -53,6 +53,8 @@
 /* Helper for fifo size calculation */
 #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
 
+/* DesignWare specific register fields */
+#define DW_UART_MCR_SIRE		BIT(6)
 
 struct dw8250_data {
 	u8			usr_reg;
@@ -254,6 +256,20 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
 	serial8250_do_set_termios(p, termios, old);
 }
 
+static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios)
+{
+	unsigned int mcr = p->serial_in(p, UART_MCR);
+
+	if (termios->c_line == N_IRDA)
+		mcr |= DW_UART_MCR_SIRE;
+	else
+		mcr &= ~DW_UART_MCR_SIRE;
+
+	p->serial_out(p, UART_MCR, mcr);
+
+	serial8250_do_set_ldisc(p, termios);
+}
+
 /*
  * dw8250_fallback_dma_filter will prevent the UART from getting just any free
  * channel on platforms that have DMA engines, but don't have any channels
@@ -392,6 +408,7 @@ static int dw8250_probe(struct platform_device *pdev)
 	p->iotype	= UPIO_MEM;
 	p->serial_in	= dw8250_serial_in;
 	p->serial_out	= dw8250_serial_out;
+	p->set_ldisc	= dw8250_set_ldisc;
 
 	p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
 	if (!p->membase)
-- 
1.9.1

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

* [PATCH 2/2] serial: 8250_dw: Add support for IrDA SIR mode
@ 2016-10-27 16:38 ` Ed Blake
  0 siblings, 0 replies; 7+ messages in thread
From: Ed Blake @ 2016-10-27 16:38 UTC (permalink / raw)
  To: gregkh
  Cc: jslaby, andriy.shevchenko, wangkefeng.wang, heikki.krogerus,
	noamc, annie.wang, linux-serial, linux-kernel, james.hartley,
	Ed Blake

Add a set_ldisc function to enable/disable IrDA SIR mode according to
the new line discipline.

Signed-off-by: Ed Blake <ed.blake@imgtec.com>
---
 drivers/tty/serial/8250/8250_dw.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 459d726..7dd5369 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -53,6 +53,8 @@
 /* Helper for fifo size calculation */
 #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
 
+/* DesignWare specific register fields */
+#define DW_UART_MCR_SIRE		BIT(6)
 
 struct dw8250_data {
 	u8			usr_reg;
@@ -254,6 +256,20 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
 	serial8250_do_set_termios(p, termios, old);
 }
 
+static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios)
+{
+	unsigned int mcr = p->serial_in(p, UART_MCR);
+
+	if (termios->c_line == N_IRDA)
+		mcr |= DW_UART_MCR_SIRE;
+	else
+		mcr &= ~DW_UART_MCR_SIRE;
+
+	p->serial_out(p, UART_MCR, mcr);
+
+	serial8250_do_set_ldisc(p, termios);
+}
+
 /*
  * dw8250_fallback_dma_filter will prevent the UART from getting just any free
  * channel on platforms that have DMA engines, but don't have any channels
@@ -392,6 +408,7 @@ static int dw8250_probe(struct platform_device *pdev)
 	p->iotype	= UPIO_MEM;
 	p->serial_in	= dw8250_serial_in;
 	p->serial_out	= dw8250_serial_out;
+	p->set_ldisc	= dw8250_set_ldisc;
 
 	p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
 	if (!p->membase)
-- 
1.9.1

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

* Re: [PATCH 2/2] serial: 8250_dw: Add support for IrDA SIR mode
  2016-10-27 16:38 ` Ed Blake
  (?)
@ 2016-10-27 16:56 ` Andy Shevchenko
  2016-10-27 17:33     ` Ed Blake
  2016-10-28  8:20   ` Heikki Krogerus
  -1 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2016-10-27 16:56 UTC (permalink / raw)
  To: Ed Blake, gregkh
  Cc: jslaby, wangkefeng.wang, heikki.krogerus, noamc, annie.wang,
	linux-serial, linux-kernel, james.hartley

On Thu, 2016-10-27 at 17:38 +0100, Ed Blake wrote:
> Add a set_ldisc function to enable/disable IrDA SIR mode according to
> the new line discipline.

Thanks for the patch.

Consider that not all implementations based on 8250_dw support IRDA
feature. I suppose you need to read capability register bits 6 and 7,
set flag and then based on the value accept or reject IRDA mode.

P.S. Use -n when prepare patches to link them if you consider them
dependent.

> 
> Signed-off-by: Ed Blake <ed.blake@imgtec.com>
> ---
>  drivers/tty/serial/8250/8250_dw.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_dw.c
> b/drivers/tty/serial/8250/8250_dw.c
> index 459d726..7dd5369 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -53,6 +53,8 @@
>  /* Helper for fifo size calculation */
>  #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
>  
> +/* DesignWare specific register fields */
> +#define DW_UART_MCR_SIRE		BIT(6)
>  
>  struct dw8250_data {
>  	u8			usr_reg;
> @@ -254,6 +256,20 @@ static void dw8250_set_termios(struct uart_port
> *p, struct ktermios *termios,
>  	serial8250_do_set_termios(p, termios, old);
>  }
>  
> +static void dw8250_set_ldisc(struct uart_port *p, struct ktermios
> *termios)
> +{
> +	unsigned int mcr = p->serial_in(p, UART_MCR);
> +
> +	if (termios->c_line == N_IRDA)
> +		mcr |= DW_UART_MCR_SIRE;
> +	else
> +		mcr &= ~DW_UART_MCR_SIRE;
> +
> +	p->serial_out(p, UART_MCR, mcr);
> +
> +	serial8250_do_set_ldisc(p, termios);
> +}
> +
>  /*
>   * dw8250_fallback_dma_filter will prevent the UART from getting just
> any free
>   * channel on platforms that have DMA engines, but don't have any
> channels
> @@ -392,6 +408,7 @@ static int dw8250_probe(struct platform_device
> *pdev)
>  	p->iotype	= UPIO_MEM;
>  	p->serial_in	= dw8250_serial_in;
>  	p->serial_out	= dw8250_serial_out;
> +	p->set_ldisc	= dw8250_set_ldisc;
>  
>  	p->membase = devm_ioremap(dev, regs->start,
> resource_size(regs));
>  	if (!p->membase)

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH 2/2] serial: 8250_dw: Add support for IrDA SIR mode
  2016-10-27 16:56 ` Andy Shevchenko
@ 2016-10-27 17:33     ` Ed Blake
  2016-10-28  8:20   ` Heikki Krogerus
  1 sibling, 0 replies; 7+ messages in thread
From: Ed Blake @ 2016-10-27 17:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: gregkh, jslaby, wangkefeng.wang, heikki.krogerus, noamc,
	annie.wang, linux-serial, linux-kernel, james.hartley

On 10/27/16 17:56, Andy Shevchenko wrote:
> On Thu, 2016-10-27 at 17:38 +0100, Ed Blake wrote:
>> Add a set_ldisc function to enable/disable IrDA SIR mode according to
>> the new line discipline.
> Thanks for the patch.
>
> Consider that not all implementations based on 8250_dw support IRDA
> feature. I suppose you need to read capability register bits 6 and 7,
> set flag and then based on the value accept or reject IRDA mode.

Thanks for the review, I'll add this for the second version.

Ed.

>
> P.S. Use -n when prepare patches to link them if you consider them
> dependent.
>
>> Signed-off-by: Ed Blake <ed.blake@imgtec.com>
>> ---
>>   drivers/tty/serial/8250/8250_dw.c | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/tty/serial/8250/8250_dw.c
>> b/drivers/tty/serial/8250/8250_dw.c
>> index 459d726..7dd5369 100644
>> --- a/drivers/tty/serial/8250/8250_dw.c
>> +++ b/drivers/tty/serial/8250/8250_dw.c
>> @@ -53,6 +53,8 @@
>>   /* Helper for fifo size calculation */
>>   #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
>>   
>> +/* DesignWare specific register fields */
>> +#define DW_UART_MCR_SIRE		BIT(6)
>>   
>>   struct dw8250_data {
>>   	u8			usr_reg;
>> @@ -254,6 +256,20 @@ static void dw8250_set_termios(struct uart_port
>> *p, struct ktermios *termios,
>>   	serial8250_do_set_termios(p, termios, old);
>>   }
>>   
>> +static void dw8250_set_ldisc(struct uart_port *p, struct ktermios
>> *termios)
>> +{
>> +	unsigned int mcr = p->serial_in(p, UART_MCR);
>> +
>> +	if (termios->c_line == N_IRDA)
>> +		mcr |= DW_UART_MCR_SIRE;
>> +	else
>> +		mcr &= ~DW_UART_MCR_SIRE;
>> +
>> +	p->serial_out(p, UART_MCR, mcr);
>> +
>> +	serial8250_do_set_ldisc(p, termios);
>> +}
>> +
>>   /*
>>    * dw8250_fallback_dma_filter will prevent the UART from getting just
>> any free
>>    * channel on platforms that have DMA engines, but don't have any
>> channels
>> @@ -392,6 +408,7 @@ static int dw8250_probe(struct platform_device
>> *pdev)
>>   	p->iotype	= UPIO_MEM;
>>   	p->serial_in	= dw8250_serial_in;
>>   	p->serial_out	= dw8250_serial_out;
>> +	p->set_ldisc	= dw8250_set_ldisc;
>>   
>>   	p->membase = devm_ioremap(dev, regs->start,
>> resource_size(regs));
>>   	if (!p->membase)

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

* Re: [PATCH 2/2] serial: 8250_dw: Add support for IrDA SIR mode
@ 2016-10-27 17:33     ` Ed Blake
  0 siblings, 0 replies; 7+ messages in thread
From: Ed Blake @ 2016-10-27 17:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: gregkh, jslaby, wangkefeng.wang, heikki.krogerus, noamc,
	annie.wang, linux-serial, linux-kernel, james.hartley

On 10/27/16 17:56, Andy Shevchenko wrote:
> On Thu, 2016-10-27 at 17:38 +0100, Ed Blake wrote:
>> Add a set_ldisc function to enable/disable IrDA SIR mode according to
>> the new line discipline.
> Thanks for the patch.
>
> Consider that not all implementations based on 8250_dw support IRDA
> feature. I suppose you need to read capability register bits 6 and 7,
> set flag and then based on the value accept or reject IRDA mode.

Thanks for the review, I'll add this for the second version.

Ed.

>
> P.S. Use -n when prepare patches to link them if you consider them
> dependent.
>
>> Signed-off-by: Ed Blake <ed.blake@imgtec.com>
>> ---
>>   drivers/tty/serial/8250/8250_dw.c | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/tty/serial/8250/8250_dw.c
>> b/drivers/tty/serial/8250/8250_dw.c
>> index 459d726..7dd5369 100644
>> --- a/drivers/tty/serial/8250/8250_dw.c
>> +++ b/drivers/tty/serial/8250/8250_dw.c
>> @@ -53,6 +53,8 @@
>>   /* Helper for fifo size calculation */
>>   #define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
>>   
>> +/* DesignWare specific register fields */
>> +#define DW_UART_MCR_SIRE		BIT(6)
>>   
>>   struct dw8250_data {
>>   	u8			usr_reg;
>> @@ -254,6 +256,20 @@ static void dw8250_set_termios(struct uart_port
>> *p, struct ktermios *termios,
>>   	serial8250_do_set_termios(p, termios, old);
>>   }
>>   
>> +static void dw8250_set_ldisc(struct uart_port *p, struct ktermios
>> *termios)
>> +{
>> +	unsigned int mcr = p->serial_in(p, UART_MCR);
>> +
>> +	if (termios->c_line == N_IRDA)
>> +		mcr |= DW_UART_MCR_SIRE;
>> +	else
>> +		mcr &= ~DW_UART_MCR_SIRE;
>> +
>> +	p->serial_out(p, UART_MCR, mcr);
>> +
>> +	serial8250_do_set_ldisc(p, termios);
>> +}
>> +
>>   /*
>>    * dw8250_fallback_dma_filter will prevent the UART from getting just
>> any free
>>    * channel on platforms that have DMA engines, but don't have any
>> channels
>> @@ -392,6 +408,7 @@ static int dw8250_probe(struct platform_device
>> *pdev)
>>   	p->iotype	= UPIO_MEM;
>>   	p->serial_in	= dw8250_serial_in;
>>   	p->serial_out	= dw8250_serial_out;
>> +	p->set_ldisc	= dw8250_set_ldisc;
>>   
>>   	p->membase = devm_ioremap(dev, regs->start,
>> resource_size(regs));
>>   	if (!p->membase)

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

* Re: [PATCH 2/2] serial: 8250_dw: Add support for IrDA SIR mode
  2016-10-27 16:56 ` Andy Shevchenko
  2016-10-27 17:33     ` Ed Blake
@ 2016-10-28  8:20   ` Heikki Krogerus
  2016-10-28 10:45     ` Andy Shevchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Heikki Krogerus @ 2016-10-28  8:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Ed Blake, gregkh, jslaby, wangkefeng.wang, noamc, annie.wang,
	linux-serial, linux-kernel, james.hartley

Hi Andy,

On Thu, Oct 27, 2016 at 07:56:10PM +0300, Andy Shevchenko wrote:
> On Thu, 2016-10-27 at 17:38 +0100, Ed Blake wrote:
> > Add a set_ldisc function to enable/disable IrDA SIR mode according to
> > the new line discipline.
> 
> Thanks for the patch.
> 
> Consider that not all implementations based on 8250_dw support IRDA
> feature. I suppose you need to read capability register bits 6 and 7,
> set flag and then based on the value accept or reject IRDA mode.
> 
> P.S. Use -n when prepare patches to link them if you consider them
> dependent.

These are numbered? Or do you mean that please prefer sending
series of patches as threads?

        % git send-email --thread...

Or something like that? I guess coverletter would be nice too.


Thanks,

-- 
heikki

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

* Re: [PATCH 2/2] serial: 8250_dw: Add support for IrDA SIR mode
  2016-10-28  8:20   ` Heikki Krogerus
@ 2016-10-28 10:45     ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2016-10-28 10:45 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Ed Blake, gregkh, jslaby, wangkefeng.wang, noamc, annie.wang,
	linux-serial, linux-kernel, james.hartley

On Fri, 2016-10-28 at 11:20 +0300, Heikki Krogerus wrote:
> Hi Andy,
> 
> On Thu, Oct 27, 2016 at 07:56:10PM +0300, Andy Shevchenko wrote:
> > P.S. Use -n when prepare patches to link them if you consider them
> > dependent.
> 
> These are numbered? Or do you mean that please prefer sending
> series of patches as threads?
> 
>         % git send-email --thread...
> 
> Or something like that? I guess coverletter would be nice too.

Yes, you are right. Sorry for confusion.


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

end of thread, other threads:[~2016-10-28 10:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 16:38 [PATCH 2/2] serial: 8250_dw: Add support for IrDA SIR mode Ed Blake
2016-10-27 16:38 ` Ed Blake
2016-10-27 16:56 ` Andy Shevchenko
2016-10-27 17:33   ` Ed Blake
2016-10-27 17:33     ` Ed Blake
2016-10-28  8:20   ` Heikki Krogerus
2016-10-28 10:45     ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.