Lines Matching full:rs485
185 if (old != port->mctrl && !(port->rs485.flags & SER_RS485_ENABLED)) in uart_update_mctrl()
1322 static int uart_check_rs485_flags(struct uart_port *port, struct serial_rs485 *rs485) in uart_check_rs485_flags() argument
1324 u32 flags = rs485->flags; in uart_check_rs485_flags()
1337 if (!(rs485->flags & SER_RS485_ADDRB) && in uart_check_rs485_flags()
1338 (rs485->flags & (SER_RS485_ADDR_RECV|SER_RS485_ADDR_DEST))) in uart_check_rs485_flags()
1342 if (!(rs485->flags & SER_RS485_ADDR_RECV) && rs485->addr_recv) in uart_check_rs485_flags()
1344 if (!(rs485->flags & SER_RS485_ADDR_DEST) && rs485->addr_dest) in uart_check_rs485_flags()
1351 struct serial_rs485 *rs485) in uart_sanitize_serial_rs485_delays() argument
1354 if (rs485->delay_rts_before_send) { in uart_sanitize_serial_rs485_delays()
1359 rs485->delay_rts_before_send = 0; in uart_sanitize_serial_rs485_delays()
1360 } else if (rs485->delay_rts_before_send > RS485_MAX_RTS_DELAY) { in uart_sanitize_serial_rs485_delays()
1361 rs485->delay_rts_before_send = RS485_MAX_RTS_DELAY; in uart_sanitize_serial_rs485_delays()
1364 port->name, port->line, rs485->delay_rts_before_send); in uart_sanitize_serial_rs485_delays()
1368 if (rs485->delay_rts_after_send) { in uart_sanitize_serial_rs485_delays()
1373 rs485->delay_rts_after_send = 0; in uart_sanitize_serial_rs485_delays()
1374 } else if (rs485->delay_rts_after_send > RS485_MAX_RTS_DELAY) { in uart_sanitize_serial_rs485_delays()
1375 rs485->delay_rts_after_send = RS485_MAX_RTS_DELAY; in uart_sanitize_serial_rs485_delays()
1378 port->name, port->line, rs485->delay_rts_after_send); in uart_sanitize_serial_rs485_delays()
1382 static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs485 *rs485) in uart_sanitize_serial_rs485() argument
1386 if (!(rs485->flags & SER_RS485_ENABLED)) { in uart_sanitize_serial_rs485()
1387 memset(rs485, 0, sizeof(*rs485)); in uart_sanitize_serial_rs485()
1391 /* Clear other RS485 flags but SER_RS485_TERMINATE_BUS and return if enabling RS422 */ in uart_sanitize_serial_rs485()
1392 if (rs485->flags & SER_RS485_MODE_RS422) { in uart_sanitize_serial_rs485()
1393 rs485->flags &= (SER_RS485_ENABLED | SER_RS485_MODE_RS422 | SER_RS485_TERMINATE_BUS); in uart_sanitize_serial_rs485()
1397 rs485->flags &= supported_flags; in uart_sanitize_serial_rs485()
1400 if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == in uart_sanitize_serial_rs485()
1401 !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { in uart_sanitize_serial_rs485()
1403 rs485->flags |= SER_RS485_RTS_ON_SEND; in uart_sanitize_serial_rs485()
1404 rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; in uart_sanitize_serial_rs485()
1410 rs485->flags |= SER_RS485_RTS_AFTER_SEND; in uart_sanitize_serial_rs485()
1411 rs485->flags &= ~SER_RS485_RTS_ON_SEND; in uart_sanitize_serial_rs485()
1419 uart_sanitize_serial_rs485_delays(port, rs485); in uart_sanitize_serial_rs485()
1422 memset(rs485->padding0, 0, sizeof(rs485->padding0)); in uart_sanitize_serial_rs485()
1423 memset(rs485->padding1, 0, sizeof(rs485->padding1)); in uart_sanitize_serial_rs485()
1427 const struct serial_rs485 *rs485) in uart_set_rs485_termination() argument
1429 if (!(rs485->flags & SER_RS485_ENABLED)) in uart_set_rs485_termination()
1433 !!(rs485->flags & SER_RS485_TERMINATE_BUS)); in uart_set_rs485_termination()
1437 const struct serial_rs485 *rs485) in uart_set_rs485_rx_during_tx() argument
1439 if (!(rs485->flags & SER_RS485_ENABLED)) in uart_set_rs485_rx_during_tx()
1443 !!(rs485->flags & SER_RS485_RX_DURING_TX)); in uart_set_rs485_rx_during_tx()
1448 struct serial_rs485 *rs485 = &port->rs485; in uart_rs485_config() local
1452 if (!(rs485->flags & SER_RS485_ENABLED)) in uart_rs485_config()
1455 uart_sanitize_serial_rs485(port, rs485); in uart_rs485_config()
1456 uart_set_rs485_termination(port, rs485); in uart_rs485_config()
1457 uart_set_rs485_rx_during_tx(port, rs485); in uart_rs485_config()
1460 ret = port->rs485_config(port, NULL, rs485); in uart_rs485_config()
1463 memset(rs485, 0, sizeof(*rs485)); in uart_rs485_config()
1473 struct serial_rs485 __user *rs485) in uart_get_rs485_config() argument
1479 aux = port->rs485; in uart_get_rs485_config()
1482 if (copy_to_user(rs485, &aux, sizeof(aux))) in uart_get_rs485_config()
1491 struct serial_rs485 rs485; in uart_set_rs485_config() local
1498 if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) in uart_set_rs485_config()
1501 ret = uart_check_rs485_flags(port, &rs485); in uart_set_rs485_config()
1504 uart_sanitize_serial_rs485(port, &rs485); in uart_set_rs485_config()
1505 uart_set_rs485_termination(port, &rs485); in uart_set_rs485_config()
1506 uart_set_rs485_rx_during_tx(port, &rs485); in uart_set_rs485_config()
1509 ret = port->rs485_config(port, &tty->termios, &rs485); in uart_set_rs485_config()
1511 port->rs485 = rs485; in uart_set_rs485_config()
1513 /* Reset RTS and other mctrl lines when disabling RS485 */ in uart_set_rs485_config()
1514 if (!(rs485.flags & SER_RS485_ENABLED)) in uart_set_rs485_config()
1521 !!(port->rs485.flags & SER_RS485_TERMINATE_BUS)); in uart_set_rs485_config()
1523 !!(port->rs485.flags & SER_RS485_RX_DURING_TX)); in uart_set_rs485_config()
1527 if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485))) in uart_set_rs485_config()
2423 if (!(uport->rs485.flags & SER_RS485_ENABLED)) in uart_suspend_port()
2512 if (!(uport->rs485.flags & SER_RS485_ENABLED)) in uart_resume_port()
2525 if (!(uport->rs485.flags & SER_RS485_ENABLED)) in uart_resume_port()
2640 if (!(port->rs485.flags & SER_RS485_ENABLED)) in uart_configure_port()
3614 * uart_get_rs485_mode() - retrieve rs485 properties for given uart
3618 * Documentation/devicetree/bindings/serial/rs485.txt.
3622 struct serial_rs485 *rs485conf = &port->rs485; in uart_get_rs485_mode()
3632 ret = device_property_read_u32_array(dev, "rs485-rts-delay", in uart_get_rs485_mode()
3653 if (device_property_read_bool(dev, "rs485-rx-during-tx")) in uart_get_rs485_mode()
3656 if (device_property_read_bool(dev, "linux,rs485-enabled-at-boot-time")) in uart_get_rs485_mode()
3659 if (device_property_read_bool(dev, "rs485-rts-active-low")) { in uart_get_rs485_mode()
3669 desc = devm_gpiod_get_optional(dev, "rs485-term", GPIOD_OUT_LOW); in uart_get_rs485_mode()
3671 return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-term-gpios\n"); in uart_get_rs485_mode()
3678 desc = devm_gpiod_get_optional(dev, "rs485-rx-during-tx", dflags); in uart_get_rs485_mode()
3680 return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-rx-during-tx-gpios\n"); in uart_get_rs485_mode()