From: Claudio Scordino <claudio@evidence.eu.com>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Alan Cox <alan@linux.intel.com>,
Juergen Beisert <jbe@pengutronix.de>,
Matthias Fuchs <mfuchs@ma-fu.de>
Subject: Re: [PATCH 2/8] serial: 8250: Add ioctl to enable auto rs485 mode with some Exar UARTs
Date: Thu, 17 Nov 2011 10:40:14 +0100 [thread overview]
Message-ID: <4EC4D67E.1050102@evidence.eu.com> (raw)
In-Reply-To: <1321460685-15753-3-git-send-email-w.sang@pengutronix.de>
Hi Wolfram,
Il 16/11/2011 17:24, Wolfram Sang ha scritto:
> From: Matthias Fuchs<mfuchs@ma-fu.de>
>
> Some Exar UARTs support an auto rs485 mode. In this mode
> the UART's RTS# pin is activated during transmitting and
> can be used to enable a rs485 line driver. This has nothing
> to do with attempts to do this by manually asserting/
> deasserting handshake lines in software.
>
> Signed-off-by: Matthias Fuchs<mfuchs@ma-fu.de>
>
> [wsa] Replaced 0xbf with define, saved some line-breaks.
>
> Signed-off-by: Wolfram Sang<w.sang@pengutronix.de>
> ---
> drivers/tty/serial/8250.c | 68 ++++++++++++++++++++++++++++++++++++++++++++
> include/linux/serial_reg.h | 1 +
> 2 files changed, 69 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
> index f8f2320..920b4df 100644
> --- a/drivers/tty/serial/8250.c
> +++ b/drivers/tty/serial/8250.c
> @@ -38,6 +38,7 @@
> #include<linux/nmi.h>
> #include<linux/mutex.h>
> #include<linux/slab.h>
> +#include<linux/uaccess.h>
>
> #include<asm/io.h>
> #include<asm/irq.h>
> @@ -2698,6 +2699,72 @@ serial8250_type(struct uart_port *port)
> return uart_config[type].name;
> }
>
> +static int serial8250_ioctl_port(struct uart_port *port,
> + unsigned int cmd, unsigned long arg)
> +{
> + struct uart_8250_port *up = (struct uart_8250_port *)port;
> + unsigned long flags;
> +
> + switch (cmd) {
> + case TIOCSRS485:
> + {
> + struct serial_rs485 rs485ctrl;
> + unsigned char fctr, lcr;
> +
> + if (port->type != PORT_16850)
> + return -ENOTTY;
> +
> + if (copy_from_user(&rs485ctrl, (struct serial_rs485 *)arg,
> + sizeof(rs485ctrl)))
> + return -EFAULT;
> +
> + spin_lock_irqsave(&up->port.lock, flags);
> + lcr = serial_inp(up, UART_LCR);
> + serial_outp(up, UART_LCR, UART_LCR_CONF_MODE_B);
> + fctr = serial_inp(up, UART_FCTR);
> + if (rs485ctrl.flags& SER_RS485_ENABLED)
> + fctr |= UART_FCTR_RS485;
> + else
> + fctr&= ~UART_FCTR_RS485;
> + serial_outp(up, UART_FCTR, fctr);
> + serial_outp(up, UART_LCR, lcr);
> + spin_unlock_irqrestore(&up->port.lock, flags);
> + return 0;
> + }
> +
> + case TIOCGRS485:
> + {
> + struct serial_rs485 rs485ctrl;
> + unsigned char lcr;
> +
> + if (port->type != PORT_16850)
> + return -ENOTTY;
> +
> + memset(&rs485ctrl, 0, sizeof(rs485ctrl));
> +
> + spin_lock_irqsave(&up->port.lock, flags);
> + lcr = serial_inp(up, UART_LCR);
> + serial_outp(up, UART_LCR, UART_LCR_CONF_MODE_B);
> + if (serial_inp(up, UART_FCTR)& UART_FCTR_RS485)
> + rs485ctrl.flags = SER_RS485_ENABLED;
> + else
> + rs485ctrl.flags = 0;
This else branch may be removed, since the structure has been already memsetted to 0.
Claudio
next prev parent reply other threads:[~2011-11-17 9:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-16 16:24 [PATCH 0/8] serial: 8250: support hw-based RS485 direction control (finally!) Wolfram Sang
2011-11-16 16:24 ` [PATCH 1/8] serial: 8250: replace hardcoded 0xbf with #define Wolfram Sang
2011-11-16 16:24 ` [PATCH 2/8] serial: 8250: Add ioctl to enable auto rs485 mode with some Exar UARTs Wolfram Sang
2011-11-17 9:40 ` Claudio Scordino [this message]
2011-11-17 10:09 ` Wolfram Sang
2011-11-16 16:24 ` [PATCH 3/8] serial: 8250: save rs485_flags per instance Wolfram Sang
2011-11-16 16:24 ` [PATCH 4/8] serial: 8250: add RX_DURING_TX capability to RS485 mode Wolfram Sang
2011-11-16 16:24 ` [PATCH 5/8] serial: 8250: reject delaying RTS with RS485 Wolfram Sang
2011-11-17 9:43 ` Claudio Scordino
2011-11-17 10:14 ` Wolfram Sang
2011-11-16 16:24 ` [PATCH 6/8] serial: 8250: update rs485 flags with polarity settings Wolfram Sang
2011-11-16 16:24 ` [PATCH 7/8] serial: 8250: add Exar 16V2750 support Wolfram Sang
2011-11-16 16:24 ` [PATCH 8/8] serial: 8250: fix comment about accessing EMSR Wolfram Sang
2011-11-23 15:03 ` [PATCH 0/8] serial: 8250: support hw-based RS485 direction control (finally!) Wolfram Sang
2011-11-24 16:05 ` Claudio Scordino
2011-11-24 16:05 ` Claudio Scordino
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=4EC4D67E.1050102@evidence.eu.com \
--to=claudio@evidence.eu.com \
--cc=alan@linux.intel.com \
--cc=jbe@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mfuchs@ma-fu.de \
--cc=w.sang@pengutronix.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 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.