prom.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Copyright 2002 Momentum Computer Inc.
  3. * Author: Matthew Dharm <mdharm@momenco.com>
  4. *
  5. * Louis Hamilton, Red Hat, Inc.
  6. * hamilton@redhat.com [MIPS64 modifications]
  7. *
  8. * Copyright 2004 PMC-Sierra
  9. * Author: Manish Lachwani (lachwani@pmc-sierra.com)
  10. *
  11. * Based on Ocelot Linux port, which is
  12. * Copyright 2001 MontaVista Software Inc.
  13. * Author: jsun@mvista.com or jsun@junsun.net
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. *
  20. * Copyright (C) 2004 MontaVista Software Inc.
  21. * Author: Manish Lachwani, mlachwani@mvista.com
  22. *
  23. */
  24. #include <linux/init.h>
  25. #include <linux/bootmem.h>
  26. #include <linux/mv643xx.h>
  27. #include <asm/addrspace.h>
  28. #include <asm/bootinfo.h>
  29. #include <asm/pmon.h>
  30. #include "ocelot_3_fpga.h"
  31. struct callvectors* debug_vectors;
  32. extern unsigned long marvell_base;
  33. extern unsigned long cpu_clock;
  34. const char *get_system_type(void)
  35. {
  36. return "Momentum Ocelot-3";
  37. }
  38. #ifdef CONFIG_64BIT
  39. unsigned long signext(unsigned long addr)
  40. {
  41. addr &= 0xffffffff;
  42. return (unsigned long)((int)addr);
  43. }
  44. void *get_arg(unsigned long args, int arc)
  45. {
  46. unsigned long ul;
  47. unsigned char *puc, uc;
  48. args += (arc * 4);
  49. ul = (unsigned long)signext(args);
  50. puc = (unsigned char *)ul;
  51. if (puc == 0)
  52. return (void *)0;
  53. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  54. uc = *puc++;
  55. ul = (unsigned long)uc;
  56. uc = *puc++;
  57. ul |= (((unsigned long)uc) << 8);
  58. uc = *puc++;
  59. ul |= (((unsigned long)uc) << 16);
  60. uc = *puc++;
  61. ul |= (((unsigned long)uc) << 24);
  62. #else /* CONFIG_CPU_LITTLE_ENDIAN */
  63. uc = *puc++;
  64. ul = ((unsigned long)uc) << 24;
  65. uc = *puc++;
  66. ul |= (((unsigned long)uc) << 16);
  67. uc = *puc++;
  68. ul |= (((unsigned long)uc) << 8);
  69. uc = *puc++;
  70. ul |= ((unsigned long)uc);
  71. #endif /* CONFIG_CPU_LITTLE_ENDIAN */
  72. ul = signext(ul);
  73. return (void *)ul;
  74. }
  75. char *arg64(unsigned long addrin, int arg_index)
  76. {
  77. unsigned long args;
  78. char *p;
  79. args = signext(addrin);
  80. p = (char *)get_arg(args, arg_index);
  81. return p;
  82. }
  83. #endif /* CONFIG_64BIT */
  84. void __init prom_init(void)
  85. {
  86. int argc = fw_arg0;
  87. char **arg = (char **) fw_arg1;
  88. char **env = (char **) fw_arg2;
  89. struct callvectors *cv = (struct callvectors *) fw_arg3;
  90. int i;
  91. #ifdef CONFIG_64BIT
  92. char *ptr;
  93. printk("prom_init - MIPS64\n");
  94. /* save the PROM vectors for debugging use */
  95. debug_vectors = (struct callvectors *)signext((unsigned long)cv);
  96. /* arg[0] is "g", the rest is boot parameters */
  97. arcs_cmdline[0] = '\0';
  98. for (i = 1; i < argc; i++) {
  99. ptr = (char *)arg64((unsigned long)arg, i);
  100. if ((strlen(arcs_cmdline) + strlen(ptr) + 1) >=
  101. sizeof(arcs_cmdline))
  102. break;
  103. strcat(arcs_cmdline, ptr);
  104. strcat(arcs_cmdline, " ");
  105. }
  106. i = 0;
  107. while (1) {
  108. ptr = (char *)arg64((unsigned long)env, i);
  109. if (! ptr)
  110. break;
  111. if (strncmp("gtbase", ptr, strlen("gtbase")) == 0) {
  112. marvell_base = simple_strtol(ptr + strlen("gtbase="),
  113. NULL, 16);
  114. if ((marvell_base & 0xffffffff00000000) == 0)
  115. marvell_base |= 0xffffffff00000000;
  116. printk("marvell_base set to 0x%016lx\n", marvell_base);
  117. }
  118. if (strncmp("cpuclock", ptr, strlen("cpuclock")) == 0) {
  119. cpu_clock = simple_strtol(ptr + strlen("cpuclock="),
  120. NULL, 10);
  121. printk("cpu_clock set to %d\n", cpu_clock);
  122. }
  123. i++;
  124. }
  125. printk("arcs_cmdline: %s\n", arcs_cmdline);
  126. #else /* CONFIG_64BIT */
  127. /* save the PROM vectors for debugging use */
  128. debug_vectors = cv;
  129. /* arg[0] is "g", the rest is boot parameters */
  130. arcs_cmdline[0] = '\0';
  131. for (i = 1; i < argc; i++) {
  132. if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
  133. >= sizeof(arcs_cmdline))
  134. break;
  135. strcat(arcs_cmdline, arg[i]);
  136. strcat(arcs_cmdline, " ");
  137. }
  138. while (*env) {
  139. if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
  140. marvell_base = simple_strtol(*env + strlen("gtbase="),
  141. NULL, 16);
  142. }
  143. if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) {
  144. cpu_clock = simple_strtol(*env + strlen("cpuclock="),
  145. NULL, 10);
  146. }
  147. env++;
  148. }
  149. #endif /* CONFIG_64BIT */
  150. mips_machgroup = MACH_GROUP_MOMENCO;
  151. mips_machtype = MACH_MOMENCO_OCELOT_3;
  152. #ifndef CONFIG_64BIT
  153. debug_vectors->printf("Booting Linux kernel...\n");
  154. #endif
  155. }
  156. void __init prom_free_prom_memory(void)
  157. {
  158. }
  159. void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
  160. {
  161. }