linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Richard Genoud <richard.genoud@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Yegor Yefremov <yegor_sub1@visionsystems.de>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexander Shiyan <shc_work@mail.ru>,
	"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH RESEND 5/5] tty/serial: at91: add interrupts for modem control lines
Date: Tue, 02 Sep 2014 07:40:18 -0400	[thread overview]
Message-ID: <5405ACA2.5010308@hurleysoftware.com> (raw)
In-Reply-To: <CACQ1gAguMJM3iBSh9RN9Sbq8c-DfQUhzFPOXav2CASVHA6Rxdw@mail.gmail.com>

On 09/01/2014 05:26 AM, Richard Genoud wrote:
> 2014-08-10 21:33 GMT+02:00 Peter Hurley <peter@hurleysoftware.com>:
>> Hi Richard,
> 
> Hi !
> Sorry for the delay !
> 
>> On 05/13/2014 02:20 PM, Richard Genoud wrote:
>>> Handle CTS/DSR/RI/DCD GPIO interrupts in atmel_serial.
>>>
>>> Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
>>> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
>>> ---
>>>  drivers/tty/serial/atmel_serial.c |  125 ++++++++++++++++++++++++++++++++++++-
>>>  1 file changed, 122 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
>>> index 43ca659..3fceae0 100644
>>> --- a/drivers/tty/serial/atmel_serial.c
>>> +++ b/drivers/tty/serial/atmel_serial.c
>>> @@ -45,6 +45,7 @@
>>>  #include <linux/gpio.h>
>>>  #include <linux/gpio/consumer.h>
>>>  #include <linux/err.h>
>>> +#include <linux/irq.h>
>>>
>>>  #include <asm/io.h>
>>>  #include <asm/ioctls.h>
>>> @@ -167,7 +168,9 @@ struct atmel_uart_port {
>>>
>>>       struct serial_rs485     rs485;          /* rs485 settings */
>>>       struct mctrl_gpios      *gpios;
>>> +     int                     gpio_irq[UART_GPIO_MAX];
>>>       unsigned int            tx_done_mask;
>>> +     bool                    ms_irq_enabled;
>>>       bool                    is_usart;       /* usart or uart */
>>>       struct timer_list       uart_timer;     /* uart timer */
>>>       int (*prepare_rx)(struct uart_port *port);
>>> @@ -489,8 +492,38 @@ static void atmel_stop_rx(struct uart_port *port)
>>>   */
>>>  static void atmel_enable_ms(struct uart_port *port)
>>>  {
>>> -     UART_PUT_IER(port, ATMEL_US_RIIC | ATMEL_US_DSRIC
>>> -                     | ATMEL_US_DCDIC | ATMEL_US_CTSIC);
>>> +     struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
>>> +     uint32_t ier = 0;
>>> +
>>> +     /*
>>> +      * Interrupt should not be enabled twice
>>> +      */
>>> +     if (atmel_port->ms_irq_enabled)
>>> +             return;
>>> +
>>> +     atmel_port->ms_irq_enabled = true;
>>> +
>>> +     if (atmel_port->gpio_irq[UART_GPIO_CTS] >= 0)
>>> +             enable_irq(atmel_port->gpio_irq[UART_GPIO_CTS]);
>>> +     else
>>> +             ier |= ATMEL_US_CTSIC;
>>> +
>>> +     if (atmel_port->gpio_irq[UART_GPIO_DSR] >= 0)
>>> +             enable_irq(atmel_port->gpio_irq[UART_GPIO_DSR]);
>>> +     else
>>> +             ier |= ATMEL_US_DSRIC;
>>> +
>>> +     if (atmel_port->gpio_irq[UART_GPIO_RI] >= 0)
>>> +             enable_irq(atmel_port->gpio_irq[UART_GPIO_RI]);
>>> +     else
>>> +             ier |= ATMEL_US_RIIC;
>>> +
>>> +     if (atmel_port->gpio_irq[UART_GPIO_DCD] >= 0)
>>> +             enable_irq(atmel_port->gpio_irq[UART_GPIO_DCD]);
>>> +     else
>>> +             ier |= ATMEL_US_DCDIC;
>>
>> Where are these gpio irqs disabled if !UART_ENABLE_MS()?
> They are disabled in atmel_shutdown()/atmel_free_gpio_irq().
> Like the doc says in Documentation/serial/driver
>   enable_ms(port)
>     Enable the modem status interrupts.
> 
>     This method may be called multiple times.  Modem status
>     interrupts should be disabled when the shutdown method is
>     called.

Thanks for replying.

The point of the UART_ENABLE_MS() macro is to allow the UART driver
to determine if modem status interrupts need to be enabled when
handling the .set_termios() method.

When handling set_termios(), if UART_ENABLE_MS is false (ie., the
serial core does not require modem status interrupts), the UART
driver can and should turn modem status interrupts off.

It is _also_ true that "modem status interrupts should be disabled
when the shutdown method is called"; in fact, _all_ UART-sourced
interrupts should be disabled when the shutdown method is called.

Regards,
Peter Hurley


  reply	other threads:[~2014-09-02 11:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 18:20 [PATCH RESEND 0/5] tty/serial: Add helpers to use GPIOs to control modem lines and implement atmel_serial.c Richard Genoud
2014-05-13 18:20 ` [PATCH RESEND 1/5] tty/serial: atmel_serial: Fix device tree documentation Richard Genoud
2014-05-13 18:20 ` [PATCH RESEND 2/5] ARM: at91: gpio: implement get_direction Richard Genoud
2014-05-13 18:20 ` [PATCH RESEND 3/5] tty/serial: Add GPIOLIB helpers for controlling modem lines Richard Genoud
2014-05-20  9:26   ` Yegor Yefremov
2014-05-28 19:45   ` Greg Kroah-Hartman
2014-05-28 19:47     ` Greg Kroah-Hartman
2014-05-13 18:20 ` [PATCH RESEND 4/5] tty/serial: at91: use mctrl_gpio helpers Richard Genoud
2014-05-13 18:20 ` [PATCH RESEND 5/5] tty/serial: at91: add interrupts for modem control lines Richard Genoud
2014-08-10 19:33   ` Peter Hurley
2014-09-01  9:26     ` Richard Genoud
2014-09-02 11:40       ` Peter Hurley [this message]
2014-09-03 10:50         ` Richard Genoud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5405ACA2.5010308@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=richard.genoud@gmail.com \
    --cc=shc_work@mail.ru \
    --cc=yegor_sub1@visionsystems.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).