Anton Vorontsov | 1 Oct 2010 15:20
Picon

[PATCH v2 0/8] Some patches for Altera UART driver

Hi all,

Here is v2. Changes:

- Addressed comments by Alan Cox and Tobias Klauser;
- In patch 'Add support for getting mapbase and IRQ from resources',
  added ioremap() return value checking;
- Added a few fixup patches.

Thanks,

--

-- 
Anton Vorontsov
email: cbouatmailru <at> gmail.com
irc://irc.freenode.net/bd2
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Anton Vorontsov | 1 Oct 2010 15:21
Picon

[PATCH 1/8] serial: Factor out uart_poll_timeout() from 8250 driver

Soon we will use that handy function in the altera_uart driver.

Signed-off-by: Anton Vorontsov <cbouatmailru <at> gmail.com>
---
 drivers/serial/8250.c       |   14 ++++----------
 include/linux/serial_core.h |    8 ++++++++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 24110f6..61e95dd 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
 <at>  <at>  -1722,12 +1722,6  <at>  <at>  static void serial_unlink_irq_chain(struct uart_8250_port *up)
 	mutex_unlock(&hash_mutex);
 }

-/* Base timer interval for polling */
-static inline int poll_timeout(int timeout)
-{
-	return timeout > 6 ? (timeout / 2 - 2) : 1;
-}
-
 /*
  * This function is used to handle ports that do not have an
  * interrupt.  This doesn't work very well for 16450's, but gives
 <at>  <at>  -1742,7 +1736,7  <at>  <at>  static void serial8250_timeout(unsigned long data)
 	iir = serial_in(up, UART_IIR);
 	if (!(iir & UART_IIR_NO_INT))
 		serial8250_handle_port(up);
-	mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout));
(Continue reading)

Anton Vorontsov | 1 Oct 2010 15:21
Picon

[PATCH 3/8] altera_uart: Add support for getting mapbase and IRQ from resources

This makes it much easier to integrate the driver with the rest of
the Linux (e.g. MFD subsystem).

The old method is still supported though.

Also, from now on, there is one platform device per port (no
changes are needed for the platform code, as no one registers
the devices anywhere in-tree yet).

Signed-off-by: Anton Vorontsov <cbouatmailru <at> gmail.com>
Acked-by: Tobias Klauser <tklauser <at> distanz.ch>
---
 drivers/serial/altera_uart.c |   60 ++++++++++++++++++++++++++---------------
 1 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index 7dd58da..1dfeffa 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
 <at>  <at>  -498,38 +498,54  <at>  <at>  static int __devinit altera_uart_probe(struct platform_device *pdev)
 {
 	struct altera_uart_platform_uart *platp = pdev->dev.platform_data;
 	struct uart_port *port;
-	int i;
+	struct resource *res_mem;
+	struct resource *res_irq;
+	int i = pdev->id;

-	for (i = 0; i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS && platp[i].mapbase; i++) {
-		port = &altera_uart_ports[i].port;
(Continue reading)

Anton Vorontsov | 1 Oct 2010 15:22
Picon

[PATCH 5/8] altera_uart: Make it possible to use Altera UART and 8250 ports together

This fixes tty name and major number conflicts. The major number
204 is used across many platform-specific serial drivers, so we
use that.

Signed-off-by: Anton Vorontsov <cbouatmailru <at> gmail.com>
Acked-by: Tobias Klauser <tklauser <at> distanz.ch>
---
 drivers/serial/altera_uart.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index f1985aa..99e007f 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
 <at>  <at>  -28,6 +28,7  <at>  <at> 
 #include <linux/altera_uart.h>

 #define DRV_NAME "altera_uart"
+#define SERIAL_ALTERA_MAJOR 204

 /*
  * Altera UART register definitions according to the Nios UART datasheet:
 <at>  <at>  -471,7 +472,7  <at>  <at>  static int __init altera_uart_console_setup(struct console *co, char *options)
 static struct uart_driver altera_uart_driver;

 static struct console altera_uart_console = {
-	.name	= "ttyS",
+	.name	= "ttyAL",
 	.write	= altera_uart_console_write,
 	.device	= uart_console_device,
(Continue reading)

Anton Vorontsov | 1 Oct 2010 15:22
Picon

[PATCH 6/8] altera_uart: Fixup type usage of port flags

port->flags is of type upf_t, which corresponds to UPF_* flags.

ASYNC_BOOT_AUTOCONF is an unsigned integer, which happen to
be the same as UPF_BOOT_AUTOCONF.

Signed-off-by: Anton Vorontsov <cbouatmailru <at> gmail.com>
---
 drivers/serial/altera_uart.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index 99e007f..304181c 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
 <at>  <at>  -420,7 +420,7  <at>  <at>  int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp)
 		port->iotype = SERIAL_IO_MEM;
 		port->irq = platp[i].irq;
 		port->uartclk = platp[i].uartclk;
-		port->flags = ASYNC_BOOT_AUTOCONF;
+		port->flags = UPF_BOOT_AUTOCONF;
 		port->ops = &altera_uart_ops;
 		port->private_data = platp;
 	}
 <at>  <at>  -550,7 +550,7  <at>  <at>  static int __devinit altera_uart_probe(struct platform_device *pdev)
 	port->iotype = SERIAL_IO_MEM;
 	port->uartclk = platp->uartclk;
 	port->ops = &altera_uart_ops;
-	port->flags = ASYNC_BOOT_AUTOCONF;
+	port->flags = UPF_BOOT_AUTOCONF;
 	port->private_data = platp;
(Continue reading)

Anton Vorontsov | 1 Oct 2010 15:22
Picon

[PATCH 7/8] altera_uart: Fix missing prototype for registering an early console

Simply add an early_altera_uart_setup() prototype declaration, otherwise
platform code have to do it in .c files, which is ugly.

Signed-off-by: Anton Vorontsov <cbouatmailru <at> gmail.com>
---
 include/linux/altera_uart.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/linux/altera_uart.h b/include/linux/altera_uart.h
index c022c82..a10a907 100644
--- a/include/linux/altera_uart.h
+++ b/include/linux/altera_uart.h
 <at>  <at>  -5,6 +5,8  <at>  <at> 
 #ifndef	__ALTUART_H
 #define	__ALTUART_H

+#include <linux/init.h>
+
 struct altera_uart_platform_uart {
 	unsigned long mapbase;	/* Physical address base */
 	unsigned int irq;	/* Interrupt vector */
 <at>  <at>  -12,4 +14,6  <at>  <at>  struct altera_uart_platform_uart {
 	unsigned int bus_shift;	/* Bus shift (address stride) */
 };

+int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp);
+
 #endif /* __ALTUART_H */
--

-- 
1.7.0.5
(Continue reading)

Anton Vorontsov | 1 Oct 2010 15:24
Picon

Re: [PATCH 4/5] altera_uart: Add support for different address strides

On Tue, Sep 28, 2010 at 05:29:29PM +0200, Tobias Klauser wrote:
[...]
> >  struct altera_uart {
> >  	struct uart_port port;
> >  	struct timer_list tmr;
> > +	int bus_shift;
> 
> This member is never used (only bus_shift from struct
> altera_uart_platform_uart). Seems to be a leftover.

Fixed, thanks!

> >  	unsigned int sigs;	/* Local copy of line sigs */
> >  	unsigned short imr;	/* Local IMR mirror */
> >  };
> >  
> > +static u32 altera_uart_readl(struct uart_port *port, int reg)
> > +{
> > +	struct altera_uart_platform_uart *platp = port->private_data;
> > +
> > +	return readl(port->membase + (reg << platp->bus_shift));
> > +}
> > +
> > +static void altera_uart_writel(struct uart_port *port, u32 dat, int reg)
> > +{
> > +	struct altera_uart_platform_uart *platp = port->private_data;
> > +
> > +	writel(dat, port->membase + (reg << platp->bus_shift));
> > +}
> 
(Continue reading)

Anton Vorontsov | 1 Oct 2010 15:24
Picon

Re: [PATCH 2/5] altera_uart: Add support for polling mode (IRQ-less)

On Tue, Sep 28, 2010 at 05:45:39PM +0200, Tobias Klauser wrote:
[...]
> > -	ret = request_irq(port->irq, altera_uart_interrupt, IRQF_DISABLED,
> > -			DRV_NAME, port);
> > -	if (ret) {
> > -		pr_err(DRV_NAME ": unable to attach Altera UART %d "
> > -		       "interrupt vector=%d\n", port->line, port->irq);
> > -		return ret;
> > -	}
> > -
> >  	spin_lock_irqsave(&port->lock, flags);
> >  
> >  	/* Enable RX interrupts now */
> >  <at>  <at>  -300,6 +304,19  <at>  <at>  static int altera_uart_startup(struct uart_port *port)
> >  
> >  	spin_unlock_irqrestore(&port->lock, flags);
> 
> Shouldn't we only enable the RX interrupt if we actually use interrupts?

Why would that matter if we don't use the interrupts? ;-)

But I made the change anyway.

> Also I would retain the order here (first register the interrupt handler
> and then enable the interrupts).

OK, fixed. Thanks!

--

-- 
Anton Vorontsov
(Continue reading)

Alan Cox | 1 Oct 2010 14:41
Picon

Re: [PATCH 5/8] altera_uart: Make it possible to use Altera UART and 8250 ports together

On Fri, 1 Oct 2010 17:22:07 +0400
Anton Vorontsov <cbouatmailru <at> gmail.com> wrote:

> This fixes tty name and major number conflicts. The major number
> 204 is used across many platform-specific serial drivers, so we
> use that.

204 is allocated in small chunks to specific low volume devices so you
need a proper minor allocation

At this point that would be 204,213 for whatever tiny range you need.

Please send me a patch for devices.txt and update accordingly,
otherwise no objections.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Tobias Klauser | 1 Oct 2010 15:50
Picon
Favicon
Gravatar

Re: [PATCH 8/8] altera_uart: Don't use plain integer as NULL pointer

On 2010-10-01 at 15:23:13 +0200, Anton Vorontsov <cbouatmailru <at> gmail.com> wrote:
> Fixes sparse warning.
> 
> Signed-off-by: Anton Vorontsov <cbouatmailru <at> gmail.com>

Acked-by: Tobias Klauser <tklauser <at> distanz.ch>
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane