Re: Extending serial port linux driver to toggle RS485 direction pin (GPIO)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 02, 2021 at 06:55:56PM +0100, Jochen wrote:
> Hello,
> 
> I have a RS485 hardware shield connected to the hardware uart of a raspberry PI3, where you have to toggle the RS485 driver DIRECTION-pin from within your software during write-commands. The DIR-Pin is connected to a GPIO pin of the PI.
> 
> As I do not want to do that in every application software, I thought it could be a good idea to enhance the serial-port driver (locally on my PI) with that functionality. Looking to the sources of amba-pl011.c I thought the "pl011_write"-function could be the right place to do so....but to be honest it seems not to work
> 
> Could you please give me a hint where to do that best in the serial port driver? (or is there already a RS485 driver with configurable Dir-GPIO-pin).
> Is there a documentation of the serial-port architecture available which could help me to solve my problem?

Other drivers do this today, using gpio pins for this.  One example is
the drivers/tty/serial/ar933x_uart.c driver (look at the
ar933x_uart_tx_chars() function)

You could do much the same in the pl011_rs485_tx_start() function when
SER_RS485_RX_DURING_TX and SER_RS485_RTS_ON_SEND are checked, right?

As for making it "generic", I think there are other drivers that allow
the gpio pins to be selected as part of their device tree, look in the
drivers/tty/serial/ directory for the use of gpio values in lots of
different drivers.

hope this helps,

greg k-h



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux