sniprom.c 5.5 KB

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