[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Veb_iu+WiUdJ6anqu3TbkjgwAU2deo8=b8TmcC7COS03A@mail.gmail.com>
Date: Mon, 1 Dec 2025 03:56:38 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Crescent Hsieh <crescentcy.hsieh@...a.com>
Cc: gregkh@...uxfoundation.org, jirislaby@...nel.org,
ilpo.jarvinen@...ux.intel.com, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org
Subject: Re: [PATCH v1 19/31] serial: 8250_mxpcie: add break signal support
under RS485
On Sun, Nov 30, 2025 at 12:45 PM Crescent Hsieh
<crescentcy.hsieh@...a.com> wrote:
>
> Moxa PCIe boards require a specific sequence to send break signals in
> RS485 mode. This patch implements the required behavior, while falling
> back to the default break mechanism in RS232 and RS422 modes.
...
> +static void mxpcie8250_software_break_ctl(struct uart_port *port, int break_state)
> +{
> + struct uart_8250_port *up = up_to_u8250p(port);
> + struct tty_struct *tty = port->state->port.tty;
> + unsigned char tx_byte = 0x01;
> + unsigned int baud, quot;
> + unsigned long flags;
> + u8 sfr;
> +
> + uart_port_lock_irqsave(port, &flags);
> +
> + if (break_state == -1) {
> + serial_out(up, UART_LCR, up->lcr | UART_LCR_DLAB);
> + serial_out(up, UART_DLL, 0);
> + serial_out(up, UART_DLM, 0);
> + serial_out(up, UART_LCR, up->lcr);
> + memcpy(port->membase + MOXA_PUART_TX_FIFO_MEM, &tx_byte, 1);
My gosh, why?
It's even different to the way you used in the previous change.
> + sfr = serial_in(up, MOXA_PUART_SFR);
> + serial_out(up, MOXA_PUART_SFR, sfr | MOXA_PUART_SFR_FORCE_TX);
> +
> + up->lcr |= UART_LCR_SBC;
> + serial_out(up, UART_LCR, up->lcr);
> + } else {
> + up->lcr &= ~UART_LCR_SBC;
> + serial_out(up, UART_LCR, up->lcr);
> +
> + sfr = serial_in(up, MOXA_PUART_SFR);
> + serial_out(up, MOXA_PUART_SFR, sfr &= ~MOXA_PUART_SFR_FORCE_TX);
> +
> + serial_out(up, UART_FCR, UART_FCR_CLEAR_XMIT);
> +
> + baud = tty_get_baud_rate(tty);
> + quot = uart_get_divisor(port, baud);
> + serial8250_do_set_divisor(port, baud, quot);
> + serial_out(up, UART_LCR, up->lcr);
> + }
> + uart_port_unlock_irqrestore(port, flags);
> +}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists