* [PATCH] [loongson] Cleanups of serial port support
@ 2009-11-24 12:54 Wu Zhangjin
2009-11-27 10:58 ` Wu Zhangjin
2009-11-27 15:08 ` Ralf Baechle
0 siblings, 2 replies; 4+ messages in thread
From: Wu Zhangjin @ 2009-11-24 12:54 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, Wu Zhangjin
Hi, Ralf
This can not be folded into the old cleanup ;)
Regards,
Wu Zhangjin
------------
This patchs uses a loongson_uart_base variable instead of the
uart_base[] array and adds a new kernel option to avoid to compile
uart_base.c all the time, which will save a little bit of memory for us.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
arch/mips/include/asm/mach-loongson/loongson.h | 14 ++++++--
arch/mips/loongson/Kconfig | 5 +++
arch/mips/loongson/common/Makefile | 5 ++-
arch/mips/loongson/common/init.c | 2 -
arch/mips/loongson/common/serial.c | 10 ++++--
arch/mips/loongson/common/uart_base.c | 41 ++++++++++++++---------
6 files changed, 51 insertions(+), 26 deletions(-)
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index 06c28f3..ee8bc83 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -31,9 +31,17 @@ extern void __init prom_init_memory(void);
extern void __init prom_init_cmdline(void);
extern void __init prom_init_machtype(void);
extern void __init prom_init_env(void);
-extern unsigned long _loongson_uart_base;
-extern unsigned long uart8250_base[];
-extern void prom_init_uart_base(void);
+#ifdef CONFIG_LOONGSON_UART_BASE
+extern unsigned long _loongson_uart_base, loongson_uart_base;
+extern void prom_init_loongson_uart_base(void);
+#endif
+
+static inline void prom_init_uart_base(void)
+{
+#ifdef CONFIG_LOONGSON_UART_BASE
+ prom_init_loongson_uart_base();
+#endif
+}
/* irq operation functions */
extern void bonito_irqdispatch(void);
diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
index 2a652f1..181cd19 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -79,6 +79,11 @@ config LOONGSON_SUSPEND
default y
depends on CPU_SUPPORTS_CPUFREQ && SUSPEND
+config LOONGSON_UART_BASE
+ bool
+ default y
+ depends on EARLY_PRINTK || SERIAL_8250
+
#
# Loongson Platform Specific Drivers
#
diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile
index a21724d..01fc2f3 100644
--- a/arch/mips/loongson/common/Makefile
+++ b/arch/mips/loongson/common/Makefile
@@ -3,13 +3,14 @@
#
obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \
- pci.o bonito-irq.o mem.o machtype.o uart_base.o
+ pci.o bonito-irq.o mem.o machtype.o
#
-# Early printk support
+# Serial port support
#
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-$(CONFIG_SERIAL_8250) += serial.o
+obj-$(CONFIG_LOONGSON_UART_BASE) += uart_base.o
#
# Enable CS5536 Virtual Support Module(VSM) to virtulize the PCI configure
diff --git a/arch/mips/loongson/common/init.c b/arch/mips/loongson/common/init.c
index 2b92a23..a2abd93 100644
--- a/arch/mips/loongson/common/init.c
+++ b/arch/mips/loongson/common/init.c
@@ -31,9 +31,7 @@ void __init prom_init(void)
prom_init_memory();
/*init the uart base address */
-#if defined(CONFIG_EARLY_PRINTK) || defined(CONFIG_SERIAL_8250)
prom_init_uart_base();
-#endif
}
void __init prom_free_prom_memory(void)
diff --git a/arch/mips/loongson/common/serial.c b/arch/mips/loongson/common/serial.c
index ea29db0..23b66a5 100644
--- a/arch/mips/loongson/common/serial.c
+++ b/arch/mips/loongson/common/serial.c
@@ -57,12 +57,16 @@ static struct platform_device uart8250_device = {
static int __init serial_init(void)
{
- if (uart8250_data[mips_machtype][0].iotype == UPIO_MEM)
+ unsigned char iotype;
+
+ iotype = uart8250_data[mips_machtype][0].iotype;
+
+ if (UPIO_MEM == iotype)
uart8250_data[mips_machtype][0].membase =
(void __iomem *)_loongson_uart_base;
- else if (uart8250_data[mips_machtype][0].iotype == UPIO_PORT)
+ else if (UPIO_PORT == iotype)
uart8250_data[mips_machtype][0].iobase =
- uart8250_base[mips_machtype] - LOONGSON_PCIIO_BASE;
+ loongson_uart_base - LOONGSON_PCIIO_BASE;
uart8250_device.dev.platform_data = uart8250_data[mips_machtype];
diff --git a/arch/mips/loongson/common/uart_base.c b/arch/mips/loongson/common/uart_base.c
index 1d636f4..78ff66a 100644
--- a/arch/mips/loongson/common/uart_base.c
+++ b/arch/mips/loongson/common/uart_base.c
@@ -13,24 +13,33 @@
#include <loongson.h>
-unsigned long __maybe_unused _loongson_uart_base;
+/* ioremapped */
+unsigned long _loongson_uart_base;
EXPORT_SYMBOL(_loongson_uart_base);
+/* raw */
+unsigned long loongson_uart_base;
+EXPORT_SYMBOL(loongson_uart_base);
-unsigned long __maybe_unused uart8250_base[] = {
- [MACH_LOONGSON_UNKNOWN] 0,
- [MACH_LEMOTE_FL2E] (LOONGSON_PCIIO_BASE + 0x3f8),
- [MACH_LEMOTE_FL2F] (LOONGSON_PCIIO_BASE + 0x2f8),
- [MACH_LEMOTE_ML2F7] (LOONGSON_LIO1_BASE + 0x3f8),
- [MACH_LEMOTE_YL2F89] (LOONGSON_LIO1_BASE + 0x3f8),
- [MACH_DEXXON_GDIUM2F10] (LOONGSON_LIO1_BASE + 0x3f8),
- [MACH_LEMOTE_NAS] (LOONGSON_LIO1_BASE + 0x3f8),
- [MACH_LEMOTE_LL2F] (LOONGSON_PCIIO_BASE + 0x2f8),
- [MACH_LOONGSON_END] 0,
-};
-EXPORT_SYMBOL(uart8250_base);
-
-void __maybe_unused prom_init_uart_base(void)
+void prom_init_loongson_uart_base(void)
{
+ switch (mips_machtype) {
+ case MACH_LEMOTE_FL2E:
+ loongson_uart_base = LOONGSON_PCIIO_BASE + 0x3f8;
+ break;
+ case MACH_LEMOTE_FL2F:
+ case MACH_LEMOTE_LL2F:
+ loongson_uart_base = LOONGSON_PCIIO_BASE + 0x2f8;
+ break;
+ case MACH_LEMOTE_ML2F7:
+ case MACH_LEMOTE_YL2F89:
+ case MACH_DEXXON_GDIUM2F10:
+ case MACH_LEMOTE_NAS:
+ default:
+ /* The CPU provided serial port */
+ loongson_uart_base = LOONGSON_LIO1_BASE + 0x3f8;
+ break;
+ }
+
_loongson_uart_base =
- (unsigned long)ioremap_nocache(uart8250_base[mips_machtype], 8);
+ (unsigned long)ioremap_nocache(loongson_uart_base, 8);
}
--
1.6.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] [loongson] Cleanups of serial port support
2009-11-24 12:54 [PATCH] [loongson] Cleanups of serial port support Wu Zhangjin
@ 2009-11-27 10:58 ` Wu Zhangjin
2009-11-27 15:08 ` Ralf Baechle
1 sibling, 0 replies; 4+ messages in thread
From: Wu Zhangjin @ 2009-11-27 10:58 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
Hi, Ralf
Could you please queue this patch to 2.6.33? and also this one:
"Lemote-2F: Suspend CS5536 MFGPT Timer".
Thanks!
Wu Zhangjin
>
> ------------
>
> This patchs uses a loongson_uart_base variable instead of the
> uart_base[] array and adds a new kernel option to avoid to compile
> uart_base.c all the time, which will save a little bit of memory for us.
>
> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
> ---
> arch/mips/include/asm/mach-loongson/loongson.h | 14 ++++++--
> arch/mips/loongson/Kconfig | 5 +++
> arch/mips/loongson/common/Makefile | 5 ++-
> arch/mips/loongson/common/init.c | 2 -
> arch/mips/loongson/common/serial.c | 10 ++++--
> arch/mips/loongson/common/uart_base.c | 41 ++++++++++++++---------
> 6 files changed, 51 insertions(+), 26 deletions(-)
>
> diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
> index 06c28f3..ee8bc83 100644
> --- a/arch/mips/include/asm/mach-loongson/loongson.h
> +++ b/arch/mips/include/asm/mach-loongson/loongson.h
> @@ -31,9 +31,17 @@ extern void __init prom_init_memory(void);
> extern void __init prom_init_cmdline(void);
> extern void __init prom_init_machtype(void);
> extern void __init prom_init_env(void);
> -extern unsigned long _loongson_uart_base;
> -extern unsigned long uart8250_base[];
> -extern void prom_init_uart_base(void);
> +#ifdef CONFIG_LOONGSON_UART_BASE
> +extern unsigned long _loongson_uart_base, loongson_uart_base;
> +extern void prom_init_loongson_uart_base(void);
> +#endif
> +
> +static inline void prom_init_uart_base(void)
> +{
> +#ifdef CONFIG_LOONGSON_UART_BASE
> + prom_init_loongson_uart_base();
> +#endif
> +}
>
> /* irq operation functions */
> extern void bonito_irqdispatch(void);
> diff --git a/arch/mips/loongson/Kconfig b/arch/mips/loongson/Kconfig
> index 2a652f1..181cd19 100644
> --- a/arch/mips/loongson/Kconfig
> +++ b/arch/mips/loongson/Kconfig
> @@ -79,6 +79,11 @@ config LOONGSON_SUSPEND
> default y
> depends on CPU_SUPPORTS_CPUFREQ && SUSPEND
>
> +config LOONGSON_UART_BASE
> + bool
> + default y
> + depends on EARLY_PRINTK || SERIAL_8250
> +
> #
> # Loongson Platform Specific Drivers
> #
> diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile
> index a21724d..01fc2f3 100644
> --- a/arch/mips/loongson/common/Makefile
> +++ b/arch/mips/loongson/common/Makefile
> @@ -3,13 +3,14 @@
> #
>
> obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \
> - pci.o bonito-irq.o mem.o machtype.o uart_base.o
> + pci.o bonito-irq.o mem.o machtype.o
>
> #
> -# Early printk support
> +# Serial port support
> #
> obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
> obj-$(CONFIG_SERIAL_8250) += serial.o
> +obj-$(CONFIG_LOONGSON_UART_BASE) += uart_base.o
>
> #
> # Enable CS5536 Virtual Support Module(VSM) to virtulize the PCI configure
> diff --git a/arch/mips/loongson/common/init.c b/arch/mips/loongson/common/init.c
> index 2b92a23..a2abd93 100644
> --- a/arch/mips/loongson/common/init.c
> +++ b/arch/mips/loongson/common/init.c
> @@ -31,9 +31,7 @@ void __init prom_init(void)
> prom_init_memory();
>
> /*init the uart base address */
> -#if defined(CONFIG_EARLY_PRINTK) || defined(CONFIG_SERIAL_8250)
> prom_init_uart_base();
> -#endif
> }
>
> void __init prom_free_prom_memory(void)
> diff --git a/arch/mips/loongson/common/serial.c b/arch/mips/loongson/common/serial.c
> index ea29db0..23b66a5 100644
> --- a/arch/mips/loongson/common/serial.c
> +++ b/arch/mips/loongson/common/serial.c
> @@ -57,12 +57,16 @@ static struct platform_device uart8250_device = {
>
> static int __init serial_init(void)
> {
> - if (uart8250_data[mips_machtype][0].iotype == UPIO_MEM)
> + unsigned char iotype;
> +
> + iotype = uart8250_data[mips_machtype][0].iotype;
> +
> + if (UPIO_MEM == iotype)
> uart8250_data[mips_machtype][0].membase =
> (void __iomem *)_loongson_uart_base;
> - else if (uart8250_data[mips_machtype][0].iotype == UPIO_PORT)
> + else if (UPIO_PORT == iotype)
> uart8250_data[mips_machtype][0].iobase =
> - uart8250_base[mips_machtype] - LOONGSON_PCIIO_BASE;
> + loongson_uart_base - LOONGSON_PCIIO_BASE;
>
> uart8250_device.dev.platform_data = uart8250_data[mips_machtype];
>
> diff --git a/arch/mips/loongson/common/uart_base.c b/arch/mips/loongson/common/uart_base.c
> index 1d636f4..78ff66a 100644
> --- a/arch/mips/loongson/common/uart_base.c
> +++ b/arch/mips/loongson/common/uart_base.c
> @@ -13,24 +13,33 @@
>
> #include <loongson.h>
>
> -unsigned long __maybe_unused _loongson_uart_base;
> +/* ioremapped */
> +unsigned long _loongson_uart_base;
> EXPORT_SYMBOL(_loongson_uart_base);
> +/* raw */
> +unsigned long loongson_uart_base;
> +EXPORT_SYMBOL(loongson_uart_base);
>
> -unsigned long __maybe_unused uart8250_base[] = {
> - [MACH_LOONGSON_UNKNOWN] 0,
> - [MACH_LEMOTE_FL2E] (LOONGSON_PCIIO_BASE + 0x3f8),
> - [MACH_LEMOTE_FL2F] (LOONGSON_PCIIO_BASE + 0x2f8),
> - [MACH_LEMOTE_ML2F7] (LOONGSON_LIO1_BASE + 0x3f8),
> - [MACH_LEMOTE_YL2F89] (LOONGSON_LIO1_BASE + 0x3f8),
> - [MACH_DEXXON_GDIUM2F10] (LOONGSON_LIO1_BASE + 0x3f8),
> - [MACH_LEMOTE_NAS] (LOONGSON_LIO1_BASE + 0x3f8),
> - [MACH_LEMOTE_LL2F] (LOONGSON_PCIIO_BASE + 0x2f8),
> - [MACH_LOONGSON_END] 0,
> -};
> -EXPORT_SYMBOL(uart8250_base);
> -
> -void __maybe_unused prom_init_uart_base(void)
> +void prom_init_loongson_uart_base(void)
> {
> + switch (mips_machtype) {
> + case MACH_LEMOTE_FL2E:
> + loongson_uart_base = LOONGSON_PCIIO_BASE + 0x3f8;
> + break;
> + case MACH_LEMOTE_FL2F:
> + case MACH_LEMOTE_LL2F:
> + loongson_uart_base = LOONGSON_PCIIO_BASE + 0x2f8;
> + break;
> + case MACH_LEMOTE_ML2F7:
> + case MACH_LEMOTE_YL2F89:
> + case MACH_DEXXON_GDIUM2F10:
> + case MACH_LEMOTE_NAS:
> + default:
> + /* The CPU provided serial port */
> + loongson_uart_base = LOONGSON_LIO1_BASE + 0x3f8;
> + break;
> + }
> +
> _loongson_uart_base =
> - (unsigned long)ioremap_nocache(uart8250_base[mips_machtype], 8);
> + (unsigned long)ioremap_nocache(loongson_uart_base, 8);
> }
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] [loongson] Cleanups of serial port support
2009-11-24 12:54 [PATCH] [loongson] Cleanups of serial port support Wu Zhangjin
2009-11-27 10:58 ` Wu Zhangjin
@ 2009-11-27 15:08 ` Ralf Baechle
2009-11-28 6:14 ` Wu Zhangjin
1 sibling, 1 reply; 4+ messages in thread
From: Ralf Baechle @ 2009-11-27 15:08 UTC (permalink / raw)
To: Wu Zhangjin; +Cc: linux-mips
On Tue, Nov 24, 2009 at 08:54:04PM +0800, Wu Zhangjin wrote:
> This can not be folded into the old cleanup ;)
The reason I've not applied it yet is because the patch rejects and that is
probably because I seem to be missing another patch which needs to be
applied before this one can be applied - but I have nothing left in
patchworks.
Ralf
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [loongson] Cleanups of serial port support
2009-11-27 15:08 ` Ralf Baechle
@ 2009-11-28 6:14 ` Wu Zhangjin
0 siblings, 0 replies; 4+ messages in thread
From: Wu Zhangjin @ 2009-11-28 6:14 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
On Fri, 2009-11-27 at 15:08 +0000, Ralf Baechle wrote:
> On Tue, Nov 24, 2009 at 08:54:04PM +0800, Wu Zhangjin wrote:
>
> > This can not be folded into the old cleanup ;)
>
> The reason I've not applied it yet is because the patch rejects and that is
> probably because I seem to be missing another patch which needs to be
> applied before this one can be applied - but I have nothing left in
> patchworks.
Thanks, will send a new one to you.
Regards,
Wu Zhangjin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-28 6:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-24 12:54 [PATCH] [loongson] Cleanups of serial port support Wu Zhangjin
2009-11-27 10:58 ` Wu Zhangjin
2009-11-27 15:08 ` Ralf Baechle
2009-11-28 6:14 ` Wu Zhangjin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox