setup.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /* MN10300 Arch-specific initialisation
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/errno.h>
  12. #include <linux/sched.h>
  13. #include <linux/kernel.h>
  14. #include <linux/mm.h>
  15. #include <linux/stddef.h>
  16. #include <linux/unistd.h>
  17. #include <linux/ptrace.h>
  18. #include <linux/user.h>
  19. #include <linux/tty.h>
  20. #include <linux/ioport.h>
  21. #include <linux/delay.h>
  22. #include <linux/init.h>
  23. #include <linux/bootmem.h>
  24. #include <linux/seq_file.h>
  25. #include <linux/cpu.h>
  26. #include <asm/processor.h>
  27. #include <linux/console.h>
  28. #include <asm/uaccess.h>
  29. #include <asm/setup.h>
  30. #include <asm/io.h>
  31. #include <asm/smp.h>
  32. #include <proc/proc.h>
  33. #include <asm/fpu.h>
  34. #include <asm/sections.h>
  35. struct mn10300_cpuinfo boot_cpu_data;
  36. /* For PCI or other memory-mapped resources */
  37. unsigned long pci_mem_start = 0x18000000;
  38. static char __initdata cmd_line[COMMAND_LINE_SIZE];
  39. char redboot_command_line[COMMAND_LINE_SIZE] =
  40. "console=ttyS0,115200 root=/dev/mtdblock3 rw";
  41. char __initdata redboot_platform_name[COMMAND_LINE_SIZE];
  42. static struct resource code_resource = {
  43. .start = 0x100000,
  44. .end = 0,
  45. .name = "Kernel code",
  46. };
  47. static struct resource data_resource = {
  48. .start = 0,
  49. .end = 0,
  50. .name = "Kernel data",
  51. };
  52. static unsigned long __initdata phys_memory_base;
  53. static unsigned long __initdata phys_memory_end;
  54. static unsigned long __initdata memory_end;
  55. unsigned long memory_size;
  56. struct thread_info *__current_ti = &init_thread_union.thread_info;
  57. struct task_struct *__current = &init_task;
  58. #define mn10300_known_cpus 5
  59. static const char *const mn10300_cputypes[] = {
  60. "am33-1",
  61. "am33-2",
  62. "am34-1",
  63. "am33-3",
  64. "am34-2",
  65. "unknown"
  66. };
  67. /*
  68. * Pick out the memory size. We look for mem=size,
  69. * where size is "size[KkMm]"
  70. */
  71. static int __init early_mem(char *p)
  72. {
  73. memory_size = memparse(p, &p);
  74. if (memory_size == 0)
  75. panic("Memory size not known\n");
  76. return 0;
  77. }
  78. early_param("mem", early_mem);
  79. /*
  80. * architecture specific setup
  81. */
  82. void __init setup_arch(char **cmdline_p)
  83. {
  84. unsigned long bootmap_size;
  85. unsigned long kstart_pfn, start_pfn, free_pfn, end_pfn;
  86. cpu_init();
  87. unit_setup();
  88. smp_init_cpus();
  89. /* save unparsed command line copy for /proc/cmdline */
  90. strlcpy(boot_command_line, redboot_command_line, COMMAND_LINE_SIZE);
  91. /* populate cmd_line too for later use, preserving boot_command_line */
  92. strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
  93. *cmdline_p = cmd_line;
  94. parse_early_param();
  95. memory_end = (unsigned long) CONFIG_KERNEL_RAM_BASE_ADDRESS +
  96. memory_size;
  97. if (memory_end > phys_memory_end)
  98. memory_end = phys_memory_end;
  99. init_mm.start_code = (unsigned long)&_text;
  100. init_mm.end_code = (unsigned long) &_etext;
  101. init_mm.end_data = (unsigned long) &_edata;
  102. init_mm.brk = (unsigned long) &_end;
  103. code_resource.start = virt_to_bus(&_text);
  104. code_resource.end = virt_to_bus(&_etext)-1;
  105. data_resource.start = virt_to_bus(&_etext);
  106. data_resource.end = virt_to_bus(&_edata)-1;
  107. start_pfn = (CONFIG_KERNEL_RAM_BASE_ADDRESS >> PAGE_SHIFT);
  108. kstart_pfn = PFN_UP(__pa(&_text));
  109. free_pfn = PFN_UP(__pa(&_end));
  110. end_pfn = PFN_DOWN(__pa(memory_end));
  111. bootmap_size = init_bootmem_node(&contig_page_data,
  112. free_pfn,
  113. start_pfn,
  114. end_pfn);
  115. if (kstart_pfn > start_pfn)
  116. free_bootmem(PFN_PHYS(start_pfn),
  117. PFN_PHYS(kstart_pfn - start_pfn));
  118. free_bootmem(PFN_PHYS(free_pfn),
  119. PFN_PHYS(end_pfn - free_pfn));
  120. /* If interrupt vector table is in main ram, then we need to
  121. reserve the page it is occupying. */
  122. if (CONFIG_INTERRUPT_VECTOR_BASE >= CONFIG_KERNEL_RAM_BASE_ADDRESS &&
  123. CONFIG_INTERRUPT_VECTOR_BASE < memory_end)
  124. reserve_bootmem(CONFIG_INTERRUPT_VECTOR_BASE, PAGE_SIZE,
  125. BOOTMEM_DEFAULT);
  126. reserve_bootmem(PAGE_ALIGN(PFN_PHYS(free_pfn)), bootmap_size,
  127. BOOTMEM_DEFAULT);
  128. #ifdef CONFIG_VT
  129. #if defined(CONFIG_VGA_CONSOLE)
  130. conswitchp = &vga_con;
  131. #elif defined(CONFIG_DUMMY_CONSOLE)
  132. conswitchp = &dummy_con;
  133. #endif
  134. #endif
  135. paging_init();
  136. }
  137. /*
  138. * perform CPU initialisation
  139. */
  140. void __init cpu_init(void)
  141. {
  142. unsigned long cpurev = CPUREV, type;
  143. type = (CPUREV & CPUREV_TYPE) >> CPUREV_TYPE_S;
  144. if (type > mn10300_known_cpus)
  145. type = mn10300_known_cpus;
  146. printk(KERN_INFO "Panasonic %s, rev %ld\n",
  147. mn10300_cputypes[type],
  148. (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S);
  149. get_mem_info(&phys_memory_base, &memory_size);
  150. phys_memory_end = phys_memory_base + memory_size;
  151. fpu_init_state();
  152. }
  153. static struct cpu cpu_devices[NR_CPUS];
  154. static int __init topology_init(void)
  155. {
  156. int i;
  157. for_each_present_cpu(i)
  158. register_cpu(&cpu_devices[i], i);
  159. return 0;
  160. }
  161. subsys_initcall(topology_init);
  162. /*
  163. * Get CPU information for use by the procfs.
  164. */
  165. static int show_cpuinfo(struct seq_file *m, void *v)
  166. {
  167. #ifdef CONFIG_SMP
  168. struct mn10300_cpuinfo *c = v;
  169. unsigned long cpu_id = c - cpu_data;
  170. unsigned long cpurev = c->type, type, icachesz, dcachesz;
  171. #else /* CONFIG_SMP */
  172. unsigned long cpu_id = 0;
  173. unsigned long cpurev = CPUREV, type, icachesz, dcachesz;
  174. #endif /* CONFIG_SMP */
  175. #ifdef CONFIG_SMP
  176. if (!cpu_online(cpu_id))
  177. return 0;
  178. #endif
  179. type = (cpurev & CPUREV_TYPE) >> CPUREV_TYPE_S;
  180. if (type > mn10300_known_cpus)
  181. type = mn10300_known_cpus;
  182. icachesz =
  183. ((cpurev & CPUREV_ICWAY ) >> CPUREV_ICWAY_S) *
  184. ((cpurev & CPUREV_ICSIZE) >> CPUREV_ICSIZE_S) *
  185. 1024;
  186. dcachesz =
  187. ((cpurev & CPUREV_DCWAY ) >> CPUREV_DCWAY_S) *
  188. ((cpurev & CPUREV_DCSIZE) >> CPUREV_DCSIZE_S) *
  189. 1024;
  190. seq_printf(m,
  191. "processor : %ld\n"
  192. "vendor_id : " PROCESSOR_VENDOR_NAME "\n"
  193. "cpu core : %s\n"
  194. "cpu rev : %lu\n"
  195. "model name : " PROCESSOR_MODEL_NAME "\n"
  196. "icache size: %lu\n"
  197. "dcache size: %lu\n",
  198. cpu_id,
  199. mn10300_cputypes[type],
  200. (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S,
  201. icachesz,
  202. dcachesz
  203. );
  204. seq_printf(m,
  205. "ioclk speed: %lu.%02luMHz\n"
  206. "bogomips : %lu.%02lu\n\n",
  207. MN10300_IOCLK / 1000000,
  208. (MN10300_IOCLK / 10000) % 100,
  209. #ifdef CONFIG_SMP
  210. c->loops_per_jiffy / (500000 / HZ),
  211. (c->loops_per_jiffy / (5000 / HZ)) % 100
  212. #else /* CONFIG_SMP */
  213. loops_per_jiffy / (500000 / HZ),
  214. (loops_per_jiffy / (5000 / HZ)) % 100
  215. #endif /* CONFIG_SMP */
  216. );
  217. return 0;
  218. }
  219. static void *c_start(struct seq_file *m, loff_t *pos)
  220. {
  221. return *pos < NR_CPUS ? cpu_data + *pos : NULL;
  222. }
  223. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  224. {
  225. ++*pos;
  226. return c_start(m, pos);
  227. }
  228. static void c_stop(struct seq_file *m, void *v)
  229. {
  230. }
  231. const struct seq_operations cpuinfo_op = {
  232. .start = c_start,
  233. .next = c_next,
  234. .stop = c_stop,
  235. .show = show_cpuinfo,
  236. };