void __init setup_cpuinfo_clk(void) { struct clk *clk; clk = of_clk_get(cpu, 0); if (IS_ERR(clk)) { pr_err("ERROR: CPU CCF input clock not found\n"); /* take timebase-frequency from DTS */ cpuinfo.cpu_clock_freq = fcpu(cpu, "timebase-frequency"); } else { cpuinfo.cpu_clock_freq = clk_get_rate(clk); } if (!cpuinfo.cpu_clock_freq) { pr_err("ERROR: CPU clock frequency not setup\n"); BUG(); } }
void __init setup_cpuinfo(void) { struct device_node *cpu; const char *str; int len; cpu = of_find_node_by_type(NULL, "cpu"); if (!cpu) panic("%s: No CPU found in devicetree!\n", __func__); if (!fcpu_has(cpu, "altr,has-initda")) panic("initda instruction is unimplemented. Please update your " "hardware system to have more than 4-byte line data " "cache\n"); cpuinfo.cpu_clock_freq = fcpu(cpu, "clock-frequency"); str = of_get_property(cpu, "altr,implementation", &len); if (str) strlcpy(cpuinfo.cpu_impl, str, sizeof(cpuinfo.cpu_impl)); else strcpy(cpuinfo.cpu_impl, "<unknown>"); cpuinfo.has_div = fcpu_has(cpu, "altr,has-div"); cpuinfo.has_mul = fcpu_has(cpu, "altr,has-mul"); cpuinfo.has_mulx = fcpu_has(cpu, "altr,has-mulx"); if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div) err_cpu("DIV"); if (IS_ENABLED(CONFIG_NIOS2_HW_MUL_SUPPORT) && !cpuinfo.has_mul) err_cpu("MUL"); if (IS_ENABLED(CONFIG_NIOS2_HW_MULX_SUPPORT) && !cpuinfo.has_mulx) err_cpu("MULX"); cpuinfo.tlb_num_ways = fcpu(cpu, "altr,tlb-num-ways"); if (!cpuinfo.tlb_num_ways) panic("altr,tlb-num-ways can't be 0. Please check your hardware " "system\n"); cpuinfo.icache_line_size = fcpu(cpu, "icache-line-size"); cpuinfo.icache_size = fcpu(cpu, "icache-size"); if (CONFIG_NIOS2_ICACHE_SIZE != cpuinfo.icache_size) pr_warn("Warning: icache size configuration mismatch " "(0x%x vs 0x%x) of CONFIG_NIOS2_ICACHE_SIZE vs " "device tree icache-size\n", CONFIG_NIOS2_ICACHE_SIZE, cpuinfo.icache_size); cpuinfo.dcache_line_size = fcpu(cpu, "dcache-line-size"); if (CONFIG_NIOS2_DCACHE_LINE_SIZE != cpuinfo.dcache_line_size) pr_warn("Warning: dcache line size configuration mismatch " "(0x%x vs 0x%x) of CONFIG_NIOS2_DCACHE_LINE_SIZE vs " "device tree dcache-line-size\n", CONFIG_NIOS2_DCACHE_LINE_SIZE, cpuinfo.dcache_line_size); cpuinfo.dcache_size = fcpu(cpu, "dcache-size"); if (CONFIG_NIOS2_DCACHE_SIZE != cpuinfo.dcache_size) pr_warn("Warning: dcache size configuration mismatch " "(0x%x vs 0x%x) of CONFIG_NIOS2_DCACHE_SIZE vs " "device tree dcache-size\n", CONFIG_NIOS2_DCACHE_SIZE, cpuinfo.dcache_size); cpuinfo.tlb_pid_num_bits = fcpu(cpu, "altr,pid-num-bits"); cpuinfo.tlb_num_ways_log2 = ilog2(cpuinfo.tlb_num_ways); cpuinfo.tlb_num_entries = fcpu(cpu, "altr,tlb-num-entries"); cpuinfo.tlb_num_lines = cpuinfo.tlb_num_entries / cpuinfo.tlb_num_ways; cpuinfo.tlb_ptr_sz = fcpu(cpu, "altr,tlb-ptr-sz"); cpuinfo.reset_addr = fcpu(cpu, "altr,reset-addr"); cpuinfo.exception_addr = fcpu(cpu, "altr,exception-addr"); cpuinfo.fast_tlb_miss_exc_addr = fcpu(cpu, "altr,fast-tlb-miss-addr"); }
void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu) { int i = 0; ci->use_instr = (fcpu(cpu, "xlnx,use-barrel") ? PVR0_USE_BARREL_MASK : 0) | (fcpu(cpu, "xlnx,use-msr-instr") ? PVR2_USE_MSR_INSTR : 0) | (fcpu(cpu, "xlnx,use-pcmp-instr") ? PVR2_USE_PCMP_INSTR : 0) | (fcpu(cpu, "xlnx,use-div") ? PVR0_USE_DIV_MASK : 0); if (CONFIG_XILINX_MICROBLAZE0_USE_BARREL) i |= PVR0_USE_BARREL_MASK; if (CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR) i |= PVR2_USE_MSR_INSTR; if (CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) i |= PVR2_USE_PCMP_INSTR; if (CONFIG_XILINX_MICROBLAZE0_USE_DIV) i |= PVR0_USE_DIV_MASK; if (ci->use_instr != i) err_printk("BARREL, MSR, PCMP or DIV"); ci->use_mult = fcpu(cpu, "xlnx,use-hw-mul"); if (ci->use_mult != CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) err_printk("HW_MUL"); ci->use_mult = (ci->use_mult > 1 ? (PVR2_USE_MUL64_MASK | PVR0_USE_HW_MUL_MASK) : (ci->use_mult == 1 ? PVR0_USE_HW_MUL_MASK : 0)); ci->use_fpu = fcpu(cpu, "xlnx,use-fpu"); if (ci->use_fpu != CONFIG_XILINX_MICROBLAZE0_USE_FPU) err_printk("HW_FPU"); ci->use_fpu = (ci->use_fpu > 1 ? (PVR2_USE_FPU2_MASK | PVR0_USE_FPU_MASK) : (ci->use_fpu == 1 ? PVR0_USE_FPU_MASK : 0)); ci->use_exc = (fcpu(cpu, "xlnx,unaligned-exceptions") ? PVR2_UNALIGNED_EXC_MASK : 0) | (fcpu(cpu, "xlnx,ill-opcode-exception") ? PVR2_ILL_OPCODE_EXC_MASK : 0) | (fcpu(cpu, "xlnx,iopb-bus-exception") ? PVR2_IOPB_BUS_EXC_MASK : 0) | (fcpu(cpu, "xlnx,dopb-bus-exception") ? PVR2_DOPB_BUS_EXC_MASK : 0) | (fcpu(cpu, "xlnx,div-zero-exception") ? PVR2_DIV_ZERO_EXC_MASK : 0) | (fcpu(cpu, "xlnx,fpu-exception") ? PVR2_FPU_EXC_MASK : 0) | (fcpu(cpu, "xlnx,fsl-exception") ? PVR2_USE_EXTEND_FSL : 0); ci->use_icache = fcpu(cpu, "xlnx,use-icache"); ci->icache_tagbits = fcpu(cpu, "xlnx,addr-tag-bits"); ci->icache_write = fcpu(cpu, "xlnx,allow-icache-wr"); ci->icache_line_length = fcpu(cpu, "xlnx,icache-line-len") << 2; if (!ci->icache_line_length) { if (fcpu(cpu, "xlnx,icache-use-fsl")) ci->icache_line_length = 4 << 2; else ci->icache_line_length = 1 << 2; } ci->icache_size = fcpu(cpu, "i-cache-size"); ci->icache_base = fcpu(cpu, "i-cache-baseaddr"); ci->icache_high = fcpu(cpu, "i-cache-highaddr"); ci->use_dcache = fcpu(cpu, "xlnx,use-dcache"); ci->dcache_tagbits = fcpu(cpu, "xlnx,dcache-addr-tag"); ci->dcache_write = fcpu(cpu, "xlnx,allow-dcache-wr"); ci->dcache_line_length = fcpu(cpu, "xlnx,dcache-line-len") << 2; if (!ci->dcache_line_length) { if (fcpu(cpu, "xlnx,dcache-use-fsl")) ci->dcache_line_length = 4 << 2; else ci->dcache_line_length = 1 << 2; } ci->dcache_size = fcpu(cpu, "d-cache-size"); ci->dcache_base = fcpu(cpu, "d-cache-baseaddr"); ci->dcache_high = fcpu(cpu, "d-cache-highaddr"); ci->dcache_wb = fcpu(cpu, "xlnx,dcache-use-writeback"); ci->use_dopb = fcpu(cpu, "xlnx,d-opb"); ci->use_iopb = fcpu(cpu, "xlnx,i-opb"); ci->use_dlmb = fcpu(cpu, "xlnx,d-lmb"); ci->use_ilmb = fcpu(cpu, "xlnx,i-lmb"); ci->num_fsl = fcpu(cpu, "xlnx,fsl-links"); ci->irq_edge = fcpu(cpu, "xlnx,interrupt-is-edge"); ci->irq_positive = fcpu(cpu, "xlnx,edge-is-positive"); ci->area_optimised = 0; ci->hw_debug = fcpu(cpu, "xlnx,debug-enabled"); ci->num_pc_brk = fcpu(cpu, "xlnx,number-of-pc-brk"); ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk"); ci->num_wr_brk = fcpu(cpu, "xlnx,number-of-wr-addr-brk"); ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1"); ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2"); ci->mmu = fcpu(cpu, "xlnx,use-mmu"); ci->mmu_privins = fcpu(cpu, "xlnx,mmu-privileged-instr"); ci->endian = fcpu(cpu, "xlnx,endianness"); ci->ver_code = 0; ci->fpga_family_code = 0; /* Do various fixups based on CPU version and FPGA family strings */ /* Resolved the CPU version code */ for (i = 0; cpu_ver_lookup[i].s != NULL; i++) { if (strcmp(cpu_ver_lookup[i].s, cpu_ver_string) == 0) ci->ver_code = cpu_ver_lookup[i].k; } /* Resolved the fpga family code */ for (i = 0; family_string_lookup[i].s != NULL; i++) { if (strcmp(family_string_lookup[i].s, family_string) == 0) ci->fpga_family_code = family_string_lookup[i].k; } /* FIXME - mb3 and spartan2 do not exist in PVR */ /* This is mb3 and on a non Spartan2 */ if (ci->ver_code == 0x20 && ci->fpga_family_code != 0xf0) /* Hardware Multiplier in use */ ci->use_mult = 1; }
void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu) { int i = 0; ci->use_instr = (fcpu(cpu, "xlnx,use-barrel") ? PVR0_USE_BARREL_MASK : 0) | (fcpu(cpu, "xlnx,use-msr-instr") ? PVR2_USE_MSR_INSTR : 0) | (fcpu(cpu, "xlnx,use-pcmp-instr") ? PVR2_USE_PCMP_INSTR : 0) | (fcpu(cpu, "xlnx,use-div") ? PVR0_USE_DIV_MASK : 0); if (CONFIG_XILINX_MICROBLAZE0_USE_BARREL) i |= PVR0_USE_BARREL_MASK; if (CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR) i |= PVR2_USE_MSR_INSTR; if (CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) i |= PVR2_USE_PCMP_INSTR; if (CONFIG_XILINX_MICROBLAZE0_USE_DIV) i |= PVR0_USE_DIV_MASK; if (ci->use_instr != i) err_printk("BARREL, MSR, PCMP or DIV"); ci->use_mult = fcpu(cpu, "xlnx,use-hw-mul"); if (ci->use_mult != CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) err_printk("HW_MUL"); ci->use_mult = (ci->use_mult > 1 ? (PVR2_USE_MUL64_MASK | PVR0_USE_HW_MUL_MASK) : (ci->use_mult == 1 ? PVR0_USE_HW_MUL_MASK : 0)); ci->use_fpu = fcpu(cpu, "xlnx,use-fpu"); if (ci->use_fpu != CONFIG_XILINX_MICROBLAZE0_USE_FPU) err_printk("HW_FPU"); ci->use_fpu = (ci->use_fpu > 1 ? (PVR2_USE_FPU2_MASK | PVR0_USE_FPU_MASK) : (ci->use_fpu == 1 ? PVR0_USE_FPU_MASK : 0)); ci->use_exc = (fcpu(cpu, "xlnx,unaligned-exceptions") ? PVR2_UNALIGNED_EXC_MASK : 0) | (fcpu(cpu, "xlnx,ill-opcode-exception") ? PVR2_ILL_OPCODE_EXC_MASK : 0) | (fcpu(cpu, "xlnx,iopb-bus-exception") ? PVR2_IOPB_BUS_EXC_MASK : 0) | (fcpu(cpu, "xlnx,dopb-bus-exception") ? PVR2_DOPB_BUS_EXC_MASK : 0) | (fcpu(cpu, "xlnx,div-zero-exception") ? PVR2_DIV_ZERO_EXC_MASK : 0) | (fcpu(cpu, "xlnx,fpu-exception") ? PVR2_FPU_EXC_MASK : 0) | (fcpu(cpu, "xlnx,fsl-exception") ? PVR2_USE_EXTEND_FSL : 0); ci->use_icache = fcpu(cpu, "xlnx,use-icache"); ci->icache_tagbits = fcpu(cpu, "xlnx,addr-tag-bits"); ci->icache_write = fcpu(cpu, "xlnx,allow-icache-wr"); ci->icache_line_length = fcpu(cpu, "xlnx,icache-line-len") << 2; if (!ci->icache_line_length) { if (fcpu(cpu, "xlnx,icache-use-fsl")) ci->icache_line_length = 4 << 2; else ci->icache_line_length = 1 << 2; } ci->icache_size = fcpu(cpu, "i-cache-size"); ci->icache_base = fcpu(cpu, "i-cache-baseaddr"); ci->icache_high = fcpu(cpu, "i-cache-highaddr"); ci->use_dcache = fcpu(cpu, "xlnx,use-dcache"); ci->dcache_tagbits = fcpu(cpu, "xlnx,dcache-addr-tag"); ci->dcache_write = fcpu(cpu, "xlnx,allow-dcache-wr"); ci->dcache_line_length = fcpu(cpu, "xlnx,dcache-line-len") << 2; if (!ci->dcache_line_length) { if (fcpu(cpu, "xlnx,dcache-use-fsl")) ci->dcache_line_length = 4 << 2; else ci->dcache_line_length = 1 << 2; } ci->dcache_size = fcpu(cpu, "d-cache-size"); ci->dcache_base = fcpu(cpu, "d-cache-baseaddr"); ci->dcache_high = fcpu(cpu, "d-cache-highaddr"); ci->dcache_wb = fcpu(cpu, "xlnx,dcache-use-writeback"); ci->use_dopb = fcpu(cpu, "xlnx,d-opb"); ci->use_iopb = fcpu(cpu, "xlnx,i-opb"); ci->use_dlmb = fcpu(cpu, "xlnx,d-lmb"); ci->use_ilmb = fcpu(cpu, "xlnx,i-lmb"); ci->num_fsl = fcpu(cpu, "xlnx,fsl-links"); ci->irq_edge = fcpu(cpu, "xlnx,interrupt-is-edge"); ci->irq_positive = fcpu(cpu, "xlnx,edge-is-positive"); ci->area_optimised = 0; ci->hw_debug = fcpu(cpu, "xlnx,debug-enabled"); ci->num_pc_brk = fcpu(cpu, "xlnx,number-of-pc-brk"); ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk"); ci->num_wr_brk = fcpu(cpu, "xlnx,number-of-wr-addr-brk"); ci->cpu_clock_freq = fcpu(cpu, "timebase-frequency"); ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1"); ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2"); ci->mmu = fcpu(cpu, "xlnx,use-mmu"); <<<<<<< HEAD
ci->irq_positive = fcpu(cpu, "xlnx,edge-is-positive"); ci->area_optimised = 0; ci->hw_debug = fcpu(cpu, "xlnx,debug-enabled"); ci->num_pc_brk = fcpu(cpu, "xlnx,number-of-pc-brk"); ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk"); ci->num_wr_brk = fcpu(cpu, "xlnx,number-of-wr-addr-brk"); ci->cpu_clock_freq = fcpu(cpu, "timebase-frequency"); ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1"); ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2"); ci->mmu = fcpu(cpu, "xlnx,use-mmu"); <<<<<<< HEAD ci->endian = fcpu(cpu, "xlnx,endianness"); ======= >>>>>>> 296c66da8a02d52243f45b80521febece5ed498a ci->ver_code = 0; ci->fpga_family_code = 0; /* Do various fixups based on CPU version and FPGA family strings */ /* Resolved the CPU version code */ for (i = 0; cpu_ver_lookup[i].s != NULL; i++) { if (strcmp(cpu_ver_lookup[i].s, cpu_ver_string) == 0) ci->ver_code = cpu_ver_lookup[i].k; } /* Resolved the fpga family code */
void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu) { struct pvr_s pvr; int temp; /* for saving temp value */ get_pvr(&pvr); CI(ver_code, VERSION); if (!ci->ver_code) { printk(KERN_ERR "ERROR: MB has broken PVR regs " "-> use DTS setting\n"); return; } temp = PVR_USE_BARREL(pvr) | PVR_USE_MSR_INSTR(pvr) |\ PVR_USE_PCMP_INSTR(pvr) | PVR_USE_DIV(pvr); if (ci->use_instr != temp) err_printk("BARREL, MSR, PCMP or DIV"); ci->use_instr = temp; temp = PVR_USE_HW_MUL(pvr) | PVR_USE_MUL64(pvr); if (ci->use_mult != temp) err_printk("HW_MUL"); ci->use_mult = temp; temp = PVR_USE_FPU(pvr) | PVR_USE_FPU2(pvr); if (ci->use_fpu != temp) err_printk("HW_FPU"); ci->use_fpu = temp; ci->use_exc = PVR_OPCODE_0x0_ILLEGAL(pvr) |\ PVR_UNALIGNED_EXCEPTION(pvr) |\ PVR_ILL_OPCODE_EXCEPTION(pvr) |\ PVR_IOPB_BUS_EXCEPTION(pvr) |\ PVR_DOPB_BUS_EXCEPTION(pvr) |\ PVR_DIV_ZERO_EXCEPTION(pvr) |\ PVR_FPU_EXCEPTION(pvr) |\ PVR_FSL_EXCEPTION(pvr); CI(pvr_user1, USER1); CI(pvr_user2, USER2); CI(mmu, USE_MMU); CI(endian, ENDIAN); CI(use_icache, USE_ICACHE); CI(icache_tagbits, ICACHE_ADDR_TAG_BITS); CI(icache_write, ICACHE_ALLOW_WR); ci->icache_line_length = PVR_ICACHE_LINE_LEN(pvr) << 2; CI(icache_size, ICACHE_BYTE_SIZE); CI(icache_base, ICACHE_BASEADDR); CI(icache_high, ICACHE_HIGHADDR); CI(use_dcache, USE_DCACHE); CI(dcache_tagbits, DCACHE_ADDR_TAG_BITS); CI(dcache_write, DCACHE_ALLOW_WR); ci->dcache_line_length = PVR_DCACHE_LINE_LEN(pvr) << 2; CI(dcache_size, DCACHE_BYTE_SIZE); CI(dcache_base, DCACHE_BASEADDR); CI(dcache_high, DCACHE_HIGHADDR); temp = PVR_DCACHE_USE_WRITEBACK(pvr); if (ci->dcache_wb != temp) err_printk("DCACHE WB"); ci->dcache_wb = temp; CI(use_dopb, D_OPB); CI(use_iopb, I_OPB); CI(use_dlmb, D_LMB); CI(use_ilmb, I_LMB); CI(num_fsl, FSL_LINKS); CI(irq_edge, INTERRUPT_IS_EDGE); CI(irq_positive, EDGE_IS_POSITIVE); CI(area_optimised, AREA_OPTIMISED); CI(hw_debug, DEBUG_ENABLED); CI(num_pc_brk, NUMBER_OF_PC_BRK); CI(num_rd_brk, NUMBER_OF_RD_ADDR_BRK); CI(num_wr_brk, NUMBER_OF_WR_ADDR_BRK); CI(fpga_family_code, TARGET_FAMILY); /* take timebase-frequency from DTS */ ci->cpu_clock_freq = fcpu(cpu, "timebase-frequency"); }