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