123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701 |
- // SPDX-License-Identifier: GPL-2.0-only
- /*
- * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
- */
- #include <linux/seq_file.h>
- #include <linux/fs.h>
- #include <linux/delay.h>
- #include <linux/root_dev.h>
- #include <linux/clk.h>
- #include <linux/clocksource.h>
- #include <linux/console.h>
- #include <linux/module.h>
- #include <linux/sizes.h>
- #include <linux/cpu.h>
- #include <linux/of_clk.h>
- #include <linux/of_fdt.h>
- #include <linux/of.h>
- #include <linux/cache.h>
- #include <uapi/linux/mount.h>
- #include <asm/sections.h>
- #include <asm/arcregs.h>
- #include <asm/asserts.h>
- #include <asm/tlb.h>
- #include <asm/setup.h>
- #include <asm/page.h>
- #include <asm/irq.h>
- #include <asm/unwind.h>
- #include <asm/mach_desc.h>
- #include <asm/smp.h>
- #include <asm/dsp-impl.h>
- #define FIX_PTR(x) __asm__ __volatile__(";" : "+r"(x))
- unsigned int intr_to_DE_cnt;
- /* Part of U-boot ABI: see head.S */
- int __initdata uboot_tag;
- int __initdata uboot_magic;
- char __initdata *uboot_arg;
- const struct machine_desc *machine_desc;
- struct task_struct *_current_task[NR_CPUS]; /* For stack switching */
- struct cpuinfo_arc cpuinfo_arc700[NR_CPUS];
- static const struct id_to_str arc_legacy_rel[] = {
- /* ID.ARCVER, Release */
- #ifdef CONFIG_ISA_ARCOMPACT
- { 0x34, "R4.10"},
- { 0x35, "R4.11"},
- #else
- { 0x51, "R2.0" },
- { 0x52, "R2.1" },
- { 0x53, "R3.0" },
- #endif
- { 0x00, NULL }
- };
- static const struct id_to_str arc_hs_ver54_rel[] = {
- /* UARCH.MAJOR, Release */
- { 0, "R3.10a"},
- { 1, "R3.50a"},
- { 2, "R3.60a"},
- { 3, "R4.00a"},
- { 0xFF, NULL }
- };
- static void read_decode_ccm_bcr(struct cpuinfo_arc *cpu)
- {
- if (is_isa_arcompact()) {
- struct bcr_iccm_arcompact iccm;
- struct bcr_dccm_arcompact dccm;
- READ_BCR(ARC_REG_ICCM_BUILD, iccm);
- if (iccm.ver) {
- cpu->iccm.sz = 4096 << iccm.sz; /* 8K to 512K */
- cpu->iccm.base_addr = iccm.base << 16;
- }
- READ_BCR(ARC_REG_DCCM_BUILD, dccm);
- if (dccm.ver) {
- unsigned long base;
- cpu->dccm.sz = 2048 << dccm.sz; /* 2K to 256K */
- base = read_aux_reg(ARC_REG_DCCM_BASE_BUILD);
- cpu->dccm.base_addr = base & ~0xF;
- }
- } else {
- struct bcr_iccm_arcv2 iccm;
- struct bcr_dccm_arcv2 dccm;
- unsigned long region;
- READ_BCR(ARC_REG_ICCM_BUILD, iccm);
- if (iccm.ver) {
- cpu->iccm.sz = 256 << iccm.sz00; /* 512B to 16M */
- if (iccm.sz00 == 0xF && iccm.sz01 > 0)
- cpu->iccm.sz <<= iccm.sz01;
- region = read_aux_reg(ARC_REG_AUX_ICCM);
- cpu->iccm.base_addr = region & 0xF0000000;
- }
- READ_BCR(ARC_REG_DCCM_BUILD, dccm);
- if (dccm.ver) {
- cpu->dccm.sz = 256 << dccm.sz0;
- if (dccm.sz0 == 0xF && dccm.sz1 > 0)
- cpu->dccm.sz <<= dccm.sz1;
- region = read_aux_reg(ARC_REG_AUX_DCCM);
- cpu->dccm.base_addr = region & 0xF0000000;
- }
- }
- }
- static void decode_arc_core(struct cpuinfo_arc *cpu)
- {
- struct bcr_uarch_build_arcv2 uarch;
- const struct id_to_str *tbl;
- if (cpu->core.family < 0x54) { /* includes arc700 */
- for (tbl = &arc_legacy_rel[0]; tbl->id != 0; tbl++) {
- if (cpu->core.family == tbl->id) {
- cpu->release = tbl->str;
- break;
- }
- }
- if (is_isa_arcompact())
- cpu->name = "ARC700";
- else if (tbl->str)
- cpu->name = "HS38";
- else
- cpu->name = cpu->release = "Unknown";
- return;
- }
- /*
- * Initial HS cores bumped AUX IDENTITY.ARCVER for each release until
- * ARCVER 0x54 which introduced AUX MICRO_ARCH_BUILD and subsequent
- * releases only update it.
- */
- READ_BCR(ARC_REG_MICRO_ARCH_BCR, uarch);
- if (uarch.prod == 4) {
- cpu->name = "HS48";
- cpu->extn.dual = 1;
- } else {
- cpu->name = "HS38";
- }
- for (tbl = &arc_hs_ver54_rel[0]; tbl->id != 0xFF; tbl++) {
- if (uarch.maj == tbl->id) {
- cpu->release = tbl->str;
- break;
- }
- }
- }
- static void read_arc_build_cfg_regs(void)
- {
- struct bcr_timer timer;
- struct bcr_generic bcr;
- struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
- struct bcr_isa_arcv2 isa;
- struct bcr_actionpoint ap;
- FIX_PTR(cpu);
- READ_BCR(AUX_IDENTITY, cpu->core);
- decode_arc_core(cpu);
- READ_BCR(ARC_REG_TIMERS_BCR, timer);
- cpu->extn.timer0 = timer.t0;
- cpu->extn.timer1 = timer.t1;
- cpu->extn.rtc = timer.rtc;
- cpu->vec_base = read_aux_reg(AUX_INTR_VEC_BASE);
- READ_BCR(ARC_REG_MUL_BCR, cpu->extn_mpy);
- /* Read CCM BCRs for boot reporting even if not enabled in Kconfig */
- read_decode_ccm_bcr(cpu);
- read_decode_mmu_bcr();
- read_decode_cache_bcr();
- if (is_isa_arcompact()) {
- struct bcr_fp_arcompact sp, dp;
- struct bcr_bpu_arcompact bpu;
- READ_BCR(ARC_REG_FP_BCR, sp);
- READ_BCR(ARC_REG_DPFP_BCR, dp);
- cpu->extn.fpu_sp = sp.ver ? 1 : 0;
- cpu->extn.fpu_dp = dp.ver ? 1 : 0;
- READ_BCR(ARC_REG_BPU_BCR, bpu);
- cpu->bpu.ver = bpu.ver;
- cpu->bpu.full = bpu.fam ? 1 : 0;
- if (bpu.ent) {
- cpu->bpu.num_cache = 256 << (bpu.ent - 1);
- cpu->bpu.num_pred = 256 << (bpu.ent - 1);
- }
- } else {
- struct bcr_fp_arcv2 spdp;
- struct bcr_bpu_arcv2 bpu;
- READ_BCR(ARC_REG_FP_V2_BCR, spdp);
- cpu->extn.fpu_sp = spdp.sp ? 1 : 0;
- cpu->extn.fpu_dp = spdp.dp ? 1 : 0;
- READ_BCR(ARC_REG_BPU_BCR, bpu);
- cpu->bpu.ver = bpu.ver;
- cpu->bpu.full = bpu.ft;
- cpu->bpu.num_cache = 256 << bpu.bce;
- cpu->bpu.num_pred = 2048 << bpu.pte;
- cpu->bpu.ret_stk = 4 << bpu.rse;
- /* if dual issue hardware, is it enabled ? */
- if (cpu->extn.dual) {
- unsigned int exec_ctrl;
- READ_BCR(AUX_EXEC_CTRL, exec_ctrl);
- cpu->extn.dual_enb = !(exec_ctrl & 1);
- }
- }
- READ_BCR(ARC_REG_AP_BCR, ap);
- if (ap.ver) {
- cpu->extn.ap_num = 2 << ap.num;
- cpu->extn.ap_full = !ap.min;
- }
- READ_BCR(ARC_REG_SMART_BCR, bcr);
- cpu->extn.smart = bcr.ver ? 1 : 0;
- READ_BCR(ARC_REG_RTT_BCR, bcr);
- cpu->extn.rtt = bcr.ver ? 1 : 0;
- READ_BCR(ARC_REG_ISA_CFG_BCR, isa);
- /* some hacks for lack of feature BCR info in old ARC700 cores */
- if (is_isa_arcompact()) {
- if (!isa.ver) /* ISA BCR absent, use Kconfig info */
- cpu->isa.atomic = IS_ENABLED(CONFIG_ARC_HAS_LLSC);
- else {
- /* ARC700_BUILD only has 2 bits of isa info */
- struct bcr_generic bcr = *(struct bcr_generic *)&isa;
- cpu->isa.atomic = bcr.info & 1;
- }
- cpu->isa.be = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN);
- /* there's no direct way to distinguish 750 vs. 770 */
- if (unlikely(cpu->core.family < 0x34 || cpu->mmu.ver < 3))
- cpu->name = "ARC750";
- } else {
- cpu->isa = isa;
- }
- }
- static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
- {
- struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id];
- struct bcr_identity *core = &cpu->core;
- char mpy_opt[16];
- int n = 0;
- FIX_PTR(cpu);
- n += scnprintf(buf + n, len - n,
- "\nIDENTITY\t: ARCVER [%#02x] ARCNUM [%#02x] CHIPID [%#4x]\n",
- core->family, core->cpu_id, core->chip_id);
- n += scnprintf(buf + n, len - n, "processor [%d]\t: %s %s (%s ISA) %s%s%s\n",
- cpu_id, cpu->name, cpu->release,
- is_isa_arcompact() ? "ARCompact" : "ARCv2",
- IS_AVAIL1(cpu->isa.be, "[Big-Endian]"),
- IS_AVAIL3(cpu->extn.dual, cpu->extn.dual_enb, " Dual-Issue "));
- n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s%s%s\nISA Extn\t: ",
- IS_AVAIL1(cpu->extn.timer0, "Timer0 "),
- IS_AVAIL1(cpu->extn.timer1, "Timer1 "),
- IS_AVAIL2(cpu->extn.rtc, "RTC [UP 64-bit] ", CONFIG_ARC_TIMERS_64BIT),
- IS_AVAIL2(cpu->extn.gfrc, "GFRC [SMP 64-bit] ", CONFIG_ARC_TIMERS_64BIT));
- if (cpu->extn_mpy.ver) {
- if (is_isa_arcompact()) {
- scnprintf(mpy_opt, 16, "mpy");
- } else {
- int opt = 2; /* stock MPY/MPYH */
- if (cpu->extn_mpy.dsp) /* OPT 7-9 */
- opt = cpu->extn_mpy.dsp + 6;
- scnprintf(mpy_opt, 16, "mpy[opt %d] ", opt);
- }
- }
- n += scnprintf(buf + n, len - n, "%s%s%s%s%s%s%s%s\n",
- IS_AVAIL2(cpu->isa.atomic, "atomic ", CONFIG_ARC_HAS_LLSC),
- IS_AVAIL2(cpu->isa.ldd, "ll64 ", CONFIG_ARC_HAS_LL64),
- IS_AVAIL2(cpu->isa.unalign, "unalign ", CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS),
- IS_AVAIL1(cpu->extn_mpy.ver, mpy_opt),
- IS_AVAIL1(cpu->isa.div_rem, "div_rem "));
- if (cpu->bpu.ver) {
- n += scnprintf(buf + n, len - n,
- "BPU\t\t: %s%s match, cache:%d, Predict Table:%d Return stk: %d",
- IS_AVAIL1(cpu->bpu.full, "full"),
- IS_AVAIL1(!cpu->bpu.full, "partial"),
- cpu->bpu.num_cache, cpu->bpu.num_pred, cpu->bpu.ret_stk);
- if (is_isa_arcv2()) {
- struct bcr_lpb lpb;
- READ_BCR(ARC_REG_LPB_BUILD, lpb);
- if (lpb.ver) {
- unsigned int ctl;
- ctl = read_aux_reg(ARC_REG_LPB_CTRL);
- n += scnprintf(buf + n, len - n, " Loop Buffer:%d %s",
- lpb.entries,
- IS_DISABLED_RUN(!ctl));
- }
- }
- n += scnprintf(buf + n, len - n, "\n");
- }
- return buf;
- }
- static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
- {
- int n = 0;
- struct cpuinfo_arc *cpu = &cpuinfo_arc700[cpu_id];
- FIX_PTR(cpu);
- n += scnprintf(buf + n, len - n, "Vector Table\t: %#x\n", cpu->vec_base);
- if (cpu->extn.fpu_sp || cpu->extn.fpu_dp)
- n += scnprintf(buf + n, len - n, "FPU\t\t: %s%s\n",
- IS_AVAIL1(cpu->extn.fpu_sp, "SP "),
- IS_AVAIL1(cpu->extn.fpu_dp, "DP "));
- if (cpu->extn.ap_num | cpu->extn.smart | cpu->extn.rtt) {
- n += scnprintf(buf + n, len - n, "DEBUG\t\t: %s%s",
- IS_AVAIL1(cpu->extn.smart, "smaRT "),
- IS_AVAIL1(cpu->extn.rtt, "RTT "));
- if (cpu->extn.ap_num) {
- n += scnprintf(buf + n, len - n, "ActionPoint %d/%s",
- cpu->extn.ap_num,
- cpu->extn.ap_full ? "full":"min");
- }
- n += scnprintf(buf + n, len - n, "\n");
- }
- if (cpu->dccm.sz || cpu->iccm.sz)
- n += scnprintf(buf + n, len - n, "Extn [CCM]\t: DCCM @ %x, %d KB / ICCM: @ %x, %d KB\n",
- cpu->dccm.base_addr, TO_KB(cpu->dccm.sz),
- cpu->iccm.base_addr, TO_KB(cpu->iccm.sz));
- if (is_isa_arcv2()) {
- /* Error Protection: ECC/Parity */
- struct bcr_erp erp;
- READ_BCR(ARC_REG_ERP_BUILD, erp);
- if (erp.ver) {
- struct ctl_erp ctl;
- READ_BCR(ARC_REG_ERP_CTRL, ctl);
- /* inverted bits: 0 means enabled */
- n += scnprintf(buf + n, len - n, "Extn [ECC]\t: %s%s%s%s%s%s\n",
- IS_AVAIL3(erp.ic, !ctl.dpi, "IC "),
- IS_AVAIL3(erp.dc, !ctl.dpd, "DC "),
- IS_AVAIL3(erp.mmu, !ctl.mpd, "MMU "));
- }
- }
- return buf;
- }
- void chk_opt_strict(char *opt_name, bool hw_exists, bool opt_ena)
- {
- if (hw_exists && !opt_ena)
- pr_warn(" ! Enable %s for working apps\n", opt_name);
- else if (!hw_exists && opt_ena)
- panic("Disable %s, hardware NOT present\n", opt_name);
- }
- void chk_opt_weak(char *opt_name, bool hw_exists, bool opt_ena)
- {
- if (!hw_exists && opt_ena)
- panic("Disable %s, hardware NOT present\n", opt_name);
- }
- static void arc_chk_core_config(void)
- {
- struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
- int present = 0;
- if (!cpu->extn.timer0)
- panic("Timer0 is not present!\n");
- if (!cpu->extn.timer1)
- panic("Timer1 is not present!\n");
- #ifdef CONFIG_ARC_HAS_DCCM
- /*
- * DCCM can be arbit placed in hardware.
- * Make sure it's placement/sz matches what Linux is built with
- */
- if ((unsigned int)__arc_dccm_base != cpu->dccm.base_addr)
- panic("Linux built with incorrect DCCM Base address\n");
- if (CONFIG_ARC_DCCM_SZ * SZ_1K != cpu->dccm.sz)
- panic("Linux built with incorrect DCCM Size\n");
- #endif
- #ifdef CONFIG_ARC_HAS_ICCM
- if (CONFIG_ARC_ICCM_SZ * SZ_1K != cpu->iccm.sz)
- panic("Linux built with incorrect ICCM Size\n");
- #endif
- /*
- * FP hardware/software config sanity
- * -If hardware present, kernel needs to save/restore FPU state
- * -If not, it will crash trying to save/restore the non-existant regs
- */
- if (is_isa_arcompact()) {
- /* only DPDP checked since SP has no arch visible regs */
- present = cpu->extn.fpu_dp;
- CHK_OPT_STRICT(CONFIG_ARC_FPU_SAVE_RESTORE, present);
- } else {
- /* Accumulator Low:High pair (r58:59) present if DSP MPY or FPU */
- present = cpu->extn_mpy.dsp | cpu->extn.fpu_sp | cpu->extn.fpu_dp;
- CHK_OPT_STRICT(CONFIG_ARC_HAS_ACCL_REGS, present);
- dsp_config_check();
- }
- }
- /*
- * Initialize and setup the processor core
- * This is called by all the CPUs thus should not do special case stuff
- * such as only for boot CPU etc
- */
- void setup_processor(void)
- {
- char str[512];
- int cpu_id = smp_processor_id();
- read_arc_build_cfg_regs();
- arc_init_IRQ();
- pr_info("%s", arc_cpu_mumbojumbo(cpu_id, str, sizeof(str)));
- arc_mmu_init();
- arc_cache_init();
- pr_info("%s", arc_extn_mumbojumbo(cpu_id, str, sizeof(str)));
- pr_info("%s", arc_platform_smp_cpuinfo());
- arc_chk_core_config();
- }
- static inline bool uboot_arg_invalid(unsigned long addr)
- {
- /*
- * Check that it is a untranslated address (although MMU is not enabled
- * yet, it being a high address ensures this is not by fluke)
- */
- if (addr < PAGE_OFFSET)
- return true;
- /* Check that address doesn't clobber resident kernel image */
- return addr >= (unsigned long)_stext && addr <= (unsigned long)_end;
- }
- #define IGNORE_ARGS "Ignore U-boot args: "
- /* uboot_tag values for U-boot - kernel ABI revision 0; see head.S */
- #define UBOOT_TAG_NONE 0
- #define UBOOT_TAG_CMDLINE 1
- #define UBOOT_TAG_DTB 2
- /* We always pass 0 as magic from U-boot */
- #define UBOOT_MAGIC_VALUE 0
- void __init handle_uboot_args(void)
- {
- bool use_embedded_dtb = true;
- bool append_cmdline = false;
- /* check that we know this tag */
- if (uboot_tag != UBOOT_TAG_NONE &&
- uboot_tag != UBOOT_TAG_CMDLINE &&
- uboot_tag != UBOOT_TAG_DTB) {
- pr_warn(IGNORE_ARGS "invalid uboot tag: '%08x'\n", uboot_tag);
- goto ignore_uboot_args;
- }
- if (uboot_magic != UBOOT_MAGIC_VALUE) {
- pr_warn(IGNORE_ARGS "non zero uboot magic\n");
- goto ignore_uboot_args;
- }
- if (uboot_tag != UBOOT_TAG_NONE &&
- uboot_arg_invalid((unsigned long)uboot_arg)) {
- pr_warn(IGNORE_ARGS "invalid uboot arg: '%px'\n", uboot_arg);
- goto ignore_uboot_args;
- }
- /* see if U-boot passed an external Device Tree blob */
- if (uboot_tag == UBOOT_TAG_DTB) {
- machine_desc = setup_machine_fdt((void *)uboot_arg);
- /* external Device Tree blob is invalid - use embedded one */
- use_embedded_dtb = !machine_desc;
- }
- if (uboot_tag == UBOOT_TAG_CMDLINE)
- append_cmdline = true;
- ignore_uboot_args:
- if (use_embedded_dtb) {
- machine_desc = setup_machine_fdt(__dtb_start);
- if (!machine_desc)
- panic("Embedded DT invalid\n");
- }
- /*
- * NOTE: @boot_command_line is populated by setup_machine_fdt() so this
- * append processing can only happen after.
- */
- if (append_cmdline) {
- /* Ensure a whitespace between the 2 cmdlines */
- strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
- strlcat(boot_command_line, uboot_arg, COMMAND_LINE_SIZE);
- }
- }
- void __init setup_arch(char **cmdline_p)
- {
- handle_uboot_args();
- /* Save unparsed command line copy for /proc/cmdline */
- *cmdline_p = boot_command_line;
- /* To force early parsing of things like mem=xxx */
- parse_early_param();
- /* Platform/board specific: e.g. early console registration */
- if (machine_desc->init_early)
- machine_desc->init_early();
- smp_init_cpus();
- setup_processor();
- setup_arch_memory();
- /* copy flat DT out of .init and then unflatten it */
- unflatten_and_copy_device_tree();
- /* Can be issue if someone passes cmd line arg "ro"
- * But that is unlikely so keeping it as it is
- */
- root_mountflags &= ~MS_RDONLY;
- arc_unwind_init();
- }
- /*
- * Called from start_kernel() - boot CPU only
- */
- void __init time_init(void)
- {
- of_clk_init(NULL);
- timer_probe();
- }
- static int __init customize_machine(void)
- {
- if (machine_desc->init_machine)
- machine_desc->init_machine();
- return 0;
- }
- arch_initcall(customize_machine);
- static int __init init_late_machine(void)
- {
- if (machine_desc->init_late)
- machine_desc->init_late();
- return 0;
- }
- late_initcall(init_late_machine);
- /*
- * Get CPU information for use by the procfs.
- */
- #define cpu_to_ptr(c) ((void *)(0xFFFF0000 | (unsigned int)(c)))
- #define ptr_to_cpu(p) (~0xFFFF0000UL & (unsigned int)(p))
- static int show_cpuinfo(struct seq_file *m, void *v)
- {
- char *str;
- int cpu_id = ptr_to_cpu(v);
- struct device *cpu_dev = get_cpu_device(cpu_id);
- struct clk *cpu_clk;
- unsigned long freq = 0;
- if (!cpu_online(cpu_id)) {
- seq_printf(m, "processor [%d]\t: Offline\n", cpu_id);
- goto done;
- }
- str = (char *)__get_free_page(GFP_KERNEL);
- if (!str)
- goto done;
- seq_printf(m, arc_cpu_mumbojumbo(cpu_id, str, PAGE_SIZE));
- cpu_clk = clk_get(cpu_dev, NULL);
- if (IS_ERR(cpu_clk)) {
- seq_printf(m, "CPU speed \t: Cannot get clock for processor [%d]\n",
- cpu_id);
- } else {
- freq = clk_get_rate(cpu_clk);
- }
- if (freq)
- seq_printf(m, "CPU speed\t: %lu.%02lu Mhz\n",
- freq / 1000000, (freq / 10000) % 100);
- seq_printf(m, "Bogo MIPS\t: %lu.%02lu\n",
- loops_per_jiffy / (500000 / HZ),
- (loops_per_jiffy / (5000 / HZ)) % 100);
- seq_printf(m, arc_mmu_mumbojumbo(cpu_id, str, PAGE_SIZE));
- seq_printf(m, arc_cache_mumbojumbo(cpu_id, str, PAGE_SIZE));
- seq_printf(m, arc_extn_mumbojumbo(cpu_id, str, PAGE_SIZE));
- seq_printf(m, arc_platform_smp_cpuinfo());
- free_page((unsigned long)str);
- done:
- seq_printf(m, "\n");
- return 0;
- }
- static void *c_start(struct seq_file *m, loff_t *pos)
- {
- /*
- * Callback returns cpu-id to iterator for show routine, NULL to stop.
- * However since NULL is also a valid cpu-id (0), we use a round-about
- * way to pass it w/o having to kmalloc/free a 2 byte string.
- * Encode cpu-id as 0xFFcccc, which is decoded by show routine.
- */
- return *pos < nr_cpu_ids ? cpu_to_ptr(*pos) : NULL;
- }
- static void *c_next(struct seq_file *m, void *v, loff_t *pos)
- {
- ++*pos;
- return c_start(m, pos);
- }
- static void c_stop(struct seq_file *m, void *v)
- {
- }
- const struct seq_operations cpuinfo_op = {
- .start = c_start,
- .next = c_next,
- .stop = c_stop,
- .show = show_cpuinfo
- };
- static DEFINE_PER_CPU(struct cpu, cpu_topology);
- static int __init topology_init(void)
- {
- int cpu;
- for_each_present_cpu(cpu)
- register_cpu(&per_cpu(cpu_topology, cpu), cpu);
- return 0;
- }
- subsys_initcall(topology_init);
|