setup.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. #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 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. printk(KERN_INFO "PHYS_OFFSET=0x%08x\n", PHYS_OFFSET);
  63. /*
  64. * Simulator has a few differences from the hardware.
  65. * For now, check uninitialized-but-mapped memory
  66. * prior to invoking setup_arch_memory().
  67. */
  68. if (*(int *)((unsigned long)_end + 8) == 0x1f1f1f1f)
  69. on_simulator = 1;
  70. else
  71. on_simulator = 0;
  72. if (p[0] != '\0')
  73. strlcpy(boot_command_line, p, COMMAND_LINE_SIZE);
  74. else
  75. strlcpy(boot_command_line, default_command_line,
  76. COMMAND_LINE_SIZE);
  77. /*
  78. * boot_command_line and the value set up by setup_arch
  79. * are both picked up by the init code. If no reason to
  80. * make them different, pass the same pointer back.
  81. */
  82. strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
  83. *cmdline_p = cmd_line;
  84. parse_early_param();
  85. setup_arch_memory();
  86. #ifdef CONFIG_SMP
  87. smp_start_cpus();
  88. #endif
  89. }
  90. /*
  91. * Functions for dumping CPU info via /proc
  92. * Probably should move to kernel/proc.c or something.
  93. */
  94. static void *c_start(struct seq_file *m, loff_t *pos)
  95. {
  96. return *pos < nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL;
  97. }
  98. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  99. {
  100. ++*pos;
  101. return c_start(m, pos);
  102. }
  103. static void c_stop(struct seq_file *m, void *v)
  104. {
  105. }
  106. /*
  107. * Eventually this will dump information about
  108. * CPU properties like ISA level, TLB size, etc.
  109. */
  110. static int show_cpuinfo(struct seq_file *m, void *v)
  111. {
  112. int cpu = (unsigned long) v - 1;
  113. #ifdef CONFIG_SMP
  114. if (!cpu_online(cpu))
  115. return 0;
  116. #endif
  117. seq_printf(m, "processor\t: %d\n", cpu);
  118. seq_printf(m, "model name\t: Hexagon Virtual Machine\n");
  119. seq_printf(m, "BogoMips\t: %lu.%02lu\n",
  120. (loops_per_jiffy * HZ) / 500000,
  121. ((loops_per_jiffy * HZ) / 5000) % 100);
  122. seq_printf(m, "\n");
  123. return 0;
  124. }
  125. const struct seq_operations cpuinfo_op = {
  126. .start = &c_start,
  127. .next = &c_next,
  128. .stop = &c_stop,
  129. .show = &show_cpuinfo,
  130. };