All of lore.kernel.org
 help / color / mirror / Atom feed
* Extending serial port linux driver to toggle RS485 direction pin (GPIO)
@ 2021-11-02 17:55 Jochen
  2021-11-02 18:58 ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Jochen @ 2021-11-02 17:55 UTC (permalink / raw)
  To: linux-serial

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?

Bests
Jochen


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Extending serial port linux driver to toggle RS485 direction pin (GPIO)
  2021-11-02 17:55 Extending serial port linux driver to toggle RS485 direction pin (GPIO) Jochen
@ 2021-11-02 18:58 ` Greg KH
  2021-11-03  7:23   ` Jochen Mades
  2021-11-16  6:43   ` Jochen Mades
  0 siblings, 2 replies; 8+ messages in thread
From: Greg KH @ 2021-11-02 18:58 UTC (permalink / raw)
  To: Jochen; +Cc: linux-serial

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Extending serial port linux driver to toggle RS485 direction pin (GPIO)
  2021-11-02 18:58 ` Greg KH
@ 2021-11-03  7:23   ` Jochen Mades
  2021-11-03  8:23     ` Greg KH
  2021-11-16  6:43   ` Jochen Mades
  1 sibling, 1 reply; 8+ messages in thread
From: Jochen Mades @ 2021-11-03  7:23 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-serial

Hi Greg,

thanks for your fast reply. I checked the sources you mentioned below, that helps a bit..

Could you please give me some more background what you mean with your question:
> 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?

Is there already a concept for RS485 drivers? ...or where to find "pl011_rs485_tx_start()"?

Bests
Jochen


> On 02/11/2021 19:58 Greg KH <gregkh@linuxfoundation.org> wrote:
> 
>  
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Extending serial port linux driver to toggle RS485 direction pin (GPIO)
  2021-11-03  7:23   ` Jochen Mades
@ 2021-11-03  8:23     ` Greg KH
  0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2021-11-03  8:23 UTC (permalink / raw)
  To: Jochen Mades; +Cc: linux-serial

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Wed, Nov 03, 2021 at 08:23:38AM +0100, Jochen Mades wrote:
> Hi Greg,
> 
> thanks for your fast reply. I checked the sources you mentioned below, that helps a bit..
> 
> Could you please give me some more background what you mean with your question:
> > 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?
> 
> Is there already a concept for RS485 drivers?

Yes, RS485 drivers control lines like you are looking for in order to
properly handle the protocol requirements.

> ...or where to find "pl011_rs485_tx_start()"?

Look in the kernel source tree for that function, that's in the driver
you were looking to modify, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Extending serial port linux driver to toggle RS485 direction pin (GPIO)
  2021-11-02 18:58 ` Greg KH
  2021-11-03  7:23   ` Jochen Mades
@ 2021-11-16  6:43   ` Jochen Mades
  2021-11-16  8:28     ` Greg KH
  1 sibling, 1 reply; 8+ messages in thread
From: Jochen Mades @ 2021-11-16  6:43 UTC (permalink / raw)
  To: Greg KH, sistik; +Cc: linux-serial

Hi Greg, Hi Ivan,

as would like to extend the RS485 behavior on my raspberry PI I did some "deep-diving" into the amba-pl011 driver and soon recognized the missing hardware support to detect "FIFO empty". Googling around I found the following patch, describing exactly my problem:
https://lore.kernel.org/linux-arm-kernel/20200107072831.GB1014453@kroah.com/T/

As I'm not familiar with your processes, I kindly ask you where I can find the patched sources of this Soft-Rs485-Amba driver and if it is planned to be intergrated in a future kernel release?

Bests
Jochen


> On 02/11/2021 19:58 Greg KH <gregkh@linuxfoundation.org> wrote:
> 
>  
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Extending serial port linux driver to toggle RS485 direction pin (GPIO)
  2021-11-16  6:43   ` Jochen Mades
@ 2021-11-16  8:28     ` Greg KH
  2021-11-16 11:47       ` Jochen Mades
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2021-11-16  8:28 UTC (permalink / raw)
  To: Jochen Mades; +Cc: sistik, linux-serial

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Tue, Nov 16, 2021 at 07:43:52AM +0100, Jochen Mades wrote:
> Hi Greg, Hi Ivan,
> 
> as would like to extend the RS485 behavior on my raspberry PI I did some "deep-diving" into the amba-pl011 driver and soon recognized the missing hardware support to detect "FIFO empty". Googling around I found the following patch, describing exactly my problem:
> https://lore.kernel.org/linux-arm-kernel/20200107072831.GB1014453@kroah.com/T/
> 
> As I'm not familiar with your processes, I kindly ask you where I can find the patched sources of this Soft-Rs485-Amba driver and if it is planned to be intergrated in a future kernel release?

I do not remember if these patches have been resubmitted or not, check
the current kernel tree for details.

If not, then obviously they need to be fixed up based on the review
comments made.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Extending serial port linux driver to toggle RS485 direction pin (GPIO)
  2021-11-16  8:28     ` Greg KH
@ 2021-11-16 11:47       ` Jochen Mades
  2021-11-16 14:21         ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Jochen Mades @ 2021-11-16 11:47 UTC (permalink / raw)
  To: Greg KH; +Cc: sistik, linux-serial


> I do not remember if these patches have been resubmitted or not, check
> the current kernel tree for details.
> 
> If not, then obviously they need to be fixed up based on the review
> comments made.
> 
> thanks,
> 
> greg k-h

In the current kernel tree there is nothing to find about these patches.
Do you know about any alternatives?

Jochen

P.S.: is this the posting style you prefer?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Extending serial port linux driver to toggle RS485 direction pin (GPIO)
  2021-11-16 11:47       ` Jochen Mades
@ 2021-11-16 14:21         ` Greg KH
  0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2021-11-16 14:21 UTC (permalink / raw)
  To: Jochen Mades; +Cc: sistik, linux-serial

On Tue, Nov 16, 2021 at 12:47:19PM +0100, Jochen Mades wrote:
> 
> > I do not remember if these patches have been resubmitted or not, check
> > the current kernel tree for details.
> > 
> > If not, then obviously they need to be fixed up based on the review
> > comments made.
> > 
> > thanks,
> > 
> > greg k-h
> 
> In the current kernel tree there is nothing to find about these patches.
> Do you know about any alternatives?

Try taking those patches and reworking them to work for you and submit
them yourself.

> P.S.: is this the posting style you prefer?

Yes please, but please include all relevant information.  Remember, some
of us get thousands of emails a day.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-16 14:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 17:55 Extending serial port linux driver to toggle RS485 direction pin (GPIO) Jochen
2021-11-02 18:58 ` Greg KH
2021-11-03  7:23   ` Jochen Mades
2021-11-03  8:23     ` Greg KH
2021-11-16  6:43   ` Jochen Mades
2021-11-16  8:28     ` Greg KH
2021-11-16 11:47       ` Jochen Mades
2021-11-16 14:21         ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.