@@ -310,7 +310,11 @@ static void serial_omap_stop_tx(struct uart_port *port)
res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ?
1 : 0;
if (gpio_get_value(up->rts_gpio) != res) {
- if (port->rs485.delay_rts_after_send > 0)
+ if (port->rs485.delay_rts_after_send > 0 &&
+ port->rs485.flags & SER_RS485_DELAY_IN_USEC)
+ udelay(
+ port->rs485.delay_rts_after_send);
+ else if (port->rs485.delay_rts_after_send > 0)
mdelay(
port->rs485.delay_rts_after_send);
gpio_set_value(up->rts_gpio, res);
@@ -420,7 +424,11 @@ static void serial_omap_start_tx(struct uart_port *port)
res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0;
if (gpio_get_value(up->rts_gpio) != res) {
gpio_set_value(up->rts_gpio, res);
- if (port->rs485.delay_rts_before_send > 0)
+ if (port->rs485.delay_rts_before_send > 0 &&
+ port->rs485.flags & SER_RS485_DELAY_IN_USEC)
+ udelay(port->rs485.delay_rts_before_send);
+ else if (port->rs485.delay_rts_before_send > 0 &&
+ !(port->rs485.flags & SER_RS485_DELAY_IN_USEC)
mdelay(port->rs485.delay_rts_before_send);
}
}
@@ -1407,8 +1415,17 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
serial_out(up, UART_IER, 0);
/* Clamp the delays to [0, 100ms] */
- rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
- rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U);
+ if (port->rs485.flags & SER_RS485_DELAY_IN_USEC) {
+ rs485->delay_rts_before_send = min(rs485->delay_rts_before_send,
+ 100000U);
+ rs485->delay_rts_after_send = min(rs485->delay_rts_after_send,
+ 100000U);
+ } else {
+ rs485->delay_rts_before_send = min(rs485->delay_rts_before_send,
+ 100);
+ rs485->delay_rts_after_send = min(rs485->delay_rts_after_send,
+ 100U);
+ }
/* store new config */
port->rs485 = *rs485;
Read struct serial_rs485's flag SER_RS485_DELAY_IN_USEC and apply the delay accordingly. Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com> --- drivers/tty/serial/omap-serial.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)