Jump to content

rrp

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by rrp

  1. I suggest you check if UART2 RTS is working on this hardware/software first. You can connecting some state indicator (LED, voltmeter, ...) to its pin and manual change RTS state (eg. Ctrl-A Ctrl-G in picocom).

     

    If RTS work OK you can try my patch. I'm not familiar with NanoPi Neo Core and I don't know how serial hardware is on its chip, so if it's not compatible with 8250_dw patch will not work. To use my patch you must build your own kernel image (https://docs.armbian.com/Developer-Guide_Build-Preparation/) with applying this patch (put it to "patch/kernel/sunxi-current" should do this).

  2. On 11/1/2021 at 6:51 PM, martinayotte said:

     

    I don't know ... I've worked on this since almost a year ...

    So ... I was trying to look too.

     

    Looks like this patch (series) make mess with your rs485-8250 patch, but don't enable software emulated rs485 for dw variant nor provide own workaround for chips without "end transmit" interrupt.

     

    I created minimal patch for add this workaround (from your patch) to current kernel:

    diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
    index 9c00d7504..bc8cd87ee 100644
    --- a/drivers/tty/serial/8250/8250_dw.c
    +++ b/drivers/tty/serial/8250/8250_dw.c
    @@ -469,6 +469,10 @@ static int dw8250_probe(struct platform_device *pdev)
     	p->set_ldisc	= dw8250_set_ldisc;
     	p->set_termios	= dw8250_set_termios;
     
    +	p->rs485_config = serial8250_em485_config;
    +	up->rs485_start_tx = serial8250_em485_start_tx;
    +	up->rs485_stop_tx = serial8250_em485_stop_tx;
    +
     	p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
     	if (!p->membase)
     		return -ENOMEM;
    diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
    index be779eb9e..c9f5b626e 100644
    --- a/drivers/tty/serial/8250/8250_port.c
    +++ b/drivers/tty/serial/8250/8250_port.c
    @@ -1541,8 +1541,14 @@ static inline void __stop_tx(struct uart_8250_port *p)
     		 * shift register are empty. It is for device driver to enable
     		 * interrupt on TEMT.
     		 */
    -		if ((lsr & BOTH_EMPTY) != BOTH_EMPTY)
    -			return;
    +		//if ((lsr & BOTH_EMPTY) != BOTH_EMPTY)
    +		//	return;
    +		// TODO: use if / while variant depending on the support / not support interrupt ...
    +		// TODO: or provide different serial8250_stop_tx for chips without interrupt
    +		while ((lsr & BOTH_EMPTY) != BOTH_EMPTY) {
    +			lsr = serial_in(p, UART_LSR);
    +			cpu_relax();
    +		}
     
     		__stop_tx_rs485(p);
     	}

    This is more "dirty hack" than "good patch" (always use "no interrupt" approach - see todo note in code), but it's work for me :) (at least for now, more tests shortly).

×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines