| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * This file is subject to the terms and conditions of the GNU General Public | 
 | 3 |  * License.  See the file "COPYING" in the main directory of this archive | 
 | 4 |  * for more details. | 
 | 5 |  * | 
 | 6 |  * identify.c: identify machine by looking up system identifier | 
 | 7 |  * | 
 | 8 |  * Copyright (C) 1998 Thomas Bogendoerfer | 
 | 9 |  * | 
 | 10 |  * This code is based on arch/mips/sgi/kernel/system.c, which is | 
 | 11 |  * | 
 | 12 |  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) | 
 | 13 |  */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/init.h> | 
 | 15 | #include <linux/kernel.h> | 
 | 16 | #include <linux/types.h> | 
 | 17 | #include <linux/string.h> | 
 | 18 |  | 
 | 19 | #include <asm/sgialib.h> | 
 | 20 | #include <asm/bootinfo.h> | 
 | 21 |  | 
 | 22 | struct smatch { | 
 | 23 | 	char *arcname; | 
 | 24 | 	char *liname; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | 	int flags; | 
 | 26 | }; | 
 | 27 |  | 
 | 28 | static struct smatch mach_table[] = { | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 29 | 	{ | 
 | 30 | 		.arcname	= "SGI-IP22", | 
 | 31 | 		.liname		= "SGI Indy", | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 32 | 		.flags		= PROM_FLAG_ARCS, | 
 | 33 | 	}, { | 
 | 34 | 		.arcname	= "SGI-IP27", | 
 | 35 | 		.liname		= "SGI Origin", | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 36 | 		.flags		= PROM_FLAG_ARCS, | 
 | 37 | 	}, { | 
 | 38 | 		.arcname	= "SGI-IP28", | 
 | 39 | 		.liname		= "SGI IP28", | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 40 | 		.flags		= PROM_FLAG_ARCS, | 
 | 41 | 	}, { | 
 | 42 | 		.arcname	= "SGI-IP30", | 
 | 43 | 		.liname		= "SGI Octane", | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 44 | 		.flags		= PROM_FLAG_ARCS, | 
 | 45 | 	}, { | 
 | 46 | 		.arcname	= "SGI-IP32", | 
 | 47 | 		.liname		= "SGI O2", | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 48 | 		.flags		= PROM_FLAG_ARCS, | 
 | 49 | 	}, { | 
 | 50 | 		.arcname	= "Microsoft-Jazz", | 
 | 51 | 		.liname		= "Jazz MIPS_Magnum_4000", | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 52 | 		.flags		= 0, | 
 | 53 | 	}, { | 
 | 54 | 		.arcname	= "PICA-61", | 
 | 55 | 		.liname		= "Jazz Acer_PICA_61", | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 56 | 		.flags		= 0, | 
 | 57 | 	}, { | 
 | 58 | 		.arcname	= "RM200PCI", | 
 | 59 | 		.liname		= "SNI RM200_PCI", | 
| Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 60 | 		.flags		= PROM_FLAG_DONT_FREE_TEMP, | 
| Thomas Bogendoerfer | 330117f | 2008-05-27 01:15:20 +0200 | [diff] [blame] | 61 | 	}, { | 
 | 62 | 		.arcname	= "RM200PCI-R5K", | 
 | 63 | 		.liname		= "SNI RM200_PCI-R5K", | 
| Thomas Bogendoerfer | 330117f | 2008-05-27 01:15:20 +0200 | [diff] [blame] | 64 | 		.flags		= PROM_FLAG_DONT_FREE_TEMP, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | 	} | 
 | 66 | }; | 
 | 67 |  | 
 | 68 | int prom_flags; | 
 | 69 |  | 
 | 70 | static struct smatch * __init string_to_mach(const char *s) | 
 | 71 | { | 
 | 72 | 	int i; | 
 | 73 |  | 
| Ahmed S. Darwish | 25b8ac3 | 2007-02-05 04:42:11 +0200 | [diff] [blame] | 74 | 	for (i = 0; i < ARRAY_SIZE(mach_table); i++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | 		if (!strcmp(s, mach_table[i].arcname)) | 
 | 76 | 			return &mach_table[i]; | 
 | 77 | 	} | 
 | 78 |  | 
 | 79 | 	panic("Yeee, could not determine architecture type <%s>", s); | 
 | 80 | } | 
 | 81 |  | 
 | 82 | char *system_type; | 
 | 83 |  | 
 | 84 | const char *get_system_type(void) | 
 | 85 | { | 
 | 86 | 	return system_type; | 
 | 87 | } | 
 | 88 |  | 
 | 89 | void __init prom_identify_arch(void) | 
 | 90 | { | 
 | 91 | 	pcomponent *p; | 
 | 92 | 	struct smatch *mach; | 
 | 93 | 	const char *iname; | 
 | 94 |  | 
 | 95 | 	/* | 
 | 96 | 	 * The root component tells us what machine architecture we have here. | 
 | 97 | 	 */ | 
 | 98 | 	p = ArcGetChild(PROM_NULL_COMPONENT); | 
 | 99 | 	if (p == NULL) { | 
 | 100 | #ifdef CONFIG_SGI_IP27 | 
 | 101 | 		/* IP27 PROM misbehaves, seems to not implement ARC | 
 | 102 | 		   GetChild().  So we just assume it's an IP27.  */ | 
 | 103 | 		iname = "SGI-IP27"; | 
 | 104 | #else | 
 | 105 | 		iname = "Unknown"; | 
 | 106 | #endif | 
 | 107 | 	} else | 
 | 108 | 		iname = (char *) (long) p->iname; | 
 | 109 |  | 
 | 110 | 	printk("ARCH: %s\n", iname); | 
 | 111 | 	mach = string_to_mach(iname); | 
 | 112 | 	system_type = mach->liname; | 
 | 113 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | 	prom_flags = mach->flags; | 
 | 115 | } |