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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,090 Views
jsj2000lyz
Contributor I

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 !

0 Kudos
1 Reply

424 Views
igorpadykov
NXP Employee
NXP Employee

Hi

if you are trying replace CTS flow control signal with gpio one can try below changes:

temp &= ~UCR2_CTS;    <----- replace with gpio assert
else
temp |= UCR2_CTS;
writel(temp, port->membase + UCR2); <----- replace with gpio deassert

..

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos