aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorWu Zhangjin <wuzj@lemote.com>2009-07-02 11:22:36 -0400
committerRalf Baechle <ralf@linux-mips.org>2009-09-17 14:07:46 -0400
commitbd92aa013e8fcd17328ec8e060477761cf3380d9 (patch)
tree0435f611a87d8be266c44629c80a2fd7459ef026 /arch/mips
parentf54a40ee6b3cb4da638d7705e433bc80aa4f49f6 (diff)
MIPS: Loongson: Split the implementation of prom and setup parts
This patch split the old initilization and setup implementation to several file, one file one logic function. the other main changes include: 1. as the script/checkpatch.pl suggests, use strict_strtol instead of simple_strtol in arch/mips/lemote/lm2e/cmdline.c 2. use the existed macros in asm/mips-boards/bonito64.h as the arguments of set_io_port_base() and remove the un-needed ones in asm/mach-lemote/pci.h Signed-off-by: Wu Zhangjin <wuzj@lemote.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/include/asm/mach-lemote/pci.h1
-rw-r--r--arch/mips/lemote/lm2e/Makefile3
-rw-r--r--arch/mips/lemote/lm2e/cmdline.c (renamed from arch/mips/lemote/lm2e/prom.c)64
-rw-r--r--arch/mips/lemote/lm2e/env.c60
-rw-r--r--arch/mips/lemote/lm2e/init.c34
-rw-r--r--arch/mips/lemote/lm2e/machtype.c15
-rw-r--r--arch/mips/lemote/lm2e/mem.c13
-rw-r--r--arch/mips/lemote/lm2e/setup.c34
-rw-r--r--arch/mips/lemote/lm2e/time.c30
9 files changed, 168 insertions, 86 deletions
diff --git a/arch/mips/include/asm/mach-lemote/pci.h b/arch/mips/include/asm/mach-lemote/pci.h
index ea6aa143b78e..0307e4935267 100644
--- a/arch/mips/include/asm/mach-lemote/pci.h
+++ b/arch/mips/include/asm/mach-lemote/pci.h
@@ -25,6 +25,5 @@
25#define LOONGSON2E_PCI_MEM_START 0x14000000UL 25#define LOONGSON2E_PCI_MEM_START 0x14000000UL
26#define LOONGSON2E_PCI_MEM_END 0x1fffffffUL 26#define LOONGSON2E_PCI_MEM_END 0x1fffffffUL
27#define LOONGSON2E_PCI_IO_START 0x00004000UL 27#define LOONGSON2E_PCI_IO_START 0x00004000UL
28#define LOONGSON2E_IO_PORT_BASE 0x1fd00000UL
29 28
30#endif /* !_LEMOTE_PCI_H_ */ 29#endif /* !_LEMOTE_PCI_H_ */
diff --git a/arch/mips/lemote/lm2e/Makefile b/arch/mips/lemote/lm2e/Makefile
index f19173252d6a..a5bc1efc362a 100644
--- a/arch/mips/lemote/lm2e/Makefile
+++ b/arch/mips/lemote/lm2e/Makefile
@@ -2,7 +2,8 @@
2# Makefile for Lemote Fulong mini-PC board. 2# Makefile for Lemote Fulong mini-PC board.
3# 3#
4 4
5obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o mem.o 5obj-y += setup.o init.o reset.o irq.o pci.o bonito-irq.o mem.o \
6 env.o cmdline.o time.o machtype.o
6 7
7# 8#
8# Early printk support 9# Early printk support
diff --git a/arch/mips/lemote/lm2e/prom.c b/arch/mips/lemote/lm2e/cmdline.c
index d78cedf28c1f..442b93587e86 100644
--- a/arch/mips/lemote/lm2e/prom.c
+++ b/arch/mips/lemote/lm2e/cmdline.c
@@ -9,83 +9,45 @@
9 * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology 9 * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
10 * Author: Fuxin Zhang, zhangfx@lemote.com 10 * Author: Fuxin Zhang, zhangfx@lemote.com
11 * 11 *
12 * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
13 * Author: Wu Zhangjin, wuzj@lemote.com
14 *
12 * This program is free software; you can redistribute it and/or modify it 15 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the 16 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your 17 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. 18 * option) any later version.
16 */ 19 */
20#include <linux/io.h>
17#include <linux/init.h> 21#include <linux/init.h>
18#include <linux/bootmem.h>
19#include <asm/bootinfo.h>
20 22
21extern unsigned long bus_clock; 23#include <asm/bootinfo.h>
22extern unsigned long cpu_clock_freq;
23extern unsigned int memsize, highmemsize;
24 24
25static int argc; 25int prom_argc;
26/* pmon passes arguments in 32bit pointers */ 26/* pmon passes arguments in 32bit pointers */
27static int *arg; 27int *_prom_argv;
28static int *env;
29
30const char *get_system_type(void)
31{
32 return "lemote-fulong";
33}
34 28
35void __init prom_init_cmdline(void) 29void __init prom_init_cmdline(void)
36{ 30{
37 int i; 31 int i;
38 long l; 32 long l;
39 33
34 /* firmware arguments are initialized in head.S */
35 prom_argc = fw_arg0;
36 _prom_argv = (int *)fw_arg1;
37
40 /* arg[0] is "g", the rest is boot parameters */ 38 /* arg[0] is "g", the rest is boot parameters */
41 arcs_cmdline[0] = '\0'; 39 arcs_cmdline[0] = '\0';
42 for (i = 1; i < argc; i++) { 40 for (i = 1; i < prom_argc; i++) {
43 l = (long)arg[i]; 41 l = (long)_prom_argv[i];
44 if (strlen(arcs_cmdline) + strlen(((char *)l) + 1) 42 if (strlen(arcs_cmdline) + strlen(((char *)l) + 1)
45 >= sizeof(arcs_cmdline)) 43 >= sizeof(arcs_cmdline))
46 break; 44 break;
47 strcat(arcs_cmdline, ((char *)l)); 45 strcat(arcs_cmdline, ((char *)l));
48 strcat(arcs_cmdline, " "); 46 strcat(arcs_cmdline, " ");
49 } 47 }
50}
51
52void __init prom_init(void)
53{
54 long l;
55 argc = fw_arg0;
56 arg = (int *)fw_arg1;
57 env = (int *)fw_arg2;
58
59 prom_init_cmdline();
60 48
61 if ((strstr(arcs_cmdline, "console=")) == NULL) 49 if ((strstr(arcs_cmdline, "console=")) == NULL)
62 strcat(arcs_cmdline, " console=ttyS0,115200"); 50 strcat(arcs_cmdline, " console=ttyS0,115200");
63 if ((strstr(arcs_cmdline, "root=")) == NULL) 51 if ((strstr(arcs_cmdline, "root=")) == NULL)
64 strcat(arcs_cmdline, " root=/dev/hda1"); 52 strcat(arcs_cmdline, " root=/dev/hda1");
65
66#define parse_even_earlier(res, option, p) \
67do { \
68 if (strncmp(option, (char *)p, strlen(option)) == 0) \
69 res = simple_strtol((char *)p + strlen(option"="), \
70 NULL, 10); \
71} while (0)
72
73 l = (long)*env;
74 while (l != 0) {
75 parse_even_earlier(bus_clock, "busclock", l);
76 parse_even_earlier(cpu_clock_freq, "cpuclock", l);
77 parse_even_earlier(memsize, "memsize", l);
78 parse_even_earlier(highmemsize, "highmemsize", l);
79 env++;
80 l = (long)*env;
81 }
82 if (memsize == 0)
83 memsize = 256;
84
85 pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n",
86 bus_clock, cpu_clock_freq, memsize, highmemsize);
87}
88
89void __init prom_free_prom_memory(void)
90{
91} 53}
diff --git a/arch/mips/lemote/lm2e/env.c b/arch/mips/lemote/lm2e/env.c
new file mode 100644
index 000000000000..9e88409f7a3a
--- /dev/null
+++ b/arch/mips/lemote/lm2e/env.c
@@ -0,0 +1,60 @@
1/*
2 * Based on Ocelot Linux port, which is
3 * Copyright 2001 MontaVista Software Inc.
4 * Author: jsun@mvista.com or jsun@junsun.net
5 *
6 * Copyright 2003 ICT CAS
7 * Author: Michael Guo <guoyi@ict.ac.cn>
8 *
9 * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
10 * Author: Fuxin Zhang, zhangfx@lemote.com
11 *
12 * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
13 * Author: Wu Zhangjin, wuzj@lemote.com
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 */
20
21#include <linux/io.h>
22#include <linux/init.h>
23
24#include <asm/bootinfo.h>
25
26unsigned long bus_clock, cpu_clock_freq;
27unsigned long memsize, highmemsize;
28
29/* pmon passes arguments in 32bit pointers */
30int *_prom_envp;
31
32#define parse_even_earlier(res, option, p) \
33do { \
34 if (strncmp(option, (char *)p, strlen(option)) == 0) \
35 strict_strtol((char *)p + strlen(option"="), \
36 10, &res); \
37} while (0)
38
39void __init prom_init_env(void)
40{
41 long l;
42
43 /* firmware arguments are initialized in head.S */
44 _prom_envp = (int *)fw_arg2;
45
46 l = (long)*_prom_envp;
47 while (l != 0) {
48 parse_even_earlier(bus_clock, "busclock", l);
49 parse_even_earlier(cpu_clock_freq, "cpuclock", l);
50 parse_even_earlier(memsize, "memsize", l);
51 parse_even_earlier(highmemsize, "highmemsize", l);
52 _prom_envp++;
53 l = (long)*_prom_envp;
54 }
55 if (memsize == 0)
56 memsize = 256;
57
58 pr_info("busclock=%ld, cpuclock=%ld, memsize=%ld, highmemsize=%ld\n",
59 bus_clock, cpu_clock_freq, memsize, highmemsize);
60}
diff --git a/arch/mips/lemote/lm2e/init.c b/arch/mips/lemote/lm2e/init.c
new file mode 100644
index 000000000000..6fe624d697ed
--- /dev/null
+++ b/arch/mips/lemote/lm2e/init.c
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
3 * Author: Wu Zhangjin, wuzj@lemote.com
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10
11#include <linux/init.h>
12#include <linux/bootmem.h>
13
14#include <asm/bootinfo.h>
15#include <asm/mips-boards/bonito64.h>
16
17extern void __init prom_init_cmdline(void);
18extern void __init prom_init_env(void);
19extern void __init prom_init_memory(void);
20
21void __init prom_init(void)
22{
23 /* init base address of io space */
24 set_io_port_base((unsigned long)
25 ioremap(BONITO_PCIIO_BASE, BONITO_PCIIO_SIZE));
26
27 prom_init_cmdline();
28 prom_init_env();
29 prom_init_memory();
30}
31
32void __init prom_free_prom_memory(void)
33{
34}
diff --git a/arch/mips/lemote/lm2e/machtype.c b/arch/mips/lemote/lm2e/machtype.c
new file mode 100644
index 000000000000..8d803eea7872
--- /dev/null
+++ b/arch/mips/lemote/lm2e/machtype.c
@@ -0,0 +1,15 @@
1/*
2 * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
3 * Author: Wu Zhangjin, wuzj@lemote.com
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10
11const char *get_system_type(void)
12{
13 return "lemote-fulong";
14}
15
diff --git a/arch/mips/lemote/lm2e/mem.c b/arch/mips/lemote/lm2e/mem.c
index 16cd21587d34..f24af70b669b 100644
--- a/arch/mips/lemote/lm2e/mem.c
+++ b/arch/mips/lemote/lm2e/mem.c
@@ -8,6 +8,19 @@
8#include <linux/fcntl.h> 8#include <linux/fcntl.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10 10
11#include <asm/bootinfo.h>
12
13extern unsigned long memsize, highmemsize;
14
15void __init prom_init_memory(void)
16{
17 add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
18#ifdef CONFIG_64BIT
19 if (highmemsize > 0)
20 add_memory_region(0x20000000, highmemsize << 20, BOOT_MEM_RAM);
21#endif /* CONFIG_64BIT */
22}
23
11/* override of arch/mips/mm/cache.c: __uncached_access */ 24/* override of arch/mips/mm/cache.c: __uncached_access */
12int __uncached_access(struct file *file, unsigned long addr) 25int __uncached_access(struct file *file, unsigned long addr)
13{ 26{
diff --git a/arch/mips/lemote/lm2e/setup.c b/arch/mips/lemote/lm2e/setup.c
index 79dae630611a..03578cf0ee7e 100644
--- a/arch/mips/lemote/lm2e/setup.c
+++ b/arch/mips/lemote/lm2e/setup.c
@@ -26,37 +26,16 @@
26 * 675 Mass Ave, Cambridge, MA 02139, USA. 26 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 * 27 *
28 */ 28 */
29#include <linux/bootmem.h>
30#include <linux/init.h> 29#include <linux/init.h>
31#include <linux/irq.h> 30#include <linux/module.h>
32 31
33#include <asm/bootinfo.h>
34#include <asm/mc146818-time.h>
35#include <asm/time.h>
36#include <asm/wbflush.h> 32#include <asm/wbflush.h>
37#include <asm/mach-lemote/pci.h>
38 33
39#ifdef CONFIG_VT 34#ifdef CONFIG_VT
40#include <linux/console.h> 35#include <linux/console.h>
41#include <linux/screen_info.h> 36#include <linux/screen_info.h>
42#endif 37#endif
43 38
44unsigned long cpu_clock_freq;
45unsigned long bus_clock;
46unsigned int memsize;
47unsigned int highmemsize = 0;
48
49void __init plat_time_init(void)
50{
51 /* setup mips r4k timer */
52 mips_hpt_frequency = cpu_clock_freq / 2;
53}
54
55unsigned long read_persistent_clock(void)
56{
57 return mc146818_get_cmos_time();
58}
59
60void (*__wbflush)(void); 39void (*__wbflush)(void);
61EXPORT_SYMBOL(__wbflush); 40EXPORT_SYMBOL(__wbflush);
62 41
@@ -73,18 +52,8 @@ static void wbflush_loongson2e(void)
73 52
74void __init plat_mem_setup(void) 53void __init plat_mem_setup(void)
75{ 54{
76 set_io_port_base((unsigned long)ioremap(LOONGSON2E_IO_PORT_BASE,
77 IO_SPACE_LIMIT - LOONGSON2E_PCI_IO_START + 1));
78
79 __wbflush = wbflush_loongson2e; 55 __wbflush = wbflush_loongson2e;
80 56
81 add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
82#ifdef CONFIG_64BIT
83 if (highmemsize > 0) {
84 add_memory_region(0x20000000, highmemsize << 20, BOOT_MEM_RAM);
85 }
86#endif
87
88#ifdef CONFIG_VT 57#ifdef CONFIG_VT
89#if defined(CONFIG_VGA_CONSOLE) 58#if defined(CONFIG_VGA_CONSOLE)
90 conswitchp = &vga_con; 59 conswitchp = &vga_con;
@@ -104,5 +73,4 @@ void __init plat_mem_setup(void)
104 conswitchp = &dummy_con; 73 conswitchp = &dummy_con;
105#endif 74#endif
106#endif 75#endif
107
108} 76}
diff --git a/arch/mips/lemote/lm2e/time.c b/arch/mips/lemote/lm2e/time.c
new file mode 100644
index 000000000000..b9d3f11b6203
--- /dev/null
+++ b/arch/mips/lemote/lm2e/time.c
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
3 * Author: Fuxin Zhang, zhangfx@lemote.com
4 *
5 * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
6 * Author: Wu Zhangjin, wuzj@lemote.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/init.h>
15
16#include <asm/mc146818-time.h>
17#include <asm/time.h>
18
19extern unsigned long cpu_clock_freq;
20
21void __init plat_time_init(void)
22{
23 /* setup mips r4k timer */
24 mips_hpt_frequency = cpu_clock_freq / 2;
25}
26
27unsigned long read_persistent_clock(void)
28{
29 return mc146818_get_cmos_time();
30}