prom.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License as published by the
  4. * Free Software Foundation; either version 2 of the License, or (at your
  5. * option) any later version.
  6. *
  7. * Copyright (C) 2003, 2004 PMC-Sierra Inc.
  8. * Author: Manish Lachwani (lachwani@pmc-sierra.com)
  9. * Copyright (C) 2004 Ralf Baechle
  10. */
  11. #include <linux/init.h>
  12. #include <linux/sched.h>
  13. #include <linux/mm.h>
  14. #include <linux/delay.h>
  15. #include <linux/pm.h>
  16. #include <linux/smp.h>
  17. #include <asm/io.h>
  18. #include <asm/pgtable.h>
  19. #include <asm/processor.h>
  20. #include <asm/reboot.h>
  21. #include <asm/smp-ops.h>
  22. #include <asm/bootinfo.h>
  23. #include <asm/pmon.h>
  24. #ifdef CONFIG_SMP
  25. extern void prom_grab_secondary(void);
  26. #else
  27. #define prom_grab_secondary() do { } while (0)
  28. #endif
  29. #include "setup.h"
  30. struct callvectors *debug_vectors;
  31. extern unsigned long yosemite_base;
  32. extern unsigned long cpu_clock_freq;
  33. const char *get_system_type(void)
  34. {
  35. return "PMC-Sierra Yosemite";
  36. }
  37. static void prom_cpu0_exit(void *arg)
  38. {
  39. void *nvram = (void *) YOSEMITE_RTC_BASE;
  40. /* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */
  41. writeb(0x84, nvram + 0xff7);
  42. /* wait for the watchdog to go off */
  43. mdelay(100 + (1000 / 16));
  44. /* if the watchdog fails for some reason, let people know */
  45. printk(KERN_NOTICE "Watchdog reset failed\n");
  46. }
  47. /*
  48. * Reset the NVRAM over the local bus
  49. */
  50. static void prom_exit(void)
  51. {
  52. #ifdef CONFIG_SMP
  53. if (smp_processor_id())
  54. /* CPU 1 */
  55. smp_call_function(prom_cpu0_exit, NULL, 1);
  56. #endif
  57. prom_cpu0_exit(NULL);
  58. }
  59. /*
  60. * Halt the system
  61. */
  62. static void prom_halt(void)
  63. {
  64. printk(KERN_NOTICE "\n** You can safely turn off the power\n");
  65. while (1)
  66. __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");
  67. }
  68. extern struct plat_smp_ops yos_smp_ops;
  69. /*
  70. * Init routine which accepts the variables from PMON
  71. */
  72. void __init prom_init(void)
  73. {
  74. int argc = fw_arg0;
  75. char **arg = (char **) fw_arg1;
  76. char **env = (char **) fw_arg2;
  77. struct callvectors *cv = (struct callvectors *) fw_arg3;
  78. int i = 0;
  79. /* Callbacks for halt, restart */
  80. _machine_restart = (void (*)(char *)) prom_exit;
  81. _machine_halt = prom_halt;
  82. pm_power_off = prom_halt;
  83. debug_vectors = cv;
  84. arcs_cmdline[0] = '\0';
  85. /* Get the boot parameters */
  86. for (i = 1; i < argc; i++) {
  87. if (strlen(arcs_cmdline) + strlen(arg[i]) + 1 >=
  88. sizeof(arcs_cmdline))
  89. break;
  90. strcat(arcs_cmdline, arg[i]);
  91. strcat(arcs_cmdline, " ");
  92. }
  93. #ifdef CONFIG_SERIAL_8250_CONSOLE
  94. if ((strstr(arcs_cmdline, "console=ttyS")) == NULL)
  95. strcat(arcs_cmdline, "console=ttyS0,115200");
  96. #endif
  97. while (*env) {
  98. if (strncmp("ocd_base", *env, strlen("ocd_base")) == 0)
  99. yosemite_base =
  100. simple_strtol(*env + strlen("ocd_base="), NULL,
  101. 16);
  102. if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0)
  103. cpu_clock_freq =
  104. simple_strtol(*env + strlen("cpuclock="), NULL,
  105. 10);
  106. env++;
  107. }
  108. prom_grab_secondary();
  109. register_smp_ops(&yos_smp_ops);
  110. }
  111. void __init prom_free_prom_memory(void)
  112. {
  113. }
  114. void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
  115. {
  116. }