identify.c 4.6 KB

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