blob: 00c62c1c28a35baafc6201f199c0f6241b4edffd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
21const 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)
34void ddb5477_runtime_detection(void);
35#endif
36
37/* [jsun@junsun.net] PMON passes arguments in C main() style */
38void __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
Ralf Baechle470b1602006-06-18 05:28:38 +010059#if defined(CONFIG_DDB5477)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 ddb5477_runtime_detection();
61 add_memory_region(0, board_ram_size, BOOT_MEM_RAM);
62#endif
63}
64
65unsigned long __init prom_free_prom_memory(void)
66{
67 return 0;
68}
69
70#if defined(CONFIG_DDB5477)
71
72#define DEFAULT_LCS1_BASE 0x19000000
73#define TESTVAL1 'K'
74#define TESTVAL2 'S'
75
76int board_ram_size;
77void ddb5477_runtime_detection(void)
78{
79 volatile char *test_offset;
80 char saved_test_byte;
81
82 /* Determine if this is a DDB5477 board, or a BSB-VR0300
83 base board. We can tell by checking for the location of
84 the NVRAM. It lives at the beginning of LCS1 on the DDB5477,
85 and the beginning of LCS1 on the BSB-VR0300 is flash memory.
86 The first 2K of the NVRAM are reserved, so don't we'll poke
87 around just after that.
88 */
89
90 /* We can only use the PCI bus to distinquish between
91 the Rockhopper and RockhopperII backplanes and this must
92 wait until ddb5477_board_init() in setup.c after the 5477
93 is initialized. So, until then handle
94 both Rockhopper and RockhopperII backplanes as Rockhopper 1
95 */
96
97 test_offset = (char *)KSEG1ADDR(DEFAULT_LCS1_BASE + 0x800);
98 saved_test_byte = *test_offset;
99
100 *test_offset = TESTVAL1;
101 if (*test_offset != TESTVAL1) {
102 /* We couldn't set our test value, so it must not be NVRAM,
103 so it's a BSB_VR0300 */
104 mips_machtype = MACH_NEC_ROCKHOPPER;
105 } else {
106 /* We may have gotten lucky, and the TESTVAL1 was already
107 stored at the test location, so we must check a second
108 test value */
109 *test_offset = TESTVAL2;
110 if (*test_offset != TESTVAL2) {
111 /* OK, we couldn't set this value either, so it must
112 definately be a BSB_VR0300 */
113 mips_machtype = MACH_NEC_ROCKHOPPER;
114 } else {
115 /* We could change the value twice, so it must be
116 NVRAM, so it's a DDB_VRC5477 */
117 mips_machtype = MACH_NEC_DDB5477;
118 }
119 }
120 /* Restore the original byte */
121 *test_offset = saved_test_byte;
122
123 /* before we know a better way, we will trust PMON for getting
124 * RAM size
125 */
126 board_ram_size = 1 << (36 - (ddb_in32(DDB_SDRAM0) & 0xf));
127
128 db_run(printk("DDB run-time detection : %s, %d MB RAM\n",
129 mips_machtype == MACH_NEC_DDB5477 ?
130 "DDB5477" : "Rockhopper",
131 board_ram_size >> 20));
132
133 /* we can't handle ram size > 128 MB */
134 db_assert(board_ram_size <= (128 << 20));
135}
136#endif