blob: c4e3c1ea0d48946f0c84b315817c43dab0f1aef6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * identify.c: machine identification code.
3 *
4 * Copyright (C) 1998 Harald Koerfgen and Paul M. Antoine
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +00005 * Copyright (C) 2002, 2003, 2004, 2005 Maciej W. Rozycki
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7#include <linux/init.h>
8#include <linux/kernel.h>
9#include <linux/mc146818rtc.h>
10#include <linux/module.h>
11#include <linux/string.h>
12#include <linux/types.h>
13
14#include <asm/bootinfo.h>
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000015
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/dec/ioasic.h>
17#include <asm/dec/ioasic_addrs.h>
18#include <asm/dec/kn01.h>
19#include <asm/dec/kn02.h>
20#include <asm/dec/kn02ba.h>
21#include <asm/dec/kn02ca.h>
22#include <asm/dec/kn03.h>
23#include <asm/dec/kn230.h>
24#include <asm/dec/prom.h>
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000025#include <asm/dec/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27#include "dectypes.h"
28
29extern unsigned long mips_machgroup;
30extern unsigned long mips_machtype;
31
32static const char *dec_system_strings[] = {
33 [MACH_DSUNKNOWN] "unknown DECstation",
34 [MACH_DS23100] "DECstation 2100/3100",
35 [MACH_DS5100] "DECsystem 5100",
36 [MACH_DS5000_200] "DECstation 5000/200",
37 [MACH_DS5000_1XX] "DECstation 5000/1xx",
38 [MACH_DS5000_XX] "Personal DECstation 5000/xx",
39 [MACH_DS5000_2X0] "DECstation 5000/2x0",
40 [MACH_DS5400] "DECsystem 5400",
41 [MACH_DS5500] "DECsystem 5500",
42 [MACH_DS5800] "DECsystem 5800",
43 [MACH_DS5900] "DECsystem 5900",
44};
45
46const char *get_system_type(void)
47{
48#define STR_BUF_LEN 64
49 static char system[STR_BUF_LEN];
50 static int called = 0;
51
52 if (called == 0) {
53 called = 1;
54 snprintf(system, STR_BUF_LEN, "Digital %s",
55 dec_system_strings[mips_machtype]);
56 }
57
58 return system;
59}
60
61
62/*
63 * Setup essential system-specific memory addresses. We need them
64 * early. Semantically the functions belong to prom/init.c, but they
65 * are compact enough we want them inlined. --macro
66 */
67volatile u8 *dec_rtc_base;
68
69EXPORT_SYMBOL(dec_rtc_base);
70
71static inline void prom_init_kn01(void)
72{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000073 dec_kn_slot_base = KN01_SLOT_BASE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 dec_kn_slot_size = KN01_SLOT_SIZE;
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000075
76 dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN01_RTC);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077}
78
79static inline void prom_init_kn230(void)
80{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000081 dec_kn_slot_base = KN01_SLOT_BASE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 dec_kn_slot_size = KN01_SLOT_SIZE;
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000083
84 dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN01_RTC);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085}
86
87static inline void prom_init_kn02(void)
88{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000089 dec_kn_slot_base = KN02_SLOT_BASE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 dec_kn_slot_size = KN02_SLOT_SIZE;
Maciej W. Rozycki33cf45b2007-02-05 16:28:26 -080091 dec_tc_bus = 1;
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000092
93 dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN02_RTC);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
96static inline void prom_init_kn02xa(void)
97{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +000098 dec_kn_slot_base = KN02XA_SLOT_BASE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 dec_kn_slot_size = IOASIC_SLOT_SIZE;
Maciej W. Rozycki33cf45b2007-02-05 16:28:26 -0800100 dec_tc_bus = 1;
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +0000101
102 ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL);
103 dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104}
105
106static inline void prom_init_kn03(void)
107{
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +0000108 dec_kn_slot_base = KN03_SLOT_BASE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 dec_kn_slot_size = IOASIC_SLOT_SIZE;
Maciej W. Rozycki33cf45b2007-02-05 16:28:26 -0800110 dec_tc_bus = 1;
Maciej W. Rozyckia5fc9c02005-07-01 16:10:40 +0000111
112 ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL);
113 dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114}
115
116
117void __init prom_identify_arch(u32 magic)
118{
119 unsigned char dec_cpunum, dec_firmrev, dec_etc, dec_systype;
120 u32 dec_sysid;
121
122 if (!prom_is_rex(magic)) {
123 dec_sysid = simple_strtoul(prom_getenv("systype"),
124 (char **)0, 0);
125 } else {
126 dec_sysid = rex_getsysid();
127 if (dec_sysid == 0) {
128 printk("Zero sysid returned from PROM! "
129 "Assuming a PMAX-like machine.\n");
130 dec_sysid = 1;
131 }
132 }
133
134 dec_cpunum = (dec_sysid & 0xff000000) >> 24;
135 dec_systype = (dec_sysid & 0xff0000) >> 16;
136 dec_firmrev = (dec_sysid & 0xff00) >> 8;
137 dec_etc = dec_sysid & 0xff;
138
139 /* We're obviously one of the DEC machines */
140 mips_machgroup = MACH_GROUP_DEC;
141
142 /*
143 * FIXME: This may not be an exhaustive list of DECStations/Servers!
144 * Put all model-specific initialisation calls here.
145 */
146 switch (dec_systype) {
147 case DS2100_3100:
148 mips_machtype = MACH_DS23100;
149 prom_init_kn01();
150 break;
151 case DS5100: /* DS5100 MIPSMATE */
152 mips_machtype = MACH_DS5100;
153 prom_init_kn230();
154 break;
155 case DS5000_200: /* DS5000 3max */
156 mips_machtype = MACH_DS5000_200;
157 prom_init_kn02();
158 break;
159 case DS5000_1XX: /* DS5000/100 3min */
160 mips_machtype = MACH_DS5000_1XX;
161 prom_init_kn02xa();
162 break;
163 case DS5000_2X0: /* DS5000/240 3max+ or DS5900 bigmax */
164 mips_machtype = MACH_DS5000_2X0;
165 prom_init_kn03();
166 if (!(ioasic_read(IO_REG_SIR) & KN03_IO_INR_3MAXP))
167 mips_machtype = MACH_DS5900;
168 break;
169 case DS5000_XX: /* Personal DS5000/xx maxine */
170 mips_machtype = MACH_DS5000_XX;
171 prom_init_kn02xa();
172 break;
173 case DS5800: /* DS5800 Isis */
174 mips_machtype = MACH_DS5800;
175 break;
176 case DS5400: /* DS5400 MIPSfair */
177 mips_machtype = MACH_DS5400;
178 break;
179 case DS5500: /* DS5500 MIPSfair-2 */
180 mips_machtype = MACH_DS5500;
181 break;
182 default:
183 mips_machtype = MACH_DSUNKNOWN;
184 break;
185 }
186
187 if (mips_machtype == MACH_DSUNKNOWN)
188 printk("This is an %s, id is %x\n",
189 dec_system_strings[mips_machtype], dec_systype);
190 else
191 printk("This is a %s\n", dec_system_strings[mips_machtype]);
192}