setup.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/seq_file.h>
  9. #include <linux/fs.h>
  10. #include <linux/delay.h>
  11. #include <linux/root_dev.h>
  12. #include <linux/console.h>
  13. #include <linux/module.h>
  14. #include <linux/cpu.h>
  15. #include <asm/arcregs.h>
  16. #include <asm/tlb.h>
  17. #include <asm/cache.h>
  18. #include <asm/setup.h>
  19. #include <asm/page.h>
  20. #include <asm/irq.h>
  21. #include <asm/arcregs.h>
  22. #define FIX_PTR(x) __asm__ __volatile__(";" : "+r"(x))
  23. int running_on_hw = 1; /* vs. on ISS */
  24. char __initdata command_line[COMMAND_LINE_SIZE];
  25. struct task_struct *_current_task[NR_CPUS]; /* For stack switching */
  26. struct cpuinfo_arc cpuinfo_arc700[NR_CPUS];
  27. void __init read_arc_build_cfg_regs(void)
  28. {
  29. read_decode_mmu_bcr();
  30. read_decode_cache_bcr();
  31. }
  32. /*
  33. * Initialize and setup the processor core
  34. * This is called by all the CPUs thus should not do special case stuff
  35. * such as only for boot CPU etc
  36. */
  37. void __init setup_processor(void)
  38. {
  39. read_arc_build_cfg_regs();
  40. arc_init_IRQ();
  41. arc_mmu_init();
  42. arc_cache_init();
  43. }
  44. void __init __attribute__((weak)) arc_platform_early_init(void)
  45. {
  46. }
  47. void __init setup_arch(char **cmdline_p)
  48. {
  49. #ifdef CONFIG_CMDLINE_UBOOT
  50. /* Make sure that a whitespace is inserted before */
  51. strlcat(command_line, " ", sizeof(command_line));
  52. #endif
  53. /*
  54. * Append .config cmdline to base command line, which might already
  55. * contain u-boot "bootargs" (handled by head.S, if so configured)
  56. */
  57. strlcat(command_line, CONFIG_CMDLINE, sizeof(command_line));
  58. /* Save unparsed command line copy for /proc/cmdline */
  59. strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
  60. *cmdline_p = command_line;
  61. /* To force early parsing of things like mem=xxx */
  62. parse_early_param();
  63. /* Platform/board specific: e.g. early console registration */
  64. arc_platform_early_init();
  65. setup_processor();
  66. setup_arch_memory();
  67. /* Can be issue if someone passes cmd line arg "ro"
  68. * But that is unlikely so keeping it as it is
  69. */
  70. root_mountflags &= ~MS_RDONLY;
  71. console_verbose();
  72. #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE)
  73. conswitchp = &dummy_con;
  74. #endif
  75. }
  76. /*
  77. * Get CPU information for use by the procfs.
  78. */
  79. #define cpu_to_ptr(c) ((void *)(0xFFFF0000 | (unsigned int)(c)))
  80. #define ptr_to_cpu(p) (~0xFFFF0000UL & (unsigned int)(p))
  81. static int show_cpuinfo(struct seq_file *m, void *v)
  82. {
  83. char *str;
  84. int cpu_id = ptr_to_cpu(v);
  85. str = (char *)__get_free_page(GFP_TEMPORARY);
  86. if (!str)
  87. goto done;
  88. seq_printf(m, "ARC700 #%d\n", cpu_id);
  89. seq_printf(m, "Bogo MIPS : \t%lu.%02lu\n",
  90. loops_per_jiffy / (500000 / HZ),
  91. (loops_per_jiffy / (5000 / HZ)) % 100);
  92. free_page((unsigned long)str);
  93. done:
  94. seq_printf(m, "\n\n");
  95. return 0;
  96. }
  97. static void *c_start(struct seq_file *m, loff_t *pos)
  98. {
  99. /*
  100. * Callback returns cpu-id to iterator for show routine, NULL to stop.
  101. * However since NULL is also a valid cpu-id (0), we use a round-about
  102. * way to pass it w/o having to kmalloc/free a 2 byte string.
  103. * Encode cpu-id as 0xFFcccc, which is decoded by show routine.
  104. */
  105. return *pos < num_possible_cpus() ? cpu_to_ptr(*pos) : NULL;
  106. }
  107. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  108. {
  109. ++*pos;
  110. return c_start(m, pos);
  111. }
  112. static void c_stop(struct seq_file *m, void *v)
  113. {
  114. }
  115. const struct seq_operations cpuinfo_op = {
  116. .start = c_start,
  117. .next = c_next,
  118. .stop = c_stop,
  119. .show = show_cpuinfo
  120. };
  121. static DEFINE_PER_CPU(struct cpu, cpu_topology);
  122. static int __init topology_init(void)
  123. {
  124. int cpu;
  125. for_each_present_cpu(cpu)
  126. register_cpu(&per_cpu(cpu_topology, cpu), cpu);
  127. return 0;
  128. }
  129. subsys_initcall(topology_init);