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