From: Bhuvanchandra DV <bhuvanchandra.dv-2KBjVHiyJgBBDgjK7y7TUQ@public.gmane.org>
To: "Jakub Kiciński" <moorray3-5tc4TXWwyLM@public.gmane.org>
Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
stefan-XLVq0VzYD2Y@public.gmane.org,
shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
jslaby-AlSwsSmVLrQ@public.gmane.org,
linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
bhuvanchandra.dv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH 3/3] tty: serial: fsl_lpuart: Add support for RS-485
Date: Fri, 29 May 2015 16:12:13 +0530 [thread overview]
Message-ID: <55684285.4000004@toradex.com> (raw)
In-Reply-To: <20150529121808.27346afc@north>
On 05/29/2015 03:48 PM, Jakub Kiciński wrote:
> On Fri, 29 May 2015 13:35:54 +0530, Bhuvanchandra DV wrote:
>> Enable Vybrid's build-in support for RS-485 auto RTS for
>> controlling line direction of RS-485 transceiver driver.
>>
>> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv-2KBjVHiyJgBBDgjK7y7TUQ@public.gmane.org>
>> ---
>> drivers/tty/serial/fsl_lpuart.c | 60 +++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 60 insertions(+)
>>
>> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
>> index 357f623..c553b14 100644
>> --- a/drivers/tty/serial/fsl_lpuart.c
>> +++ b/drivers/tty/serial/fsl_lpuart.c
>> @@ -820,6 +820,50 @@ static unsigned int lpuart32_tx_empty(struct uart_port *port)
>> TIOCSER_TEMT : 0;
>> }
>>
>> +static int lpuart_config_rs485(struct uart_port *port,
>> + struct serial_rs485 *rs485)
>> +{
>> + struct lpuart_port *sport = container_of(port,
>> + struct lpuart_port, port);
>> + u8 modem = readb(sport->port.membase + UARTMODEM) &
>> + ~(UARTMODEM_TXRTSPOL | UARTMODEM_TXRTSE);
>
> Please put empty line between variables and code.
Ok
>
>> + writeb(modem, sport->port.membase + UARTMODEM);
>> +
>> + if (rs485->flags & SER_RS485_ENABLED) {
>> + /* Enable auto RS-485 RTS mode */
>> + modem |= UARTMODEM_TXRTSE;
>> +
>> + /*
>> + * RTS needs to be logic HIGH either during transer _or_ after
>> + * transfer, other variants are not supported by the hardware.
>> + */
>
> Indentation is off here. '*' should be aligned.
Ok
>
>> + if (!(rs485->flags & (SER_RS485_RTS_ON_SEND |
>> + SER_RS485_RTS_AFTER_SEND)))
>
> and here - things should be aligned on the containing bracket (SER_
> under SER_ here).
Ok
>
>> + rs485->flags |= SER_RS485_RTS_ON_SEND;
>> +
>> + if (rs485->flags & SER_RS485_RTS_ON_SEND &&
>> + rs485->flags & SER_RS485_RTS_AFTER_SEND)
>
> and here - same bracket rule (rs485-> under rs485->)
Ok
>
>> + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND;
>> +
>> + /*
>> + * The hardware defaults to RTS logic HIGH while transfer.
>> + * Switch polarity in case RTS shall be logic HIGH
>> + * after transfer.
>> + * Note: UART is assumed to be active high.
>> + */
>> + if (rs485->flags & SER_RS485_RTS_ON_SEND)
>> + modem &= ~UARTMODEM_TXRTSPOL;
>
> UARTMODEM_TXRTSPOL was already clear when you read modem.
Ok
>
>> + else if (rs485->flags & SER_RS485_RTS_AFTER_SEND)
>> + modem |= UARTMODEM_TXRTSPOL;
>> + }
>> +
>> + /* Store the new configuration */
>> + sport->port.rs485 = *rs485;
>> +
>> + writeb(modem, sport->port.membase + UARTMODEM);
>> + return 0;
>> +}
>> +
>> static unsigned int lpuart_get_mctrl(struct uart_port *port)
>> {
>> return TIOCM_CAR | TIOCM_CTS | TIOCM_DSR;
> [...]
>> @@ -1802,6 +1854,14 @@ static int lpuart_probe(struct platform_device *pdev)
>> dev_info(sport->port.dev, "DMA rx channel request failed, "
>> "operating without rx DMA\n");
>>
>> + if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) {
>> + sport->port.rs485.flags |= SER_RS485_ENABLED;
>> + sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
>> + writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
>> + } else {
>> + sport->port.rs485.flags &= ~SER_RS485_ENABLED;
>
> Why the need to clear the flag? sport was kzalloc'ed.
Will remove it.
>
Best Regards,
Bhuvan
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: bhuvanchandra.dv@toradex.com (Bhuvanchandra DV)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] tty: serial: fsl_lpuart: Add support for RS-485
Date: Fri, 29 May 2015 16:12:13 +0530 [thread overview]
Message-ID: <55684285.4000004@toradex.com> (raw)
In-Reply-To: <20150529121808.27346afc@north>
On 05/29/2015 03:48 PM, Jakub Kici?ski wrote:
> On Fri, 29 May 2015 13:35:54 +0530, Bhuvanchandra DV wrote:
>> Enable Vybrid's build-in support for RS-485 auto RTS for
>> controlling line direction of RS-485 transceiver driver.
>>
>> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
>> ---
>> drivers/tty/serial/fsl_lpuart.c | 60 +++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 60 insertions(+)
>>
>> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
>> index 357f623..c553b14 100644
>> --- a/drivers/tty/serial/fsl_lpuart.c
>> +++ b/drivers/tty/serial/fsl_lpuart.c
>> @@ -820,6 +820,50 @@ static unsigned int lpuart32_tx_empty(struct uart_port *port)
>> TIOCSER_TEMT : 0;
>> }
>>
>> +static int lpuart_config_rs485(struct uart_port *port,
>> + struct serial_rs485 *rs485)
>> +{
>> + struct lpuart_port *sport = container_of(port,
>> + struct lpuart_port, port);
>> + u8 modem = readb(sport->port.membase + UARTMODEM) &
>> + ~(UARTMODEM_TXRTSPOL | UARTMODEM_TXRTSE);
>
> Please put empty line between variables and code.
Ok
>
>> + writeb(modem, sport->port.membase + UARTMODEM);
>> +
>> + if (rs485->flags & SER_RS485_ENABLED) {
>> + /* Enable auto RS-485 RTS mode */
>> + modem |= UARTMODEM_TXRTSE;
>> +
>> + /*
>> + * RTS needs to be logic HIGH either during transer _or_ after
>> + * transfer, other variants are not supported by the hardware.
>> + */
>
> Indentation is off here. '*' should be aligned.
Ok
>
>> + if (!(rs485->flags & (SER_RS485_RTS_ON_SEND |
>> + SER_RS485_RTS_AFTER_SEND)))
>
> and here - things should be aligned on the containing bracket (SER_
> under SER_ here).
Ok
>
>> + rs485->flags |= SER_RS485_RTS_ON_SEND;
>> +
>> + if (rs485->flags & SER_RS485_RTS_ON_SEND &&
>> + rs485->flags & SER_RS485_RTS_AFTER_SEND)
>
> and here - same bracket rule (rs485-> under rs485->)
Ok
>
>> + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND;
>> +
>> + /*
>> + * The hardware defaults to RTS logic HIGH while transfer.
>> + * Switch polarity in case RTS shall be logic HIGH
>> + * after transfer.
>> + * Note: UART is assumed to be active high.
>> + */
>> + if (rs485->flags & SER_RS485_RTS_ON_SEND)
>> + modem &= ~UARTMODEM_TXRTSPOL;
>
> UARTMODEM_TXRTSPOL was already clear when you read modem.
Ok
>
>> + else if (rs485->flags & SER_RS485_RTS_AFTER_SEND)
>> + modem |= UARTMODEM_TXRTSPOL;
>> + }
>> +
>> + /* Store the new configuration */
>> + sport->port.rs485 = *rs485;
>> +
>> + writeb(modem, sport->port.membase + UARTMODEM);
>> + return 0;
>> +}
>> +
>> static unsigned int lpuart_get_mctrl(struct uart_port *port)
>> {
>> return TIOCM_CAR | TIOCM_CTS | TIOCM_DSR;
> [...]
>> @@ -1802,6 +1854,14 @@ static int lpuart_probe(struct platform_device *pdev)
>> dev_info(sport->port.dev, "DMA rx channel request failed, "
>> "operating without rx DMA\n");
>>
>> + if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) {
>> + sport->port.rs485.flags |= SER_RS485_ENABLED;
>> + sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
>> + writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
>> + } else {
>> + sport->port.rs485.flags &= ~SER_RS485_ENABLED;
>
> Why the need to clear the flag? sport was kzalloc'ed.
Will remove it.
>
Best Regards,
Bhuvan
WARNING: multiple messages have this Message-ID (diff)
From: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
To: "Jakub Kiciński" <moorray3@wp.pl>
Cc: <gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>,
<stefan@agner.ch>, <shawn.guo@linaro.org>,
<kernel@pengutronix.de>, <jslaby@suse.cz>,
<linux-serial@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <bhuvanchandra.dv@gmail.com>
Subject: Re: [PATCH 3/3] tty: serial: fsl_lpuart: Add support for RS-485
Date: Fri, 29 May 2015 16:12:13 +0530 [thread overview]
Message-ID: <55684285.4000004@toradex.com> (raw)
In-Reply-To: <20150529121808.27346afc@north>
On 05/29/2015 03:48 PM, Jakub Kiciński wrote:
> On Fri, 29 May 2015 13:35:54 +0530, Bhuvanchandra DV wrote:
>> Enable Vybrid's build-in support for RS-485 auto RTS for
>> controlling line direction of RS-485 transceiver driver.
>>
>> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
>> ---
>> drivers/tty/serial/fsl_lpuart.c | 60 +++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 60 insertions(+)
>>
>> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
>> index 357f623..c553b14 100644
>> --- a/drivers/tty/serial/fsl_lpuart.c
>> +++ b/drivers/tty/serial/fsl_lpuart.c
>> @@ -820,6 +820,50 @@ static unsigned int lpuart32_tx_empty(struct uart_port *port)
>> TIOCSER_TEMT : 0;
>> }
>>
>> +static int lpuart_config_rs485(struct uart_port *port,
>> + struct serial_rs485 *rs485)
>> +{
>> + struct lpuart_port *sport = container_of(port,
>> + struct lpuart_port, port);
>> + u8 modem = readb(sport->port.membase + UARTMODEM) &
>> + ~(UARTMODEM_TXRTSPOL | UARTMODEM_TXRTSE);
>
> Please put empty line between variables and code.
Ok
>
>> + writeb(modem, sport->port.membase + UARTMODEM);
>> +
>> + if (rs485->flags & SER_RS485_ENABLED) {
>> + /* Enable auto RS-485 RTS mode */
>> + modem |= UARTMODEM_TXRTSE;
>> +
>> + /*
>> + * RTS needs to be logic HIGH either during transer _or_ after
>> + * transfer, other variants are not supported by the hardware.
>> + */
>
> Indentation is off here. '*' should be aligned.
Ok
>
>> + if (!(rs485->flags & (SER_RS485_RTS_ON_SEND |
>> + SER_RS485_RTS_AFTER_SEND)))
>
> and here - things should be aligned on the containing bracket (SER_
> under SER_ here).
Ok
>
>> + rs485->flags |= SER_RS485_RTS_ON_SEND;
>> +
>> + if (rs485->flags & SER_RS485_RTS_ON_SEND &&
>> + rs485->flags & SER_RS485_RTS_AFTER_SEND)
>
> and here - same bracket rule (rs485-> under rs485->)
Ok
>
>> + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND;
>> +
>> + /*
>> + * The hardware defaults to RTS logic HIGH while transfer.
>> + * Switch polarity in case RTS shall be logic HIGH
>> + * after transfer.
>> + * Note: UART is assumed to be active high.
>> + */
>> + if (rs485->flags & SER_RS485_RTS_ON_SEND)
>> + modem &= ~UARTMODEM_TXRTSPOL;
>
> UARTMODEM_TXRTSPOL was already clear when you read modem.
Ok
>
>> + else if (rs485->flags & SER_RS485_RTS_AFTER_SEND)
>> + modem |= UARTMODEM_TXRTSPOL;
>> + }
>> +
>> + /* Store the new configuration */
>> + sport->port.rs485 = *rs485;
>> +
>> + writeb(modem, sport->port.membase + UARTMODEM);
>> + return 0;
>> +}
>> +
>> static unsigned int lpuart_get_mctrl(struct uart_port *port)
>> {
>> return TIOCM_CAR | TIOCM_CTS | TIOCM_DSR;
> [...]
>> @@ -1802,6 +1854,14 @@ static int lpuart_probe(struct platform_device *pdev)
>> dev_info(sport->port.dev, "DMA rx channel request failed, "
>> "operating without rx DMA\n");
>>
>> + if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time")) {
>> + sport->port.rs485.flags |= SER_RS485_ENABLED;
>> + sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND;
>> + writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM);
>> + } else {
>> + sport->port.rs485.flags &= ~SER_RS485_ENABLED;
>
> Why the need to clear the flag? sport was kzalloc'ed.
Will remove it.
>
Best Regards,
Bhuvan
next prev parent reply other threads:[~2015-05-29 10:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 8:05 [PATCH 0/3] Add RS-485 support and fix RTS/CTS implementation Bhuvanchandra DV
2015-05-29 8:05 ` Bhuvanchandra DV
2015-05-29 8:05 ` Bhuvanchandra DV
2015-05-29 8:05 ` [PATCH 1/3] ARM: dts: colibri-vf: Add pinmux for UART_0 aka UART_A RTS/CTS pins Bhuvanchandra DV
2015-05-29 8:05 ` Bhuvanchandra DV
2015-05-29 8:05 ` Bhuvanchandra DV
2015-05-29 8:05 ` [PATCH 2/3] tty: serial: fsl_lpuart: remove RTS/CTS control from set/get_mctrl Bhuvanchandra DV
2015-05-29 8:05 ` Bhuvanchandra DV
2015-05-29 8:05 ` Bhuvanchandra DV
2015-05-29 10:04 ` Jakub Kiciński
2015-05-29 10:04 ` Jakub Kiciński
2015-05-29 10:04 ` Jakub Kiciński
2015-05-29 10:10 ` Bhuvanchandra DV
2015-05-29 10:10 ` Bhuvanchandra DV
2015-05-29 10:10 ` Bhuvanchandra DV
2015-05-29 8:05 ` [PATCH 3/3] tty: serial: fsl_lpuart: Add support for RS-485 Bhuvanchandra DV
2015-05-29 8:05 ` Bhuvanchandra DV
2015-05-29 8:05 ` Bhuvanchandra DV
2015-05-29 10:18 ` Jakub Kiciński
2015-05-29 10:18 ` Jakub Kiciński
2015-05-29 10:18 ` Jakub Kiciński
2015-05-29 10:42 ` Bhuvanchandra DV [this message]
2015-05-29 10:42 ` Bhuvanchandra DV
2015-05-29 10:42 ` Bhuvanchandra DV
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=55684285.4000004@toradex.com \
--to=bhuvanchandra.dv-2kbjvhiyjgbbdgjk7y7tuq@public.gmane.org \
--cc=bhuvanchandra.dv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=jslaby-AlSwsSmVLrQ@public.gmane.org \
--cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=moorray3-5tc4TXWwyLM@public.gmane.org \
--cc=shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=stefan-XLVq0VzYD2Y@public.gmane.org \
/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.