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