[OpenWrt-Devel] [PATCH v3 1/2] ath79: ar9330-uart: add support for half-duplex using DTR signal
Petr Štetiar
ynezz at true.cz
Tue Feb 11 12:40:28 EST 2020
Hi,
> Add support for RS485 tranceiver with transmit/receive switch hooked
> to the DTR GPIO.
^
now it's RTS, but it could be whatever (ditto with subject).
This should probably be "serial: ar933x_uart: add rs485 support" and taken
through upstream to get more eyes on this.
> This is how RS485 is implemented on the Teltonika
Which doesn't mean, that it's upstream material.
> + static inline void ar933x_uart_putc(struct ar933x_uart_port *up, int ch)
> + {
> + unsigned int rdata;
> ++ struct serial_rs485 rs485conf = up->port.rs485;
> +
> + rdata = ch & AR933X_UART_DATA_TX_RX_MASK;
> + rdata |= AR933X_UART_DATA_TX_CSR;
> +- ar933x_uart_write(up, AR933X_UART_DATA_REG, rdata);
if (unlikely(rs485conf.flags & SER_RS485_ENABLED)) {
ar933x_rs485_putc(up, rdata);
return;
}
ar933x_uart_write(up, AR933X_UART_DATA_REG, rdata);
}
> ++ struct gpio_desc *rts_gpio = mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS);
No need for this, just use mctrl_gpio_set and you probably dont want to do
this each time for every byte.
> ++ if (!IS_ERR_OR_NULL(rts_gpio))
> ++ gpiod_set_value(rts_gpio, !!(rs485conf.flags & SER_RS485_RTS_ON_SEND));
This should be probably handled in ar933x_uart_set_mctrl and with mctrl_gpio_set.
-- ynezz
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list