setup.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Arch related setup for Hexagon
  3. *
  4. * Copyright (c) 2010-2013, 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. char cmd_line[COMMAND_LINE_SIZE];
  35. static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
  36. int on_simulator;
  37. void calibrate_delay(void)
  38. {
  39. loops_per_jiffy = thread_freq_mhz * 1000000 / HZ;
  40. }
  41. /*
  42. * setup_arch - high level architectural setup routine
  43. * @cmdline_p: pointer to pointer to command-line arguments
  44. */
  45. void __init setup_arch(char **cmdline_p)
  46. {
  47. char *p = &external_cmdline_buffer;
  48. /*
  49. * These will eventually be pulled in via either some hypervisor
  50. * or devicetree description. Hardwiring for now.
  51. */
  52. pcycle_freq_mhz = 600;
  53. thread_freq_mhz = 100;
  54. sleep_clk_freq = 32000;
  55. /*
  56. * Set up event bindings to handle exceptions and interrupts.
  57. */
  58. __vmsetvec(_K_VM_event_vector);
  59. printk(KERN_INFO "PHYS_OFFSET=0x%08x\n", PHYS_OFFSET);
  60. /*
  61. * Simulator has a few differences from the hardware.
  62. * For now, check uninitialized-but-mapped memory
  63. * prior to invoking setup_arch_memory().
  64. */
  65. if (*(int *)((unsigned long)_end + 8) == 0x1f1f1f1f)
  66. on_simulator = 1;
  67. else
  68. on_simulator = 0;
  69. if (p[0] != '\0')
  70. strlcpy(boot_command_line, p, COMMAND_LINE_SIZE);
  71. else
  72. strlcpy(boot_command_line, default_command_line,
  73. COMMAND_LINE_SIZE);
  74. /*
  75. * boot_command_line and the value set up by setup_arch
  76. * are both picked up by the init code. If no reason to
  77. * make them different, pass the same pointer back.
  78. */
  79. strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
  80. *cmdline_p = cmd_line;
  81. parse_early_param();
  82. setup_arch_memory();
  83. #ifdef CONFIG_SMP
  84. smp_start_cpus();
  85. #endif
  86. }
  87. /*
  88. * Functions for dumping CPU info via /proc
  89. * Probably should move to kernel/proc.c or something.
  90. */
  91. static void *c_start(struct seq_file *m, loff_t *pos)
  92. {
  93. return *pos < nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL;
  94. }
  95. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  96. {
  97. ++*pos;
  98. return c_start(m, pos);
  99. }
  100. static void c_stop(struct seq_file *m, void *v)
  101. {
  102. }
  103. /*
  104. * Eventually this will dump information about
  105. * CPU properties like ISA level, TLB size, etc.
  106. */
  107. static int show_cpuinfo(struct seq_file *m, void *v)
  108. {
  109. int cpu = (unsigned long) v - 1;
  110. #ifdef CONFIG_SMP
  111. if (!cpu_online(cpu))
  112. return 0;
  113. #endif
  114. seq_printf(m, "processor\t: %d\n", cpu);
  115. seq_printf(m, "model name\t: Hexagon Virtual Machine\n");
  116. seq_printf(m, "BogoMips\t: %lu.%02lu\n",
  117. (loops_per_jiffy * HZ) / 500000,
  118. ((loops_per_jiffy * HZ) / 5000) % 100);
  119. seq_printf(m, "\n");
  120. return 0;
  121. }
  122. const struct seq_operations cpuinfo_op = {
  123. .start = &c_start,
  124. .next = &c_next,
  125. .stop = &c_stop,
  126. .show = &show_cpuinfo,
  127. };