AnsweredAssumed Answered

Linux4.1 for  IMX6UL ,RS232 driver does not use CTS, use an additional GPIO control to receive and send, which changed the RS485 driver?

Question asked by 延柱 李 on Dec 10, 2016
Latest reply on Dec 11, 2016 by igorpadykov

I found  a function which named - static void imx_start_tx (struct uart_port * port)  in  the  source code of the linux nernel 4.1 for IMX6UL, here  how to changed  the RS232 driver code  to  control the GPIO port used to control RS485 send and receive?

Thanks!

The code file name and directory:Imx.c (linux-src\drivers\tty\serial) 

The function code:

static void imx_start_tx(struct uart_port *port)
{
struct imx_port *sport = (struct imx_port *)port;
unsigned long temp;

 

if (port->rs485.flags & SER_RS485_ENABLED) {
/* enable transmitter and shifter empty irq */
temp = readl(port->membase + UCR2);
if (port->rs485.flags & SER_RS485_RTS_ON_SEND)
temp &= ~UCR2_CTS;
else
temp |= UCR2_CTS;
writel(temp, port->membase + UCR2);

 

temp = readl(port->membase + UCR4);
temp |= UCR4_TCEN;
writel(temp, port->membase + UCR4);
}

 

if (!sport->dma_is_enabled) {
temp = readl(sport->port.membase + UCR1);
writel(temp | UCR1_TXMPTYEN, sport->port.membase + UCR1);
}

 

if (sport->dma_is_enabled) {
if (sport->port.x_char) {
/* We have X-char to send, so enable TX IRQ and
 * disable TX DMA to let TX interrupt to send X-char */
temp = readl(sport->port.membase + UCR1);
temp &= ~UCR1_TDMAEN;
temp |= UCR1_TXMPTYEN;
writel(temp, sport->port.membase + UCR1);
return;
}

 

schedule_delayed_work(&sport->tsk_dma_tx, 0);
return;
}
}

 

Thanks again !

Outcomes