12f56cfddSAurelien Jarno /*
22f56cfddSAurelien Jarno * This file is subject to the terms and conditions of the GNU General Public
32f56cfddSAurelien Jarno * License. See the file "COPYING" in the main directory of this archive
42f56cfddSAurelien Jarno * for more details.
52f56cfddSAurelien Jarno *
62f56cfddSAurelien Jarno * identify.c: identify machine by looking up system identifier
72f56cfddSAurelien Jarno *
82f56cfddSAurelien Jarno * Copyright (C) 1998 Thomas Bogendoerfer
92f56cfddSAurelien Jarno *
102f56cfddSAurelien Jarno * This code is based on arch/mips/sgi/kernel/system.c, which is
112f56cfddSAurelien Jarno *
1279add627SJustin P. Mattock * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
132f56cfddSAurelien Jarno */
1450af5eadSPaul Gortmaker #include <linux/bug.h>
152f56cfddSAurelien Jarno #include <linux/init.h>
162f56cfddSAurelien Jarno #include <linux/kernel.h>
172f56cfddSAurelien Jarno #include <linux/types.h>
182f56cfddSAurelien Jarno #include <linux/string.h>
192f56cfddSAurelien Jarno
202f56cfddSAurelien Jarno #include <asm/sgialib.h>
212f56cfddSAurelien Jarno #include <asm/bootinfo.h>
222f56cfddSAurelien Jarno
232f56cfddSAurelien Jarno struct smatch {
242f56cfddSAurelien Jarno char *arcname;
252f56cfddSAurelien Jarno char *liname;
262f56cfddSAurelien Jarno int flags;
272f56cfddSAurelien Jarno };
282f56cfddSAurelien Jarno
292f56cfddSAurelien Jarno static struct smatch mach_table[] = {
30112b20a1SRalf Baechle {
31112b20a1SRalf Baechle .arcname = "SGI-IP22",
32112b20a1SRalf Baechle .liname = "SGI Indy",
33112b20a1SRalf Baechle .flags = PROM_FLAG_ARCS,
34112b20a1SRalf Baechle }, {
35112b20a1SRalf Baechle .arcname = "SGI-IP28",
36112b20a1SRalf Baechle .liname = "SGI IP28",
37112b20a1SRalf Baechle .flags = PROM_FLAG_ARCS,
38112b20a1SRalf Baechle }, {
39112b20a1SRalf Baechle .arcname = "SGI-IP30",
40112b20a1SRalf Baechle .liname = "SGI Octane",
41112b20a1SRalf Baechle .flags = PROM_FLAG_ARCS,
42112b20a1SRalf Baechle }, {
43112b20a1SRalf Baechle .arcname = "SGI-IP32",
44112b20a1SRalf Baechle .liname = "SGI O2",
45112b20a1SRalf Baechle .flags = PROM_FLAG_ARCS,
46112b20a1SRalf Baechle }, {
47112b20a1SRalf Baechle .arcname = "Microsoft-Jazz",
48112b20a1SRalf Baechle .liname = "Jazz MIPS_Magnum_4000",
49112b20a1SRalf Baechle .flags = 0,
50112b20a1SRalf Baechle }, {
51112b20a1SRalf Baechle .arcname = "PICA-61",
52112b20a1SRalf Baechle .liname = "Jazz Acer_PICA_61",
53112b20a1SRalf Baechle .flags = 0,
54112b20a1SRalf Baechle }, {
55112b20a1SRalf Baechle .arcname = "RM200PCI",
56112b20a1SRalf Baechle .liname = "SNI RM200_PCI",
57112b20a1SRalf Baechle .flags = PROM_FLAG_DONT_FREE_TEMP,
58330117ffSThomas Bogendoerfer }, {
59330117ffSThomas Bogendoerfer .arcname = "RM200PCI-R5K",
60330117ffSThomas Bogendoerfer .liname = "SNI RM200_PCI-R5K",
61330117ffSThomas Bogendoerfer .flags = PROM_FLAG_DONT_FREE_TEMP,
622f56cfddSAurelien Jarno }
632f56cfddSAurelien Jarno };
642f56cfddSAurelien Jarno
652f56cfddSAurelien Jarno int prom_flags;
662f56cfddSAurelien Jarno
string_to_mach(const char * s)672f56cfddSAurelien Jarno static struct smatch * __init string_to_mach(const char *s)
682f56cfddSAurelien Jarno {
692f56cfddSAurelien Jarno int i;
702f56cfddSAurelien Jarno
712f56cfddSAurelien Jarno for (i = 0; i < ARRAY_SIZE(mach_table); i++) {
722f56cfddSAurelien Jarno if (!strcmp(s, mach_table[i].arcname))
732f56cfddSAurelien Jarno return &mach_table[i];
742f56cfddSAurelien Jarno }
752f56cfddSAurelien Jarno
762f56cfddSAurelien Jarno panic("Yeee, could not determine architecture type <%s>", s);
772f56cfddSAurelien Jarno }
782f56cfddSAurelien Jarno
792f56cfddSAurelien Jarno char *system_type;
802f56cfddSAurelien Jarno
get_system_type(void)812f56cfddSAurelien Jarno const char *get_system_type(void)
822f56cfddSAurelien Jarno {
832f56cfddSAurelien Jarno return system_type;
842f56cfddSAurelien Jarno }
852f56cfddSAurelien Jarno
ArcGetChild(pcomponent * Current)86*d11646b5SThomas Bogendoerfer static pcomponent * __init ArcGetChild(pcomponent *Current)
87*d11646b5SThomas Bogendoerfer {
88*d11646b5SThomas Bogendoerfer return (pcomponent *) ARC_CALL1(child_component, Current);
89*d11646b5SThomas Bogendoerfer }
90*d11646b5SThomas Bogendoerfer
prom_identify_arch(void)912f56cfddSAurelien Jarno void __init prom_identify_arch(void)
922f56cfddSAurelien Jarno {
932f56cfddSAurelien Jarno pcomponent *p;
942f56cfddSAurelien Jarno struct smatch *mach;
952f56cfddSAurelien Jarno const char *iname;
962f56cfddSAurelien Jarno
972f56cfddSAurelien Jarno /*
982f56cfddSAurelien Jarno * The root component tells us what machine architecture we have here.
992f56cfddSAurelien Jarno */
1002f56cfddSAurelien Jarno p = ArcGetChild(PROM_NULL_COMPONENT);
1012f56cfddSAurelien Jarno if (p == NULL) {
1022f56cfddSAurelien Jarno iname = "Unknown";
1032f56cfddSAurelien Jarno } else
1042f56cfddSAurelien Jarno iname = (char *) (long) p->iname;
1052f56cfddSAurelien Jarno
1062f56cfddSAurelien Jarno printk("ARCH: %s\n", iname);
1072f56cfddSAurelien Jarno mach = string_to_mach(iname);
1082f56cfddSAurelien Jarno system_type = mach->liname;
1092f56cfddSAurelien Jarno
1102f56cfddSAurelien Jarno prom_flags = mach->flags;
1112f56cfddSAurelien Jarno }
112