xref: /openbmc/linux/arch/mips/dec/prom/identify.c (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * identify.c: machine identification code.
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (C) 1998 Harald Koerfgen and Paul M. Antoine
6a5fc9c0bSMaciej W. Rozycki  * Copyright (C) 2002, 2003, 2004, 2005  Maciej W. Rozycki
71da177e4SLinus Torvalds  */
81da177e4SLinus Torvalds #include <linux/init.h>
91da177e4SLinus Torvalds #include <linux/kernel.h>
101da177e4SLinus Torvalds #include <linux/mc146818rtc.h>
1126dd3e4fSPaul Gortmaker #include <linux/export.h>
121da177e4SLinus Torvalds #include <linux/string.h>
131da177e4SLinus Torvalds #include <linux/types.h>
141da177e4SLinus Torvalds 
151da177e4SLinus Torvalds #include <asm/bootinfo.h>
16a5fc9c0bSMaciej W. Rozycki 
171da177e4SLinus Torvalds #include <asm/dec/ioasic.h>
181da177e4SLinus Torvalds #include <asm/dec/ioasic_addrs.h>
191da177e4SLinus Torvalds #include <asm/dec/kn01.h>
201da177e4SLinus Torvalds #include <asm/dec/kn02.h>
211da177e4SLinus Torvalds #include <asm/dec/kn02ba.h>
221da177e4SLinus Torvalds #include <asm/dec/kn02ca.h>
231da177e4SLinus Torvalds #include <asm/dec/kn03.h>
241da177e4SLinus Torvalds #include <asm/dec/kn230.h>
251da177e4SLinus Torvalds #include <asm/dec/prom.h>
26a5fc9c0bSMaciej W. Rozycki #include <asm/dec/system.h>
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds #include "dectypes.h"
291da177e4SLinus Torvalds 
301da177e4SLinus Torvalds static const char *dec_system_strings[] = {
311da177e4SLinus Torvalds 	[MACH_DSUNKNOWN]	"unknown DECstation",
321da177e4SLinus Torvalds 	[MACH_DS23100]		"DECstation 2100/3100",
331da177e4SLinus Torvalds 	[MACH_DS5100]		"DECsystem 5100",
341da177e4SLinus Torvalds 	[MACH_DS5000_200]	"DECstation 5000/200",
351da177e4SLinus Torvalds 	[MACH_DS5000_1XX]	"DECstation 5000/1xx",
361da177e4SLinus Torvalds 	[MACH_DS5000_XX]	"Personal DECstation 5000/xx",
371da177e4SLinus Torvalds 	[MACH_DS5000_2X0]	"DECstation 5000/2x0",
381da177e4SLinus Torvalds 	[MACH_DS5400]		"DECsystem 5400",
391da177e4SLinus Torvalds 	[MACH_DS5500]		"DECsystem 5500",
401da177e4SLinus Torvalds 	[MACH_DS5800]		"DECsystem 5800",
411da177e4SLinus Torvalds 	[MACH_DS5900]		"DECsystem 5900",
421da177e4SLinus Torvalds };
431da177e4SLinus Torvalds 
get_system_type(void)441da177e4SLinus Torvalds const char *get_system_type(void)
451da177e4SLinus Torvalds {
461da177e4SLinus Torvalds #define STR_BUF_LEN	64
471da177e4SLinus Torvalds 	static char system[STR_BUF_LEN];
481da177e4SLinus Torvalds 	static int called = 0;
491da177e4SLinus Torvalds 
501da177e4SLinus Torvalds 	if (called == 0) {
511da177e4SLinus Torvalds 		called = 1;
521da177e4SLinus Torvalds 		snprintf(system, STR_BUF_LEN, "Digital %s",
531da177e4SLinus Torvalds 			 dec_system_strings[mips_machtype]);
541da177e4SLinus Torvalds 	}
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds 	return system;
571da177e4SLinus Torvalds }
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds 
601da177e4SLinus Torvalds /*
611da177e4SLinus Torvalds  * Setup essential system-specific memory addresses.  We need them
621da177e4SLinus Torvalds  * early.  Semantically the functions belong to prom/init.c, but they
631da177e4SLinus Torvalds  * are compact enough we want them inlined. --macro
641da177e4SLinus Torvalds  */
651da177e4SLinus Torvalds volatile u8 *dec_rtc_base;
661da177e4SLinus Torvalds 
671da177e4SLinus Torvalds EXPORT_SYMBOL(dec_rtc_base);
681da177e4SLinus Torvalds 
prom_init_kn01(void)691da177e4SLinus Torvalds static inline void prom_init_kn01(void)
701da177e4SLinus Torvalds {
71a5fc9c0bSMaciej W. Rozycki 	dec_kn_slot_base = KN01_SLOT_BASE;
721da177e4SLinus Torvalds 	dec_kn_slot_size = KN01_SLOT_SIZE;
73a5fc9c0bSMaciej W. Rozycki 
74a5fc9c0bSMaciej W. Rozycki 	dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN01_RTC);
751da177e4SLinus Torvalds }
761da177e4SLinus Torvalds 
prom_init_kn230(void)771da177e4SLinus Torvalds static inline void prom_init_kn230(void)
781da177e4SLinus Torvalds {
79a5fc9c0bSMaciej W. Rozycki 	dec_kn_slot_base = KN01_SLOT_BASE;
801da177e4SLinus Torvalds 	dec_kn_slot_size = KN01_SLOT_SIZE;
81a5fc9c0bSMaciej W. Rozycki 
82a5fc9c0bSMaciej W. Rozycki 	dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN01_RTC);
831da177e4SLinus Torvalds }
841da177e4SLinus Torvalds 
prom_init_kn02(void)851da177e4SLinus Torvalds static inline void prom_init_kn02(void)
861da177e4SLinus Torvalds {
87a5fc9c0bSMaciej W. Rozycki 	dec_kn_slot_base = KN02_SLOT_BASE;
881da177e4SLinus Torvalds 	dec_kn_slot_size = KN02_SLOT_SIZE;
8933cf45b9SMaciej W. Rozycki 	dec_tc_bus = 1;
90a5fc9c0bSMaciej W. Rozycki 
91a5fc9c0bSMaciej W. Rozycki 	dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + KN02_RTC);
921da177e4SLinus Torvalds }
931da177e4SLinus Torvalds 
prom_init_kn02xa(void)941da177e4SLinus Torvalds static inline void prom_init_kn02xa(void)
951da177e4SLinus Torvalds {
96a5fc9c0bSMaciej W. Rozycki 	dec_kn_slot_base = KN02XA_SLOT_BASE;
971da177e4SLinus Torvalds 	dec_kn_slot_size = IOASIC_SLOT_SIZE;
9833cf45b9SMaciej W. Rozycki 	dec_tc_bus = 1;
99a5fc9c0bSMaciej W. Rozycki 
100a5fc9c0bSMaciej W. Rozycki 	ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL);
101a5fc9c0bSMaciej W. Rozycki 	dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY);
1021da177e4SLinus Torvalds }
1031da177e4SLinus Torvalds 
prom_init_kn03(void)1041da177e4SLinus Torvalds static inline void prom_init_kn03(void)
1051da177e4SLinus Torvalds {
106a5fc9c0bSMaciej W. Rozycki 	dec_kn_slot_base = KN03_SLOT_BASE;
1071da177e4SLinus Torvalds 	dec_kn_slot_size = IOASIC_SLOT_SIZE;
10833cf45b9SMaciej W. Rozycki 	dec_tc_bus = 1;
109a5fc9c0bSMaciej W. Rozycki 
110a5fc9c0bSMaciej W. Rozycki 	ioasic_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_IOCTL);
111a5fc9c0bSMaciej W. Rozycki 	dec_rtc_base = (void *)CKSEG1ADDR(dec_kn_slot_base + IOASIC_TOY);
1121da177e4SLinus Torvalds }
1131da177e4SLinus Torvalds 
1141da177e4SLinus Torvalds 
prom_identify_arch(u32 magic)1151da177e4SLinus Torvalds void __init prom_identify_arch(u32 magic)
1161da177e4SLinus Torvalds {
1171da177e4SLinus Torvalds 	unsigned char dec_cpunum, dec_firmrev, dec_etc, dec_systype;
1181da177e4SLinus Torvalds 	u32 dec_sysid;
1191da177e4SLinus Torvalds 
1201da177e4SLinus Torvalds 	if (!prom_is_rex(magic)) {
1211da177e4SLinus Torvalds 		dec_sysid = simple_strtoul(prom_getenv("systype"),
1221da177e4SLinus Torvalds 					   (char **)0, 0);
1231da177e4SLinus Torvalds 	} else {
1241da177e4SLinus Torvalds 		dec_sysid = rex_getsysid();
1251da177e4SLinus Torvalds 		if (dec_sysid == 0) {
1261da177e4SLinus Torvalds 			printk("Zero sysid returned from PROM! "
1271da177e4SLinus Torvalds 			       "Assuming a PMAX-like machine.\n");
1281da177e4SLinus Torvalds 			dec_sysid = 1;
1291da177e4SLinus Torvalds 		}
1301da177e4SLinus Torvalds 	}
1311da177e4SLinus Torvalds 
1321da177e4SLinus Torvalds 	dec_cpunum = (dec_sysid & 0xff000000) >> 24;
1331da177e4SLinus Torvalds 	dec_systype = (dec_sysid & 0xff0000) >> 16;
1341da177e4SLinus Torvalds 	dec_firmrev = (dec_sysid & 0xff00) >> 8;
1351da177e4SLinus Torvalds 	dec_etc = dec_sysid & 0xff;
1361da177e4SLinus Torvalds 
1371da177e4SLinus Torvalds 	/*
1381da177e4SLinus Torvalds 	 * FIXME: This may not be an exhaustive list of DECStations/Servers!
1391da177e4SLinus Torvalds 	 * Put all model-specific initialisation calls here.
1401da177e4SLinus Torvalds 	 */
1411da177e4SLinus Torvalds 	switch (dec_systype) {
1421da177e4SLinus Torvalds 	case DS2100_3100:
1431da177e4SLinus Torvalds 		mips_machtype = MACH_DS23100;
1441da177e4SLinus Torvalds 		prom_init_kn01();
1451da177e4SLinus Torvalds 		break;
1461da177e4SLinus Torvalds 	case DS5100:		/* DS5100 MIPSMATE */
1471da177e4SLinus Torvalds 		mips_machtype = MACH_DS5100;
1481da177e4SLinus Torvalds 		prom_init_kn230();
1491da177e4SLinus Torvalds 		break;
1501da177e4SLinus Torvalds 	case DS5000_200:	/* DS5000 3max */
1511da177e4SLinus Torvalds 		mips_machtype = MACH_DS5000_200;
1521da177e4SLinus Torvalds 		prom_init_kn02();
1531da177e4SLinus Torvalds 		break;
1541da177e4SLinus Torvalds 	case DS5000_1XX:	/* DS5000/100 3min */
1551da177e4SLinus Torvalds 		mips_machtype = MACH_DS5000_1XX;
1561da177e4SLinus Torvalds 		prom_init_kn02xa();
1571da177e4SLinus Torvalds 		break;
1581da177e4SLinus Torvalds 	case DS5000_2X0:	/* DS5000/240 3max+ or DS5900 bigmax */
1591da177e4SLinus Torvalds 		mips_machtype = MACH_DS5000_2X0;
1601da177e4SLinus Torvalds 		prom_init_kn03();
1611da177e4SLinus Torvalds 		if (!(ioasic_read(IO_REG_SIR) & KN03_IO_INR_3MAXP))
1621da177e4SLinus Torvalds 			mips_machtype = MACH_DS5900;
1631da177e4SLinus Torvalds 		break;
1641da177e4SLinus Torvalds 	case DS5000_XX:		/* Personal DS5000/xx maxine */
1651da177e4SLinus Torvalds 		mips_machtype = MACH_DS5000_XX;
1661da177e4SLinus Torvalds 		prom_init_kn02xa();
1671da177e4SLinus Torvalds 		break;
1681da177e4SLinus Torvalds 	case DS5800:		/* DS5800 Isis */
1691da177e4SLinus Torvalds 		mips_machtype = MACH_DS5800;
1701da177e4SLinus Torvalds 		break;
1711da177e4SLinus Torvalds 	case DS5400:		/* DS5400 MIPSfair */
1721da177e4SLinus Torvalds 		mips_machtype = MACH_DS5400;
1731da177e4SLinus Torvalds 		break;
1741da177e4SLinus Torvalds 	case DS5500:		/* DS5500 MIPSfair-2 */
1751da177e4SLinus Torvalds 		mips_machtype = MACH_DS5500;
1761da177e4SLinus Torvalds 		break;
1771da177e4SLinus Torvalds 	default:
1781da177e4SLinus Torvalds 		mips_machtype = MACH_DSUNKNOWN;
1791da177e4SLinus Torvalds 		break;
1801da177e4SLinus Torvalds 	}
1811da177e4SLinus Torvalds 
1821da177e4SLinus Torvalds 	if (mips_machtype == MACH_DSUNKNOWN)
1831da177e4SLinus Torvalds 		printk("This is an %s, id is %x\n",
1841da177e4SLinus Torvalds 		       dec_system_strings[mips_machtype], dec_systype);
1851da177e4SLinus Torvalds 	else
1861da177e4SLinus Torvalds 		printk("This is a %s\n", dec_system_strings[mips_machtype]);
1871da177e4SLinus Torvalds }
188