sniprom.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 <linux/console.h>
  15. #include <asm/addrspace.h>
  16. #include <asm/sni.h>
  17. #include <asm/mipsprom.h>
  18. #include <asm/mipsregs.h>
  19. #include <asm/bootinfo.h>
  20. #include <asm/setup.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_GET_HWCONF 61
  30. #define PROM_VEC (u64 *)CKSEG1ADDR(0x1fc00000)
  31. #define PROM_ENTRY(x) (PROM_VEC + (x))
  32. #define ___prom_putchar ((int *(*)(int))PROM_ENTRY(PROM_PUTCHAR))
  33. #define ___prom_getenv ((char *(*)(char *))PROM_ENTRY(PROM_GETENV))
  34. #define ___prom_get_memconf ((void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF))
  35. #define ___prom_get_hwconf ((u32 (*)(void))PROM_ENTRY(PROM_GET_HWCONF))
  36. #ifdef CONFIG_64BIT
  37. /* O32 stack has to be 8-byte aligned. */
  38. static u64 o32_stk[4096];
  39. #define O32_STK (&o32_stk[ARRAY_SIZE(o32_stk)])
  40. #define __PROM_O32(fun, arg) fun arg __asm__(#fun); \
  41. __asm__(#fun " = call_o32")
  42. int __PROM_O32(__prom_putchar, (int *(*)(int), void *, int));
  43. char *__PROM_O32(__prom_getenv, (char *(*)(char *), void *, char *));
  44. void __PROM_O32(__prom_get_memconf, (void (*)(void *), void *, void *));
  45. u32 __PROM_O32(__prom_get_hwconf, (u32 (*)(void), void *));
  46. #define _prom_putchar(x) __prom_putchar(___prom_putchar, O32_STK, x)
  47. #define _prom_getenv(x) __prom_getenv(___prom_getenv, O32_STK, x)
  48. #define _prom_get_memconf(x) __prom_get_memconf(___prom_get_memconf, O32_STK, x)
  49. #define _prom_get_hwconf() __prom_get_hwconf(___prom_get_hwconf, O32_STK)
  50. #else
  51. #define _prom_putchar(x) ___prom_putchar(x)
  52. #define _prom_getenv(x) ___prom_getenv(x)
  53. #define _prom_get_memconf(x) ___prom_get_memconf(x)
  54. #define _prom_get_hwconf(x) ___prom_get_hwconf(x)
  55. #endif
  56. void prom_putchar(char c)
  57. {
  58. _prom_putchar(c);
  59. }
  60. char *prom_getenv(char *s)
  61. {
  62. return _prom_getenv(s);
  63. }
  64. void *prom_get_hwconf(void)
  65. {
  66. u32 hwconf = _prom_get_hwconf();
  67. if (hwconf == 0xffffffff)
  68. return NULL;
  69. return (void *)CKSEG1ADDR(hwconf);
  70. }
  71. void __init prom_free_prom_memory(void)
  72. {
  73. }
  74. /*
  75. * /proc/cpuinfo system type
  76. *
  77. */
  78. char *system_type = "Unknown";
  79. const char *get_system_type(void)
  80. {
  81. return system_type;
  82. }
  83. static void __init sni_mem_init(void)
  84. {
  85. int i, memsize;
  86. struct membank {
  87. u32 size;
  88. u32 base;
  89. u32 size2;
  90. u32 pad1;
  91. u32 pad2;
  92. } memconf[8];
  93. int brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE;
  94. /* MemSIZE from prom in 16MByte chunks */
  95. memsize = *((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
  96. pr_debug("IDProm memsize: %u MByte\n", memsize);
  97. /* get memory bank layout from prom */
  98. _prom_get_memconf(&memconf);
  99. pr_debug("prom_get_mem_conf memory configuration:\n");
  100. for (i = 0; i < 8 && memconf[i].size; i++) {
  101. if (brd_type == SNI_BRD_PCI_TOWER ||
  102. brd_type == SNI_BRD_PCI_TOWER_CPLUS) {
  103. if (memconf[i].base >= 0x20000000 &&
  104. memconf[i].base < 0x30000000)
  105. memconf[i].base -= 0x20000000;
  106. }
  107. pr_debug("Bank%d: %08x @ %08x\n", i,
  108. memconf[i].size, memconf[i].base);
  109. add_memory_region(memconf[i].base, memconf[i].size,
  110. BOOT_MEM_RAM);
  111. }
  112. }
  113. void __init prom_init(void)
  114. {
  115. int argc = fw_arg0;
  116. u32 *argv = (u32 *)CKSEG0ADDR(fw_arg1);
  117. int i;
  118. sni_mem_init();
  119. /* copy prom cmdline parameters to kernel cmdline */
  120. for (i = 1; i < argc; i++) {
  121. strcat(arcs_cmdline, (char *)CKSEG0ADDR(argv[i]));
  122. if (i < (argc - 1))
  123. strcat(arcs_cmdline, " ");
  124. }
  125. }