ramips: properly setup the FEATURES variable
[openwrt.git] / target / linux / ramips / files-3.7 / arch / mips / ralink / common / setup.c
1 /*
2  * Ralink SoC common setup
3  *
4  * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5  * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published
9  * by the Free Software Foundation.
10  */
11
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/io.h>
15 #include <linux/serial_8250.h>
16
17 #include <asm/bootinfo.h>
18 #include <asm/addrspace.h>
19
20 #include <asm/mach-ralink/common.h>
21 #include <asm/mach-ralink/machine.h>
22
23 unsigned char ramips_sys_type[RAMIPS_SYS_TYPE_LEN];
24 unsigned long (*ramips_get_mem_size)(void);
25
26 const char *get_system_type(void)
27 {
28         return ramips_sys_type;
29 }
30
31 static void __init detect_mem_size(void)
32 {
33         unsigned long size;
34
35         if (ramips_get_mem_size) {
36                 size = ramips_get_mem_size();
37         } else {
38                 void *base;
39
40                 base = (void *) KSEG1ADDR(detect_mem_size);
41                 for (size = ramips_mem_size_min; size < ramips_mem_size_max;
42                      size <<= 1 ) {
43                         if (!memcmp(base, base + size, 1024))
44                                 break;
45                 }
46         }
47
48         add_memory_region(ramips_mem_base, size, BOOT_MEM_RAM);
49 }
50
51 void __init ramips_early_serial_setup(int line, unsigned base, unsigned freq,
52                                       unsigned irq)
53 {
54         struct uart_port p;
55         int err;
56
57         memset(&p, 0, sizeof(p));
58         p.flags         = UPF_SKIP_TEST | UPF_FIXED_TYPE;
59         p.iotype        = UPIO_AU;
60         p.uartclk       = freq;
61         p.regshift      = 2;
62         p.type          = PORT_16550A;
63
64         p.mapbase       = base;
65         p.membase       = ioremap_nocache(p.mapbase, PAGE_SIZE);
66         p.line          = line;
67         p.irq           = irq;
68
69         err = early_serial_setup(&p);
70         if (err)
71                 printk(KERN_ERR "early serial%d registration failed %d\n",
72                        line, err);
73 }
74
75 void __init plat_mem_setup(void)
76 {
77         set_io_port_base(KSEG1);
78
79         detect_mem_size();
80         ramips_soc_setup();
81 }
82
83 __setup("board=", mips_machtype_setup);
84
85 static int __init ramips_machine_setup(void)
86 {
87         mips_machine_setup();
88         return 0;
89 }
90
91 arch_initcall(ramips_machine_setup);
92
93 static void __init ramips_generic_init(void)
94 {
95 }
96
97 MIPS_MACHINE(RAMIPS_MACH_GENERIC, "Generic", "Generic Ralink board",
98              ramips_generic_init);