From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755980AbbE2KnD (ORCPT ); Fri, 29 May 2015 06:43:03 -0400 Received: from mail-am1on0140.outbound.protection.outlook.com ([157.56.112.140]:63648 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750998AbbE2Kmr (ORCPT ); Fri, 29 May 2015 06:42:47 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=bhuvanchandra.dv@toradex.com; Message-ID: <55684285.4000004@toradex.com> Date: Fri, 29 May 2015 16:12:13 +0530 From: Bhuvanchandra DV User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: =?UTF-8?B?SmFrdWIgS2ljacWEc2tp?= CC: , , , , , , , , , Subject: Re: [PATCH 3/3] tty: serial: fsl_lpuart: Add support for RS-485 References: <1432886754-30115-1-git-send-email-bhuvanchandra.dv@toradex.com> <1432886754-30115-4-git-send-email-bhuvanchandra.dv@toradex.com> <20150529121808.27346afc@north> In-Reply-To: <20150529121808.27346afc@north> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [115.115.225.206] X-ClientProxiedBy: SIXPR04CA0092.apcprd04.prod.outlook.com (10.141.119.50) To DB4PR05MB271.eurprd05.prod.outlook.com (10.242.158.26) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB4PR05MB271; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:DB4PR05MB271;BCL:0;PCL:0;RULEID:;SRVR:DB4PR05MB271; X-Forefront-PRVS: 059185FE08 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(6049001)(479174004)(51704005)(24454002)(189002)(199003)(377454003)(81156007)(68736005)(46102003)(4001350100001)(42186005)(105586002)(5001860100001)(189998001)(62966003)(64706001)(65806001)(77156002)(4001540100001)(2950100001)(36756003)(92566002)(40100003)(117636001)(110136002)(122386002)(77096005)(5001960100002)(47776003)(65956001)(97736004)(99136001)(23676002)(19580395003)(83506001)(54356999)(50466002)(59896002)(66066001)(5001830100001)(101416001)(106356001)(87976001)(65816999)(87266999)(19580405001)(76176999)(50986999)(86362001)(64126003)(62816006);DIR:OUT;SFP:1102;SCL:1;SRVR:DB4PR05MB271;H:[10.18.0.154];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-OriginatorOrg: toradex.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2015 10:42:38.6472 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR05MB271 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> 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