From 7a302a9674593259866de4a9d5ae8edc03dc1934 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Mon, 14 May 2007 12:50:43 +0900 Subject: sh: Split out CPU topology initialization. Split out the CPU topology initialization to a separate file, and switch it to a percpu type, rather than an NR_CPUS array. At the same time, switch to only registering present CPUs, rather than using the possible CPU map. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index c2772913593..61152b43832 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -389,20 +390,6 @@ struct sh_machine_vector* __init get_mv_byname(const char* name) return NULL; } -static struct cpu cpu[NR_CPUS]; - -static int __init topology_init(void) -{ - int cpu_id; - - for_each_possible_cpu(cpu_id) - register_cpu(&cpu[cpu_id], cpu_id); - - return 0; -} - -subsys_initcall(topology_init); - static const char *cpu_name[] = { [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619", [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300", -- cgit v1.2.3 From 9655ad03af2d232c3b26e7562ab4f8c29b107e49 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Mon, 14 May 2007 15:59:09 +0900 Subject: sh: Fixup machvec support. This fixes up much of the machvec handling, allowing for it to be overloaded on boot. Making practical use of this still requires some Kconfig munging, however. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 162 +++++-------------------------------------------- 1 file changed, 14 insertions(+), 148 deletions(-) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 61152b43832..0ad71583399 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -46,16 +46,8 @@ struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, }; struct screen_info screen_info; #endif -#if defined(CONFIG_SH_UNKNOWN) -struct sh_machine_vector sh_mv; -#endif - extern int root_mountflags; -#define MV_NAME_SIZE 32 - -static struct sh_machine_vector* __init get_mv_byname(const char* name); - /* * This is set up by the setup-routine at boot-time */ @@ -81,131 +73,17 @@ static struct resource data_resource = { .name = "Kernel data", }; unsigned long memory_start, memory_end; -static inline void parse_cmdline (char ** cmdline_p, char mv_name[MV_NAME_SIZE], - struct sh_machine_vector** mvp, - unsigned long *mv_io_base) +static int __init early_parse_mem(char *p) { - char c = ' ', *to = command_line, *from = COMMAND_LINE; - int len = 0; - - /* Save unparsed command line copy for /proc/cmdline */ - memcpy(boot_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); - boot_command_line[COMMAND_LINE_SIZE-1] = '\0'; + unsigned long size; memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; - memory_end = memory_start + __MEMORY_SIZE; - - for (;;) { - /* - * "mem=XXX[kKmM]" defines a size of memory. - */ - if (c == ' ' && !memcmp(from, "mem=", 4)) { - if (to != command_line) - to--; - { - unsigned long mem_size; - - mem_size = memparse(from+4, &from); - memory_end = memory_start + mem_size; - } - } - - if (c == ' ' && !memcmp(from, "sh_mv=", 6)) { - char* mv_end; - char* mv_comma; - int mv_len; - if (to != command_line) - to--; - from += 6; - mv_end = strchr(from, ' '); - if (mv_end == NULL) - mv_end = from + strlen(from); - - mv_comma = strchr(from, ','); - if ((mv_comma != NULL) && (mv_comma < mv_end)) { - int ints[3]; - get_options(mv_comma+1, ARRAY_SIZE(ints), ints); - *mv_io_base = ints[1]; - mv_len = mv_comma - from; - } else { - mv_len = mv_end - from; - } - if (mv_len > (MV_NAME_SIZE-1)) - mv_len = MV_NAME_SIZE-1; - memcpy(mv_name, from, mv_len); - mv_name[mv_len] = '\0'; - from = mv_end; - - *mvp = get_mv_byname(mv_name); - } - - c = *(from++); - if (!c) - break; - if (COMMAND_LINE_SIZE <= ++len) - break; - *(to++) = c; - } - *to = '\0'; - *cmdline_p = command_line; -} - -static int __init sh_mv_setup(char **cmdline_p) -{ -#ifdef CONFIG_SH_UNKNOWN - extern struct sh_machine_vector mv_unknown; -#endif - struct sh_machine_vector *mv = NULL; - char mv_name[MV_NAME_SIZE] = ""; - unsigned long mv_io_base = 0; - - parse_cmdline(cmdline_p, mv_name, &mv, &mv_io_base); - -#ifdef CONFIG_SH_UNKNOWN - if (mv == NULL) { - mv = &mv_unknown; - if (*mv_name != '\0') { - printk("Warning: Unsupported machine %s, using unknown\n", - mv_name); - } - } - sh_mv = *mv; -#endif - - /* - * Manually walk the vec, fill in anything that the board hasn't yet - * by hand, wrapping to the generic implementation. - */ -#define mv_set(elem) do { \ - if (!sh_mv.mv_##elem) \ - sh_mv.mv_##elem = generic_##elem; \ -} while (0) - - mv_set(inb); mv_set(inw); mv_set(inl); - mv_set(outb); mv_set(outw); mv_set(outl); - - mv_set(inb_p); mv_set(inw_p); mv_set(inl_p); - mv_set(outb_p); mv_set(outw_p); mv_set(outl_p); - - mv_set(insb); mv_set(insw); mv_set(insl); - mv_set(outsb); mv_set(outsw); mv_set(outsl); - - mv_set(readb); mv_set(readw); mv_set(readl); - mv_set(writeb); mv_set(writew); mv_set(writel); - - mv_set(ioport_map); - mv_set(ioport_unmap); - mv_set(irq_demux); - -#ifdef CONFIG_SH_UNKNOWN - __set_io_port_base(mv_io_base); -#endif - - if (!sh_mv.mv_nr_irqs) - sh_mv.mv_nr_irqs = NR_IRQS; + size = memparse(p, &p); + memory_end = memory_start + size; return 0; } +early_param("mem", early_parse_mem); /* * Register fully available low RAM pages with the bootmem allocator. @@ -340,9 +218,17 @@ void __init setup_arch(char **cmdline_p) data_resource.start = virt_to_phys(_etext); data_resource.end = virt_to_phys(_edata)-1; + memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; + memory_end = memory_start + __MEMORY_SIZE; + + /* Save unparsed command line copy for /proc/cmdline */ + strlcpy(boot_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); + + *cmdline_p = command_line; + parse_early_param(); - sh_mv_setup(cmdline_p); + sh_mv_setup(); /* * Find the highest page frame number we have available @@ -369,26 +255,6 @@ void __init setup_arch(char **cmdline_p) sh_mv.mv_setup(cmdline_p); } -struct sh_machine_vector* __init get_mv_byname(const char* name) -{ - extern long __machvec_start, __machvec_end; - struct sh_machine_vector *all_vecs = - (struct sh_machine_vector *)&__machvec_start; - - int i, n = ((unsigned long)&__machvec_end - - (unsigned long)&__machvec_start)/ - sizeof(struct sh_machine_vector); - - for (i = 0; i < n; ++i) { - struct sh_machine_vector *mv = &all_vecs[i]; - if (mv == NULL) - continue; - if (strcasecmp(name, get_system_type()) == 0) { - return mv; - } - } - return NULL; -} static const char *cpu_name[] = { [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619", -- cgit v1.2.3 From ba36197cf4ff68f631bb1b3d4cc442d567279fe3 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Mon, 14 May 2007 17:48:00 +0900 Subject: sh: Fixup cmdline handling from machvec changes. The command line wasn't being saved off properly after the machvec changes went in, fix it up. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 0ad71583399..65c093145da 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -194,10 +194,6 @@ void __init setup_arch(char **cmdline_p) { enable_mmu(); -#ifdef CONFIG_CMDLINE_BOOL - strcpy(COMMAND_LINE, CONFIG_CMDLINE); -#endif - ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV); #ifdef CONFIG_BLK_DEV_RAM @@ -221,9 +217,14 @@ void __init setup_arch(char **cmdline_p) memory_start = (unsigned long)PAGE_OFFSET+__MEMORY_START; memory_end = memory_start + __MEMORY_SIZE; - /* Save unparsed command line copy for /proc/cmdline */ - strlcpy(boot_command_line, COMMAND_LINE, COMMAND_LINE_SIZE); +#ifdef CONFIG_CMDLINE_BOOL + strlcpy(command_line, CONFIG_CMDLINE, sizeof(command_line)); +#else + strlcpy(command_line, COMMAND_LINE, sizeof(command_line)); +#endif + /* Save unparsed command line copy for /proc/cmdline */ + memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); *cmdline_p = command_line; parse_early_param(); -- cgit v1.2.3 From 82f81f4784479df17a80caff4a7156da0a2f7dea Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Tue, 15 May 2007 15:19:34 +0900 Subject: sh: Kill off machvec aliases. We now throw all of the machvecs in to .machvec.init and either select one on the command line, or copy out the first (and usually only) one to sh_mv. The rest are freed as usual. This gets rid of all of the silly sh_mv aliasing and makes the selection explicit rather than link-order dependent. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 65c093145da..55ed653c7a6 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -42,6 +42,13 @@ extern void * __rd_start, * __rd_end; * The bigger value means no problem. */ struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, }; + +/* + * The machine vector. First entry in .machvec.init, or clobbered by + * sh_mv= on the command line, prior to .machvec.init teardown. + */ +struct sh_machine_vector sh_mv = { .mv_name = "Unknown", }; + #ifdef CONFIG_VT struct screen_info screen_info; #endif -- cgit v1.2.3 From fd8f20e8e2f8f1d9201086bff444c8d35f0a6a45 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Tue, 15 May 2007 15:38:30 +0900 Subject: sh: Rip out special unknown machvec. This kills off the BareCPU board as a "special" machvec, rather, we leave this as a default for when no other vector is available, or when we want to use it in combination with other vectors for testing with generic ops. As sh_mv is copied out anyways (or overloaded when an alternate vector is explicitly selected), this doesn't consume any additional memory. The generic machvec can be forcibly selected with sh_mv=generic, or by not having any other boards enabled. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 55ed653c7a6..6f1ea9b3337 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -47,7 +47,7 @@ struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, }; * The machine vector. First entry in .machvec.init, or clobbered by * sh_mv= on the command line, prior to .machvec.init teardown. */ -struct sh_machine_vector sh_mv = { .mv_name = "Unknown", }; +struct sh_machine_vector sh_mv = { .mv_name = "generic", }; #ifdef CONFIG_VT struct screen_info screen_info; -- cgit v1.2.3 From dfbb9042801eaeb4df9015bb86224291a39a0f52 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Wed, 23 May 2007 17:48:36 +0900 Subject: sh: sparsemem support. This implements basic sparsemem support for SH. Presently this only uses static sparsemem, and we still permit explicit selection of flatmem. Those boards that want sparsemem can select it as usual. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 6f1ea9b3337..3241a6274b8 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -128,6 +128,7 @@ void __init setup_bootmem_allocator(unsigned long start_pfn) bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn, min_low_pfn, max_low_pfn); + add_active_range(0, min_low_pfn, max_low_pfn); register_bootmem_low_pages(); node_set_online(0); @@ -192,6 +193,7 @@ static void __init setup_memory(void) */ start_pfn = PFN_UP(__pa(_end)); setup_bootmem_allocator(start_pfn); + sparse_memory_present_with_active_regions(0); } #else extern void __init setup_memory(void); @@ -250,8 +252,9 @@ void __init setup_arch(char **cmdline_p) min_low_pfn = __MEMORY_START >> PAGE_SHIFT; nodes_clear(node_online_map); + + /* Setup bootmem with available RAM */ setup_memory(); - paging_init(); sparse_init(); #ifdef CONFIG_DUMMY_CONSOLE @@ -261,8 +264,9 @@ void __init setup_arch(char **cmdline_p) /* Perform the machine specific initialisation */ if (likely(sh_mv.mv_setup)) sh_mv.mv_setup(cmdline_p); -} + paging_init(); +} static const char *cpu_name[] = { [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619", -- cgit v1.2.3 From 2826fa61c13716816c7ae658b8f1c5a4a505d8ac Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Fri, 1 Jun 2007 17:04:36 +0900 Subject: sh: Mark sparsemem regions present earlier. We have to call in to sparse_memory_present_with_active_regions() earlier in order for sparsemem to be happy. This was being called too late, and was causing troubles with the platforms that needed to enable sparsemem. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 3241a6274b8..c2c6bfdf4df 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -116,7 +116,7 @@ static void __init register_bootmem_low_pages(void) free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages)); } -void __init setup_bootmem_allocator(unsigned long start_pfn) +void __init setup_bootmem_allocator(unsigned long free_pfn) { unsigned long bootmap_size; @@ -125,7 +125,7 @@ void __init setup_bootmem_allocator(unsigned long start_pfn) * bootstrap step all allocations (until the page allocator * is intact) must be done via bootmem_alloc(). */ - bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn, + bootmap_size = init_bootmem_node(NODE_DATA(0), free_pfn, min_low_pfn, max_low_pfn); add_active_range(0, min_low_pfn, max_low_pfn); @@ -141,7 +141,7 @@ void __init setup_bootmem_allocator(unsigned long start_pfn) * an invalid RAM area. */ reserve_bootmem(__MEMORY_START+PAGE_SIZE, - (PFN_PHYS(start_pfn)+bootmap_size+PAGE_SIZE-1)-__MEMORY_START); + (PFN_PHYS(free_pfn)+bootmap_size+PAGE_SIZE-1)-__MEMORY_START); /* * reserve physical page 0 - it's a special BIOS page on many boxes, @@ -149,6 +149,8 @@ void __init setup_bootmem_allocator(unsigned long start_pfn) */ reserve_bootmem(__MEMORY_START, PAGE_SIZE); + sparse_memory_present_with_active_regions(0); + #ifdef CONFIG_BLK_DEV_INITRD ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0); if (&__rd_start != &__rd_end) { @@ -193,7 +195,6 @@ static void __init setup_memory(void) */ start_pfn = PFN_UP(__pa(_end)); setup_bootmem_allocator(start_pfn); - sparse_memory_present_with_active_regions(0); } #else extern void __init setup_memory(void); -- cgit v1.2.3 From b9601c5e59dd25693345558a301e833741bf5874 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Fri, 8 Jun 2007 11:55:28 +0900 Subject: sh: Kill off dead SH7604 support. This was added during 2.5.x, but was never moved along. This can easily be resurrected if someone has one they wish to work with, but it's not worth keeping around in its current form. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index c2c6bfdf4df..765f83c1bca 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -271,7 +271,7 @@ void __init setup_arch(char **cmdline_p) static const char *cpu_name[] = { [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619", - [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300", + [CPU_SH7300] = "SH7300", [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706", [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708", [CPU_SH7709] = "SH7709", [CPU_SH7710] = "SH7710", -- cgit v1.2.3 From 2b1bd1ac5d4bffe3fd542bfe1784a583bd7df4fa Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Wed, 20 Jun 2007 18:27:10 +0900 Subject: sh: Preliminary support for the SH-X3 CPU. This adds basic support for UP SH-X3. Signed-off-by: Paul Mundt --- arch/sh/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/sh/kernel/setup.c') diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index 765f83c1bca..de8e6e2f2c8 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c @@ -285,7 +285,7 @@ static const char *cpu_name[] = { [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780", [CPU_SH7781] = "SH7781", [CPU_SH7343] = "SH7343", [CPU_SH7785] = "SH7785", [CPU_SH7722] = "SH7722", - [CPU_SH_NONE] = "Unknown" + [CPU_SHX3] = "SH-X3", [CPU_SH_NONE] = "Unknown" }; const char *get_cpu_subtype(struct sh_cpuinfo *c) -- cgit v1.2.3