2011-03-11 06:02:27

by Nobuhiro Iwamatsu

[permalink] [raw]
Subject: [PATCH 1/2] tty: serial: Fix build on architecture that does not have ioport

Some CPU's do not have ioport. Therefore, these do not have inX/outX.
Because they define CONFIG_NO_IOPORT, These CPU's use this and do not
use inX/outX.

Signed-off-by: Nobuhiro Iwamatsu <[email protected]>
---
drivers/tty/serial/8250.c | 18 ++++++++++++++++--
drivers/tty/serial/8250_early.c | 4 ++++
drivers/tty/serial/serial_core.c | 4 ++++
3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index 3975df6..5c1f353 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -387,6 +387,7 @@ static inline int map_8250_out_reg(struct uart_port *p, int offset)

#endif

+#ifndef CONFIG_NO_IOPORT
static unsigned int hub6_serial_in(struct uart_port *p, int offset)
{
offset = map_8250_in_reg(p, offset) << p->regshift;
@@ -400,6 +401,7 @@ static void hub6_serial_out(struct uart_port *p, int offset, int value)
outb(p->hub6 - 1 + offset, p->iobase);
outb(value, p->iobase + 1);
}
+#endif /* CONFIG_NO_IOPORT */

static unsigned int mem_serial_in(struct uart_port *p, int offset)
{
@@ -491,6 +493,7 @@ static void dwapb32_serial_out(struct uart_port *p, int offset, int value)
dwapb_check_clear_ier(p, save_offset);
}

+#ifndef CONFIG_NO_IOPORT
static unsigned int io_serial_in(struct uart_port *p, int offset)
{
offset = map_8250_in_reg(p, offset) << p->regshift;
@@ -502,17 +505,19 @@ static void io_serial_out(struct uart_port *p, int offset, int value)
offset = map_8250_out_reg(p, offset) << p->regshift;
outb(value, p->iobase + offset);
}
+#endif

static void set_io_from_upio(struct uart_port *p)
{
struct uart_8250_port *up =
container_of(p, struct uart_8250_port, port);
switch (p->iotype) {
+#ifndef CONFIG_NO_IOPORT
case UPIO_HUB6:
p->serial_in = hub6_serial_in;
p->serial_out = hub6_serial_out;
break;
-
+#endif
case UPIO_MEM:
p->serial_in = mem_serial_in;
p->serial_out = mem_serial_out;
@@ -545,8 +550,10 @@ static void set_io_from_upio(struct uart_port *p)
break;

default:
+#ifndef CONFIG_NO_IOPORT
p->serial_in = io_serial_in;
p->serial_out = io_serial_out;
+#endif
break;
}
/* Remember loaded iotype */
@@ -2539,11 +2546,13 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
}
break;

+#ifndef CONFIG_NO_IOPORT
case UPIO_HUB6:
case UPIO_PORT:
if (!request_region(up->port.iobase, size, "serial"))
ret = -EBUSY;
break;
+#endif
}
return ret;
}
@@ -2570,10 +2579,12 @@ static void serial8250_release_std_resource(struct uart_8250_port *up)
release_mem_region(up->port.mapbase, size);
break;

+#ifndef CONFIG_NO_IOPORT
case UPIO_HUB6:
case UPIO_PORT:
release_region(up->port.iobase, size);
break;
+#endif
}
}

@@ -2584,6 +2595,7 @@ static int serial8250_request_rsa_resource(struct uart_8250_port *up)
int ret = -EINVAL;

switch (up->port.iotype) {
+#ifndef CONFIG_NO_IOPORT
case UPIO_HUB6:
case UPIO_PORT:
start += up->port.iobase;
@@ -2593,7 +2605,7 @@ static int serial8250_request_rsa_resource(struct uart_8250_port *up)
ret = -EBUSY;
break;
}
-
+#endif
return ret;
}

@@ -2603,11 +2615,13 @@ static void serial8250_release_rsa_resource(struct uart_8250_port *up)
unsigned int size = 8 << up->port.regshift;

switch (up->port.iotype) {
+#ifndef CONFIG_NO_IOPORT
case UPIO_HUB6:
case UPIO_PORT:
release_region(up->port.iobase + offset, size);
break;
}
+#endif
}

static void serial8250_release_port(struct uart_port *port)
diff --git a/drivers/tty/serial/8250_early.c b/drivers/tty/serial/8250_early.c
index eaafb98..5169f9e 100644
--- a/drivers/tty/serial/8250_early.c
+++ b/drivers/tty/serial/8250_early.c
@@ -55,8 +55,10 @@ static unsigned int __init serial_in(struct uart_port *port, int offset)
return readb(port->membase + offset);
case UPIO_MEM32:
return readl(port->membase + (offset << 2));
+#if defined(CONFIG_NO_IOPORT)
case UPIO_PORT:
return inb(port->iobase + offset);
+#endif
default:
return 0;
}
@@ -71,9 +73,11 @@ static void __init serial_out(struct uart_port *port, int offset, int value)
case UPIO_MEM32:
writel(value, port->membase + (offset << 2));
break;
+#if defined(CONFIG_NO_IOPORT)
case UPIO_PORT:
outb(value, port->iobase + offset);
break;
+#endif
}
}

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 460a72d..eb7ceba 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2126,6 +2126,7 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port)
char address[64];

switch (port->iotype) {
+#ifndef CONFIG_NO_IOPORT
case UPIO_PORT:
snprintf(address, sizeof(address), "I/O 0x%lx", port->iobase);
break;
@@ -2133,6 +2134,7 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port)
snprintf(address, sizeof(address),
"I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
break;
+#endif
case UPIO_MEM:
case UPIO_MEM32:
case UPIO_AU:
@@ -2549,11 +2551,13 @@ int uart_match_port(struct uart_port *port1, struct uart_port *port2)
return 0;

switch (port1->iotype) {
+#ifndef CONFIG_NO_IOPORT
case UPIO_PORT:
return (port1->iobase == port2->iobase);
case UPIO_HUB6:
return (port1->iobase == port2->iobase) &&
(port1->hub6 == port2->hub6);
+#endif
case UPIO_MEM:
case UPIO_MEM32:
case UPIO_AU:
--
1.7.2.3


2011-03-11 06:02:43

by Nobuhiro Iwamatsu

[permalink] [raw]
Subject: [PATCH 2/2] tty: serial: Check UPF_FOURPORT, when CONFIG_SERIAL_8250_FOURPORT is defined

When CONFIG_SERIAL_8250_FOURPORT is defined, driver uses UPF_FOURPORT in port.flags.
Though CONFIG_SERIAL_8250_FOURPORT is not defined, there is a case to check UPF_FOURPORT.
When CONFIG_SERIAL_8250_FOURPORT is defined only, this checks UPF_FOURPORT.

Signed-off-by: Nobuhiro Iwamatsu <[email protected]>
---
drivers/tty/serial/8250.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index 5c1f353..c7d8f63 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -1297,17 +1297,20 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
static void autoconfig_irq(struct uart_8250_port *up)
{
unsigned char save_mcr, save_ier;
- unsigned char save_ICP = 0;
- unsigned int ICP = 0;
unsigned long irqs;
int irq;

+#ifdef CONFIG_SERIAL_8250_FOURPORT
+ unsigned char save_ICP = 0;
+ unsigned int ICP = 0;
+
if (up->port.flags & UPF_FOURPORT) {
ICP = (up->port.iobase & 0xfe0) | 0x1f;
save_ICP = inb_p(ICP);
outb_p(0x80, ICP);
(void) inb_p(ICP);
}
+#endif /* CONFIG_SERIAL_8250_FOURPORT */

/* forget possible initially masked and pending IRQ */
probe_irq_off(probe_irq_on());
@@ -1337,8 +1340,10 @@ static void autoconfig_irq(struct uart_8250_port *up)
serial_outp(up, UART_MCR, save_mcr);
serial_outp(up, UART_IER, save_ier);

+#ifdef CONFIG_SERIAL_8250_FOURPORT
if (up->port.flags & UPF_FOURPORT)
outb_p(save_ICP, ICP);
+#endif

up->port.irq = (irq > 0) ? irq : 0;
}
@@ -2199,6 +2204,7 @@ dont_test_tx_en:
up->ier = UART_IER_RLSI | UART_IER_RDI;
serial_outp(up, UART_IER, up->ier);

+#ifdef CONFIG_SERIAL_8250_FOURPORT
if (up->port.flags & UPF_FOURPORT) {
unsigned int icp;
/*
@@ -2208,6 +2214,7 @@ dont_test_tx_en:
outb_p(0x80, icp);
(void) inb_p(icp);
}
+#endif

return 0;
}
@@ -2225,11 +2232,13 @@ static void serial8250_shutdown(struct uart_port *port)
serial_outp(up, UART_IER, 0);

spin_lock_irqsave(&up->port.lock, flags);
+#ifdef CONFIG_SERIAL_8250_FOURPORT
if (up->port.flags & UPF_FOURPORT) {
/* reset interrupts on the AST Fourport board */
inb((up->port.iobase & 0xfe0) | 0x1f);
up->port.mctrl |= TIOCM_OUT1;
} else
+#endif
up->port.mctrl &= ~TIOCM_OUT2;

serial8250_set_mctrl(&up->port, up->port.mctrl);
--
1.7.2.3

2011-03-11 07:58:39

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 1/2] tty: serial: Fix build on architecture that does not have ioport

On Friday 11 March 2011 06:54:56 Nobuhiro Iwamatsu wrote:
> Some CPU's do not have ioport. Therefore, these do not have inX/outX.
> Because they define CONFIG_NO_IOPORT, These CPU's use this and do not
> use inX/outX.
>
> Signed-off-by: Nobuhiro Iwamatsu <[email protected]>

I like this patch, I had played with something similar before
but never got it to the state where I was happy with submitting
it. I'd really like to get us to the point where platforms without
PCI support do don't need to define inb/outb and can still
use all other drivers.

There are two small improvements that I would like to suggest
to this patch:

* use #ifdef CONFIG_SERIAL_8250_HUB6 to configure out hub6 support.
It's already disabled on most systems, so we can save a bit
binary code without making the driver uglier.

* Introduce a new CONFIG_SERIAL_8250_IOPORT symbol and make
the normal io_serial_* code depend on that. It can be a silent
Kconfig symbol that automatically gets selected in the appropriate
cases. I find this clearer than the double negation in "not no ioport".
The code that is used in both HUB6 and regular cases can be under
this symbol.

Arnd

2011-03-11 08:04:14

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 2/2] tty: serial: Check UPF_FOURPORT, when CONFIG_SERIAL_8250_FOURPORT is defined

On Friday 11 March 2011 06:54:57 Nobuhiro Iwamatsu wrote:
>
> When CONFIG_SERIAL_8250_FOURPORT is defined, driver uses UPF_FOURPORT in port.flags.
> Though CONFIG_SERIAL_8250_FOURPORT is not defined, there is a case to check UPF_FOURPORT.
> When CONFIG_SERIAL_8250_FOURPORT is defined only, this checks UPF_FOURPORT.
>
> Signed-off-by: Nobuhiro Iwamatsu <[email protected]>

Looks good to me.

Acked-by: Arnd Bergmann <[email protected]>

2011-03-11 12:57:45

by Nobuhiro Iwamatsu

[permalink] [raw]
Subject: Re: [PATCH 1/2] tty: serial: Fix build on architecture that does not have ioport

Hi,

Thanks for your comment!

2011/3/11 Arnd Bergmann <[email protected]>:
> On Friday 11 March 2011 06:54:56 Nobuhiro Iwamatsu wrote:
>> Some CPU's do not have ioport. Therefore, these do not have inX/outX.
>> Because they define CONFIG_NO_IOPORT, These CPU's use this and do not
>> use inX/outX.
>>
>> Signed-off-by: Nobuhiro Iwamatsu <[email protected]>
>
> I like this patch, I had played with something similar before
> but never got it to the state where I was happy with submitting
> it. I'd really like to get us to the point where platforms without
> PCI support do don't need to define inb/outb and can still
> use all other drivers.
>
> There are two small improvements that I would like to suggest
> to this patch:
>
> * use #ifdef CONFIG_SERIAL_8250_HUB6 to configure out hub6 support.
> ?It's already disabled on most systems, so we can save a bit
> ?binary code without making the driver uglier.
>

OK.

> * Introduce a new CONFIG_SERIAL_8250_IOPORT symbol and make
> ?the normal io_serial_* code depend on that. It can be a silent
> ?Kconfig symbol that automatically gets selected in the appropriate
> ?cases. I find this clearer than the double negation in "not no ioport".
> ?The code that is used in both HUB6 and regular cases can be under
> ?this symbol.
>

Yes, you are right. I will send new patch.

Thanks!

Nobuhiro

--
Nobuhiro Iwamatsu