Commit 6974711c authored by Gerhard Engleder's avatar Gerhard Engleder Committed by Greg Kroah-Hartman
Browse files

serial: Keep rs485 settings for devices without firmware node



Commit fe7f0fa4 ("serial: 8250: Support rs485 devicetree properties")
retrieves rs485 properties for 8250 drivers. These properties are read
from the firmware node of the device within uart_get_rs485_mode(). If the
firmware node does not exist, then the rs485 flags are still reset. Thus,
8250 driver cannot set rs485 flags to enable a defined rs485 mode during
driver loading. This is no problem so far, as no 8250 driver sets the
rs485 flags.

The default rs485 mode can also be set by firmware nodes. But for some
devices a firmware node does not exist. E.g., for a PCIe based serial
interface on x86 no device tree is available and the ACPI information of
the BIOS often cannot by modified. In this case it shall be possible,
that a driver works out of the box by setting a reasonable default rs485
mode.

If no firmware node exists, then it should be possible for the driver to
set a reasonable default rs485 mode. Therefore, reset rs485 flags only
if a firmware node exists.

Signed-off-by: default avatarGerhard Engleder <eg@keba.com>
Cc: Lukas Wunner <lukas@wunner.de>
Reviewed-by: default avatarLukas Wunner <lukas@wunner.de>
Link: https://patch.msgid.link/20251023151229.11774-2-gerhard@engleder-embedded.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent abffd1e6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -3502,6 +3502,14 @@ int uart_get_rs485_mode(struct uart_port *port)
	if (!(port->rs485_supported.flags & SER_RS485_ENABLED))
		return 0;

	/*
	 * Retrieve properties only if a firmware node exists. If no firmware
	 * node exists, then don't touch rs485 config and keep initial rs485
	 * properties set by driver.
	 */
	if (!dev_fwnode(dev))
		return 0;

	ret = device_property_read_u32_array(dev, "rs485-rts-delay",
					     rs485_delay, 2);
	if (!ret) {