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 | * |
Justin P. Mattock | 79add62 | 2011-04-04 14:15:29 -0700 | [diff] [blame] | 12 | * Copyright (C) 1996 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | */ |
Paul Gortmaker | 50af5ea | 2012-01-20 18:35:53 -0500 | [diff] [blame] | 14 | #include <linux/bug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/init.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/types.h> |
| 18 | #include <linux/string.h> |
| 19 | |
| 20 | #include <asm/sgialib.h> |
| 21 | #include <asm/bootinfo.h> |
| 22 | |
| 23 | struct smatch { |
| 24 | char *arcname; |
| 25 | char *liname; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | int flags; |
| 27 | }; |
| 28 | |
| 29 | static struct smatch mach_table[] = { |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 30 | { |
| 31 | .arcname = "SGI-IP22", |
| 32 | .liname = "SGI Indy", |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 33 | .flags = PROM_FLAG_ARCS, |
| 34 | }, { |
| 35 | .arcname = "SGI-IP27", |
| 36 | .liname = "SGI Origin", |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 37 | .flags = PROM_FLAG_ARCS, |
| 38 | }, { |
| 39 | .arcname = "SGI-IP28", |
| 40 | .liname = "SGI IP28", |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 41 | .flags = PROM_FLAG_ARCS, |
| 42 | }, { |
| 43 | .arcname = "SGI-IP30", |
| 44 | .liname = "SGI Octane", |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 45 | .flags = PROM_FLAG_ARCS, |
| 46 | }, { |
| 47 | .arcname = "SGI-IP32", |
| 48 | .liname = "SGI O2", |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 49 | .flags = PROM_FLAG_ARCS, |
| 50 | }, { |
| 51 | .arcname = "Microsoft-Jazz", |
| 52 | .liname = "Jazz MIPS_Magnum_4000", |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 53 | .flags = 0, |
| 54 | }, { |
| 55 | .arcname = "PICA-61", |
| 56 | .liname = "Jazz Acer_PICA_61", |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 57 | .flags = 0, |
| 58 | }, { |
| 59 | .arcname = "RM200PCI", |
| 60 | .liname = "SNI RM200_PCI", |
Ralf Baechle | 112b20a | 2007-10-11 23:46:07 +0100 | [diff] [blame] | 61 | .flags = PROM_FLAG_DONT_FREE_TEMP, |
Thomas Bogendoerfer | 330117f | 2008-05-27 01:15:20 +0200 | [diff] [blame] | 62 | }, { |
| 63 | .arcname = "RM200PCI-R5K", |
| 64 | .liname = "SNI RM200_PCI-R5K", |
Thomas Bogendoerfer | 330117f | 2008-05-27 01:15:20 +0200 | [diff] [blame] | 65 | .flags = PROM_FLAG_DONT_FREE_TEMP, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | } |
| 67 | }; |
| 68 | |
| 69 | int prom_flags; |
| 70 | |
| 71 | static struct smatch * __init string_to_mach(const char *s) |
| 72 | { |
| 73 | int i; |
| 74 | |
Ahmed S. Darwish | 25b8ac3 | 2007-02-05 04:42:11 +0200 | [diff] [blame] | 75 | for (i = 0; i < ARRAY_SIZE(mach_table); i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | if (!strcmp(s, mach_table[i].arcname)) |
| 77 | return &mach_table[i]; |
| 78 | } |
| 79 | |
| 80 | panic("Yeee, could not determine architecture type <%s>", s); |
| 81 | } |
| 82 | |
| 83 | char *system_type; |
| 84 | |
| 85 | const char *get_system_type(void) |
| 86 | { |
| 87 | return system_type; |
| 88 | } |
| 89 | |
| 90 | void __init prom_identify_arch(void) |
| 91 | { |
| 92 | pcomponent *p; |
| 93 | struct smatch *mach; |
| 94 | const char *iname; |
| 95 | |
| 96 | /* |
| 97 | * The root component tells us what machine architecture we have here. |
| 98 | */ |
| 99 | p = ArcGetChild(PROM_NULL_COMPONENT); |
| 100 | if (p == NULL) { |
| 101 | #ifdef CONFIG_SGI_IP27 |
| 102 | /* IP27 PROM misbehaves, seems to not implement ARC |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 103 | GetChild(). So we just assume it's an IP27. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | iname = "SGI-IP27"; |
| 105 | #else |
| 106 | iname = "Unknown"; |
| 107 | #endif |
| 108 | } else |
| 109 | iname = (char *) (long) p->iname; |
| 110 | |
| 111 | printk("ARCH: %s\n", iname); |
| 112 | mach = string_to_mach(iname); |
| 113 | system_type = mach->liname; |
| 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | prom_flags = mach->flags; |
| 116 | } |