Skip to contentSkip to conversation

8250_early console support for au1x00

PATCH In review Rodolfo Giometti 2 participants 9 messages May 4, 2006 – Aug 30, 2006 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 8250_early console support for au1x00

Done! :)

Here the patch (against «linux-2.6.16-stable» and tested with au1100 based board):

http://ftp.enneenne.com/pub/misc/au1100-patches/linux/patch-patch-au1x00-early-console

My kernel command line has now:

console=uart,au,0x11100000,115200

so, I suppose, it's important that the serial lines physical addresses are specified as 0x11100000 and not as 0xB1100000!

Please, note also the «know bugs» section.

Ciao,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail:    [email protected]
Linux Device Driver                             [email protected]
Embedded Systems                     		[email protected]
UNIX programming                     phone:     +39 349 2432127
#1 lore raw

Hello.

Quoted 6 lines · Rodolfo Giometti

Done! :)

Here the patch (against «linux-2.6.16-stable» and tested with au1100 based board):

   http://ftp.enneenne.com/pub/misc/au1100-patches/linux/patch-patch-au1x00-early-console

The following 2 fragments are kind of contradictory:

Quoted 43 lines
drivers/serial/8250.c +5 -3
@@ -2322,16 +2322,18 @@ static int __init find_port(struct uart_
 
 int __init serial8250_start_console(struct uart_port *port, char *options)
 {
-	int line;
+	int line, mmio;
 
 	line = find_port(port);
 	if (line < 0)
 		return -ENODEV;
 
 	add_preferred_console("ttyS", line, options);
+	mmio = (port->iotype == UPIO_MEM) || (port->iotype == UPIO_AU);
 	printk("Adding console on ttyS%d at %s 0x%lx (options '%s')\n",
-		line, port->iotype == UPIO_MEM ? "MMIO" : "I/O port",
-		port->iotype == UPIO_MEM ? (unsigned long) port->mapbase :
+		line,
+	       	mmio ? "MMIO" : "I/O port",
+		mmio ? (unsigned long) port->mapbase :
 		    (unsigned long) port->iobase, options);
 	if (!(serial8250_console.flags & CON_ENABLED)) {
 
drivers/serial/8250_early.c +1 -4
@@ -232,22 +380,23 @@ static int __init early_uart_console_swi
 {
 	struct early_uart_device *device = &early_device;
 	struct uart_port *port = &device->port;
-	int mmio, line;
+	int line;
 
 	if (!(early_uart_console.flags & CON_ENABLED))
 		return 0;
 
 	/* Try to start the normal driver on a matching line.  */
-	mmio = (port->iotype == UPIO_MEM);
 	line = serial8250_start_console(port, device->options);
 	if (line < 0)
 		printk("No ttyS device at %s 0x%lx for console\n",
-			mmio ? "MMIO" : "I/O port",
-			mmio ? port->mapbase :

drivers/serial/8250_early.c static int __init early_uart_console_swi · line 400

Quoted 10 lines
drivers/serial/8250_early.c +5 -1
+			(port->iotype == UPIO_MEM) ? "MMIO" : \
+			(port->iotype == UPIO_AU)  ? "AU"   : "I/O port",
+			(port->iotype == UPIO_MEM) || \
+			(port->iotype == UPIO_AU) ? port->mapbase :
 			    (unsigned long) port->iobase);
 
 	unregister_console(&early_uart_console);
-	if (mmio)
+	if ((port->iotype == UPIO_MEM) || (port->iotype == UPIO_AU))
 		iounmap(port->membase);

Why the different code here? I suggest sticking to the 8250.c variant...
And, as I said. there's not much sense in calling iomap() on Alchemy UART, UPIO_IOREMAP flag wasn't really needed...

Quoted 1 line

Please, note also the «know bugs» section.

You propably meant "known bugs"? :-)

Quoted 3 lines

Ciao,

Rodolfo

WBR, Sergei

#2 lore raw
Quoted 2 lines · Sergei Shtylyov

The following 2 fragments are kind of contradictory:

I see, but I decided to keep it different since the kernel message is:

Adding console on ttyS0 at MMIO 0x11100000 (options '115200')

and setting it as:

Adding console on ttyS0 at AU 0x11100000 (options '115200')

sounds bad to me. :)

Quoted 2 lines

And, as I said. there's not much sense in calling iomap() on Alchemy UART, UPIO_IOREMAP flag wasn't really needed...

Mmm... to be «coherent» I think it should be done...

Quoted 1 line

You propably meant "known bugs"? :-)

Yes. :)

Ciao,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail:    [email protected]
Linux Device Driver                             [email protected]
Embedded Systems                     		[email protected]
UNIX programming                     phone:     +39 349 2432127
#3 lore raw

Hello.

Quoted 6 lines · Rodolfo Giometti
Quoted 1 line · Sergei Shtylyov

The following 2 fragments are kind of contradictory:

I see, but I decided to keep it different since the kernel message is:

Quoted 7 lines

Adding console on ttyS0 at MMIO 0x11100000 (options '115200')

and setting it as:

Adding console on ttyS0 at AU 0x11100000 (options '115200')

sounds bad to me. :)

Yes. But the error msg emmitted by your patch would look this way, i.e.
AU, not MMIO. No symmetry. :-)

Quoted 4 lines
Quoted 1 line

And, as I said. there's not much sense in calling iomap() on Alchemy UART, UPIO_IOREMAP flag wasn't really needed...

Mmm... to be «coherent» I think it should be done...

Wouldn't hurt, just useless. So, I think no special checks are needed to
avoid it. :-)

Quoted 3 lines

Ciao,

Rodolfo

WBR, Sergei

#4 lore raw
Quoted 3 lines · Sergei Shtylyov

Yes. But the error msg emmitted by your patch would look this way, i.e.
AU, not MMIO. No symmetry. :-)

Ah! Now I see... ok, I'll fix it! :)

Quoted 2 lines

Wouldn't hurt, just useless. So, I think no special checks are needed to
avoid it. :-)

If don't hurt I think we should use the physical address instead of KSEG1...

Ciao,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail:    [email protected]
Linux Device Driver                             [email protected]
Embedded Systems                     		[email protected]
UNIX programming                     phone:     +39 349 2432127
#5 lore raw

PATCH 1/1 8250_early console support for au1x00 (again)

Hello.

Here, attached and published on my site, my two new proposal for serial line and early console for au1x00.

The first patch:

http://ftp.enneenne.com/pub/misc/au1100-patches/linux/patch-au1x00-early-console

adds early console support for au1x00. In this version I decided to add the "AU" serial type in all kernel messages.

The second patch:

http://ftp.enneenne.com/pub/misc/au1100-patches/linux/patch-au1x00-serial-phys-addr

fixes serial address space by using only physical addresses. Please, note that this change allow to simply file "drivers/serial/8250.c" since functions __raw_readl()/__raw_writel() can be replaced by functions readl()/writel().

At boot time I get:

Starting kernel .Linux version 2.6.17-rc4-gde4a1dae-dirty (giometti@zaigor) (gcc version 3.4.3) #83 Mon May 22 22:34:47 CEST 2006 CPU revision is: 02030204
Board WWPC1000 version 1.0
WWPC-setup: uC=off
(PRId 02030204) @ 396MHZ
BCLK switching enabled!
Early serial console at AU 0x11100000 (options '115200')
...
Serial: 8250/16550 driver $Revision: 1.90 $ 3 ports, IRQ sharing disabled
serial8250.8: ttyS0 at MMIO 0x11100000 (irq = 0) is a 16550A
serial8250.8: ttyS1 at MMIO 0x11200000 (irq = 1) is a 16550A
serial8250.8: ttyS2 at MMIO 0x11400000 (irq = 3) is a 16550A
...
Adding console on ttyS0 at AU 0x11100000 (options '115200')
...

and at system running time I get:

   hostname:~# cat /proc/iomem
   10100000-101fffff : au1xxx-ohci.0
     10100000-101fffff : ohci_hcd
   10500000-1050ffff : eth-base
   10520000-10520003 : eth-mac
   11100000-111fffff : serial
   11200000-112fffff : serial
   11400000-114fffff : serial                                                      

which is coherent with other system devices. :)

Ciao,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail:    [email protected]
Linux Device Driver                             [email protected]
Embedded Systems                     		[email protected]
UNIX programming                     phone:     +39 349 2432127
arch/mips/kernel/setup.c +5 -0
index bcf1b10..78dcded 100644
@@ -32,6 +32,7 @@
 #include <linux/kdev_t.h>
 #include <linux/root_dev.h>
 #include <linux/highmem.h>
+#include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/mmzone.h>
 #include <linux/pfn.h>
@@ -517,6 +518,10 @@ void __init setup_arch(char **cmdline_p)
 
 	*cmdline_p = command_line;
 
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+	early_serial_console_init(*cmdline_p);
+#endif
+
 	parse_cmdline_early();
 	bootmem_init();
 	sparse_init();
drivers/serial/8250.c +5 -2
index bbf78aa..784d9d3 100644
@@ -2336,8 +2336,11 @@ int __init serial8250_start_console(stru
 
 	add_preferred_console("ttyS", line, options);
 	printk("Adding console on ttyS%d at %s 0x%lx (options '%s')\n",
-		line, port->iotype == UPIO_MEM ? "MMIO" : "I/O port",
-		port->iotype == UPIO_MEM ? (unsigned long) port->mapbase :
+		line,
+	       	(port->iotype == UPIO_MEM) ? "MMIO" : \
+		(port->iotype == UPIO_AU)  ? "AU"   : "I/O port",
+		(port->iotype == UPIO_MEM) || \
+		(port->iotype == UPIO_AU) ? (unsigned long) port->mapbase :
 		    (unsigned long) port->iobase, options);
 	if (!(serial8250_console.flags & CON_ENABLED)) {
 		serial8250_console.flags &= ~CON_PRINTBUFFER;
drivers/serial/8250_early.c +160 -20

279 lines not on this page · raw message

drivers/serial/serial_core.c +1 -0
index 17839e7..9e27aee 100644
@@ -2367,6 +2367,7 @@ int uart_match_port(struct uart_port *po
 		return (port1->iobase == port2->iobase) &&
 		       (port1->hub6   == port2->hub6);
 	case UPIO_MEM:
+	case UPIO_AU:
 		return (port1->mapbase == port2->mapbase);
 	}
 	return 0;
drivers/serial/8250.c +4 -13
index 784d9d3..40c9097 100644
@@ -311,12 +311,8 @@ static unsigned int serial_in(struct uar
 		return readb(up->port.membase + offset);
 
 	case UPIO_MEM32:
-		return readl(up->port.membase + offset);
-
-#ifdef CONFIG_SERIAL_8250_AU1X00
 	case UPIO_AU:
-		return __raw_readl(up->port.membase + offset);
-#endif
+		return readl(up->port.membase + offset);
 
 	default:
 		return inb(up->port.iobase + offset);
@@ -339,14 +335,9 @@ serial_out(struct uart_8250_port *up, in
 		break;
 
 	case UPIO_MEM32:
-		writel(value, up->port.membase + offset);
-		break;
-
-#ifdef CONFIG_SERIAL_8250_AU1X00
 	case UPIO_AU:
-		__raw_writel(value, up->port.membase + offset);
+		writel(value, up->port.membase + offset);
 		break;
-#endif
 
 	default:
 		outb(value, up->port.iobase + offset);
@@ -380,7 +371,7 @@ static inline void _serial_dl_write(stru
 static int serial_dl_read(struct uart_8250_port *up)
 {
 	if (up->port.iotype == UPIO_AU)
-		return __raw_readl(up->port.membase + 0x28);
+		return readl(up->port.membase + 0x28);
 	else
 		return _serial_dl_read(up);
 }
@@ -388,7 +379,7 @@ static int serial_dl_read(struct uart_82
 static void serial_dl_write(struct uart_8250_port *up, int value)
 {
 	if (up->port.iotype == UPIO_AU)
-		__raw_writel(value, up->port.membase + 0x28);
+		writel(value, up->port.membase + 0x28);
 	else
 		_serial_dl_write(up, value);
 }
drivers/serial/8250_au1x00.c +17 -17
index 58015fd..9d0f1be 100644
@@ -29,36 +29,36 @@
 #define PORT(_base, _irq)				\
 	{						\
 		.iobase		= _base,		\
-		.membase	= (void __iomem *)_base,\
-		.mapbase	= CPHYSADDR(_base),	\
+		.mapbase	= _base,		\
 		.irq		= _irq,			\
 		.uartclk	= 0,	/* filled */	\
 		.regshift	= 2,			\
 		.iotype		= UPIO_AU,		\
-		.flags		= UPF_SKIP_TEST 	\
+		.flags		= UPF_SKIP_TEST | 	\
+				  UPF_IOREMAP		\
 	}
 
 static struct plat_serial8250_port au1x00_data[] = {
 #if defined(CONFIG_SOC_AU1000)
-	PORT(UART0_ADDR, AU1000_UART0_INT),
-	PORT(UART1_ADDR, AU1000_UART1_INT),
-	PORT(UART2_ADDR, AU1000_UART2_INT),
-	PORT(UART3_ADDR, AU1000_UART3_INT),
+	PORT(UART0_PHYS_ADDR, AU1000_UART0_INT),
+	PORT(UART1_PHYS_ADDR, AU1000_UART1_INT),
+	PORT(UART2_PHYS_ADDR, AU1000_UART2_INT),
+	PORT(UART3_PHYS_ADDR, AU1000_UART3_INT),
 #elif defined(CONFIG_SOC_AU1500)
-	PORT(UART0_ADDR, AU1500_UART0_INT),
-	PORT(UART3_ADDR, AU1500_UART3_INT),
+	PORT(UART0_PHYS_ADDR, AU1500_UART0_INT),
+	PORT(UART3_PHYS_ADDR, AU1500_UART3_INT),
 #elif defined(CONFIG_SOC_AU1100)
-	PORT(UART0_ADDR, AU1100_UART0_INT),
-	PORT(UART1_ADDR, AU1100_UART1_INT),
+	PORT(UART0_PHYS_ADDR, AU1100_UART0_INT),
+	PORT(UART1_PHYS_ADDR, AU1100_UART1_INT),
 	/* The internal UART2 does not exist on the AU1100 processor. */
-	PORT(UART3_ADDR, AU1100_UART3_INT),
+	PORT(UART3_PHYS_ADDR, AU1100_UART3_INT),
 #elif defined(CONFIG_SOC_AU1550)
-	PORT(UART0_ADDR, AU1550_UART0_INT),
-	PORT(UART1_ADDR, AU1550_UART1_INT),
-	PORT(UART3_ADDR, AU1550_UART3_INT),
+	PORT(UART0_PHYS_ADDR, AU1550_UART0_INT),
+	PORT(UART1_PHYS_ADDR, AU1550_UART1_INT),
+	PORT(UART3_PHYS_ADDR, AU1550_UART3_INT),
 #elif defined(CONFIG_SOC_AU1200)
-	PORT(UART0_ADDR, AU1200_UART0_INT),
-	PORT(UART1_ADDR, AU1200_UART1_INT),
+	PORT(UART0_PHYS_ADDR, AU1200_UART0_INT),
+	PORT(UART1_PHYS_ADDR, AU1200_UART1_INT),
 #endif
 	{ },
 };
#6 lore raw

Re: [PATCH] 8250_early console support for au1x00 (again)

Hello.

Quoted 10 lines · Rodolfo Giometti

Here, attached and published on my site, my two new proposal for serial line and early console for au1x00.

The first patch:

   http://ftp.enneenne.com/pub/misc/au1100-patches/linux/patch-au1x00-early-console

adds early console support for au1x00. In this version I decided to add the "AU" serial type in all kernel messages.

Quoted 8 lines

The second patch:

   http://ftp.enneenne.com/pub/misc/au1100-patches/linux/patch-au1x00-serial-phys-addr

fixes serial address space by using only physical addresses. Please, note that this change allow to simply file "drivers/serial/8250.c" since functions __raw_readl()/__raw_writel() can be replaced by functions readl()/writel().

Sorry for follwing up 2 month ago, I just happen to stumble on some issues
addresses by these patches as well. I assume you haven't tried sending them to Russel King?
Below are my comments:

Quoted 47 lines

------------------------------------------------------------------------

arch/mips/kernel/setup.c +5 -0
index bcf1b10..78dcded 100644
@@ -32,6 +32,7 @@
 #include <linux/kdev_t.h>
 #include <linux/root_dev.h>
 #include <linux/highmem.h>
+#include <linux/serial.h>
 #include <linux/console.h>
 #include <linux/mmzone.h>
 #include <linux/pfn.h>
@@ -517,6 +518,10 @@ void __init setup_arch(char **cmdline_p)
 
 	*cmdline_p = command_line;
 
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+	early_serial_console_init(*cmdline_p);
+#endif
+
 	parse_cmdline_early();
 	bootmem_init();
 	sparse_init();
drivers/serial/8250.c +5 -2
index bbf78aa..784d9d3 100644
@@ -2336,8 +2336,11 @@ int __init serial8250_start_console(stru
 
 	add_preferred_console("ttyS", line, options);
 	printk("Adding console on ttyS%d at %s 0x%lx (options '%s')\n",
-		line, port->iotype == UPIO_MEM ? "MMIO" : "I/O port",
-		port->iotype == UPIO_MEM ? (unsigned long) port->mapbase :
+		line,
+	       	(port->iotype == UPIO_MEM) ? "MMIO" : \
+		(port->iotype == UPIO_AU)  ? "AU"   : "I/O port",
+		(port->iotype == UPIO_MEM) || \
+		(port->iotype == UPIO_AU) ? (unsigned long) port->mapbase :
 		    (unsigned long) port->iobase, options);
 	if (!(serial8250_console.flags & CON_ENABLED)) {
 		serial8250_console.flags &= ~CON_PRINTBUFFER;
drivers/serial/8250_early.c +0 -0
index 7e51119..319baa9 100644

[...]

Quoted 1 line
drivers/serial/8250_early.c +0 -0
@@ -44,22 +52,133 @@ struct early_uart_device {

[...]

drivers/serial/8250_early.c struct early_uart_device { · line 108

Quoted 9 lines
drivers/serial/8250_early.c +7 -1
+static unsigned int serial_in(struct uart_port *port, int offset)
 {
-	if (port->iotype == UPIO_MEM)
+	offset = map_in_reg(port, offset) << port->regshift;
+
+	switch (port->iotype) {
+	case UPIO_HUB6:
+		outb(port->hub6 - 1 + offset, port->iobase);
+		return inb(port->iobase + 1);

This module can't handle HAB6 otherwise, so whay add it here?

drivers/serial/8250_early.c struct early_uart_device { · line 115

Quoted 7 lines
drivers/serial/8250_early.c +5 -1
+	case UPIO_MEM:
 		return readb(port->membase + offset);
-	else
+
+	case UPIO_MEM32:
+	case UPIO_AU:
+		return readl(port->membase + offset);

NAK. readl() can't be used to read from Alchemy SOC peripherals because
it'll break in BE mode. Alchemy automagically handles byteswap for the SOC peripherals.

Quoted 19 lines
drivers/serial/8250_early.c +13 -2
+
+	default:
 		return inb(port->iobase + offset);
+	}
 }
 
-static void __init serial_out(struct uart_port *port, int offset, int value)
+static void
+serial_out(struct uart_port *port, int offset, int value)
 {
-	if (port->iotype == UPIO_MEM)
+	offset = map_out_reg(port, offset) << port->regshift;
+
+	switch (port->iotype) {
+	case UPIO_HUB6:
+		outb(port->hub6 - 1 + offset, port->iobase);
+		outb(value, port->iobase + 1);
+		break;
+

drivers/serial/8250_early.c struct early_uart_device { · line 141

Quoted 10 lines
drivers/serial/8250_early.c +8 -1
+	case UPIO_MEM:
 		writeb(value, port->membase + offset);
-	else
+		break;
+
+	case UPIO_MEM32:
+	case UPIO_AU:
+		writel(value, port->membase + offset);
+		break;
+

The same NAK with writel()...

Quoted 66 lines
drivers/serial/8250_early.c +42 -4
+	default:
 		outb(value, port->iobase + offset);
+	}
+}
+
+/* Uart divisor latch read */
+static inline int _serial_dl_read(struct uart_port *port)
+{
+	return serial_in(port, UART_DLL) | serial_in(port, UART_DLM) << 8;
+}
+
+/* Uart divisor latch write */
+static inline void _serial_dl_write(struct uart_port *port, int value)
+{
+	serial_out(port, UART_DLL, value & 0xff);
+	serial_out(port, UART_DLM, value >> 8 & 0xff);
+}
+
+#ifdef CONFIG_SERIAL_8250_AU1X00
+/* Au1x00 haven't got a standard divisor latch */
+static int serial_dl_read(struct uart_port *port)
+{
+	if (port->iotype == UPIO_AU)
+		return readl(port->membase + 0x28);
+	else
+		return _serial_dl_read(port);
 }
 
+static void serial_dl_write(struct uart_port *port, int value)
+{
+	if (port->iotype == UPIO_AU)
+		writel(value, port->membase + 0x28);
+	else
+		_serial_dl_write(port, value);
+}
+#else
+#define serial_dl_read(port) _serial_dl_read(port)
+#define serial_dl_write(port, value) _serial_dl_write(port, value)
+#endif
+
 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 
 static void __init wait_for_xmitr(struct uart_port *port)
@@ -98,16 +217,17 @@ static void __init early_uart_write(stru
 
 static unsigned int __init probe_baud(struct uart_port *port)
 {
-	unsigned char lcr, dll, dlm;
+	unsigned char lcr;
 	unsigned int quot;
+	int sd = ((int)(__raw_readl(SYS_POWERCTRL)&0x03)) + 2;   /* Au1x00 SD */
 
 	lcr = serial_in(port, UART_LCR);
 	serial_out(port, UART_LCR, lcr | UART_LCR_DLAB);
-	dll = serial_in(port, UART_DLL);
-	dlm = serial_in(port, UART_DLM);
+	quot = serial_dl_read(port);
 	serial_out(port, UART_LCR, lcr);
 
-	quot = (dlm << 8) | dll;
+	if (port->iotype == UPIO_AU)
+		return CPU_SPEED / (sd * quot * 32);
 	return (port->uartclk / 16) / quot;
 }
 

drivers/serial/8250_early.c static int __init parse_options(struct e · line 269

Quoted 4 lines
drivers/serial/8250_early.c +1 -0
@@ -142,6 +266,7 @@ static int __init parse_options(struct e
 	port->uartclk = BASE_BAUD * 16;
 	if (!strncmp(options, "mmio,", 5)) {
 		port->iotype = UPIO_MEM;
+		port->regshift = 0;

Maybe regshift even deserves the separate (but optional) field in the boot
option...

[...]

Quoted 22 lines
drivers/serial/8250_early.c +2 -4
@@ -169,8 +309,7 @@ static int __init parse_options(struct e
 	}
 
 	printk(KERN_INFO "Early serial console at %s 0x%lx (options '%s')\n",
-		mmio ? "MMIO" : "I/O port",
-		mmio ? port->mapbase : (unsigned long) port->iobase,
+		buf, mmio ? port->mapbase : (unsigned long) port->iobase,
 		device->options);
 	return 0;
 }
@@ -227,22 +366,23 @@ static int __init early_uart_console_swi
 {
 	struct early_uart_device *device = &early_device;
 	struct uart_port *port = &device->port;
-	int mmio, line;
+	int line;
 
 	if (!(early_uart_console.flags & CON_ENABLED))
 		return 0;
 
 	/* Try to start the normal driver on a matching line.  */
-	mmio = (port->iotype == UPIO_MEM);

drivers/serial/8250_early.c static int __init early_uart_console_swi · line 382

Quoted 10 lines
drivers/serial/8250_early.c +4 -2
 	line = serial8250_start_console(port, device->options);
 	if (line < 0)
 		printk("No ttyS device at %s 0x%lx for console\n",
-			mmio ? "MMIO" : "I/O port",
-			mmio ? port->mapbase :
+			(port->iotype == UPIO_MEM) ? "MMIO" : \
+			(port->iotype == UPIO_AU)  ? "AU"   : "I/O port",
+			(port->iotype == UPIO_MEM) || \
+			(port->iotype == UPIO_AU) ? port->mapbase :
 			    (unsigned long) port->iobase);

I'd simply map UPIO_AU to "MMIO" in the message because it's memory mapped
UART after all...

drivers/serial/serial_core.c int uart_match_port(struct uart_port *po · line 2370

Quoted 9 lines
drivers/serial/serial_core.c +1 -0
index 17839e7..9e27aee 100644
@@ -2367,6 +2367,7 @@ int uart_match_port(struct uart_port *po
 		return (port1->iobase == port2->iobase) &&
 		       (port1->hub6   == port2->hub6);
 	case UPIO_MEM:
+	case UPIO_AU:

Also needs cases for UPIO_MEM32 and UPIO_TSI.

Quoted 12 lines
drivers/serial/serial_core.c +0 -1
 		return (port1->mapbase == port2->mapbase);
 	}
 	return 0;
 
 
------------------------------------------------------------------------
drivers/serial/8250.c +0 -0
index 784d9d3..40c9097 100644

drivers/serial/8250.c static unsigned int serial_in(struct uar · line 315

Quoted 10 lines
drivers/serial/8250.c +1 -5
@@ -311,12 +311,8 @@ static unsigned int serial_in(struct uar
 		return readb(up->port.membase + offset);
 
 	case UPIO_MEM32:
-		return readl(up->port.membase + offset);
-
-#ifdef CONFIG_SERIAL_8250_AU1X00
 	case UPIO_AU:
-		return __raw_readl(up->port.membase + offset);
-#endif
+		return readl(up->port.membase + offset);

NAK for the reason already stated.

drivers/serial/8250.c serial_out(struct uart_8250_port *up, in · line 349

Quoted 13 lines
drivers/serial/8250.c +1 -6
@@ -339,14 +335,9 @@ serial_out(struct uart_8250_port *up, in
 		break;
 
 	case UPIO_MEM32:
-		writel(value, up->port.membase + offset);
-		break;
-
-#ifdef CONFIG_SERIAL_8250_AU1X00
 	case UPIO_AU:
-		__raw_writel(value, up->port.membase + offset);
+		writel(value, up->port.membase + offset);
 		break;
-#endif

Ditto writel().

Quoted 10 lines
drivers/serial/8250.c +1 -1
@@ -380,7 +371,7 @@ static inline void _serial_dl_write(stru
 static int serial_dl_read(struct uart_8250_port *up)
 {
 	if (up->port.iotype == UPIO_AU)
-		return __raw_readl(up->port.membase + 0x28);
+		return readl(up->port.membase + 0x28);
 	else
 		return _serial_dl_read(up);
 }

drivers/serial/8250.c static int serial_dl_read(struct uart_82 · line 385

Quoted 8 lines
drivers/serial/8250.c +1 -1
@@ -388,7 +379,7 @@ static int serial_dl_read(struct uart_82
 static void serial_dl_write(struct uart_8250_port *up, int value)
 {
 	if (up->port.iotype == UPIO_AU)
-		__raw_writel(value, up->port.membase + 0x28);
+		writel(value, up->port.membase + 0x28);
 	else
 		_serial_dl_write(up, value);
 }

Ditto here.

drivers/serial/8250_au1x00.c

Quoted 4 lines
drivers/serial/8250_au1x00.c +0 -0
index 58015fd..9d0f1be 100644

The reason this file came into being at all is doubtful to me, BTW...
The platform devices should be registered in the platform setup code.

WBR, Sergei

#7 lore raw

Re: [PATCH] 8250_early console support for au1x00 (again)

Quoted 3 lines

Sorry for follwing up 2 month ago, I just happen to stumble on some issues addresses by these patches as well. I assume you haven't tried
sending them to Russel King?

Not yet, I just waiting for some comments. :)

Quoted 6 lines

drivers/serial/8250_early.c struct early_uart_device { · line 108

Quoted 4 lines
drivers/serial/8250_early.c +4 -0
+	switch (port->iotype) {
+	case UPIO_HUB6:
+		outb(port->hub6 - 1 + offset, port->iobase);
+		return inb(port->iobase + 1);

This module can't handle HAB6 otherwise, so whay add it here?

Ok. I'm going to remove it.

Quoted 7 lines

drivers/serial/8250_early.c struct early_uart_device { · line 115

Quoted 3 lines
drivers/serial/8250_early.c +3 -0
+	case UPIO_MEM32:
+	case UPIO_AU:
+		return readl(port->membase + offset);

NAK. readl() can't be used to read from Alchemy SOC peripherals because
it'll break in BE mode. Alchemy automagically handles byteswap for the SOC peripherals.

Ok. I'm going to fix it by using au_readl() but in this case I have to add an ifdef with au1xxx include file. Can it be acceptable?

Quoted 8 lines

drivers/serial/8250_early.c static int __init parse_options(struct e · line 269

Quoted 5 lines
drivers/serial/8250_early.c +1 -0
@@ -142,6 +266,7 @@ static int __init parse_options(struct e
 	port->uartclk = BASE_BAUD * 16;
 	if (!strncmp(options, "mmio,", 5)) {
 		port->iotype = UPIO_MEM;
+		port->regshift = 0;

Maybe regshift even deserves the separate (but optional) field in the boot option...

Mmm... I don't know. However I have to set a default value.

Quoted 8 lines
Quoted 5 lines
drivers/serial/8250_early.c +4 -0
+			(port->iotype == UPIO_MEM) ? "MMIO" : \
+			(port->iotype == UPIO_AU)  ? "AU"   : "I/O port",
+			(port->iotype == UPIO_MEM) || \
+			(port->iotype == UPIO_AU) ? port->mapbase :
			    (unsigned long) port->iobase);

I'd simply map UPIO_AU to "MMIO" in the message because it's memory mapped UART after all...

Yes, but in the kernel command line we must supply "au"... That's why I used different string, so the user can verify whatever he/she passed to the kernel.

Quoted 10 lines

drivers/serial/serial_core.c int uart_match_port(struct uart_port *po · line 2370

Quoted 8 lines

index 17839e7..9e27aee 100644

drivers/serial/serial_core.c +1 -0
@@ -2367,6 +2367,7 @@ int uart_match_port(struct uart_port *po
 		return (port1->iobase == port2->iobase) &&
 		       (port1->hub6   == port2->hub6);
 	case UPIO_MEM:
+	case UPIO_AU:

Also needs cases for UPIO_MEM32 and UPIO_TSI.

I just added the code for au1xxx. Why should I consider those cases also?

Quoted 8 lines
Quoted 6 lines
drivers/serial/serial_core.c +1 -2
-#ifdef CONFIG_SERIAL_8250_AU1X00
 	case UPIO_AU:
-		__raw_writel(value, up->port.membase + offset);
+		writel(value, up->port.membase + offset);
		break;

-#endif

Ditto writel().

Is __raw_writel() correct?

Quoted 1 line

WBR, Sergei

Thanks for your suggestions.

Ciao,

Rodolfo

Signature · 4 lines
GNU/Linux Solutions                  e-mail:    [email protected]
Linux Device Driver                             [email protected]
Embedded Systems                     		[email protected]
UNIX programming                     phone:     +39 349 2432127
#8 lore raw

Re: [PATCH] 8250_early console support for au1x00 (again)

Hello.

Quoted 1 line · Rodolfo Giometti
Quoted 1 line

Sorry for follwing up 2 month ago, I just happen to stumble on some

I was going to type "3 months ago" since 3 months have apssed indeed. :-<

Quoted 4 lines
Quoted 2 lines

issues addresses by these patches as well. I assume you haven't tried
sending them to Russel King?

Not yet, I just waiting for some comments. :)

Now you have some at last. :-)

Quoted 9 lines
Quoted 6 lines

drivers/serial/8250_early.c struct early_uart_device { · line 115

Quoted 3 lines
drivers/serial/8250_early.c +3 -0
+	case UPIO_MEM32:
+	case UPIO_AU:
+		return readl(port->membase + offset);

NAK. readl() can't be used to read from Alchemy SOC peripherals because
it'll break in BE mode. Alchemy automagically handles byteswap for the SOC peripherals.

Ok. I'm going to fix it by using au_readl() but in this case I have to add an ifdef with au1xxx include file. Can it be acceptable?

I think so. But it's Russel who will decide. :-)

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
drivers/serial/8250_early.c +4 -0
+			(port->iotype == UPIO_MEM) ? "MMIO" : \
+			(port->iotype == UPIO_AU)  ? "AU"   : "I/O port",
+			(port->iotype == UPIO_MEM) || \
+			(port->iotype == UPIO_AU) ? port->mapbase :
			    (unsigned long) port->iobase);

I'd simply map UPIO_AU to "MMIO" in the message because it's memory mapped UART after all...

Quoted 3 lines

Yes, but in the kernel command line we must supply "au"... That's why I used different string, so the user can verify whatever he/she passed to the kernel.

I can also suggest something like "Au1xx0 MMIO"... :-)

Quoted 11 lines
Quoted 10 lines

drivers/serial/serial_core.c int uart_match_port(struct uart_port *po · line 2370

Quoted 8 lines

index 17839e7..9e27aee 100644

drivers/serial/serial_core.c +1 -0
@@ -2367,6 +2367,7 @@ int uart_match_port(struct uart_port *po
 		return (port1->iobase == port2->iobase) &&
 		       (port1->hub6   == port2->hub6);
 	case UPIO_MEM:
+	case UPIO_AU:

Also needs cases for UPIO_MEM32 and UPIO_TSI.

Quoted 2 lines

I just added the code for au1xxx. Why should I consider those cases also?

It seems that you can remove this hunk altogether now -- Russel has
accepted my patch adding cases for UPIO_MEM32, UPIO_AU and UPIO_TSI...

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
drivers/serial/serial_core.c +1 -2
-#ifdef CONFIG_SERIAL_8250_AU1X00
 	case UPIO_AU:
-		__raw_writel(value, up->port.membase + offset);
+		writel(value, up->port.membase + offset);
		break;

-#endif

Ditto writel().

Is __raw_writel() correct?

It should be.

Quoted 5 lines

Thanks for your suggestions.

Ciao,

Rodolfo

WBR, Sergei