Path: blob/master/arch/microblaze/kernel/cpu/cpuinfo-static.c
26481 views
/*1* Copyright (C) 2007-2009 Michal Simek <[email protected]>2* Copyright (C) 2007-2009 PetaLogix3* Copyright (C) 2007 John Williams <[email protected]>4*5* This file is subject to the terms and conditions of the GNU General Public6* License. See the file "COPYING" in the main directory of this archive7* for more details.8*/910#include <linux/kernel.h>11#include <linux/init.h>12#include <linux/string.h>13#include <asm/cpuinfo.h>14#include <asm/pvr.h>1516static const char family_string[] = CONFIG_XILINX_MICROBLAZE0_FAMILY;17static const char cpu_ver_string[] = CONFIG_XILINX_MICROBLAZE0_HW_VER;1819#define err_printk(x) \20pr_err("ERROR: Microblaze " x "-different for kernel and DTS\n");2122void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu)23{24u32 i = 0;2526ci->use_instr =27(fcpu(cpu, "xlnx,use-barrel") ? PVR0_USE_BARREL_MASK : 0) |28(fcpu(cpu, "xlnx,use-msr-instr") ? PVR2_USE_MSR_INSTR : 0) |29(fcpu(cpu, "xlnx,use-pcmp-instr") ? PVR2_USE_PCMP_INSTR : 0) |30(fcpu(cpu, "xlnx,use-div") ? PVR0_USE_DIV_MASK : 0);31if (CONFIG_XILINX_MICROBLAZE0_USE_BARREL)32i |= PVR0_USE_BARREL_MASK;33if (CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR)34i |= PVR2_USE_MSR_INSTR;35if (CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR)36i |= PVR2_USE_PCMP_INSTR;37if (CONFIG_XILINX_MICROBLAZE0_USE_DIV)38i |= PVR0_USE_DIV_MASK;39if (ci->use_instr != i)40err_printk("BARREL, MSR, PCMP or DIV");4142ci->use_mult = fcpu(cpu, "xlnx,use-hw-mul");43if (ci->use_mult != CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)44err_printk("HW_MUL");45ci->use_mult =46(ci->use_mult > 1 ?47(PVR2_USE_MUL64_MASK | PVR0_USE_HW_MUL_MASK) :48(ci->use_mult == 1 ? PVR0_USE_HW_MUL_MASK : 0));4950ci->use_fpu = fcpu(cpu, "xlnx,use-fpu");51if (ci->use_fpu != CONFIG_XILINX_MICROBLAZE0_USE_FPU)52err_printk("HW_FPU");53ci->use_fpu = (ci->use_fpu > 1 ?54(PVR2_USE_FPU2_MASK | PVR0_USE_FPU_MASK) :55(ci->use_fpu == 1 ? PVR0_USE_FPU_MASK : 0));5657ci->use_exc =58(fcpu(cpu, "xlnx,unaligned-exceptions") ?59PVR2_UNALIGNED_EXC_MASK : 0) |60(fcpu(cpu, "xlnx,ill-opcode-exception") ?61PVR2_ILL_OPCODE_EXC_MASK : 0) |62(fcpu(cpu, "xlnx,iopb-bus-exception") ?63PVR2_IOPB_BUS_EXC_MASK : 0) |64(fcpu(cpu, "xlnx,dopb-bus-exception") ?65PVR2_DOPB_BUS_EXC_MASK : 0) |66(fcpu(cpu, "xlnx,div-zero-exception") ?67PVR2_DIV_ZERO_EXC_MASK : 0) |68(fcpu(cpu, "xlnx,fpu-exception") ? PVR2_FPU_EXC_MASK : 0) |69(fcpu(cpu, "xlnx,fsl-exception") ? PVR2_USE_EXTEND_FSL : 0);7071ci->use_icache = fcpu(cpu, "xlnx,use-icache");72ci->icache_tagbits = fcpu(cpu, "xlnx,addr-tag-bits");73ci->icache_write = fcpu(cpu, "xlnx,allow-icache-wr");74ci->icache_line_length = fcpu(cpu, "xlnx,icache-line-len") << 2;75if (!ci->icache_line_length) {76if (fcpu(cpu, "xlnx,icache-use-fsl"))77ci->icache_line_length = 4 << 2;78else79ci->icache_line_length = 1 << 2;80}81ci->icache_size = fcpu(cpu, "i-cache-size");82ci->icache_base = fcpu(cpu, "i-cache-baseaddr");83ci->icache_high = fcpu(cpu, "i-cache-highaddr");8485ci->use_dcache = fcpu(cpu, "xlnx,use-dcache");86ci->dcache_tagbits = fcpu(cpu, "xlnx,dcache-addr-tag");87ci->dcache_write = fcpu(cpu, "xlnx,allow-dcache-wr");88ci->dcache_line_length = fcpu(cpu, "xlnx,dcache-line-len") << 2;89if (!ci->dcache_line_length) {90if (fcpu(cpu, "xlnx,dcache-use-fsl"))91ci->dcache_line_length = 4 << 2;92else93ci->dcache_line_length = 1 << 2;94}95ci->dcache_size = fcpu(cpu, "d-cache-size");96ci->dcache_base = fcpu(cpu, "d-cache-baseaddr");97ci->dcache_high = fcpu(cpu, "d-cache-highaddr");98ci->dcache_wb = fcpu(cpu, "xlnx,dcache-use-writeback");99100ci->use_dopb = fcpu(cpu, "xlnx,d-opb");101ci->use_iopb = fcpu(cpu, "xlnx,i-opb");102ci->use_dlmb = fcpu(cpu, "xlnx,d-lmb");103ci->use_ilmb = fcpu(cpu, "xlnx,i-lmb");104105ci->num_fsl = fcpu(cpu, "xlnx,fsl-links");106ci->irq_edge = fcpu(cpu, "xlnx,interrupt-is-edge");107ci->irq_positive = fcpu(cpu, "xlnx,edge-is-positive");108ci->area_optimised = 0;109110ci->hw_debug = fcpu(cpu, "xlnx,debug-enabled");111ci->num_pc_brk = fcpu(cpu, "xlnx,number-of-pc-brk");112ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk");113ci->num_wr_brk = fcpu(cpu, "xlnx,number-of-wr-addr-brk");114115ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1");116ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2");117118ci->mmu = fcpu(cpu, "xlnx,use-mmu");119ci->mmu_privins = fcpu(cpu, "xlnx,mmu-privileged-instr");120ci->endian = fcpu(cpu, "xlnx,endianness");121122ci->ver_code = 0;123ci->fpga_family_code = 0;124125/* Do various fixups based on CPU version and FPGA family strings */126127/* Resolved the CPU version code */128for (i = 0; cpu_ver_lookup[i].s != NULL; i++) {129if (strcmp(cpu_ver_lookup[i].s, cpu_ver_string) == 0)130ci->ver_code = cpu_ver_lookup[i].k;131}132133/* Resolved the fpga family code */134for (i = 0; family_string_lookup[i].s != NULL; i++) {135if (strcmp(family_string_lookup[i].s, family_string) == 0)136ci->fpga_family_code = family_string_lookup[i].k;137}138139/* FIXME - mb3 and spartan2 do not exist in PVR */140/* This is mb3 and on a non Spartan2 */141if (ci->ver_code == 0x20 && ci->fpga_family_code != 0xf0)142/* Hardware Multiplier in use */143ci->use_mult = 1;144}145146147