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