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/system.h>
  23. #include <asm/bootinfo.h>
  24. #include <asm/pmon.h>
  25. #ifdef CONFIG_SMP
  26. extern void prom_grab_secondary(void);
  27. #else
  28. #define prom_grab_secondary() do { } while (0)
  29. #endif
  30. #include "setup.h"
  31. struct callvectors *debug_vectors;
  32. extern unsigned long yosemite_base;
  33. extern unsigned long cpu_clock_freq;
  34. const char *get_system_type(void)
  35. {
  36. return "PMC-Sierra Yosemite";
  37. }
  38. static void prom_cpu0_exit(void *arg)
  39. {
  40. void *nvram = (void *) YOSEMITE_RTC_BASE;
  41. /* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */
  42. writeb(0x84, nvram + 0xff7);
  43. /* wait for the watchdog to go off */
  44. mdelay(100 + (1000 / 16));
  45. /* if the watchdog fails for some reason, let people know */
  46. printk(KERN_NOTICE "Watchdog reset failed\n");
  47. }
  48. /*
  49. * Reset the NVRAM over the local bus
  50. */
  51. static void prom_exit(void)
  52. {
  53. #ifdef CONFIG_SMP
  54. if (smp_processor_id())
  55. /* CPU 1 */
  56. smp_call_function(prom_cpu0_exit, NULL, 1);
  57. #endif
  58. prom_cpu0_exit(NULL);
  59. }
  60. /*
  61. * Halt the system
  62. */
  63. static void prom_halt(void)
  64. {
  65. printk(KERN_NOTICE "\n** You can safely turn off the power\n");
  66. while (1)
  67. __asm__(".set\tmips3\n\t" "wait\n\t" ".set\tmips0");
  68. }
  69. extern struct plat_smp_ops yos_smp_ops;
  70. /*
  71. * Init routine which accepts the variables from PMON
  72. */
  73. void __init prom_init(void)
  74. {
  75. int argc = fw_arg0;
  76. char **arg = (char **) fw_arg1;
  77. char **env = (char **) fw_arg2;
  78. struct callvectors *cv = (struct callvectors *) fw_arg3;
  79. int i = 0;
  80. /* Callbacks for halt, restart */
  81. _machine_restart = (void (*)(char *)) prom_exit;
  82. _machine_halt = prom_halt;
  83. pm_power_off = prom_halt;
  84. debug_vectors = cv;
  85. arcs_cmdline[0] = '\0';
  86. /* Get the boot parameters */
  87. for (i = 1; i < argc; i++) {
  88. if (strlen(arcs_cmdline) + strlen(arg[i] + 1) >=
  89. sizeof(arcs_cmdline))
  90. break;
  91. strcat(arcs_cmdline, arg[i]);
  92. strcat(arcs_cmdline, " ");
  93. }
  94. #ifdef CONFIG_SERIAL_8250_CONSOLE
  95. if ((strstr(arcs_cmdline, "console=ttyS")) == NULL)
  96. strcat(arcs_cmdline, "console=ttyS0,115200");
  97. #endif
  98. while (*env) {
  99. if (strncmp("ocd_base", *env, strlen("ocd_base")) == 0)
  100. yosemite_base =
  101. simple_strtol(*env + strlen("ocd_base="), NULL,
  102. 16);
  103. if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0)
  104. cpu_clock_freq =
  105. simple_strtol(*env + strlen("cpuclock="), NULL,
  106. 10);
  107. env++;
  108. }
  109. prom_grab_secondary();
  110. register_smp_ops(&yos_smp_ops);
  111. }
  112. void __init prom_free_prom_memory(void)
  113. {
  114. }
  115. void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
  116. {
  117. }