Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sc16is7xx: Add flag to activate IrDA mode

This series of uart controllers is able to work in IrDA mode.
Add per-port flag to the device-tree to enable that feature if needed.

Signed-off-by: Pascal Huerst <pascal.huerst@gmail.com>
Signed-off-by: Daniel Mack <daniel@zonque.org>
Link: https://lore.kernel.org/r/20200529055058.1606910-3-daniel@zonque.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Pascal Huerst and committed by
Greg Kroah-Hartman
9eb90d57 4a9b984f

+20
+20
drivers/tty/serial/sc16is7xx.c
··· 315 315 struct kthread_work tx_work; 316 316 struct kthread_work reg_work; 317 317 struct sc16is7xx_one_config config; 318 + bool irda_mode; 318 319 }; 319 320 320 321 struct sc16is7xx_port { ··· 987 986 988 987 static int sc16is7xx_startup(struct uart_port *port) 989 988 { 989 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 990 990 struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 991 991 unsigned int val; 992 992 ··· 1025 1023 1026 1024 /* Now, initialize the UART */ 1027 1025 sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_WORD_LEN_8); 1026 + 1027 + /* Enable IrDA mode if requested in DT */ 1028 + /* This bit must be written with LCR[7] = 0 */ 1029 + sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, 1030 + SC16IS7XX_MCR_IRDA_BIT, 1031 + one->irda_mode ? 1032 + SC16IS7XX_MCR_IRDA_BIT : 0); 1028 1033 1029 1034 /* Enable the Rx and Tx FIFO */ 1030 1035 sc16is7xx_port_update(port, SC16IS7XX_EFCR_REG, ··· 1311 1302 1312 1303 /* Go to suspend mode */ 1313 1304 sc16is7xx_power(&s->p[i].port, 0); 1305 + } 1306 + 1307 + if (dev->of_node) { 1308 + struct property *prop; 1309 + const __be32 *p; 1310 + u32 u; 1311 + 1312 + of_property_for_each_u32(dev->of_node, "irda-mode-ports", 1313 + prop, p, u) 1314 + if (u < devtype->nr_uart) 1315 + s->p[u].irda_mode = true; 1314 1316 } 1315 1317 1316 1318 /*