identify.c 4.6 KB

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