setup.c 3.0 KB

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