prom.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. * Based on Ocelot Linux port, which is
  9. * Copyright 2001 MontaVista Software Inc.
  10. * Author: jsun@mvista.com or jsun@junsun.net
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. *
  17. * Added changes for SMP - Manish Lachwani (lachwani@pmc-sierra.com)
  18. */
  19. #include <linux/init.h>
  20. #include <linux/mm.h>
  21. #include <linux/sched.h>
  22. #include <linux/bootmem.h>
  23. #include <linux/mv643xx.h>
  24. #include <asm/addrspace.h>
  25. #include <asm/bootinfo.h>
  26. #include <asm/pmon.h>
  27. #include "jaguar_atx_fpga.h"
  28. extern void ja_setup_console(void);
  29. struct callvectors *debug_vectors;
  30. extern unsigned long cpu_clock;
  31. const char *get_system_type(void)
  32. {
  33. return "Momentum Jaguar-ATX";
  34. }
  35. #ifdef CONFIG_64BIT
  36. unsigned long signext(unsigned long addr)
  37. {
  38. addr &= 0xffffffff;
  39. return (unsigned long)((int)addr);
  40. }
  41. void *get_arg(unsigned long args, int arc)
  42. {
  43. unsigned long ul;
  44. unsigned char *puc, uc;
  45. args += (arc * 4);
  46. ul = (unsigned long)signext(args);
  47. puc = (unsigned char *)ul;
  48. if (puc == 0)
  49. return (void *)0;
  50. #ifdef CONFIG_CPU_LITTLE_ENDIAN
  51. uc = *puc++;
  52. l = (unsigned long)uc;
  53. uc = *puc++;
  54. ul |= (((unsigned long)uc) << 8);
  55. uc = *puc++;
  56. ul |= (((unsigned long)uc) << 16);
  57. uc = *puc++;
  58. ul |= (((unsigned long)uc) << 24);
  59. #else
  60. uc = *puc++;
  61. ul = ((unsigned long)uc) << 24;
  62. uc = *puc++;
  63. ul |= (((unsigned long)uc) << 16);
  64. uc = *puc++;
  65. ul |= (((unsigned long)uc) << 8);
  66. uc = *puc++;
  67. ul |= ((unsigned long)uc);
  68. #endif
  69. ul = signext(ul);
  70. return (void *)ul;
  71. }
  72. char *arg64(unsigned long addrin, int arg_index)
  73. {
  74. unsigned long args;
  75. char *p;
  76. args = signext(addrin);
  77. p = (char *)get_arg(args, arg_index);
  78. return p;
  79. }
  80. #endif /* CONFIG_64BIT */
  81. /* PMON passes arguments in C main() style */
  82. void __init prom_init(void)
  83. {
  84. int argc = fw_arg0;
  85. char **arg = (char **) fw_arg1;
  86. char **env = (char **) fw_arg2;
  87. struct callvectors *cv = (struct callvectors *) fw_arg3;
  88. int i;
  89. #ifdef CONFIG_SERIAL_8250_CONSOLE
  90. // ja_setup_console(); /* The very first thing. */
  91. #endif
  92. #ifdef CONFIG_64BIT
  93. char *ptr;
  94. printk("Mips64 Jaguar-ATX\n");
  95. /* save the PROM vectors for debugging use */
  96. debug_vectors = (struct callvectors *)signext((unsigned long)cv);
  97. /* arg[0] is "g", the rest is boot parameters */
  98. arcs_cmdline[0] = '\0';
  99. for (i = 1; i < argc; i++) {
  100. ptr = (char *)arg64((unsigned long)arg, i);
  101. if ((strlen(arcs_cmdline) + strlen(ptr) + 1) >=
  102. sizeof(arcs_cmdline))
  103. break;
  104. strcat(arcs_cmdline, ptr);
  105. strcat(arcs_cmdline, " ");
  106. }
  107. i = 0;
  108. while (1) {
  109. ptr = (char *)arg64((unsigned long)env, i);
  110. if (! ptr)
  111. break;
  112. if (strncmp("gtbase", ptr, strlen("gtbase")) == 0) {
  113. marvell_base = simple_strtol(ptr + strlen("gtbase="),
  114. NULL, 16);
  115. if ((marvell_base & 0xffffffff00000000) == 0)
  116. marvell_base |= 0xffffffff00000000;
  117. printk("marvell_base set to 0x%016lx\n", marvell_base);
  118. }
  119. if (strncmp("cpuclock", ptr, strlen("cpuclock")) == 0) {
  120. cpu_clock = simple_strtol(ptr + strlen("cpuclock="),
  121. NULL, 10);
  122. printk("cpu_clock set to %d\n", cpu_clock);
  123. }
  124. i++;
  125. }
  126. printk("arcs_cmdline: %s\n", arcs_cmdline);
  127. #else /* CONFIG_64BIT */
  128. /* save the PROM vectors for debugging use */
  129. debug_vectors = cv;
  130. /* arg[0] is "g", the rest is boot parameters */
  131. arcs_cmdline[0] = '\0';
  132. for (i = 1; i < argc; i++) {
  133. if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
  134. >= sizeof(arcs_cmdline))
  135. break;
  136. strcat(arcs_cmdline, arg[i]);
  137. strcat(arcs_cmdline, " ");
  138. }
  139. while (*env) {
  140. if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
  141. marvell_base = simple_strtol(*env + strlen("gtbase="),
  142. NULL, 16);
  143. }
  144. if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) {
  145. cpu_clock = simple_strtol(*env + strlen("cpuclock="),
  146. NULL, 10);
  147. }
  148. env++;
  149. }
  150. #endif /* CONFIG_64BIT */
  151. mips_machgroup = MACH_GROUP_MOMENCO;
  152. mips_machtype = MACH_MOMENCO_JAGUAR_ATX;
  153. }
  154. void __init prom_free_prom_memory(void)
  155. {
  156. }
  157. void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
  158. {
  159. }
  160. int prom_boot_secondary(int cpu, unsigned long sp, unsigned long gp)
  161. {
  162. /* Clear the semaphore */
  163. *(volatile uint32_t *)(0xbb000a68) = 0x80000000;
  164. return 1;
  165. }
  166. void prom_init_secondary(void)
  167. {
  168. clear_c0_config(CONF_CM_CMASK);
  169. set_c0_config(0x2);
  170. clear_c0_status(ST0_IM);
  171. set_c0_status(0x1ffff);
  172. }
  173. void prom_smp_finish(void)
  174. {
  175. }