serial: RS485 termination improvements
Subsystems (11)
Ilpo Järvinen
maintainercover serial: RS485 termination improvements
This series improves termination handling for RS485. Effectively, .rs485_supported is made a per port and the termination flag is enabled when DT configures termination. The downside of this is that embedded struct consumes a little bit of more memory, especially as struct serial_rs485 has the padding field.
There is other problem on this area besides the one addressed by this series which is new since the introduction of .rs485_supported. Lino's patch series addresses the ability to tweak the termination through ->rs485_config() for any driver.
For kernel uses, struct kserial_rs485 version of serial_rs485 could be added and both .rs485 and .rs485_supported converted to it leaving struct_rs485 only for UAPI use. This series, howver, doesn't attempt it. It seems relatively easy to build it on top of these changes though.
Ilpo Järvinen (2):
serial: Embed rs485_supported
serial: RS485 termination is supported if DT provides one
drivers/tty/serial/8250/8250_bcm2835aux.c | 2 +- drivers/tty/serial/8250/8250_dwlib.c | 4 ++-- drivers/tty/serial/8250/8250_exar.c | 2 +- drivers/tty/serial/8250/8250_fintek.c | 4 ++-- drivers/tty/serial/8250/8250_lpc18xx.c | 2 +- drivers/tty/serial/8250/8250_of.c | 2 +- drivers/tty/serial/8250/8250_pci.c | 2 +- drivers/tty/serial/amba-pl011.c | 2 +- drivers/tty/serial/ar933x_uart.c | 4 ++-- drivers/tty/serial/atmel_serial.c | 2 +- drivers/tty/serial/fsl_lpuart.c | 2 +- drivers/tty/serial/imx.c | 4 ++-- drivers/tty/serial/max310x.c | 2 +- drivers/tty/serial/mcf.c | 4 ++-- drivers/tty/serial/omap-serial.c | 2 +- drivers/tty/serial/sc16is7xx.c | 2 +- drivers/tty/serial/serial_core.c | 10 ++++++---- drivers/tty/serial/stm32-usart.c | 2 +- include/linux/serial_core.h | 2 +- 19 files changed, 29 insertions(+), 27 deletions(-)
Signature · 1 line
2.30.2
Ilpo Järvinen
maintainerPATCH 1/2 serial: Embed rs485_supported to uart_port
Embed rs485_supported to uart_port to allow serial core to tweak it as needed.
--- drivers/tty/serial/8250/8250_bcm2835aux.c | 2 +- drivers/tty/serial/8250/8250_dwlib.c | 4 ++-- drivers/tty/serial/8250/8250_exar.c | 2 +- drivers/tty/serial/8250/8250_fintek.c | 4 ++-- drivers/tty/serial/8250/8250_lpc18xx.c | 2 +- drivers/tty/serial/8250/8250_of.c | 2 +- drivers/tty/serial/8250/8250_pci.c | 2 +- drivers/tty/serial/amba-pl011.c | 2 +- drivers/tty/serial/ar933x_uart.c | 4 ++-- drivers/tty/serial/atmel_serial.c | 2 +- drivers/tty/serial/fsl_lpuart.c | 2 +- drivers/tty/serial/imx.c | 4 ++-- drivers/tty/serial/max310x.c | 2 +- drivers/tty/serial/mcf.c | 4 ++-- drivers/tty/serial/omap-serial.c | 2 +- drivers/tty/serial/sc16is7xx.c | 2 +- drivers/tty/serial/serial_core.c | 8 ++++---- drivers/tty/serial/stm32-usart.c | 2 +- include/linux/serial_core.h | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-)
drivers/tty/serial/8250/8250_bcm2835aux.c +1 -1
@@ -108,7 +108,7 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev) up.port.flags =UPF_SHARE_IRQ |UPF_FIXED_PORT |UPF_FIXED_TYPE |UPF_SKIP_TEST |UPF_IOREMAP ; up.port.rs485_config = serial8250_em485_config; - up.port.rs485_supported = &serial8250_em485_supported; + up.port.rs485_supported = serial8250_em485_supported; up.rs485_start_tx = bcm2835aux_rs485_start_tx; up.rs485_stop_tx = bcm2835aux_rs485_stop_tx;
drivers/tty/serial/8250/8250_dwlib.c +2 -2
@@ -255,10 +255,10 @@ void dw8250_setup_port(struct uart_port *p)if (pd->hw_rs485_support) { p->rs485_config = dw8250_rs485_config; up->lsr_save_mask =LSR_SAVE_FLAGS |DW_UART_LSR_ADDR_RCVD ; - p->rs485_supported = &dw8250_rs485_supported; + p->rs485_supported = dw8250_rs485_supported; }else { p->rs485_config = serial8250_em485_config; - p->rs485_supported = &serial8250_em485_supported; + p->rs485_supported = serial8250_em485_supported; up->rs485_start_tx = serial8250_em485_start_tx; up->rs485_stop_tx = serial8250_em485_stop_tx; }
drivers/tty/serial/8250/8250_exar.c +1 -1
@@ -550,7 +550,7 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev, port->port.uartclk = baud *16 ; port->port.rs485_config = platform->rs485_config; - port->port.rs485_supported = platform->rs485_supported; + port->port.rs485_supported = *(platform->rs485_supported);/* * Setup the UART clock for the devices on expansion slot to
drivers/tty/serial/8250/8250_fintek.c +2 -2
@@ -433,9 +433,9 @@ static void fintek_8250_set_rs485_handler(struct uart_8250_port *uart)case CHIP_ID_F81865 : uart->port.rs485_config = fintek_8250_rs485_config;if (!pdata->index) - uart->port.rs485_supported = &fintek_8250_rs485_supported_port0; + uart->port.rs485_supported = fintek_8250_rs485_supported_port0;else - uart->port.rs485_supported = &fintek_8250_rs485_supported; + uart->port.rs485_supported = fintek_8250_rs485_supported;break ;default :/* No RS485 Auto direction functional */
drivers/tty/serial/8250/8250_lpc18xx.c +1 -1
@@ -161,7 +161,7 @@ static int lpc18xx_serial_probe(struct platform_device *pdev) uart.port.uartclk =clk_get_rate (data->clk_uart); uart.port.private_data = data; uart.port.rs485_config = lpc18xx_rs485_config; - uart.port.rs485_supported = &lpc18xx_rs485_supported; + uart.port.rs485_supported = lpc18xx_rs485_supported; uart.port.serial_out = lpc18xx_uart_serial_out; uart.dma = &data->dma;
drivers/tty/serial/8250/8250_of.c +1 -1
@@ -165,7 +165,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev, port->dev = &ofdev->dev; port->rs485_config = serial8250_em485_config; - port->rs485_supported = &serial8250_em485_supported; + port->rs485_supported = serial8250_em485_supported; up->rs485_start_tx = serial8250_em485_start_tx; up->rs485_stop_tx = serial8250_em485_stop_tx;
drivers/tty/serial/8250/8250_pci.c +1 -1
@@ -1607,7 +1607,7 @@ static int pci_fintek_setup(struct serial_private *priv, port->port.iotype =UPIO_PORT ; port->port.iobase = iobase; port->port.rs485_config = pci_fintek_rs485_config; - port->port.rs485_supported = &pci_fintek_rs485_supported; + port->port.rs485_supported = pci_fintek_rs485_supported; data =devm_kzalloc (&pdev->dev,sizeof (u8),GFP_KERNEL );if (!data)
drivers/tty/serial/amba-pl011.c +1 -1
@@ -2779,7 +2779,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) uap->port.irq = dev->irq[0 ]; uap->port.ops = &amba_pl011_pops; uap->port.rs485_config = pl011_rs485_config; - uap->port.rs485_supported = &pl011_rs485_supported; + uap->port.rs485_supported = pl011_rs485_supported;snprintf (uap->type,sizeof (uap->type),"PL011 rev%u" ,amba_rev (dev)); ret =pl011_setup_port (&dev->dev, uap, &dev->res, portnr);
drivers/tty/serial/ar933x_uart.c +2 -2
@@ -778,7 +778,7 @@ static int ar933x_uart_probe(struct platform_device *pdev) port->fifosize =AR933X_UART_FIFO_SIZE ; port->ops = &ar933x_uart_ops; port->rs485_config = ar933x_config_rs485; - port->rs485_supported = &ar933x_rs485_supported; + port->rs485_supported = ar933x_rs485_supported; baud =ar933x_uart_get_baud (port->uartclk,AR933X_UART_MAX_SCALE ,1 ); up->min_baud = max_t(unsigned int, baud, AR933X_UART_MIN_BAUD);
@@ -802,7 +802,7 @@ static int ar933x_uart_probe(struct platform_device *pdev) !up->rts_gpiod) {dev_err (&pdev->dev,"lacking rts-gpio, disabling RS485\n" ); port->rs485.flags &= ~SER_RS485_ENABLED ; - port->rs485_supported = &ar933x_no_rs485; + port->rs485_supported = ar933x_no_rs485; }#ifdef CONFIG_SERIAL_AR933X_CONSOLE
drivers/tty/serial/atmel_serial.c +1 -1
@@ -2498,7 +2498,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port, port->mapbase = mpdev->resource[0 ].start; port->irq =platform_get_irq (mpdev,0 ); port->rs485_config = atmel_config_rs485; - port->rs485_supported = &atmel_rs485_supported; + port->rs485_supported = atmel_rs485_supported; port->iso7816_config = atmel_config_iso7816; port->membase =NULL ;
drivers/tty/serial/fsl_lpuart.c +1 -1
@@ -2655,7 +2655,7 @@ static int lpuart_probe(struct platform_device *pdev) sport->port.rs485_config = lpuart32_config_rs485; else sport->port.rs485_config = lpuart_config_rs485; - sport->port.rs485_supported = &lpuart_rs485_supported; + sport->port.rs485_supported = lpuart_rs485_supported; sport->ipg_clk =devm_clk_get (&pdev->dev,"ipg" );if (IS_ERR (sport->ipg_clk)) {
drivers/tty/serial/imx.c +2 -2
@@ -2285,9 +2285,9 @@ static int imx_uart_probe(struct platform_device *pdev) sport->port.rs485_config = imx_uart_rs485_config;/* RTS is required to control the RS485 transmitter */ if (sport->have_rtscts || sport->have_rtsgpio) - sport->port.rs485_supported = &imx_rs485_supported; + sport->port.rs485_supported = imx_rs485_supported;else - sport->port.rs485_supported = &imx_no_rs485; + sport->port.rs485_supported = imx_no_rs485; sport->port.flags =UPF_BOOT_AUTOCONF ;timer_setup (&sport->timer, imx_uart_timeout,0 );
drivers/tty/serial/max310x.c +1 -1
@@ -1370,7 +1370,7 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty s->p[i].port.membase = (void __iomem *)~0 ; s->p[i].port.uartclk = uartclk; s->p[i].port.rs485_config = max310x_rs485_config; - s->p[i].port.rs485_supported = &max310x_rs485_supported; + s->p[i].port.rs485_supported = max310x_rs485_supported; s->p[i].port.ops = &max310x_ops; s->p[i].regmap = regmaps[i];
drivers/tty/serial/mcf.c +2 -2
@@ -506,7 +506,7 @@ int __init early_mcf_setup(struct mcf_platform_uart *platp) port->uartclk =MCF_BUSCLK ; port->flags =UPF_BOOT_AUTOCONF ; port->rs485_config = mcf_config_rs485; - port->rs485_supported = &mcf_rs485_supported; + port->rs485_supported = mcf_rs485_supported; port->ops = &mcf_uart_ops; }
@@ -634,7 +634,7 @@ static int mcf_probe(struct platform_device *pdev) port->ops = &mcf_uart_ops; port->flags =UPF_BOOT_AUTOCONF ; port->rs485_config = mcf_config_rs485; - port->rs485_supported = &mcf_rs485_supported; + port->rs485_supported = mcf_rs485_supported; port->has_sysrq =IS_ENABLED (CONFIG_SERIAL_MCF_CONSOLE );uart_add_one_port (&mcf_driver, port);
drivers/tty/serial/omap-serial.c +1 -1
@@ -1643,7 +1643,7 @@ static int serial_omap_probe(struct platform_device *pdev) up->port.flags = omap_up_info->flags; up->port.uartclk = omap_up_info->uartclk; up->port.rs485_config = serial_omap_config_rs485; - up->port.rs485_supported = &serial_omap_rs485_supported; + up->port.rs485_supported = serial_omap_rs485_supported;if (!up->port.uartclk) { up->port.uartclk =DEFAULT_CLK_SPEED ; dev_warn(&pdev->dev,
drivers/tty/serial/sc16is7xx.c +1 -1
@@ -1461,7 +1461,7 @@ static int sc16is7xx_probe(struct device *dev, s->p[i].port.iotype =UPIO_PORT ; s->p[i].port.uartclk = freq; s->p[i].port.rs485_config = sc16is7xx_config_rs485; - s->p[i].port.rs485_supported = &sc16is7xx_rs485_supported; + s->p[i].port.rs485_supported = sc16is7xx_rs485_supported; s->p[i].port.ops = &sc16is7xx_ops; s->p[i].old_mctrl =0 ; s->p[i].port.line =sc16is7xx_alloc_line ();
drivers/tty/serial/serial_core.c +4 -4
@@ -1285,7 +1285,7 @@ static int uart_check_rs485_flags(struct uart_port *port, struct serial_rs485 *r* For any bit outside of the legacy ones that is not supported by * the driver, return -EINVAL. */ -if (flags & ~port->rs485_supported->flags) +if (flags & ~port->rs485_supported.flags)return -EINVAL ;/* Asking for address w/o addressing mode? */
@@ -1304,7 +1304,7 @@ static int uart_check_rs485_flags(struct uart_port *port, struct serial_rs485 *rstatic void uart_sanitize_serial_rs485 (struct uart_port *port,struct serial_rs485 *rs485) { -u32 supported_flags = port->rs485_supported->flags; +u32 supported_flags = port->rs485_supported.flags;if (!(rs485->flags &SER_RS485_ENABLED )) {memset (rs485,0 ,sizeof (*rs485));
@@ -1323,7 +1323,7 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 supported_flags |=SER_RS485_RTS_ON_SEND |SER_RS485_RTS_AFTER_SEND ; } -if (!port->rs485_supported->delay_rts_before_send) { +if (!port->rs485_supported.delay_rts_before_send) {if (rs485->delay_rts_before_send) { dev_warn_ratelimited(port->dev, "%s (%d): RTS delay before sending not supported\n",
@@ -1337,7 +1337,7 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 port->name, port->line, rs485->delay_rts_before_send); } -if (!port->rs485_supported->delay_rts_after_send) { +if (!port->rs485_supported.delay_rts_after_send) {if (rs485->delay_rts_after_send) { dev_warn_ratelimited(port->dev, "%s (%d): RTS delay after sending not supported\n",
drivers/tty/serial/stm32-usart.c +1 -1
@@ -1401,7 +1401,7 @@ static int stm32_usart_init_port(struct stm32_port *stm32port, port->has_sysrq =IS_ENABLED (CONFIG_SERIAL_STM32_CONSOLE ); port->irq = irq; port->rs485_config = stm32_usart_config_rs485; - port->rs485_supported = &stm32_rs485_supported; + port->rs485_supported = stm32_rs485_supported; ret =stm32_usart_init_rs485 (port, pdev);if (ret)
include/linux/serial_core.h +1 -1
@@ -255,7 +255,7 @@ struct uart_port {struct attribute_group *attr_group;/* port specific attributes */ const struct attribute_group **tty_groups;/* all attributes (serial core use only) */ struct serial_rs485 rs485; -const struct serial_rs485 *rs485_supported;/* Supported mask for serial_rs485 */ +struct serial_rs485 rs485_supported;/* Supported mask for serial_rs485 */ struct gpio_desc *rs485_term_gpio;/* enable RS485 bus termination */ struct serial_iso7816 iso7816;void *private_data;/* generic platform data pointer */
Signature · 1 line
2.30.2
Re: [PATCH 1/2] serial: Embed rs485_supported to uart_port
Quoted 320 lines · Ilpo Järvinen
Embed
rs485_supportedtouart_portto allow serial core to tweak it as needed.Signed-off-by Ilpo Järvinen <[email protected]>--- drivers/tty/serial/8250/8250_bcm2835aux.c | 2 +- drivers/tty/serial/8250/8250_dwlib.c | 4 ++-- drivers/tty/serial/8250/8250_exar.c | 2 +- drivers/tty/serial/8250/8250_fintek.c | 4 ++-- drivers/tty/serial/8250/8250_lpc18xx.c | 2 +- drivers/tty/serial/8250/8250_of.c | 2 +- drivers/tty/serial/8250/8250_pci.c | 2 +- drivers/tty/serial/amba-pl011.c | 2 +- drivers/tty/serial/ar933x_uart.c | 4 ++-- drivers/tty/serial/atmel_serial.c | 2 +- drivers/tty/serial/fsl_lpuart.c | 2 +- drivers/tty/serial/imx.c | 4 ++-- drivers/tty/serial/max310x.c | 2 +- drivers/tty/serial/mcf.c | 4 ++-- drivers/tty/serial/omap-serial.c | 2 +- drivers/tty/serial/sc16is7xx.c | 2 +- drivers/tty/serial/serial_core.c | 8 ++++---- drivers/tty/serial/stm32-usart.c | 2 +- include/linux/serial_core.h | 2 +- 19 files changed, 27 insertions(+), 27 deletions(-)drivers/tty/serial/8250/8250_bcm2835aux.c +1
-1@@ -108,7 +108,7 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev) up.port.flags =UPF_SHARE_IRQ |UPF_FIXED_PORT |UPF_FIXED_TYPE |UPF_SKIP_TEST |UPF_IOREMAP ; up.port.rs485_config = serial8250_em485_config; - up.port.rs485_supported = &serial8250_em485_supported; + up.port.rs485_supported = serial8250_em485_supported; up.rs485_start_tx = bcm2835aux_rs485_start_tx; up.rs485_stop_tx = bcm2835aux_rs485_stop_tx;drivers/tty/serial/8250/8250_dwlib.c +2
-2@@ -255,10 +255,10 @@ void dw8250_setup_port(struct uart_port *p)if (pd->hw_rs485_support) { p->rs485_config = dw8250_rs485_config; up->lsr_save_mask =LSR_SAVE_FLAGS |DW_UART_LSR_ADDR_RCVD ; - p->rs485_supported = &dw8250_rs485_supported; + p->rs485_supported = dw8250_rs485_supported; }else { p->rs485_config = serial8250_em485_config; - p->rs485_supported = &serial8250_em485_supported; + p->rs485_supported = serial8250_em485_supported; up->rs485_start_tx = serial8250_em485_start_tx; up->rs485_stop_tx = serial8250_em485_stop_tx; }drivers/tty/serial/8250/8250_exar.c +1
-1@@ -550,7 +550,7 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev, port->port.uartclk = baud *16 ; port->port.rs485_config = platform->rs485_config; - port->port.rs485_supported = platform->rs485_supported; + port->port.rs485_supported = *(platform->rs485_supported);/* * Setup the UART clock for the devices on expansion slot to drivers/tty/serial/8250/8250_fintek.c +2
-2@@ -433,9 +433,9 @@ static void fintek_8250_set_rs485_handler(struct uart_8250_port *uart)case CHIP_ID_F81865 : uart->port.rs485_config = fintek_8250_rs485_config;if (!pdata->index) - uart->port.rs485_supported = &fintek_8250_rs485_supported_port0; + uart->port.rs485_supported = fintek_8250_rs485_supported_port0;else - uart->port.rs485_supported = &fintek_8250_rs485_supported; + uart->port.rs485_supported = fintek_8250_rs485_supported;break ;default :/* No RS485 Auto direction functional */ drivers/tty/serial/8250/8250_lpc18xx.c +1
-1@@ -161,7 +161,7 @@ static int lpc18xx_serial_probe(struct platform_device *pdev) uart.port.uartclk =clk_get_rate (data->clk_uart); uart.port.private_data = data; uart.port.rs485_config = lpc18xx_rs485_config; - uart.port.rs485_supported = &lpc18xx_rs485_supported; + uart.port.rs485_supported = lpc18xx_rs485_supported; uart.port.serial_out = lpc18xx_uart_serial_out; uart.dma = &data->dma;drivers/tty/serial/8250/8250_of.c +1
-1@@ -165,7 +165,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev, port->dev = &ofdev->dev; port->rs485_config = serial8250_em485_config; - port->rs485_supported = &serial8250_em485_supported; + port->rs485_supported = serial8250_em485_supported; up->rs485_start_tx = serial8250_em485_start_tx; up->rs485_stop_tx = serial8250_em485_stop_tx;drivers/tty/serial/8250/8250_pci.c +1
-1@@ -1607,7 +1607,7 @@ static int pci_fintek_setup(struct serial_private *priv, port->port.iotype =UPIO_PORT ; port->port.iobase = iobase; port->port.rs485_config = pci_fintek_rs485_config; - port->port.rs485_supported = &pci_fintek_rs485_supported; + port->port.rs485_supported = pci_fintek_rs485_supported; data =devm_kzalloc (&pdev->dev,sizeof (u8),GFP_KERNEL );if (!data)drivers/tty/serial/amba-pl011.c +1
-1@@ -2779,7 +2779,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) uap->port.irq = dev->irq[0 ]; uap->port.ops = &amba_pl011_pops; uap->port.rs485_config = pl011_rs485_config; - uap->port.rs485_supported = &pl011_rs485_supported; + uap->port.rs485_supported = pl011_rs485_supported;snprintf (uap->type,sizeof (uap->type),"PL011 rev%u" ,amba_rev (dev)); ret =pl011_setup_port (&dev->dev, uap, &dev->res, portnr);drivers/tty/serial/ar933x_uart.c +2
-2@@ -778,7 +778,7 @@ static int ar933x_uart_probe(struct platform_device *pdev) port->fifosize =AR933X_UART_FIFO_SIZE ; port->ops = &ar933x_uart_ops; port->rs485_config = ar933x_config_rs485; - port->rs485_supported = &ar933x_rs485_supported; + port->rs485_supported = ar933x_rs485_supported; baud =ar933x_uart_get_baud (port->uartclk,AR933X_UART_MAX_SCALE ,1 ); up->min_baud = max_t(unsigned int, baud, AR933X_UART_MIN_BAUD);@@ -802,7 +802,7 @@ static int ar933x_uart_probe(struct platform_device *pdev) !up->rts_gpiod) {dev_err (&pdev->dev,"lacking rts-gpio, disabling RS485\n" ); port->rs485.flags &= ~SER_RS485_ENABLED ; - port->rs485_supported = &ar933x_no_rs485; + port->rs485_supported = ar933x_no_rs485; }#ifdef CONFIG_SERIAL_AR933X_CONSOLE drivers/tty/serial/atmel_serial.c +1
-1@@ -2498,7 +2498,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port, port->mapbase = mpdev->resource[0 ].start; port->irq =platform_get_irq (mpdev,0 ); port->rs485_config = atmel_config_rs485; - port->rs485_supported = &atmel_rs485_supported; + port->rs485_supported = atmel_rs485_supported; port->iso7816_config = atmel_config_iso7816; port->membase =NULL ;drivers/tty/serial/fsl_lpuart.c +1
-1@@ -2655,7 +2655,7 @@ static int lpuart_probe(struct platform_device *pdev) sport->port.rs485_config = lpuart32_config_rs485; else sport->port.rs485_config = lpuart_config_rs485; - sport->port.rs485_supported = &lpuart_rs485_supported; + sport->port.rs485_supported = lpuart_rs485_supported; sport->ipg_clk =devm_clk_get (&pdev->dev,"ipg" );if (IS_ERR (sport->ipg_clk)) {drivers/tty/serial/imx.c +2
-2@@ -2285,9 +2285,9 @@ static int imx_uart_probe(struct platform_device *pdev) sport->port.rs485_config = imx_uart_rs485_config;/* RTS is required to control the RS485 transmitter */ if (sport->have_rtscts || sport->have_rtsgpio) - sport->port.rs485_supported = &imx_rs485_supported; + sport->port.rs485_supported = imx_rs485_supported;else - sport->port.rs485_supported = &imx_no_rs485; + sport->port.rs485_supported = imx_no_rs485; sport->port.flags =UPF_BOOT_AUTOCONF ;timer_setup (&sport->timer, imx_uart_timeout,0 );drivers/tty/serial/max310x.c +1
-1@@ -1370,7 +1370,7 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty s->p[i].port.membase = (void __iomem *)~0 ; s->p[i].port.uartclk = uartclk; s->p[i].port.rs485_config = max310x_rs485_config; - s->p[i].port.rs485_supported = &max310x_rs485_supported; + s->p[i].port.rs485_supported = max310x_rs485_supported; s->p[i].port.ops = &max310x_ops; s->p[i].regmap = regmaps[i];drivers/tty/serial/mcf.c +2
-2@@ -506,7 +506,7 @@ int __init early_mcf_setup(struct mcf_platform_uart *platp) port->uartclk =MCF_BUSCLK ; port->flags =UPF_BOOT_AUTOCONF ; port->rs485_config = mcf_config_rs485; - port->rs485_supported = &mcf_rs485_supported; + port->rs485_supported = mcf_rs485_supported; port->ops = &mcf_uart_ops; }@@ -634,7 +634,7 @@ static int mcf_probe(struct platform_device *pdev) port->ops = &mcf_uart_ops; port->flags =UPF_BOOT_AUTOCONF ; port->rs485_config = mcf_config_rs485; - port->rs485_supported = &mcf_rs485_supported; + port->rs485_supported = mcf_rs485_supported; port->has_sysrq =IS_ENABLED (CONFIG_SERIAL_MCF_CONSOLE );uart_add_one_port (&mcf_driver, port);drivers/tty/serial/omap-serial.c +1
-1@@ -1643,7 +1643,7 @@ static int serial_omap_probe(struct platform_device *pdev) up->port.flags = omap_up_info->flags; up->port.uartclk = omap_up_info->uartclk; up->port.rs485_config = serial_omap_config_rs485; - up->port.rs485_supported = &serial_omap_rs485_supported; + up->port.rs485_supported = serial_omap_rs485_supported;if (!up->port.uartclk) { up->port.uartclk =DEFAULT_CLK_SPEED ; dev_warn(&pdev->dev,drivers/tty/serial/sc16is7xx.c +1
-1@@ -1461,7 +1461,7 @@ static int sc16is7xx_probe(struct device *dev, s->p[i].port.iotype =UPIO_PORT ; s->p[i].port.uartclk = freq; s->p[i].port.rs485_config = sc16is7xx_config_rs485; - s->p[i].port.rs485_supported = &sc16is7xx_rs485_supported; + s->p[i].port.rs485_supported = sc16is7xx_rs485_supported; s->p[i].port.ops = &sc16is7xx_ops; s->p[i].old_mctrl =0 ; s->p[i].port.line =sc16is7xx_alloc_line ();drivers/tty/serial/serial_core.c +4
-4@@ -1285,7 +1285,7 @@ static int uart_check_rs485_flags(struct uart_port *port, struct serial_rs485 *r* For any bit outside of the legacy ones that is not supported by * the driver, return -EINVAL. */ -if (flags & ~port->rs485_supported->flags) +if (flags & ~port->rs485_supported.flags)return -EINVAL ;/* Asking for address w/o addressing mode? */ @@ -1304,7 +1304,7 @@ static int uart_check_rs485_flags(struct uart_port *port, struct serial_rs485 *rstatic void uart_sanitize_serial_rs485 (struct uart_port *port,struct serial_rs485 *rs485) { -u32 supported_flags = port->rs485_supported->flags; +u32 supported_flags = port->rs485_supported.flags;if (!(rs485->flags &SER_RS485_ENABLED )) {memset (rs485,0 ,sizeof (*rs485));@@ -1323,7 +1323,7 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 supported_flags |=SER_RS485_RTS_ON_SEND |SER_RS485_RTS_AFTER_SEND ; } -if (!port->rs485_supported->delay_rts_before_send) { +if (!port->rs485_supported.delay_rts_before_send) {if (rs485->delay_rts_before_send) { dev_warn_ratelimited(port->dev, "%s (%d): RTS delay before sending not supported\n",@@ -1337,7 +1337,7 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 port->name, port->line, rs485->delay_rts_before_send); } -if (!port->rs485_supported->delay_rts_after_send) { +if (!port->rs485_supported.delay_rts_after_send) {if (rs485->delay_rts_after_send) { dev_warn_ratelimited(port->dev, "%s (%d): RTS delay after sending not supported\n",drivers/tty/serial/stm32-usart.c +1
-1@@ -1401,7 +1401,7 @@ static int stm32_usart_init_port(struct stm32_port *stm32port, port->has_sysrq =IS_ENABLED (CONFIG_SERIAL_STM32_CONSOLE ); port->irq = irq; port->rs485_config = stm32_usart_config_rs485; - port->rs485_supported = &stm32_rs485_supported; + port->rs485_supported = stm32_rs485_supported; ret =stm32_usart_init_rs485 (port, pdev);if (ret)include/linux/serial_core.h +0
-0
include/linux/serial_core.h struct uart_port { · line 261
Quoted 8 lines
include/linux/serial_core.h +1
-1@@ -255,7 +255,7 @@ struct uart_port {struct attribute_group *attr_group;/* port specific attributes */ const struct attribute_group **tty_groups;/* all attributes (serial core use only) */ struct serial_rs485 rs485; -const struct serial_rs485 *rs485_supported;/* Supported mask for serial_rs485 */ +struct serial_rs485 rs485_supported;/* Supported mask for serial_rs485 */ struct gpio_desc *rs485_term_gpio;/* enable RS485 bus termination */ struct serial_iso7816 iso7816;void *private_data;/* generic platform data pointer */
Regards,
Lino
Ilpo Järvinen
maintainerPATCH 2/2 serial: RS485 termination is supported if DT provides one
In reply to Ilpo JärvinenWhen DT provides rs485-term, set termination flag as supported.
--- drivers/tty/serial/serial_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/serial_core.c +2 -0
@@ -3409,6 +3409,8 @@ int uart_get_rs485_mode(struct uart_port *port) port->rs485_term_gpio =NULL ;return dev_err_probe (dev, ret,"Cannot get rs485-term-gpios\n" ); } +if (port->rs485_term_gpio) + port->rs485_supported.flags |=SER_RS485_TERMINATE_BUS ;return 0 ; }
Signature · 1 line
2.30.2
Re: [PATCH 2/2] serial: RS485 termination is supported if DT provides one
Quoted 12 lines · Ilpo Järvinen
When DT provides rs485-term, set termination flag as supported.
Signed-off-by Ilpo Järvinen <[email protected]>--- drivers/tty/serial/serial_core.c | 2 ++ 1 file changed, 2 insertions(+)drivers/tty/serial/serial_core.c +0
-0
drivers/tty/serial/serial_core.c int uart_get_rs485_mode(struct uart_port *port) · line 3416
Quoted 8 lines
drivers/tty/serial/serial_core.c +2
-0@@ -3409,6 +3409,8 @@ int uart_get_rs485_mode(struct uart_port *port) port->rs485_term_gpio =NULL ;return dev_err_probe (dev, ret,"Cannot get rs485-term-gpios\n" ); } +if (port->rs485_term_gpio) + port->rs485_supported.flags |=SER_RS485_TERMINATE_BUS ;return 0 ; }
FWIW:
Regards,
Lino