All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Gerhard Engleder <gerhard@engleder-embedded.com>
Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
	jirislaby@kernel.org, lukas@wunner.de,
	Gerhard Engleder <eg@keba.com>, Daniel Gierlinger <gida@keba.com>
Subject: Re: [PATCH v4 2/2] serial: 8250: add driver for KEBA UART
Date: Wed, 26 Nov 2025 14:17:43 +0100	[thread overview]
Message-ID: <aSb99zuXhUh3VD4J@black.igk.intel.com> (raw)
In-Reply-To: <20251023151229.11774-3-gerhard@engleder-embedded.com>

On Thu, Oct 23, 2025 at 05:12:29PM +0200, Gerhard Engleder wrote:
> 
> The KEBA UART is found in the system FPGA of KEBA PLC devices. It is
> mostly 8250 compatible with extension for some UART modes.
> 
> 3 different variants exist. The simpliest variant supports only RS-232
> and is used for debug interfaces. The next variant supports only RS-485
> and is used mostly for communication with KEBA panel devices. The third
> variant is able to support RS-232, RS-485 and RS-422. For this variant
> not only the mode of the UART is configured, also the physics and
> transceivers are switched according to the mode.

...

> +#include <linux/auxiliary_bus.h>

+ bits.h
+ container_of.h

> +#include <linux/device.h>

I don't see how it's being used.
What I see are

+ dev_printk.h
+ device/devres.h

+ err.h

> +#include <linux/io.h>
> +#include <linux/misc/keba.h>

+ mod_devicetable.h

> +#include <linux/module.h>

+ spinlock.h
+ types.h

...

> +static int kuart_probe(struct auxiliary_device *auxdev,
> +		       const struct auxiliary_device_id *id)
> +{
> +	struct device *dev = &auxdev->dev;
> +	struct uart_8250_port uart = {};
> +	struct resource res;
> +	struct kuart *kuart;
> +	int retval;
> +
> +	kuart = devm_kzalloc(dev, sizeof(*kuart), GFP_KERNEL);
> +	if (!kuart)
> +		return -ENOMEM;
> +	kuart->auxdev = container_of(auxdev, struct keba_uart_auxdev, auxdev);
> +	kuart->flags = id->driver_data;
> +	auxiliary_set_drvdata(auxdev, kuart);
> +
> +	/*
> +	 * map only memory in front of UART registers, UART registers will be
> +	 * mapped by serial port
> +	 */
> +	res = kuart->auxdev->io;
> +	res.end = res.start + KUART_BASE - 1;
> +	kuart->base = devm_ioremap_resource(dev, &res);
> +	if (IS_ERR(kuart->base))
> +		return PTR_ERR(kuart->base);
> +
> +	if (kuart->flags & KUART_USE_CAPABILITY) {
> +		/*
> +		 * supported modes are read from capability register, at least
> +		 * one mode other than none must be supported
> +		 */
> +		kuart->capability = ioread8(kuart->base + KUART_CAPABILITY) &
> +				    KUART_CAPABILITY_MASK;
> +		if ((kuart->capability & ~KUART_CAPABILITY_NONE) == 0)
> +			return -EIO;
> +	}
> +
> +	spin_lock_init(&uart.port.lock);
> +	uart.port.dev = dev;
> +	uart.port.mapbase = kuart->auxdev->io.start + KUART_BASE;
> +	uart.port.irq = kuart->auxdev->irq;
> +	uart.port.uartclk = KUART_CLK;
> +	uart.port.private_data = kuart;
> +
> +	/* 8 bit registers are 32 bit aligned => shift register offset */
> +	uart.port.iotype = UPIO_MEM32;
> +	uart.port.regshift = KUART_REGSHIFT;

Can't you call uart_read_port_properties()?

If ever you gain some properties either via FW description or via software
nodes, they will be automatically used without need to update the driver!

> +	/*
> +	 * UART mixes 16550, 16750 and 16C950 (for RS485) standard => auto
> +	 * configuration works best
> +	 */
> +	uart.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_IOREMAP;
> +
> +	/*
> +	 * UART supports RS485, RS422 and RS232 with switching of physical
> +	 * interface
> +	 */
> +	uart.port.rs485_config = kuart_rs485_config;
> +	if (kuart->flags & KUART_RS485) {
> +		uart.port.rs485_supported.flags = SER_RS485_ENABLED |
> +						  SER_RS485_RTS_ON_SEND;
> +		uart.port.rs485.flags = SER_RS485_ENABLED |
> +					SER_RS485_RTS_ON_SEND;
> +	}
> +	if (kuart->flags & KUART_USE_CAPABILITY) {
> +		/* default mode priority is RS485 > RS422 > RS232 */
> +		if (kuart->capability & KUART_CAPABILITY_RS422) {
> +			uart.port.rs485_supported.flags |= SER_RS485_ENABLED |
> +							   SER_RS485_RTS_ON_SEND |
> +							   SER_RS485_MODE_RS422;
> +			uart.port.rs485.flags = SER_RS485_ENABLED |
> +						SER_RS485_RTS_ON_SEND |
> +						SER_RS485_MODE_RS422;
> +		}
> +		if (kuart->capability & KUART_CAPABILITY_RS485) {
> +			uart.port.rs485_supported.flags |= SER_RS485_ENABLED |
> +							   SER_RS485_RTS_ON_SEND;
> +			uart.port.rs485.flags = SER_RS485_ENABLED |
> +						SER_RS485_RTS_ON_SEND;
> +		}
> +	}
> +
> +	retval = serial8250_register_8250_port(&uart);
> +	if (retval < 0) {

> +		dev_err(&auxdev->dev, "UART registration failed!\n");
> +		return retval;

		return dev_err_probe(...);

> +	}
> +	kuart->line = retval;
> +
> +	return 0;
> +}

...

Since driver is about to be applied to serial-next, I suggest to send a
followup(s) to address my comments.

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2025-11-26 13:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23 15:12 [PATCH v4 0/2] serial: add KEBA UART driver Gerhard Engleder
2025-10-23 15:12 ` [PATCH v4 1/2] serial: Keep rs485 settings for devices without firmware node Gerhard Engleder
2025-10-26  9:25   ` Lukas Wunner
2025-11-26 13:10   ` Andy Shevchenko
2025-11-26 20:42     ` Gerhard Engleder
2025-10-23 15:12 ` [PATCH v4 2/2] serial: 8250: add driver for KEBA UART Gerhard Engleder
2025-10-26  9:30   ` Lukas Wunner
2025-11-26 13:17   ` Andy Shevchenko [this message]
2025-11-26 21:06     ` Gerhard Engleder
2025-11-26 21:33       ` Andy Shevchenko
2025-11-27 19:40         ` Gerhard Engleder
2025-11-27 19:58           ` Andy Shevchenko
2025-11-26 15:46   ` Ilpo Järvinen
2025-11-26 21:30     ` Gerhard Engleder
2025-11-27  9:28       ` Ilpo Järvinen
2025-11-27 19:43         ` Gerhard Engleder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aSb99zuXhUh3VD4J@black.igk.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=eg@keba.com \
    --cc=gerhard@engleder-embedded.com \
    --cc=gida@keba.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lukas@wunner.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.