setup.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Arch related setup for Hexagon
  3. *
  4. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. #include <linux/init.h>
  21. #include <linux/bootmem.h>
  22. #include <linux/mmzone.h>
  23. #include <linux/mm.h>
  24. #include <linux/seq_file.h>
  25. #include <linux/console.h>
  26. #include <linux/of_fdt.h>
  27. #include <asm/io.h>
  28. #include <asm/sections.h>
  29. #include <asm/setup.h>
  30. #include <asm/processor.h>
  31. #include <asm/hexagon_vm.h>
  32. #include <asm/vm_mmu.h>
  33. #include <asm/time.h>
  34. #ifdef CONFIG_OF
  35. #include <asm/prom.h>
  36. #endif
  37. char cmd_line[COMMAND_LINE_SIZE];
  38. static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
  39. int on_simulator;
  40. void __cpuinit calibrate_delay(void)
  41. {
  42. loops_per_jiffy = thread_freq_mhz * 1000000 / HZ;
  43. }
  44. /*
  45. * setup_arch - high level architectural setup routine
  46. * @cmdline_p: pointer to pointer to command-line arguments
  47. */
  48. void __init setup_arch(char **cmdline_p)
  49. {
  50. char *p = &external_cmdline_buffer;
  51. /*
  52. * These will eventually be pulled in via either some hypervisor
  53. * or devicetree description. Hardwiring for now.
  54. */
  55. pcycle_freq_mhz = 600;
  56. thread_freq_mhz = 100;
  57. sleep_clk_freq = 32000;
  58. /*
  59. * Set up event bindings to handle exceptions and interrupts.
  60. */
  61. __vmsetvec(_K_VM_event_vector);
  62. /*
  63. * Simulator has a few differences from the hardware.
  64. * For now, check uninitialized-but-mapped memory
  65. * prior to invoking setup_arch_memory().
  66. */
  67. if (*(int *)((unsigned long)_end + 8) == 0x1f1f1f1f)
  68. on_simulator = 1;
  69. else
  70. on_simulator = 0;
  71. if (p[0] != '\0')
  72. strlcpy(boot_command_line, p, COMMAND_LINE_SIZE);
  73. else
  74. strlcpy(boot_command_line, default_command_line,
  75. COMMAND_LINE_SIZE);
  76. /*
  77. * boot_command_line and the value set up by setup_arch
  78. * are both picked up by the init code. If no reason to
  79. * make them different, pass the same pointer back.
  80. */
  81. strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
  82. *cmdline_p = cmd_line;
  83. parse_early_param();
  84. setup_arch_memory();
  85. #ifdef CONFIG_SMP
  86. smp_start_cpus();
  87. #endif
  88. }
  89. /*
  90. * Functions for dumping CPU info via /proc
  91. * Probably should move to kernel/proc.c or something.
  92. */
  93. static void *c_start(struct seq_file *m, loff_t *pos)
  94. {
  95. return *pos < nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL;
  96. }
  97. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  98. {
  99. ++*pos;
  100. return c_start(m, pos);
  101. }
  102. static void c_stop(struct seq_file *m, void *v)
  103. {
  104. }
  105. /*
  106. * Eventually this will dump information about
  107. * CPU properties like ISA level, TLB size, etc.
  108. */
  109. static int show_cpuinfo(struct seq_file *m, void *v)
  110. {
  111. int cpu = (unsigned long) v - 1;
  112. seq_printf(m, "processor\t: %d\n", cpu);
  113. seq_printf(m, "model name\t: Hexagon Virtual Machine\n");
  114. seq_printf(m, "BogoMips\t: %lu.%02lu\n",
  115. (loops_per_jiffy * HZ) / 500000,
  116. ((loops_per_jiffy * HZ) / 5000) % 100);
  117. seq_printf(m, "\n");
  118. return 0;
  119. }
  120. const struct seq_operations cpuinfo_op = {
  121. .start = &c_start,
  122. .next = &c_next,
  123. .stop = &c_stop,
  124. .show = &show_cpuinfo,
  125. };