setup.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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/clk-provider.h>
  13. #include <linux/clocksource.h>
  14. #include <linux/console.h>
  15. #include <linux/module.h>
  16. #include <linux/cpu.h>
  17. #include <linux/of_fdt.h>
  18. #include <linux/of.h>
  19. #include <linux/cache.h>
  20. #include <asm/sections.h>
  21. #include <asm/arcregs.h>
  22. #include <asm/tlb.h>
  23. #include <asm/setup.h>
  24. #include <asm/page.h>
  25. #include <asm/irq.h>
  26. #include <asm/unwind.h>
  27. #include <asm/mach_desc.h>
  28. #include <asm/smp.h>
  29. #define FIX_PTR(x) __asm__ __volatile__(";" : "+r"(x))
  30. unsigned int intr_to_DE_cnt;
  31. /* Part of U-boot ABI: see head.S */
  32. int __initdata uboot_tag;
  33. char __initdata *uboot_arg;
  34. const struct machine_desc *machine_desc;
  35. struct task_struct *_current_task[NR_CPUS]; /* For stack switching */
  36. struct cpuinfo_arc cpuinfo_arc700[NR_CPUS];
  37. static const struct id_to_str arc_cpu_rel[] = {
  38. #ifdef CONFIG_ISA_ARCOMPACT
  39. { 0x34, "R4.10"},
  40. { 0x35, "R4.11"},
  41. #else
  42. { 0x51, "R2.0" },
  43. { 0x52, "R2.1" },
  44. { 0x53, "R3.0" },
  45. #endif
  46. { 0x00, NULL }
  47. };
  48. static const struct id_to_str arc_cpu_nm[] = {
  49. #ifdef CONFIG_ISA_ARCOMPACT
  50. { 0x20, "ARC 600" },
  51. { 0x30, "ARC 770" }, /* 750 identified seperately */
  52. #else
  53. { 0x40, "ARC EM" },
  54. { 0x50, "ARC HS38" },
  55. #endif
  56. { 0x00, "Unknown" }
  57. };
  58. static void read_decode_ccm_bcr(struct cpuinfo_arc *cpu)
  59. {
  60. if (is_isa_arcompact()) {
  61. struct bcr_iccm_arcompact iccm;
  62. struct bcr_dccm_arcompact dccm;
  63. READ_BCR(ARC_REG_ICCM_BUILD, iccm);
  64. if (iccm.ver) {
  65. cpu->iccm.sz = 4096 << iccm.sz; /* 8K to 512K */
  66. cpu->iccm.base_addr = iccm.base << 16;
  67. }
  68. READ_BCR(ARC_REG_DCCM_BUILD, dccm);
  69. if (dccm.ver) {
  70. unsigned long base;
  71. cpu->dccm.sz = 2048 << dccm.sz; /* 2K to 256K */
  72. base = read_aux_reg(ARC_REG_DCCM_BASE_BUILD);
  73. cpu->dccm.base_addr = base & ~0xF;
  74. }
  75. } else {
  76. struct bcr_iccm_arcv2 iccm;
  77. struct bcr_dccm_arcv2 dccm;
  78. unsigned long region;
  79. READ_BCR(ARC_REG_ICCM_BUILD, iccm);
  80. if (iccm.ver) {
  81. cpu->iccm.sz = 256 << iccm.sz00; /* 512B to 16M */
  82. if (iccm.sz00 == 0xF && iccm.sz01 > 0)
  83. cpu->iccm.sz <<= iccm.sz01;
  84. region = read_aux_reg(ARC_REG_AUX_ICCM);
  85. cpu->iccm.base_addr = region & 0xF0000000;
  86. }
  87. READ_BCR(ARC_REG_DCCM_BUILD, dccm);
  88. if (dccm.ver) {
  89. cpu->dccm.sz = 256 << dccm.sz0;
  90. if (dccm.sz0 == 0xF && dccm.sz1 > 0)
  91. cpu->dccm.sz <<= dccm.sz1;
  92. region = read_aux_reg(ARC_REG_AUX_DCCM);
  93. cpu->dccm.base_addr = region & 0xF0000000;
  94. }
  95. }
  96. }
  97. static void read_arc_build_cfg_regs(void)
  98. {
  99. struct bcr_timer timer;
  100. struct bcr_generic bcr;
  101. struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
  102. const struct id_to_str *tbl;
  103. FIX_PTR(cpu);
  104. READ_BCR(AUX_IDENTITY, cpu->core);
  105. READ_BCR(ARC_REG_ISA_CFG_BCR, cpu->isa);
  106. for (tbl = &arc_cpu_rel[0]; tbl->id != 0; tbl++) {
  107. if (cpu->core.family == tbl->id) {
  108. cpu->details = tbl->str;
  109. break;
  110. }
  111. }
  112. for (tbl = &arc_cpu_nm[0]; tbl->id != 0; tbl++) {
  113. if ((cpu->core.family & 0xF0) == tbl->id)
  114. break;
  115. }
  116. cpu->name = tbl->str;
  117. READ_BCR(ARC_REG_TIMERS_BCR, timer);
  118. cpu->extn.timer0 = timer.t0;
  119. cpu->extn.timer1 = timer.t1;
  120. cpu->extn.rtc = timer.rtc;
  121. cpu->vec_base = read_aux_reg(AUX_INTR_VEC_BASE);
  122. READ_BCR(ARC_REG_MUL_BCR, cpu->extn_mpy);
  123. cpu->extn.norm = read_aux_reg(ARC_REG_NORM_BCR) > 1 ? 1 : 0; /* 2,3 */
  124. cpu->extn.barrel = read_aux_reg(ARC_REG_BARREL_BCR) > 1 ? 1 : 0; /* 2,3 */
  125. cpu->extn.swap = read_aux_reg(ARC_REG_SWAP_BCR) ? 1 : 0; /* 1,3 */
  126. cpu->extn.crc = read_aux_reg(ARC_REG_CRC_BCR) ? 1 : 0;
  127. cpu->extn.minmax = read_aux_reg(ARC_REG_MIXMAX_BCR) > 1 ? 1 : 0; /* 2 */
  128. cpu->extn.swape = (cpu->core.family >= 0x34) ? 1 :
  129. IS_ENABLED(CONFIG_ARC_HAS_SWAPE);
  130. READ_BCR(ARC_REG_XY_MEM_BCR, cpu->extn_xymem);
  131. /* Read CCM BCRs for boot reporting even if not enabled in Kconfig */
  132. read_decode_ccm_bcr(cpu);
  133. read_decode_mmu_bcr();
  134. read_decode_cache_bcr();
  135. if (is_isa_arcompact()) {
  136. struct bcr_fp_arcompact sp, dp;
  137. struct bcr_bpu_arcompact bpu;
  138. READ_BCR(ARC_REG_FP_BCR, sp);
  139. READ_BCR(ARC_REG_DPFP_BCR, dp);
  140. cpu->extn.fpu_sp = sp.ver ? 1 : 0;
  141. cpu->extn.fpu_dp = dp.ver ? 1 : 0;
  142. READ_BCR(ARC_REG_BPU_BCR, bpu);
  143. cpu->bpu.ver = bpu.ver;
  144. cpu->bpu.full = bpu.fam ? 1 : 0;
  145. if (bpu.ent) {
  146. cpu->bpu.num_cache = 256 << (bpu.ent - 1);
  147. cpu->bpu.num_pred = 256 << (bpu.ent - 1);
  148. }
  149. } else {
  150. struct bcr_fp_arcv2 spdp;
  151. struct bcr_bpu_arcv2 bpu;
  152. READ_BCR(ARC_REG_FP_V2_BCR, spdp);
  153. cpu->extn.fpu_sp = spdp.sp ? 1 : 0;
  154. cpu->extn.fpu_dp = spdp.dp ? 1 : 0;
  155. READ_BCR(ARC_REG_BPU_BCR, bpu);
  156. cpu->bpu.ver = bpu.ver;
  157. cpu->bpu.full = bpu.ft;
  158. cpu->bpu.num_cache = 256 << bpu.bce;
  159. cpu->bpu.num_pred = 2048 << bpu.pte;
  160. }
  161. READ_BCR(ARC_REG_AP_BCR, bcr);
  162. cpu->extn.ap = bcr.ver ? 1 : 0;
  163. READ_BCR(ARC_REG_SMART_BCR, bcr);
  164. cpu->extn.smart = bcr.ver ? 1 : 0;
  165. READ_BCR(ARC_REG_RTT_BCR, bcr);
  166. cpu->extn.rtt = bcr.ver ? 1 : 0;
  167. cpu->extn.debug = cpu->extn.ap | cpu->extn.smart | cpu->extn.rtt;
  168. /* some hacks for lack of feature BCR info in old ARC700 cores */
  169. if (is_isa_arcompact()) {
  170. if (!cpu->isa.ver) /* ISA BCR absent, use Kconfig info */
  171. cpu->isa.atomic = IS_ENABLED(CONFIG_ARC_HAS_LLSC);
  172. else
  173. cpu->isa.atomic = cpu->isa.atomic1;
  174. cpu->isa.be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
  175. /* there's no direct way to distinguish 750 vs. 770 */
  176. if (unlikely(cpu->core.family < 0x34 || cpu->mmu.ver < 3))
  177. cpu->name = "ARC750";
  178. }
  179. }
  180. static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
  181. {
  182. struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id];
  183. struct bcr_identity *core = &cpu->core;
  184. int i, n = 0;
  185. FIX_PTR(cpu);
  186. n += scnprintf(buf + n, len - n,
  187. "\nIDENTITY\t: ARCVER [%#02x] ARCNUM [%#02x] CHIPID [%#4x]\n",
  188. core->family, core->cpu_id, core->chip_id);
  189. n += scnprintf(buf + n, len - n, "processor [%d]\t: %s %s (%s ISA) %s\n",
  190. cpu_id, cpu->name, cpu->details,
  191. is_isa_arcompact() ? "ARCompact" : "ARCv2",
  192. IS_AVAIL1(cpu->isa.be, "[Big-Endian]"));
  193. n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s%s%s\nISA Extn\t: ",
  194. IS_AVAIL1(cpu->extn.timer0, "Timer0 "),
  195. IS_AVAIL1(cpu->extn.timer1, "Timer1 "),
  196. IS_AVAIL2(cpu->extn.rtc, "RTC [UP 64-bit] ", CONFIG_ARC_TIMERS_64BIT),
  197. IS_AVAIL2(cpu->extn.gfrc, "GFRC [SMP 64-bit] ", CONFIG_ARC_TIMERS_64BIT));
  198. n += i = scnprintf(buf + n, len - n, "%s%s%s%s%s",
  199. IS_AVAIL2(cpu->isa.atomic, "atomic ", CONFIG_ARC_HAS_LLSC),
  200. IS_AVAIL2(cpu->isa.ldd, "ll64 ", CONFIG_ARC_HAS_LL64),
  201. IS_AVAIL1(cpu->isa.unalign, "unalign (not used)"));
  202. if (i)
  203. n += scnprintf(buf + n, len - n, "\n\t\t: ");
  204. if (cpu->extn_mpy.ver) {
  205. if (cpu->extn_mpy.ver <= 0x2) { /* ARCompact */
  206. n += scnprintf(buf + n, len - n, "mpy ");
  207. } else {
  208. int opt = 2; /* stock MPY/MPYH */
  209. if (cpu->extn_mpy.dsp) /* OPT 7-9 */
  210. opt = cpu->extn_mpy.dsp + 6;
  211. n += scnprintf(buf + n, len - n, "mpy[opt %d] ", opt);
  212. }
  213. }
  214. n += scnprintf(buf + n, len - n, "%s%s%s%s%s%s%s%s\n",
  215. IS_AVAIL1(cpu->isa.div_rem, "div_rem "),
  216. IS_AVAIL1(cpu->extn.norm, "norm "),
  217. IS_AVAIL1(cpu->extn.barrel, "barrel-shift "),
  218. IS_AVAIL1(cpu->extn.swap, "swap "),
  219. IS_AVAIL1(cpu->extn.minmax, "minmax "),
  220. IS_AVAIL1(cpu->extn.crc, "crc "),
  221. IS_AVAIL2(cpu->extn.swape, "swape", CONFIG_ARC_HAS_SWAPE));
  222. if (cpu->bpu.ver)
  223. n += scnprintf(buf + n, len - n,
  224. "BPU\t\t: %s%s match, cache:%d, Predict Table:%d\n",
  225. IS_AVAIL1(cpu->bpu.full, "full"),
  226. IS_AVAIL1(!cpu->bpu.full, "partial"),
  227. cpu->bpu.num_cache, cpu->bpu.num_pred);
  228. return buf;
  229. }
  230. static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
  231. {
  232. int n = 0;
  233. struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id];
  234. FIX_PTR(cpu);
  235. n += scnprintf(buf + n, len - n, "Vector Table\t: %#x\n", cpu->vec_base);
  236. if (cpu->extn.fpu_sp || cpu->extn.fpu_dp)
  237. n += scnprintf(buf + n, len - n, "FPU\t\t: %s%s\n",
  238. IS_AVAIL1(cpu->extn.fpu_sp, "SP "),
  239. IS_AVAIL1(cpu->extn.fpu_dp, "DP "));
  240. if (cpu->extn.debug)
  241. n += scnprintf(buf + n, len - n, "DEBUG\t\t: %s%s%s\n",
  242. IS_AVAIL1(cpu->extn.ap, "ActionPoint "),
  243. IS_AVAIL1(cpu->extn.smart, "smaRT "),
  244. IS_AVAIL1(cpu->extn.rtt, "RTT "));
  245. if (cpu->dccm.sz || cpu->iccm.sz)
  246. n += scnprintf(buf + n, len - n, "Extn [CCM]\t: DCCM @ %x, %d KB / ICCM: @ %x, %d KB\n",
  247. cpu->dccm.base_addr, TO_KB(cpu->dccm.sz),
  248. cpu->iccm.base_addr, TO_KB(cpu->iccm.sz));
  249. n += scnprintf(buf + n, len - n, "OS ABI [v%d]\t: %s\n",
  250. EF_ARC_OSABI_CURRENT >> 8,
  251. EF_ARC_OSABI_CURRENT == EF_ARC_OSABI_V3 ?
  252. "no-legacy-syscalls" : "64-bit data any register aligned");
  253. return buf;
  254. }
  255. static void arc_chk_core_config(void)
  256. {
  257. struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
  258. int fpu_enabled;
  259. if (!cpu->extn.timer0)
  260. panic("Timer0 is not present!\n");
  261. if (!cpu->extn.timer1)
  262. panic("Timer1 is not present!\n");
  263. #ifdef CONFIG_ARC_HAS_DCCM
  264. /*
  265. * DCCM can be arbit placed in hardware.
  266. * Make sure it's placement/sz matches what Linux is built with
  267. */
  268. if ((unsigned int)__arc_dccm_base != cpu->dccm.base_addr)
  269. panic("Linux built with incorrect DCCM Base address\n");
  270. if (CONFIG_ARC_DCCM_SZ != cpu->dccm.sz)
  271. panic("Linux built with incorrect DCCM Size\n");
  272. #endif
  273. #ifdef CONFIG_ARC_HAS_ICCM
  274. if (CONFIG_ARC_ICCM_SZ != cpu->iccm.sz)
  275. panic("Linux built with incorrect ICCM Size\n");
  276. #endif
  277. /*
  278. * FP hardware/software config sanity
  279. * -If hardware contains DPFP, kernel needs to save/restore FPU state
  280. * -If not, it will crash trying to save/restore the non-existant regs
  281. *
  282. * (only DPDP checked since SP has no arch visible regs)
  283. */
  284. fpu_enabled = IS_ENABLED(CONFIG_ARC_FPU_SAVE_RESTORE);
  285. if (cpu->extn.fpu_dp && !fpu_enabled)
  286. pr_warn("CONFIG_ARC_FPU_SAVE_RESTORE needed for working apps\n");
  287. else if (!cpu->extn.fpu_dp && fpu_enabled)
  288. panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n");
  289. }
  290. /*
  291. * Initialize and setup the processor core
  292. * This is called by all the CPUs thus should not do special case stuff
  293. * such as only for boot CPU etc
  294. */
  295. void setup_processor(void)
  296. {
  297. char str[512];
  298. int cpu_id = smp_processor_id();
  299. read_arc_build_cfg_regs();
  300. arc_init_IRQ();
  301. printk(arc_cpu_mumbojumbo(cpu_id, str, sizeof(str)));
  302. arc_mmu_init();
  303. arc_cache_init();
  304. printk(arc_extn_mumbojumbo(cpu_id, str, sizeof(str)));
  305. printk(arc_platform_smp_cpuinfo());
  306. arc_chk_core_config();
  307. }
  308. static inline int is_kernel(unsigned long addr)
  309. {
  310. if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
  311. return 1;
  312. return 0;
  313. }
  314. void __init setup_arch(char **cmdline_p)
  315. {
  316. #ifdef CONFIG_ARC_UBOOT_SUPPORT
  317. /* make sure that uboot passed pointer to cmdline/dtb is valid */
  318. if (uboot_tag && is_kernel((unsigned long)uboot_arg))
  319. panic("Invalid uboot arg\n");
  320. /* See if u-boot passed an external Device Tree blob */
  321. machine_desc = setup_machine_fdt(uboot_arg); /* uboot_tag == 2 */
  322. if (!machine_desc)
  323. #endif
  324. {
  325. /* No, so try the embedded one */
  326. machine_desc = setup_machine_fdt(__dtb_start);
  327. if (!machine_desc)
  328. panic("Embedded DT invalid\n");
  329. /*
  330. * If we are here, it is established that @uboot_arg didn't
  331. * point to DT blob. Instead if u-boot says it is cmdline,
  332. * append to embedded DT cmdline.
  333. * setup_machine_fdt() would have populated @boot_command_line
  334. */
  335. if (uboot_tag == 1) {
  336. /* Ensure a whitespace between the 2 cmdlines */
  337. strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
  338. strlcat(boot_command_line, uboot_arg,
  339. COMMAND_LINE_SIZE);
  340. }
  341. }
  342. /* Save unparsed command line copy for /proc/cmdline */
  343. *cmdline_p = boot_command_line;
  344. /* To force early parsing of things like mem=xxx */
  345. parse_early_param();
  346. /* Platform/board specific: e.g. early console registration */
  347. if (machine_desc->init_early)
  348. machine_desc->init_early();
  349. smp_init_cpus();
  350. setup_processor();
  351. setup_arch_memory();
  352. /* copy flat DT out of .init and then unflatten it */
  353. unflatten_and_copy_device_tree();
  354. /* Can be issue if someone passes cmd line arg "ro"
  355. * But that is unlikely so keeping it as it is
  356. */
  357. root_mountflags &= ~MS_RDONLY;
  358. #if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE)
  359. conswitchp = &dummy_con;
  360. #endif
  361. arc_unwind_init();
  362. }
  363. /*
  364. * Called from start_kernel() - boot CPU only
  365. */
  366. void __init time_init(void)
  367. {
  368. of_clk_init(NULL);
  369. clocksource_probe();
  370. }
  371. static int __init customize_machine(void)
  372. {
  373. if (machine_desc->init_machine)
  374. machine_desc->init_machine();
  375. return 0;
  376. }
  377. arch_initcall(customize_machine);
  378. static int __init init_late_machine(void)
  379. {
  380. if (machine_desc->init_late)
  381. machine_desc->init_late();
  382. return 0;
  383. }
  384. late_initcall(init_late_machine);
  385. /*
  386. * Get CPU information for use by the procfs.
  387. */
  388. #define cpu_to_ptr(c) ((void *)(0xFFFF0000 | (unsigned int)(c)))
  389. #define ptr_to_cpu(p) (~0xFFFF0000UL & (unsigned int)(p))
  390. static int show_cpuinfo(struct seq_file *m, void *v)
  391. {
  392. char *str;
  393. int cpu_id = ptr_to_cpu(v);
  394. struct device_node *core_clk = of_find_node_by_name(NULL, "core_clk");
  395. u32 freq = 0;
  396. if (!cpu_online(cpu_id)) {
  397. seq_printf(m, "processor [%d]\t: Offline\n", cpu_id);
  398. goto done;
  399. }
  400. str = (char *)__get_free_page(GFP_TEMPORARY);
  401. if (!str)
  402. goto done;
  403. seq_printf(m, arc_cpu_mumbojumbo(cpu_id, str, PAGE_SIZE));
  404. of_property_read_u32(core_clk, "clock-frequency", &freq);
  405. if (freq)
  406. seq_printf(m, "CPU speed\t: %u.%02u Mhz\n",
  407. freq / 1000000, (freq / 10000) % 100);
  408. seq_printf(m, "Bogo MIPS\t: %lu.%02lu\n",
  409. loops_per_jiffy / (500000 / HZ),
  410. (loops_per_jiffy / (5000 / HZ)) % 100);
  411. seq_printf(m, arc_mmu_mumbojumbo(cpu_id, str, PAGE_SIZE));
  412. seq_printf(m, arc_cache_mumbojumbo(cpu_id, str, PAGE_SIZE));
  413. seq_printf(m, arc_extn_mumbojumbo(cpu_id, str, PAGE_SIZE));
  414. seq_printf(m, arc_platform_smp_cpuinfo());
  415. free_page((unsigned long)str);
  416. done:
  417. seq_printf(m, "\n");
  418. return 0;
  419. }
  420. static void *c_start(struct seq_file *m, loff_t *pos)
  421. {
  422. /*
  423. * Callback returns cpu-id to iterator for show routine, NULL to stop.
  424. * However since NULL is also a valid cpu-id (0), we use a round-about
  425. * way to pass it w/o having to kmalloc/free a 2 byte string.
  426. * Encode cpu-id as 0xFFcccc, which is decoded by show routine.
  427. */
  428. return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL;
  429. }
  430. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  431. {
  432. ++*pos;
  433. return c_start(m, pos);
  434. }
  435. static void c_stop(struct seq_file *m, void *v)
  436. {
  437. }
  438. const struct seq_operations cpuinfo_op = {
  439. .start = c_start,
  440. .next = c_next,
  441. .stop = c_stop,
  442. .show = show_cpuinfo
  443. };
  444. static DEFINE_PER_CPU(struct cpu, cpu_topology);
  445. static int __init topology_init(void)
  446. {
  447. int cpu;
  448. for_each_present_cpu(cpu)
  449. register_cpu(&per_cpu(cpu_topology, cpu), cpu);
  450. return 0;
  451. }
  452. subsys_initcall(topology_init);