serial: Add common rs485 device tree parsing function
Several drivers have the same device tree parsing code. Create a common helper function for it. This patch bases on work done by Sascha Hauer. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
c45e2d2547
Коммит
ef838a81dd
|
@ -3026,5 +3026,41 @@ EXPORT_SYMBOL(uart_resume_port);
|
|||
EXPORT_SYMBOL(uart_add_one_port);
|
||||
EXPORT_SYMBOL(uart_remove_one_port);
|
||||
|
||||
/**
|
||||
* of_get_rs485_mode() - Implement parsing rs485 properties
|
||||
* @np: uart node
|
||||
* @rs485conf: output parameter
|
||||
*
|
||||
* This function implements the device tree binding described in
|
||||
* Documentation/devicetree/bindings/serial/rs485.txt.
|
||||
*/
|
||||
void of_get_rs485_mode(struct device_node *np, struct serial_rs485 *rs485conf)
|
||||
{
|
||||
u32 rs485_delay[2];
|
||||
int ret;
|
||||
|
||||
ret = of_property_read_u32_array(np, "rs485-rts-delay", rs485_delay, 2);
|
||||
if (!ret) {
|
||||
rs485conf->delay_rts_before_send = rs485_delay[0];
|
||||
rs485conf->delay_rts_after_send = rs485_delay[1];
|
||||
} else {
|
||||
rs485conf->delay_rts_before_send = 0;
|
||||
rs485conf->delay_rts_after_send = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* clear full-duplex and enabled flags to get to a defined state with
|
||||
* the two following properties.
|
||||
*/
|
||||
rs485conf->flags &= ~(SER_RS485_RX_DURING_TX | SER_RS485_ENABLED);
|
||||
|
||||
if (of_property_read_bool(np, "rs485-rx-during-tx"))
|
||||
rs485conf->flags |= SER_RS485_RX_DURING_TX;
|
||||
|
||||
if (of_property_read_bool(np, "linux,rs485-enabled-at-boot-time"))
|
||||
rs485conf->flags |= SER_RS485_ENABLED;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_get_rs485_mode);
|
||||
|
||||
MODULE_DESCRIPTION("Serial driver core");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
@ -501,4 +501,9 @@ static inline int uart_handle_break(struct uart_port *port)
|
|||
(cflag) & CRTSCTS || \
|
||||
!((cflag) & CLOCAL))
|
||||
|
||||
/*
|
||||
* Common device tree parsing helpers
|
||||
*/
|
||||
void of_get_rs485_mode(struct device_node *np, struct serial_rs485 *rs485conf);
|
||||
|
||||
#endif /* LINUX_SERIAL_CORE_H */
|
||||
|
|
Загрузка…
Ссылка в новой задаче