sniprom.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * Big Endian PROM code for SNI RM machines
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2005-2006 Florian Lohoff (flo@rfc822.org)
  9. * Copyright (C) 2005-2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
  10. */
  11. #define DEBUG
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/string.h>
  15. #include <linux/console.h>
  16. #include <asm/addrspace.h>
  17. #include <asm/sni.h>
  18. #include <asm/mipsprom.h>
  19. #include <asm/mipsregs.h>
  20. #include <asm/bootinfo.h>
  21. /* special SNI prom calls */
  22. /*
  23. * This does not exist in all proms - SINIX compares
  24. * the prom env variable "version" against "2.0008"
  25. * or greater. If lesser it tries to probe interesting
  26. * registers
  27. */
  28. #define PROM_GET_MEMCONF 58
  29. #define PROM_VEC (u64 *)CKSEG1ADDR(0x1fc00000)
  30. #define PROM_ENTRY(x) (PROM_VEC + (x))
  31. static int *(*__prom_putchar)(int) = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR);
  32. void prom_putchar(char c)
  33. {
  34. __prom_putchar(c);
  35. }
  36. static char *(*__prom_getenv)(char *) = (char *(*)(char *))PROM_ENTRY(PROM_GETENV);
  37. static void (*__prom_get_memconf)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF);
  38. char *prom_getenv(char *s)
  39. {
  40. return __prom_getenv(s);
  41. }
  42. void __init prom_free_prom_memory(void)
  43. {
  44. }
  45. /*
  46. * /proc/cpuinfo system type
  47. *
  48. */
  49. static const char *systype = "Unknown";
  50. const char *get_system_type(void)
  51. {
  52. return systype;
  53. }
  54. #define SNI_IDPROM_BASE 0xbff00000
  55. #define SNI_IDPROM_MEMSIZE (SNI_IDPROM_BASE+0x28) /* Memsize in 16MB quantities */
  56. #define SNI_IDPROM_BRDTYPE (SNI_IDPROM_BASE+0x29) /* Board Type */
  57. #define SNI_IDPROM_CPUTYPE (SNI_IDPROM_BASE+0x30) /* CPU Type */
  58. #define SNI_IDPROM_SIZE 0x1000
  59. #ifdef DEBUG
  60. static void __init sni_idprom_dump(void)
  61. {
  62. int i;
  63. pr_debug("SNI IDProm dump:\n");
  64. for (i = 0; i < 256; i++) {
  65. if (i%16 == 0)
  66. pr_debug("%04x ", i);
  67. printk("%02x ", *(unsigned char *) (SNI_IDPROM_BASE + i));
  68. if (i % 16 == 15)
  69. printk("\n");
  70. }
  71. }
  72. #endif
  73. static void __init sni_mem_init(void )
  74. {
  75. int i, memsize;
  76. struct membank {
  77. u32 size;
  78. u32 base;
  79. u32 size2;
  80. u32 pad1;
  81. u32 pad2;
  82. } memconf[8];
  83. /* MemSIZE from prom in 16MByte chunks */
  84. memsize = *((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
  85. pr_debug("IDProm memsize: %lu MByte\n", memsize);
  86. /* get memory bank layout from prom */
  87. __prom_get_memconf(&memconf);
  88. pr_debug("prom_get_mem_conf memory configuration:\n");
  89. for (i = 0;i < 8 && memconf[i].size; i++) {
  90. if (sni_brd_type == SNI_BRD_PCI_TOWER ||
  91. sni_brd_type == SNI_BRD_PCI_TOWER_CPLUS) {
  92. if (memconf[i].base >= 0x20000000 &&
  93. memconf[i].base < 0x30000000) {
  94. memconf[i].base -= 0x20000000;
  95. }
  96. }
  97. pr_debug("Bank%d: %08x @ %08x\n", i,
  98. memconf[i].size, memconf[i].base);
  99. add_memory_region(memconf[i].base, memconf[i].size, BOOT_MEM_RAM);
  100. }
  101. }
  102. static void __init sni_console_setup(void)
  103. {
  104. char *ctype;
  105. char *cdev;
  106. char *baud;
  107. int port;
  108. static char options[8];
  109. cdev = prom_getenv("console_dev");
  110. if (strncmp (cdev, "tty", 3) == 0) {
  111. ctype = prom_getenv("console");
  112. switch (*ctype) {
  113. default:
  114. case 'l':
  115. port = 0;
  116. baud = prom_getenv("lbaud");
  117. break;
  118. case 'r':
  119. port = 1;
  120. baud = prom_getenv("rbaud");
  121. break;
  122. }
  123. if (baud)
  124. strcpy(options, baud);
  125. if (strncmp (cdev, "tty552", 6) == 0)
  126. add_preferred_console("ttyS", port, baud ? options : NULL);
  127. else
  128. add_preferred_console("ttySC", port, baud ? options : NULL);
  129. }
  130. }
  131. void __init prom_init(void)
  132. {
  133. int argc = fw_arg0;
  134. char **argv = (void *)fw_arg1;
  135. int i;
  136. int cputype;
  137. sni_brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE;
  138. cputype = *(unsigned char *)SNI_IDPROM_CPUTYPE;
  139. switch (sni_brd_type) {
  140. case SNI_BRD_TOWER_OASIC:
  141. switch (cputype) {
  142. case SNI_CPU_M8030:
  143. systype = "RM400-330";
  144. break;
  145. case SNI_CPU_M8031:
  146. systype = "RM400-430";
  147. break;
  148. case SNI_CPU_M8037:
  149. systype = "RM400-530";
  150. break;
  151. case SNI_CPU_M8034:
  152. systype = "RM400-730";
  153. break;
  154. default:
  155. systype = "RM400-xxx";
  156. break;
  157. }
  158. break;
  159. case SNI_BRD_MINITOWER:
  160. switch (cputype) {
  161. case SNI_CPU_M8021:
  162. case SNI_CPU_M8043:
  163. systype = "RM400-120";
  164. break;
  165. case SNI_CPU_M8040:
  166. systype = "RM400-220";
  167. break;
  168. case SNI_CPU_M8053:
  169. systype = "RM400-225";
  170. break;
  171. case SNI_CPU_M8050:
  172. systype = "RM400-420";
  173. break;
  174. default:
  175. systype = "RM400-xxx";
  176. break;
  177. }
  178. break;
  179. case SNI_BRD_PCI_TOWER:
  180. systype = "RM400-Cxx";
  181. break;
  182. case SNI_BRD_RM200:
  183. systype = "RM200-xxx";
  184. break;
  185. case SNI_BRD_PCI_MTOWER:
  186. systype = "RM300-Cxx";
  187. break;
  188. case SNI_BRD_PCI_DESKTOP:
  189. switch (read_c0_prid() & 0xff00) {
  190. case PRID_IMP_R4600:
  191. case PRID_IMP_R4700:
  192. systype = "RM200-C20";
  193. break;
  194. case PRID_IMP_R5000:
  195. systype = "RM200-C40";
  196. break;
  197. default:
  198. systype = "RM200-Cxx";
  199. break;
  200. }
  201. break;
  202. case SNI_BRD_PCI_TOWER_CPLUS:
  203. systype = "RM400-Exx";
  204. break;
  205. case SNI_BRD_PCI_MTOWER_CPLUS:
  206. systype = "RM300-Exx";
  207. break;
  208. }
  209. pr_debug("Found SNI brdtype %02x name %s\n", sni_brd_type, systype);
  210. #ifdef DEBUG
  211. sni_idprom_dump();
  212. #endif
  213. sni_mem_init();
  214. sni_console_setup();
  215. /* copy prom cmdline parameters to kernel cmdline */
  216. for (i = 1; i < argc; i++) {
  217. strcat(arcs_cmdline, argv[i]);
  218. if (i < (argc - 1))
  219. strcat(arcs_cmdline, " ");
  220. }
  221. }