sniprom.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/string.h>
  14. #include <asm/addrspace.h>
  15. #include <asm/sni.h>
  16. #include <asm/mipsprom.h>
  17. #include <asm/bootinfo.h>
  18. /* special SNI prom calls */
  19. /*
  20. * This does not exist in all proms - SINIX compares
  21. * the prom env variable "version" against "2.0008"
  22. * or greater. If lesser it tries to probe interesting
  23. * registers
  24. */
  25. #define PROM_GET_MEMCONF 58
  26. #define PROM_VEC (u64 *)CKSEG1ADDR(0x1fc00000)
  27. #define PROM_ENTRY(x) (PROM_VEC + (x))
  28. #undef DEBUG
  29. #ifdef DEBUG
  30. #define DBG_PRINTF(x...) prom_printf(x)
  31. #else
  32. #define DBG_PRINTF(x...)
  33. #endif
  34. static int *(*__prom_putchar)(int) = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR);
  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 prom_printf(char *fmt, ...)
  42. {
  43. va_list args;
  44. char ppbuf[1024];
  45. char *bptr;
  46. va_start(args, fmt);
  47. vsprintf(ppbuf, fmt, args);
  48. bptr = ppbuf;
  49. while (*bptr != 0) {
  50. if (*bptr == '\n')
  51. __prom_putchar('\r');
  52. __prom_putchar(*bptr++);
  53. }
  54. va_end(args);
  55. }
  56. void __init prom_free_prom_memory(void)
  57. {
  58. }
  59. /*
  60. * /proc/cpuinfo system type
  61. *
  62. */
  63. static const char *systype = "Unknown";
  64. const char *get_system_type(void)
  65. {
  66. return systype;
  67. }
  68. #define SNI_IDPROM_BASE 0xbff00000
  69. #define SNI_IDPROM_MEMSIZE (SNI_IDPROM_BASE+0x28) /* Memsize in 16MB quantities */
  70. #define SNI_IDPROM_BRDTYPE (SNI_IDPROM_BASE+0x29) /* Board Type */
  71. #define SNI_IDPROM_CPUTYPE (SNI_IDPROM_BASE+0x30) /* CPU Type */
  72. #define SNI_IDPROM_SIZE 0x1000
  73. #ifdef DEBUG
  74. static void sni_idprom_dump(void)
  75. {
  76. int i;
  77. prom_printf("SNI IDProm dump (first 128byte):\n");
  78. for(i=0;i<128;i++) {
  79. if (i%16 == 0)
  80. prom_printf("%04x ", i);
  81. prom_printf("%02x ", *(unsigned char *) (SNI_IDPROM_BASE+i));
  82. if (i%16 == 15)
  83. prom_printf("\n");
  84. }
  85. }
  86. #endif
  87. static void sni_mem_init(void )
  88. {
  89. int i, memsize;
  90. struct membank {
  91. u32 size;
  92. u32 base;
  93. u32 size2;
  94. u32 pad1;
  95. u32 pad2;
  96. } memconf[8];
  97. /* MemSIZE from prom in 16MByte chunks */
  98. memsize=*((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
  99. DBG_PRINTF("IDProm memsize: %lu MByte\n", memsize);
  100. /* get memory bank layout from prom */
  101. __prom_get_memconf(&memconf);
  102. DBG_PRINTF("prom_get_mem_conf memory configuration:\n");
  103. for(i=0;i<8 && memconf[i].size;i++) {
  104. prom_printf("Bank%d: %08x @ %08x\n", i,
  105. memconf[i].size, memconf[i].base);
  106. add_memory_region(memconf[i].base, memconf[i].size, BOOT_MEM_RAM);
  107. }
  108. }
  109. void __init prom_init(void)
  110. {
  111. int argc = fw_arg0;
  112. char **argv = (void *)fw_arg1;
  113. unsigned int sni_brd_type = *(unsigned char *) SNI_IDPROM_BRDTYPE;
  114. int i;
  115. DBG_PRINTF("Found SNI brdtype %02x\n", sni_brd_type);
  116. #ifdef DEBUG
  117. sni_idprom_dump();
  118. #endif
  119. sni_mem_init();
  120. /* copy prom cmdline parameters to kernel cmdline */
  121. for (i = 1; i < argc; i++) {
  122. strcat(arcs_cmdline, argv[i]);
  123. if (i < (argc - 1))
  124. strcat(arcs_cmdline, " ");
  125. }
  126. }