]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/mips/ddb5xxx/common/prom.c
Linux-2.6.12-rc2
[mirror_ubuntu-artful-kernel.git] / arch / mips / ddb5xxx / common / prom.c
1 /*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: jsun@mvista.com or jsun@junsun.net
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 #include <linux/config.h>
11 #include <linux/init.h>
12 #include <linux/mm.h>
13 #include <linux/sched.h>
14 #include <linux/bootmem.h>
15
16 #include <asm/addrspace.h>
17 #include <asm/bootinfo.h>
18 #include <asm/ddb5xxx/ddb5xxx.h>
19 #include <asm/debug.h>
20
21 const char *get_system_type(void)
22 {
23 switch (mips_machtype) {
24 case MACH_NEC_DDB5074: return "NEC DDB Vrc-5074";
25 case MACH_NEC_DDB5476: return "NEC DDB Vrc-5476";
26 case MACH_NEC_DDB5477: return "NEC DDB Vrc-5477";
27 case MACH_NEC_ROCKHOPPER: return "NEC Rockhopper";
28 case MACH_NEC_ROCKHOPPERII: return "NEC RockhopperII";
29 default: return "Unknown NEC board";
30 }
31 }
32
33 #if defined(CONFIG_DDB5477)
34 void ddb5477_runtime_detection(void);
35 #endif
36
37 /* [jsun@junsun.net] PMON passes arguments in C main() style */
38 void __init prom_init(void)
39 {
40 int argc = fw_arg0;
41 char **arg = (char**) fw_arg1;
42 int i;
43
44 /* if user passes kernel args, ignore the default one */
45 if (argc > 1)
46 arcs_cmdline[0] = '\0';
47
48 /* arg[0] is "g", the rest is boot parameters */
49 for (i = 1; i < argc; i++) {
50 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
51 >= sizeof(arcs_cmdline))
52 break;
53 strcat(arcs_cmdline, arg[i]);
54 strcat(arcs_cmdline, " ");
55 }
56
57 mips_machgroup = MACH_GROUP_NEC_DDB;
58
59 #if defined(CONFIG_DDB5074)
60 mips_machtype = MACH_NEC_DDB5074;
61 add_memory_region(0, DDB_SDRAM_SIZE, BOOT_MEM_RAM);
62 #elif defined(CONFIG_DDB5476)
63 mips_machtype = MACH_NEC_DDB5476;
64 add_memory_region(0, DDB_SDRAM_SIZE, BOOT_MEM_RAM);
65 #elif defined(CONFIG_DDB5477)
66 ddb5477_runtime_detection();
67 add_memory_region(0, board_ram_size, BOOT_MEM_RAM);
68 #endif
69 }
70
71 unsigned long __init prom_free_prom_memory(void)
72 {
73 return 0;
74 }
75
76 #if defined(CONFIG_DDB5477)
77
78 #define DEFAULT_LCS1_BASE 0x19000000
79 #define TESTVAL1 'K'
80 #define TESTVAL2 'S'
81
82 int board_ram_size;
83 void ddb5477_runtime_detection(void)
84 {
85 volatile char *test_offset;
86 char saved_test_byte;
87
88 /* Determine if this is a DDB5477 board, or a BSB-VR0300
89 base board. We can tell by checking for the location of
90 the NVRAM. It lives at the beginning of LCS1 on the DDB5477,
91 and the beginning of LCS1 on the BSB-VR0300 is flash memory.
92 The first 2K of the NVRAM are reserved, so don't we'll poke
93 around just after that.
94 */
95
96 /* We can only use the PCI bus to distinquish between
97 the Rockhopper and RockhopperII backplanes and this must
98 wait until ddb5477_board_init() in setup.c after the 5477
99 is initialized. So, until then handle
100 both Rockhopper and RockhopperII backplanes as Rockhopper 1
101 */
102
103 test_offset = (char *)KSEG1ADDR(DEFAULT_LCS1_BASE + 0x800);
104 saved_test_byte = *test_offset;
105
106 *test_offset = TESTVAL1;
107 if (*test_offset != TESTVAL1) {
108 /* We couldn't set our test value, so it must not be NVRAM,
109 so it's a BSB_VR0300 */
110 mips_machtype = MACH_NEC_ROCKHOPPER;
111 } else {
112 /* We may have gotten lucky, and the TESTVAL1 was already
113 stored at the test location, so we must check a second
114 test value */
115 *test_offset = TESTVAL2;
116 if (*test_offset != TESTVAL2) {
117 /* OK, we couldn't set this value either, so it must
118 definately be a BSB_VR0300 */
119 mips_machtype = MACH_NEC_ROCKHOPPER;
120 } else {
121 /* We could change the value twice, so it must be
122 NVRAM, so it's a DDB_VRC5477 */
123 mips_machtype = MACH_NEC_DDB5477;
124 }
125 }
126 /* Restore the original byte */
127 *test_offset = saved_test_byte;
128
129 /* before we know a better way, we will trust PMON for getting
130 * RAM size
131 */
132 board_ram_size = 1 << (36 - (ddb_in32(DDB_SDRAM0) & 0xf));
133
134 db_run(printk("DDB run-time detection : %s, %d MB RAM\n",
135 mips_machtype == MACH_NEC_DDB5477 ?
136 "DDB5477" : "Rockhopper",
137 board_ram_size >> 20));
138
139 /* we can't handle ram size > 128 MB */
140 db_assert(board_ram_size <= (128 << 20));
141 }
142 #endif