Skip to content

Commit bb3aac8

Browse files
committed
8250: Use proper set_mctrl callback for ni16550 clock divider
Commit b4a29b9 ("serial: 8250: Move Alpha-specific quirk out of the core") removed the mcr_mask and mcr_force members from struct uart_8250_port. Upstream they are only used for an Alpha-specific quirk. The Alpha code was instead refactored to use the proper '->set_mctrl' callback. The out-of-tree patches for the 8250 ni16550 serial driver rely on mcr_force to set UART_MCR_CLKSEL (divide clock by 4) for certain clock rate configurations. Refactor the code to use a '->set_mctrl' callback instead to set this MCR bit flag. Fixes: ff4f5de ("8250_pnp: Add new ID NIC792B for NI 16550 UART 25MHz") Fixes: c170227 ("serial: 8250_ni16550: Add support for NIC7A69") Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
1 parent 266b84d commit bb3aac8

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/tty/serial/8250/8250_core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,6 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
10301030
uart->rs485_stop_tx = up->rs485_stop_tx;
10311031
uart->lsr_save_mask = up->lsr_save_mask;
10321032
uart->dma = up->dma;
1033-
uart->mcr_force = up->mcr_force;
10341033

10351034
/* Take tx_loadsz from fifosize if it wasn't set separately */
10361035
if (uart->port.fifosize && !uart->tx_loadsz)

drivers/tty/serial/8250/8250_ni16550.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ void ni16550_config_prescaler(unsigned long iobase, uint8_t prescaler)
193193
outb(prescaler, iobase + UART_ICR);
194194
}
195195

196+
void ni16550_set_mctrl(struct uart_port *port, unsigned int mctrl)
197+
{
198+
mctrl |= UART_MCR_CLKSEL;
199+
200+
serial8250_do_set_mctrl(port, mctrl);
201+
}
202+
196203
static struct txvr_ops ni16550_txvr_ops = {
197204
.enable_transceivers = ni16550_enable_transceivers,
198205
.disable_transceivers = ni16550_disable_transceivers,

drivers/tty/serial/8250/8250_pnp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
514514
* with prescaler 1.125.
515515
*/
516516
uart.port.uartclk = 22222222;
517-
uart.mcr_force = UART_MCR_CLKSEL;
517+
uart.port.set_mctrl = ni16550_set_mctrl;
518518
ni16550_config_prescaler(uart.port.iobase, 0x9);
519519
}
520520

@@ -526,7 +526,7 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
526526
* with prescaler 1.125.
527527
*/
528528
uart.port.uartclk = 29629629;
529-
uart.mcr_force = UART_MCR_CLKSEL;
529+
uart.port.set_mctrl = ni16550_set_mctrl;
530530
ni16550_config_prescaler(uart.port.iobase, 0x9);
531531

532532
if (device_property_read_string(&dev->dev,

include/linux/ni16550.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
bool is_rs232_mode(unsigned long iobase);
2525
void ni16550_port_setup(struct uart_port *port);
2626
void ni16550_config_prescaler(unsigned long iobase, uint8_t prescaler);
27+
void ni16550_set_mctrl(struct uart_port *port, unsigned int mctrl);
2728

2829
#endif

0 commit comments

Comments
 (0)