setup.c 3.7 KB

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